app.dhover×508 error×27all
// macOS/AppKit F16 demo — clipboard + drag-and-drop (../../../features/f16-clipboard-dnd.md).
// The pasteboard server (com.apple.pboard) is the negotiation peer; this demo logs
// every step of the format negotiation:
//   COPY (eager): clearContents (changeCount bump = the ownership signal) +
//     setString:"é漢🎈" forType:public.utf8-plain-text; verified cross-process by
//     spawning `pbpaste` and diffing its bytes.
//   COPY (lazy): declareTypes:owner: + pasteboard:provideDataForType: — the promise
//     variant. The demo measures WHEN the promise is demanded (only when `pbpaste`
//     actually reads, N ticks after the declare) and on which thread.
//   Source-exits-first: run modes WSI_MODE=promise-exit-return / promise-exit-hard
//     declare a promise and quit WITHOUT rendering it — the driver's pbpaste then
//     shows who pays (run.sh / the findings doc record the outcome).
//   PASTE: an external `pbcopy` write is detected by polling changeCount in the
//     tick timer (there is NO change notification on macOS — polling is the only
//     change signal); the demo then logs the offered types array, the chosen type,
//     and the byte count. pasteboardChangedOwner: on the old owner logs the
//     ownership-loss callback (or its absence).
//   DnD: the content view is registerForDraggedTypes: (file URL + string) and
//     implements the full NSDraggingDestination protocol (draggingEntered/Updated/
//     Exited/performDragOperation, NSDragOperation masks logged); the source side
//     starts beginDraggingSessionWithItems:event:source: (NSDraggingSource) with a
//     synthetic mouse-down over its own view. Under A[ssh]+locked console the
//     session may never deliver destination events — logged honestly (Tier C).
//
// Modes: WSI_AUTO_EXIT=1 = bounded scripted run (default for CI);
//        WSI_MODE=promise-exit-return | promise-exit-hard = the unrendered-promise
//        probes (no run loop; exits immediately after the declare).
// Headless-safe: prints `SKIP:` and exits 0 when no window server is reachable.
module 
(module) app
app
;
import
(package) core
core
.
(module) core.attribute

This module contains UDA's (User Defined Attributes) either used in the runtime or special UDA's recognized by compiler.

Attribute Name, Linkage, Description

gnuAbiTag, C++, Declares an ABI tag on a C++ symbol. mustuse,, Ensures that values of a struct or union type are not discarded. optional, Objective-C, Makes an Objective-C interface method optional. selector, Objective-C, Attaches an Objective-C selector to a method. standalone,, Marks a shared module constructor as not depending on any other module constructor being run first. weak,, Specifies that a global symbol should be emitted with weak linkage.

Source

core/attribute.d

@copyrightCopyright Jacob Carlborg 2015.@licenseBoost License 1.0@authorsJacob Carlborg
attribute
: selector;
module `core.attribute` import `selector` not found
import
(package) core
core
.
(package) core.stdc
stdc
.
(module) core.stdc.stdio

D header file for C99 <stdio.h>

pubs.opengroup.org/onlinepubs/009695399/basedefs/stdio.h.html, stdio.h

Source

core/stdc/stdio.d

@copyrightCopyright Sean Kelly 2005 - 2009.@licenseDistributed under the Boost Software License 1.0. (See accompanying file LICENSE)@authorsSean Kelly, Alex Rønne Petersen@standardsISO/IEC 9899:1999 (E)
stdio
:
(alias) app.printf = int core.stdc.stdio.printf(scope const(char*) format, scope const ...) nothrow @nogc
printf
,
(alias) app.fopen = shared(core.stdc.stdio._IO_FILE)* core.stdc.stdio.fopen(scope const(char*) filename, scope const(char*) mode) nothrow @nogc
fopen
,
(alias) app.fread = ulong core.stdc.stdio.fread(scope void* ptr, ulong size, ulong nmemb, shared(core.stdc.stdio._IO_FILE)* stream) nothrow @nogc
fread
,
(alias) app.fclose = int core.stdc.stdio.fclose(shared(core.stdc.stdio._IO_FILE)* stream) nothrow @nogc
fclose
,
(struct) core.stdc.stdio._IO_FILE
FILE
,
(alias) app.snprintf = int core.stdc.stdio.snprintf(scope char* s, ulong n, scope const(char*) format, scope const ...) nothrow @nogc
snprintf
;
import
(package) core
core
.
(package) core.stdc
stdc
.
(module) core.stdc.stdlib

D header file for C99.

pubs.opengroup.org/onlinepubs/009695399/basedefs/stdlib.h.html, stdlib.h

Source

core/stdc/stdlib.d

@copyrightCopyright Sean Kelly 2005 - 2014.@licenseDistributed under the Boost Software License 1.0. (See accompanying file LICENSE)@authorsSean Kelly@standardsISO/IEC 9899:1999 (E)
stdlib
:
(alias) app.getenv = char* core.stdc.stdlib.getenv(scope const(char*) name) nothrow @nogc
getenv
,
(alias) app.system = int core.stdc.stdlib.system(scope const(char*) string) nothrow @nogc
system
;
import
(package) core
core
.
(package) core.stdc
stdc
.
(module) core.stdc.string

D header file for C99.

pubs.opengroup.org/onlinepubs/009695399/basedefs/string.h.html, string.h

Source

core/stdc/string.d

@copyrightCopyright Sean Kelly 2005 - 2009.@licenseDistributed under the Boost Software License 1.0. (See accompanying file LICENSE)@authorsSean Kelly@standardsISO/IEC 9899:1999 (E)
string
:
(alias) app.strlen = ulong core.stdc.string.strlen(scope const(char*) s) pure nothrow @nogc
strlen
,
(alias) app.strcmp = int core.stdc.string.strcmp(scope const(char*) s1, scope const(char*) s2) pure nothrow @nogc
strcmp
;
import instrument : instr, instrInit, instrNowUs;
unable to read module `instrument` Expected 'instrument.d' or 'instrument/package.d' in one of the following import paths:
unable to read module `instrument` Expected 'instrument.d' or 'instrument/package.d' in one of the following import paths:
unable to read module `instrument` Expected 'instrument.d' or 'instrument/package.d' in one of the following import paths:
import objc.autorelease : autoreleasepool_push, autoreleasepool_pop; // objective-d
unable to read module `autorelease` Expected 'objc/autorelease.d' or 'objc/autorelease/package.d' in one of the following import paths:
unable to read module `autorelease` Expected 'objc/autorelease.d' or 'objc/autorelease/package.d' in one of the following import paths:
unable to read module `autorelease` Expected 'objc/autorelease.d' or 'objc/autorelease/package.d' in one of the following import paths:
import objc.rt : SEL;
unable to read module `rt` Expected 'objc/rt.d' or 'objc/rt/package.d' in one of the following import paths:
unable to read module `rt` Expected 'objc/rt.d' or 'objc/rt/package.d' in one of the following import paths:
unable to read module `rt` Expected 'objc/rt.d' or 'objc/rt/package.d' in one of the following import paths:
// --- Geometry ---------------------------------------------------------------------- extern (C) struct
(struct) app.NSPoint
NSPoint
{ double
(field) double app.NSPoint.x
x
,
(field) double app.NSPoint.y
y
;
} extern (C) struct
(struct) app.NSSize
NSSize
{ double
(field) double app.NSSize.width
width
,
(field) double app.NSSize.height
height
;
} extern (C) struct
(struct) app.NSRect
NSRect
{
(struct) app.NSPoint
NSPoint
(field) app.NSPoint app.NSRect.origin
origin
;
(struct) app.NSSize
NSSize
(field) app.NSSize app.NSRect.size
size
;
} // --- CoreGraphics / CoreFoundation / libc ------------------------------------------ extern (C) nothrow @nogc { uint
uint app.CGMainDisplayID() nothrow @nogc
CGMainDisplayID
();
void
void app.CFRelease(void* obj) nothrow @nogc
CFRelease
(void*
(parameter) void* obj
obj
);
void*
void* app.CGSessionCopyCurrentDictionary() nothrow @nogc
CGSessionCopyCurrentDictionary
();
void*
void* app.CFStringCreateWithCString(void* alloc, const(char)* s, uint encoding) nothrow @nogc
CFStringCreateWithCString
(void*
(parameter) void* alloc
alloc
, const(char)*
(parameter) const(char)* s
s
, uint
(parameter) uint encoding
encoding
);
void*
void* app.CFDictionaryGetValue(void* dict, void* key) nothrow @nogc
CFDictionaryGetValue
(void*
(parameter) void* dict
dict
, void*
(parameter) void* key
key
);
ubyte
ubyte app.CFBooleanGetValue(void* b) nothrow @nogc
CFBooleanGetValue
(void*
(parameter) void* b
b
);
void
void app.CGContextSetRGBFillColor(void* ctx, double r, double g, double b, double a) nothrow @nogc
CGContextSetRGBFillColor
(void*
(parameter) void* ctx
ctx
, double
(parameter) double r
r
, double
(parameter) double g
g
, double
(parameter) double b
b
, double
(parameter) double a
a
);
void
void app.CGContextFillRect(void* ctx, app.NSRect rect) nothrow @nogc
CGContextFillRect
(void*
(parameter) void* ctx
ctx
,
(struct) app.NSRect
NSRect
(parameter) app.NSRect rect
rect
);
int
int app.pthread_main_np() nothrow @nogc
pthread_main_np
();
void
void app._exit(int code) nothrow @nogc
_exit
(int
(parameter) int code
code
);
} enum uint
(constant) uint app.kCFStringEncodingUTF8 = 134217984u
kCFStringEncodingUTF8
= 0x08000100;
void
void app.logSessionLockState()
logSessionLockState
()
{ void*
(local variable) void* dict
dict
=
void* app.CGSessionCopyCurrentDictionary() nothrow @nogc
CGSessionCopyCurrentDictionary
();
if (
(local variable) void* dict
dict
is null)
{ instr("session", "lock_state=no_session_dictionary"); return; } void*
(local variable) void* kLocked
kLocked
=
void* app.CFStringCreateWithCString(void* alloc, const(char)* s, uint encoding) nothrow @nogc
CFStringCreateWithCString
(null, "CGSSessionScreenIsLocked",
(constant) uint app.kCFStringEncodingUTF8 = 134217984u
kCFStringEncodingUTF8
);
void*
(local variable) void* locked
locked
=
void* app.CFDictionaryGetValue(void* dict, void* key) nothrow @nogc
CFDictionaryGetValue
(
(local variable) void* dict
dict
,
(local variable) void* kLocked
kLocked
);
instr("session", "screen_locked=%d", locked !is null && CFBooleanGetValue(locked) ? 1 : 0);
void app.CFRelease(void* obj) nothrow @nogc
CFRelease
(
(local variable) void* kLocked
kLocked
);
void app.CFRelease(void* obj) nothrow @nogc
CFRelease
(
(local variable) void* dict
dict
);
} // --- AppKit class declarations ----------------------------------------------------- extern (Objective-C): extern class
(class) app.NSObject
NSObject
class `app.NSObject` Objective-C classes not supported
{ // id<NSDraggingInfo> accessors — NSDraggingInfo is a protocol (no class object // to link against), and Objective-C dispatch is by selector, so declaring the // selectors on NSObject lets the destination methods message the info object.
(class) app.NSPasteboard
NSPasteboard
app.NSPasteboard app.NSObject.draggingPasteboard()
draggingPasteboard
() @selector("draggingPasteboard");
ulong
ulong app.NSObject.draggingSourceOperationMask()
draggingSourceOperationMask
() @selector("draggingSourceOperationMask");
(struct) app.NSPoint
NSPoint
app.NSPoint app.NSObject.draggingLocation()
draggingLocation
() @selector("draggingLocation");
} extern class
(class) app.NSString
NSString
:
(class) app.NSObject
NSObject
class `app.NSString` Objective-C classes not supported
{ static
(class) app.NSString
NSString
app.NSString app.NSString.alloc()
alloc
() @selector("alloc");
(class) app.NSString
NSString
app.NSString app.NSString.initWithUTF8String(const(char)* s)
initWithUTF8String
(const(char)*
(parameter) const(char)* s
s
) @selector("initWithUTF8String:");
const(char)*
const(char)* app.NSString.UTF8String()
UTF8String
() @selector("UTF8String");
ulong
ulong app.NSString.lengthOfBytesUsingEncoding(ulong enc)
lengthOfBytesUsingEncoding
(ulong
(parameter) ulong enc
enc
) @selector("lengthOfBytesUsingEncoding:");
} extern class
(class) app.NSArray
NSArray
:
(class) app.NSObject
NSObject
class `app.NSArray` Objective-C classes not supported
{ static
(class) app.NSArray
NSArray
app.NSArray app.NSArray.arrayWithObject(app.NSObject o)
arrayWithObject
(
(class) app.NSObject
NSObject
(parameter) app.NSObject o
o
) @selector("arrayWithObject:");
ulong
ulong app.NSArray.count()
count
() @selector("count");
(class) app.NSObject
NSObject
app.NSObject app.NSArray.objectAtIndex(ulong i)
objectAtIndex
(ulong
(parameter) ulong i
i
) @selector("objectAtIndex:");
} extern class
(class) app.NSMutableArray
NSMutableArray
:
(class) app.NSArray
NSArray
class `app.NSMutableArray` Objective-C classes not supported
{ static
(class) app.NSMutableArray
NSMutableArray
app.NSMutableArray app.NSMutableArray.array()
array
() @selector("array");
void
void app.NSMutableArray.addObject(app.NSObject o)
addObject
(
(class) app.NSObject
NSObject
(parameter) app.NSObject o
o
) @selector("addObject:");
} extern class
(class) app.NSPasteboard
NSPasteboard
:
(class) app.NSObject
NSObject
class `app.NSPasteboard` Objective-C classes not supported
{ static
(class) app.NSPasteboard
NSPasteboard
app.NSPasteboard app.NSPasteboard.generalPasteboard()
generalPasteboard
() @selector("generalPasteboard");
static
(class) app.NSPasteboard
NSPasteboard
app.NSPasteboard app.NSPasteboard.pasteboardWithName(app.NSString name)
pasteboardWithName
(
(class) app.NSString
NSString
(parameter) app.NSString name
name
) @selector("pasteboardWithName:");
(class) app.NSString
NSString
app.NSString app.NSPasteboard.name()
name
() @selector("name");
long
long app.NSPasteboard.changeCount()
changeCount
() @selector("changeCount");
long
long app.NSPasteboard.clearContents()
clearContents
() @selector("clearContents");
bool
bool app.NSPasteboard.setString(app.NSString s, app.NSString type)
setString
(
(class) app.NSString
NSString
(parameter) app.NSString s
s
,
(class) app.NSString
NSString
(parameter) app.NSString type
type
) @selector("setString:forType:");
(class) app.NSString
NSString
app.NSString app.NSPasteboard.stringForType(app.NSString type)
stringForType
(
(class) app.NSString
NSString
(parameter) app.NSString type
type
) @selector("stringForType:");
(class) app.NSArray
NSArray
app.NSArray app.NSPasteboard.types()
types
() @selector("types");
long
long app.NSPasteboard.declareTypes(app.NSArray types, app.NSObject owner)
declareTypes
(
(class) app.NSArray
NSArray
(parameter) app.NSArray types
types
,
(class) app.NSObject
NSObject
(parameter) app.NSObject owner
owner
) @selector("declareTypes:owner:");
} extern class
(class) app.NSPasteboardItem
NSPasteboardItem
:
(class) app.NSObject
NSObject
class `app.NSPasteboardItem` Objective-C classes not supported
{ static
(class) app.NSPasteboardItem
NSPasteboardItem
app.NSPasteboardItem app.NSPasteboardItem.alloc()
alloc
() @selector("alloc");
(class) app.NSPasteboardItem
NSPasteboardItem
app.NSPasteboardItem app.NSPasteboardItem.init()
init
() @selector("init");
bool
bool app.NSPasteboardItem.setString(app.NSString s, app.NSString type)
setString
(
(class) app.NSString
NSString
(parameter) app.NSString s
s
,
(class) app.NSString
NSString
(parameter) app.NSString type
type
) @selector("setString:forType:");
} extern class
(class) app.NSDraggingItem
NSDraggingItem
:
(class) app.NSObject
NSObject
class `app.NSDraggingItem` Objective-C classes not supported
{ static
(class) app.NSDraggingItem
NSDraggingItem
app.NSDraggingItem app.NSDraggingItem.alloc()
alloc
() @selector("alloc");
(class) app.NSDraggingItem
NSDraggingItem
app.NSDraggingItem app.NSDraggingItem.initWithPasteboardWriter(app.NSObject writer)
initWithPasteboardWriter
(
(class) app.NSObject
NSObject
(parameter) app.NSObject writer
writer
)
@selector("initWithPasteboardWriter:"); void
void app.NSDraggingItem.setDraggingFrame(app.NSRect frame, app.NSObject contents)
setDraggingFrame
(
(struct) app.NSRect
NSRect
(parameter) app.NSRect frame
frame
,
(class) app.NSObject
NSObject
(parameter) app.NSObject contents
contents
)
@selector("setDraggingFrame:contents:"); } extern class
(class) app.NSDraggingSession
NSDraggingSession
:
(class) app.NSObject
NSObject
class `app.NSDraggingSession` Objective-C classes not supported
{ long
long app.NSDraggingSession.draggingSequenceNumber()
draggingSequenceNumber
() @selector("draggingSequenceNumber");
} extern class
(class) app.NSEvent
NSEvent
:
(class) app.NSObject
NSObject
class `app.NSEvent` Objective-C classes not supported
{ static
(class) app.NSEvent
NSEvent
app.NSEvent app.NSEvent.mouseEventWithType(long type, app.NSPoint location, ulong modifierFlags, double timestamp, long windowNumber, app.NSObject context, long eventNumber, long clickCount, double pressure)
mouseEventWithType
(long
(parameter) long type
type
,
(struct) app.NSPoint
NSPoint
(parameter) app.NSPoint location
location
, ulong
(parameter) ulong modifierFlags
modifierFlags
,
double
(parameter) double timestamp
timestamp
, long
(parameter) long windowNumber
windowNumber
,
(class) app.NSObject
NSObject
(parameter) app.NSObject context
context
, long
(parameter) long eventNumber
eventNumber
,
long
(parameter) long clickCount
clickCount
, double
(parameter) double pressure
pressure
)
@selector("mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:"); static
(class) app.NSEvent
NSEvent
app.NSEvent app.NSEvent.otherEventWithType(long type, app.NSPoint location, ulong modifierFlags, double timestamp, long windowNumber, app.NSObject context, short subtype, long data1, long data2)
otherEventWithType
(long
(parameter) long type
type
,
(struct) app.NSPoint
NSPoint
(parameter) app.NSPoint location
location
, ulong
(parameter) ulong modifierFlags
modifierFlags
,
double
(parameter) double timestamp
timestamp
, long
(parameter) long windowNumber
windowNumber
,
(class) app.NSObject
NSObject
(parameter) app.NSObject context
context
, short
(parameter) short subtype
subtype
,
long
(parameter) long data1
data1
, long
(parameter) long data2
data2
)
@selector("otherEventWithType:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:"); long
long app.NSEvent.type()
type
() @selector("type");
} extern class
(class) app.NSTimer
NSTimer
:
(class) app.NSObject
NSObject
class `app.NSTimer` Objective-C classes not supported
{ static
(class) app.NSTimer
NSTimer
app.NSTimer.scheduledTimerWithTimeInterval
scheduledTimerWithTimeInterval
(double interval,
(class) app.NSObject
NSObject
target,
SEL sel,
(class) app.NSObject
NSObject
userInfo, bool repeats)
@selector("scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:"); } extern class
(class) app.NSApplication
NSApplication
:
(class) app.NSObject
NSObject
class `app.NSApplication` Objective-C classes not supported
{ static
(class) app.NSApplication
NSApplication
app.NSApplication app.NSApplication.sharedApplication()
sharedApplication
() @selector("sharedApplication");
void
void app.NSApplication.setActivationPolicy(long policy)
setActivationPolicy
(long
(parameter) long policy
policy
) @selector("setActivationPolicy:");
void
void app.NSApplication.run()
run
() @selector("run");
void
void app.NSApplication.stop(app.NSObject sender)
stop
(
(class) app.NSObject
NSObject
(parameter) app.NSObject sender
sender
) @selector("stop:");
void
void app.NSApplication.postEvent(app.NSEvent event, bool atStart)
postEvent
(
(class) app.NSEvent
NSEvent
(parameter) app.NSEvent event
event
, bool
(parameter) bool atStart
atStart
) @selector("postEvent:atStart:");
} extern class
(class) app.NSGraphicsContext
NSGraphicsContext
:
(class) app.NSObject
NSObject
class `app.NSGraphicsContext` Objective-C classes not supported
{ static
(class) app.NSGraphicsContext
NSGraphicsContext
app.NSGraphicsContext app.NSGraphicsContext.currentContext()
currentContext
() @selector("currentContext");
void*
void* app.NSGraphicsContext.CGContext()
CGContext
() @selector("CGContext");
} extern class
(class) app.NSView
NSView
:
(class) app.NSObject
NSObject
class `app.NSView` Objective-C classes not supported
{
(struct) app.NSRect
NSRect
app.NSRect app.NSView.bounds()
bounds
() @selector("bounds");
void
void app.NSView.registerForDraggedTypes(app.NSArray types)
registerForDraggedTypes
(
(class) app.NSArray
NSArray
(parameter) app.NSArray types
types
) @selector("registerForDraggedTypes:");
(class) app.NSWindow
NSWindow
app.NSWindow app.NSView.window()
window
() @selector("window");
(class) app.NSDraggingSession
NSDraggingSession
app.NSDraggingSession app.NSView.beginDraggingSession(app.NSArray items, app.NSEvent event, app.NSObject source)
beginDraggingSession
(
(class) app.NSArray
NSArray
(parameter) app.NSArray items
items
,
(class) app.NSEvent
NSEvent
(parameter) app.NSEvent event
event
,
(class) app.NSObject
NSObject
(parameter) app.NSObject source
source
)
@selector("beginDraggingSessionWithItems:event:source:"); } extern class
(class) app.NSWindow
NSWindow
:
(class) app.NSObject
NSObject
class `app.NSWindow` Objective-C classes not supported
{
(class) app.NSWindow
NSWindow
app.NSWindow app.NSWindow.initWithContentRect(app.NSRect contentRect, ulong styleMask, ulong backing, bool defer)
initWithContentRect
(
(struct) app.NSRect
NSRect
(parameter) app.NSRect contentRect
contentRect
, ulong
(parameter) ulong styleMask
styleMask
,
ulong
(parameter) ulong backing
backing
, bool
(parameter) bool defer
defer
) @selector("initWithContentRect:styleMask:backing:defer:");
void
void app.NSWindow.setTitle(app.NSString title)
setTitle
(
(class) app.NSString
NSString
(parameter) app.NSString title
title
) @selector("setTitle:");
void
void app.NSWindow.setContentView(app.NSObject view)
setContentView
(
(class) app.NSObject
NSObject
(parameter) app.NSObject view
view
) @selector("setContentView:");
void
void app.NSWindow.setReleasedWhenClosed(bool b)
setReleasedWhenClosed
(bool
(parameter) bool b
b
) @selector("setReleasedWhenClosed:");
void
void app.NSWindow.makeKeyAndOrderFront(app.NSObject sender)
makeKeyAndOrderFront
(
(class) app.NSObject
NSObject
(parameter) app.NSObject sender
sender
) @selector("makeKeyAndOrderFront:");
long
long app.NSWindow.windowNumber()
windowNumber
() @selector("windowNumber");
} class
(class) app.PlainWindow
PlainWindow
:
(class) app.NSWindow
NSWindow
class `app.PlainWindow` Objective-C classes not supported
{ static
(class) app.PlainWindow
PlainWindow
app.PlainWindow app.PlainWindow.alloc()
alloc
() @selector("alloc");
} // Pasteboard owner: the lazy-promise provider + the ownership-loss callback; // also the NSDraggingSource for the DnD attempt. class
(class) app.PBOwner
PBOwner
:
(class) app.NSObject
NSObject
class `app.PBOwner` Objective-C classes not supported
{ static
(class) app.PBOwner
PBOwner
app.PBOwner app.PBOwner.alloc()
alloc
() @selector("alloc");
(class) app.PBOwner
PBOwner
app.PBOwner app.PBOwner.init()
init
() @selector("init");
// The promise is demanded HERE — only when a reader actually asks for the type. void
void app.PBOwner.pasteboardProvideDataForType(app.NSPasteboard pb, app.NSString type)
pasteboardProvideDataForType
(
(class) app.NSPasteboard
NSPasteboard
(parameter) app.NSPasteboard pb
pb
,
(class) app.NSString
NSString
(parameter) app.NSString type
type
)
@selector("pasteboard:provideDataForType:") { ++g_provideCalls; instr("clip_request", "fmt=%s lazy=1 main_thread=%d declare_to_demand_us=%llu", type.
type.UTF8String
UTF8String
(), pthread_main_np(), instrNowUs() - g_declareUs);
pb.
pb.setString
setString
(nsstr(kPayload), type); // render the promise
instr("clip_send", "bytes=%d fmt=%s lazy=1", cast(int) strlen(kPayload), type.
type.UTF8String
UTF8String
());
} // Old owner's loss signal (clipboard taken by another app). HAZARD, measured: // AppKit delivers this from INSIDE -[NSPasteboard changeCount] (the poll), and // calling changeCount here re-enters handleOwnershipChange → unbounded // recursion → stack-overflow SIGSEGV. Do not touch the pasteboard here. void
void app.PBOwner.pasteboardChangedOwner(app.NSPasteboard pb)
pasteboardChangedOwner
(
(class) app.NSPasteboard
NSPasteboard
(parameter) app.NSPasteboard pb
pb
) @selector("pasteboardChangedOwner:")
{ ++g_ownerLost; instr("ownership_lost", "callback=pasteboardChangedOwner main_thread=%d n=%d", pthread_main_np(), g_ownerLost); } // NSDraggingSource (required method). ulong
ulong app.PBOwner.sourceOperationMask(app.NSDraggingSession session, long context)
sourceOperationMask
(
(class) app.NSDraggingSession
NSDraggingSession
(parameter) app.NSDraggingSession session
session
, long
(parameter) long context
context
)
@selector("draggingSession:sourceOperationMaskForDraggingContext:") { instr("dnd_source", "event=sourceOperationMask context=%ld mask=copy", context); return 1; // NSDragOperationCopy } void
void app.PBOwner.sessionWillBegin(app.NSDraggingSession session, app.NSPoint p)
sessionWillBegin
(
(class) app.NSDraggingSession
NSDraggingSession
(parameter) app.NSDraggingSession session
session
,
(struct) app.NSPoint
NSPoint
(parameter) app.NSPoint p
p
)
@selector("draggingSession:willBeginAtPoint:") { instr("dnd_source", "event=willBeginAtPoint loc=(%.0f,%.0f)", p.
p.x
x
, p.
p.y
y
);
} void
void app.PBOwner.sessionEnded(app.NSDraggingSession session, app.NSPoint p, ulong op)
sessionEnded
(
(class) app.NSDraggingSession
NSDraggingSession
(parameter) app.NSDraggingSession session
session
,
(struct) app.NSPoint
NSPoint
(parameter) app.NSPoint p
p
, ulong
(parameter) ulong op
op
)
@selector("draggingSession:endedAtPoint:operation:") { instr("dnd_source", "event=endedAtPoint loc=(%.0f,%.0f) operation=%lu", p.
p.x
x
, p.
p.y
y
, op);
} void
void app.PBOwner.tick(app.NSTimer t)
tick
(
(class) app.NSTimer
NSTimer
(parameter) app.NSTimer t
t
) @selector("tick:")
{ onStep(); } } // The drop target: full NSDraggingDestination protocol, every callback logged. class
(class) app.DropView
DropView
:
(class) app.NSView
NSView
class `app.DropView` Objective-C classes not supported
{ static
(class) app.DropView
DropView
app.DropView app.DropView.alloc()
alloc
() @selector("alloc");
(class) app.DropView
DropView
app.DropView app.DropView.initWithFrame(app.NSRect frame)
initWithFrame
(
(struct) app.NSRect
NSRect
(parameter) app.NSRect frame
frame
) @selector("initWithFrame:");
void
void app.DropView.drawRect(app.NSRect dirtyRect)
drawRect
(
(struct) app.NSRect
NSRect
(parameter) app.NSRect dirtyRect
dirtyRect
) @selector("drawRect:")
{ void*
_error_ ctx
ctx
= NSGraphicsContext.
NSGraphicsContext.currentContext
currentContext
().
NSGraphicsContext.currentContext().CGContext
CGContext
();
CGContextSetRGBFillColor(ctx, 0.15, 0.2, 0.25, 1); CGContextFillRect(ctx, this.
this.bounds
bounds
());
} ulong
ulong app.DropView.draggingEntered(app.NSObject info)
draggingEntered
(
(class) app.NSObject
NSObject
(parameter) app.NSObject info
info
) @selector("draggingEntered:")
{ ++g_dndEntered; logOffer("dnd_enter", info.
info.draggingPasteboard
draggingPasteboard
());
instr("dnd_enter", "source_mask=0x%lx loc=(%.0f,%.0f) accept=copy", info.
info.draggingSourceOperationMask
draggingSourceOperationMask
(), info.
info.draggingLocation
draggingLocation
().
info.draggingLocation().x
x
,
info.
info.draggingLocation
draggingLocation
().
info.draggingLocation().y
y
);
return 1; // NSDragOperationCopy } ulong
ulong app.DropView.draggingUpdated(app.NSObject info)
draggingUpdated
(
(class) app.NSObject
NSObject
(parameter) app.NSObject info
info
) @selector("draggingUpdated:")
{ ++g_dndUpdated; if (g_dndUpdated <= 3) instr("dnd_update", "loc=(%.0f,%.0f) accept=copy", info.
info.draggingLocation
draggingLocation
().
info.draggingLocation().x
x
, info.
info.draggingLocation
draggingLocation
().
info.draggingLocation().y
y
);
return 1; } void
void app.DropView.draggingExited(app.NSObject info)
draggingExited
(
(class) app.NSObject
NSObject
(parameter) app.NSObject info
info
) @selector("draggingExited:")
{ instr("dnd_exit", ""); } bool
bool app.DropView.prepareForDragOperation(app.NSObject info)
prepareForDragOperation
(
(class) app.NSObject
NSObject
(parameter) app.NSObject info
info
)
@selector("prepareForDragOperation:") { instr("dnd_prepare", "accept=1"); return true; } bool
bool app.DropView.performDragOperation(app.NSObject info)
performDragOperation
(
(class) app.NSObject
NSObject
(parameter) app.NSObject info
info
) @selector("performDragOperation:")
{ ++g_dndDropped; auto
_error_ pb
pb
= info.
info.draggingPasteboard
draggingPasteboard
();
logOffer("dnd_drop_offer", pb);
(unresolved type) NSString
NSString
_error_ url
url
= pb.
pb.stringForType
stringForType
(nsstr("public.file-url"));
if (url !is null) instr("dnd_drop", "fmt=public.file-url bytes=%lu data=%s", url.
url.lengthOfBytesUsingEncoding
lengthOfBytesUsingEncoding
(4), url.
url.UTF8String
UTF8String
());
(unresolved type) NSString
NSString
_error_ s
s
= pb.
pb.stringForType
stringForType
(nsstr("public.utf8-plain-text"));
if (s !is null) instr("dnd_drop", "fmt=public.utf8-plain-text bytes=%lu data=%s", s.
s.lengthOfBytesUsingEncoding
lengthOfBytesUsingEncoding
(4), s.
s.UTF8String
UTF8String
());
return true; } void
void app.DropView.concludeDragOperation(app.NSObject info)
concludeDragOperation
(
(class) app.NSObject
NSObject
(parameter) app.NSObject info
info
)
@selector("concludeDragOperation:") { instr("dnd_conclude", ""); } } extern (D): // back to D linkage enum
(constant) int app.NSApplicationActivationPolicyRegular = 0
NSApplicationActivationPolicyRegular
= 0;
enum ulong
(constant) ulong app.NSWindowStyleMaskTitled = 1LU
NSWindowStyleMaskTitled
= 1;
enum ulong
(constant) ulong app.NSBackingStoreBuffered = 2LU
NSBackingStoreBuffered
= 2;
enum long
(constant) long app.NSEventTypeLeftMouseDown = 1L
NSEventTypeLeftMouseDown
= 1;
enum long
(constant) long app.NSEventTypeApplicationDefined = 15L
NSEventTypeApplicationDefined
= 15;
enum ulong
(constant) ulong app.NSUTF8StringEncoding = 4LU
NSUTF8StringEncoding
= 4;
// The non-ASCII payload required by the spec: 2 + 3 + 4 UTF-8 bytes. __gshared const(char)*
(__gshared global) const(char)* app.kPayload
kPayload
= "é漢🎈";
__gshared
(class) app.NSApplication
NSApplication
(__gshared global) app.NSApplication app.g_app
g_app
;
__gshared
(class) app.NSWindow
NSWindow
(__gshared global) app.NSWindow app.g_win
g_win
;
__gshared
(class) app.DropView
DropView
(__gshared global) app.DropView app.g_view
g_view
;
__gshared
(class) app.PBOwner
PBOwner
(__gshared global) app.PBOwner app.g_owner
g_owner
;
__gshared
(class) app.NSPasteboard
NSPasteboard
(__gshared global) app.NSPasteboard app.g_pb
g_pb
;
__gshared bool
(__gshared global) bool app.g_auto
g_auto
;
__gshared int
(__gshared global) int app.g_step
g_step
;
__gshared long
(__gshared global) long app.g_lastSeenCC
g_lastSeenCC
; // the changeCount poll (the only change signal)
__gshared bool
(__gshared global) bool app.g_pollArmed
g_pollArmed
;
__gshared int
(__gshared global) int app.g_provideCalls
g_provideCalls
;
__gshared int
(__gshared global) int app.g_ownerLost
g_ownerLost
;
__gshared ulong
(__gshared global) ulong app.g_declareUs
g_declareUs
;
__gshared int
(__gshared global) int app.g_dndEntered
g_dndEntered
,
(__gshared global) int app.g_dndUpdated
g_dndUpdated
,
(__gshared global) int app.g_dndDropped
g_dndDropped
;
__gshared
(class) app.NSDraggingSession
NSDraggingSession
(__gshared global) app.NSDraggingSession app.g_session
g_session
;
(class) app.NSString
NSString
app.NSString app.nsstr(const(char)* s)
nsstr
(const(char)*
(parameter) const(char)* s
s
)
{ return NSString.
NSString.alloc
alloc
().
NSString.alloc().initWithUTF8String
initWithUTF8String
(s);
} void
void app.logOffer(const(char)* kind, app.NSPasteboard pb)
logOffer
(const(char)*
(parameter) const(char)* kind
kind
,
(class) app.NSPasteboard
NSPasteboard
(parameter) app.NSPasteboard pb
pb
)
{ auto
_error_ types
types
= pb.
pb.types
types
();
immutable
_error_ n
n
= types !is null ? types.
types.count
count
() : 0;
char[1024]
_error_ buf
buf
= 0;
size_t
_error_ off
off
= 0;
foreach (
(parameter) i
i
; 0 .. n)
{ auto
_error_ t
t
= (cast(
(unresolved type) NSString
NSString
) types.
types.objectAtIndex
objectAtIndex
(i)).
(cast(NSString)types.objectAtIndex(i)).UTF8String
UTF8String
();
off += snprintf(buf.ptr + off, buf.length - off, "%s%s", i ? ",".ptr : "".ptr, t); if (off >= buf.length - 1) break; } instr(kind, "change_count=%ld formats=[%s] n=%lu", pb.
pb.changeCount
changeCount
(), buf.ptr, n);
} // Read a small file written by a background pbpaste; returns bytes read. int
int app.readBack(const(char)* path, char[] sink)
readBack
(const(char)*
(parameter) const(char)* path
path
, char[]
(parameter) char[] sink
sink
)
{
(unresolved type) FILE
FILE
*
_error_ f
f
= fopen(path, "rb");
if (f is null) return -1; immutable
_error_ n
n
= cast(int) fread(sink.ptr, 1, sink.length - 1, f);
fclose(f); sink[n < 0 ? 0 : n] = 0; return n; } void
void app.stopApp()
stopApp
()
{ instr("step", "name=NSApp_stop"); g_app.
g_app.stop
stop
(null);
(unresolved type) NSEvent
NSEvent
_error_ ev
ev
= NSEvent.
NSEvent.otherEventWithType
otherEventWithType
(NSEventTypeApplicationDefined,
NSPoint(0, 0), 0, 0, 0, null, 0, 0, 0); g_app.
g_app.postEvent
postEvent
(ev, true);
} // --- The scripted run (one step per 300 ms tick) ------------------------------------ void
void app.onStep()
onStep
()
{ // The changeCount poll runs on every tick: this IS the macOS clipboard event // model — NSPasteboard posts no notification on change; readers poll. if (g_pollArmed) { immutable
_error_ cc
cc
= g_pb.
g_pb.changeCount
changeCount
();
if (cc != g_lastSeenCC) { instr("clip_external_change", "detected_by=changeCount_poll old=%ld new=%ld", g_lastSeenCC, cc); g_lastSeenCC = cc; } } if (!g_auto) return; switch (g_step) { case 0: // Baseline. g_lastSeenCC = g_pb.
g_pb.changeCount
changeCount
();
instr("step", "name=baseline pb=%s change_count=%ld", g_pb.
g_pb.name
name
().
g_pb.name().UTF8String
UTF8String
(), g_lastSeenCC);
break; case 1: // COPY, eager: clearContents bump + setString. { immutable
_error_ cc0
cc0
= g_pb.
g_pb.changeCount
changeCount
();
immutable
_error_ cc1
cc1
= g_pb.
g_pb.clearContents
clearContents
();
immutable
_error_ ok
ok
= g_pb.
g_pb.setString
setString
(nsstr(kPayload), nsstr("public.utf8-plain-text"));
immutable
_error_ cc2
cc2
= g_pb.
g_pb.changeCount
changeCount
();
instr("clip_copy", "mode=eager fmt=public.utf8-plain-text bytes=%d ok=%d change_count=%ld->%ld(clear)->%ld", cast(int) strlen(kPayload), ok ? 1 : 0, cc0, cc1, cc2); g_lastSeenCC = cc2; // Cross-process verification: pbpaste in another process, async so the // run loop keeps servicing the pasteboard server. system("/bin/sh -c 'LANG=en_US.UTF-8 pbpaste > /tmp/wsi-m8/f16-eager.txt 2>&1 &'"); } break; case 2: // Read pbpaste's harvest back. { char[256]
_error_ sink
sink
;
immutable
_error_ n
n
= readBack("/tmp/wsi-m8/f16-eager.txt", sink);
instr("clip_verify", "via=pbpaste mode=eager bytes=%d data=%s match=%d", n, sink.ptr, n == cast(int) strlen(kPayload) && strcmp(sink.ptr, kPayload) == 0 ? 1 : 0); } break; case 3: // COPY, lazy: declareTypes:owner: — the promise. { immutable
_error_ cc0
cc0
= g_pb.
g_pb.changeCount
changeCount
();
auto
_error_ types
types
= NSMutableArray.
NSMutableArray.array
array
();
types.
types.addObject
addObject
(nsstr("public.utf8-plain-text"));
immutable
_error_ cc1
cc1
= g_pb.
g_pb.declareTypes
declareTypes
(types, g_owner);
g_declareUs = instrNowUs(); instr("clip_offer", "mode=lazy formats=[public.utf8-plain-text] change_count=%ld->%ld provider_called=%d", cc0, cc1, g_provideCalls); g_lastSeenCC = g_pb.
g_pb.changeCount
changeCount
();
} break; case 4: // One full tick later: still not demanded? Then unleash the reader. instr("clip_lazy", "provider_called=%d note=no_reader_yet", g_provideCalls); system("/bin/sh -c 'LANG=en_US.UTF-8 pbpaste > /tmp/wsi-m8/f16-lazy.txt 2>&1 &'"); break; case 5: // The promise should have been demanded by pbpaste by now. { char[256]
_error_ sink
sink
;
immutable
_error_ n
n
= readBack("/tmp/wsi-m8/f16-lazy.txt", sink);
instr("clip_verify", "via=pbpaste mode=lazy bytes=%d data=%s provider_called=%d match=%d", n, sink.ptr, g_provideCalls, n == cast(int) strlen(kPayload) && strcmp(sink.ptr, kPayload) == 0 ? 1 : 0); } break; case 6: // Ownership loss: an external pbcopy takes the board from us. instr("step", "name=external_pbcopy_takeover promise_state=fulfilled"); system("/bin/sh -c \"printf 'external-Ω' | LANG=en_US.UTF-8 pbcopy &\""); g_pollArmed = true; // detection = changeCount poll (top of tick) break; case 7: // (poll fires above) — nothing; give the takeover a full tick. break; case 8: // PASTE: offered types first, then the chosen one + byte count. { logOffer("clip_offer_read", g_pb);
(unresolved type) NSString
NSString
_error_ s
s
= g_pb.
g_pb.stringForType
stringForType
(nsstr("public.utf8-plain-text"));
if (s !is null) instr("clip_paste", "fmt=public.utf8-plain-text bytes=%lu data=%s ownership_lost_callbacks=%d", s.
s.lengthOfBytesUsingEncoding
lengthOfBytesUsingEncoding
(NSUTF8StringEncoding),
s.
s.UTF8String
UTF8String
(), g_ownerLost);
else instr("clip_paste", "fmt=public.utf8-plain-text result=nil"); } break; case 9: // Ownership loss with an UNFULFILLED promise: declare lazy again … { auto
_error_ types
types
= NSMutableArray.
NSMutableArray.array
array
();
types.
types.addObject
addObject
(nsstr("public.utf8-plain-text"));
immutable
_error_ cc
cc
= g_pb.
g_pb.declareTypes
declareTypes
(types, g_owner);
instr("clip_offer", "mode=lazy_unfulfilled change_count=%ld ownership_lost_callbacks=%d", cc, g_ownerLost); g_lastSeenCC = g_pb.
g_pb.changeCount
changeCount
();
} break; case 10: // … and let pbcopy take the board while the promise is pending. instr("step", "name=external_pbcopy_takeover promise_state=unfulfilled"); system("/bin/sh -c \"printf 'takeover2' | LANG=en_US.UTF-8 pbcopy &\""); break; case 11: // Did pasteboardChangedOwner: fire this time? instr("ownership_probe", "callbacks=%d provider_calls=%d note=takeover_with_pending_promise", g_ownerLost, g_provideCalls); break; case 12: // DnD: in-process drag attempt over our own registered view. { system("/bin/sh -c 'echo wsi-f16-drop-payload > /tmp/wsi-m8/f16-drop.txt'"); auto
_error_ item
item
= NSPasteboardItem.
NSPasteboardItem.alloc
alloc
().
NSPasteboardItem.alloc().init
init
();
item.
item.setString
setString
(nsstr("file:///tmp/wsi-m8/f16-drop.txt"), nsstr("public.file-url"));
item.
item.setString
setString
(nsstr(kPayload), nsstr("public.utf8-plain-text"));
auto
_error_ drag
drag
= NSDraggingItem.
NSDraggingItem.alloc
alloc
().
NSDraggingItem.alloc().initWithPasteboardWriter
initWithPasteboardWriter
(item);
drag.
drag.setDraggingFrame
setDraggingFrame
(NSRect(NSPoint(100, 100), NSSize(32, 32)), null);
(unresolved type) NSEvent
NSEvent
_error_ down
down
= NSEvent.
NSEvent.mouseEventWithType
mouseEventWithType
(NSEventTypeLeftMouseDown,
NSPoint(120, 120), 0, 0, g_win.
g_win.windowNumber
windowNumber
(), null, 0, 1, 0);
instr("dnd_begin", "api=beginDraggingSessionWithItems types=[public.file-url,public.utf8-plain-text]"); g_session = g_view.
g_view.beginDraggingSession
beginDraggingSession
(NSArray.
NSArray.arrayWithObject
arrayWithObject
(drag),
down, g_owner); instr("dnd_session", "started=%d seq=%ld", g_session !is null ? 1 : 0, g_session !is null ? g_session.
g_session.draggingSequenceNumber
draggingSequenceNumber
() : -1);
} break; case 13: // Inspect the DRAG pasteboard the session populated. case 14: break; case 15: { auto
_error_ dragPb
dragPb
= NSPasteboard.
NSPasteboard.pasteboardWithName
pasteboardWithName
(nsstr("Apple CFPasteboard drag"));
logOffer("dnd_drag_pasteboard", dragPb);
(unresolved type) NSString
NSString
_error_ url
url
= dragPb.
dragPb.stringForType
stringForType
(nsstr("public.file-url"));
instr("dnd_drag_pasteboard", "file_url=%s", url !is null ? url.
url.UTF8String
UTF8String
() : "nil");
instr("dnd_summary", "entered=%d updated=%d dropped=%d note=%s", g_dndEntered, g_dndUpdated, g_dndDropped, g_dndEntered == 0 ? "no_destination_events_headless_locked_session_tierC".ptr : "destination_protocol_exercised".ptr); } break; case 16: instr("summary", "provider_calls=%d ownership_lost=%d dnd_entered=%d dnd_dropped=%d", g_provideCalls, g_ownerLost, g_dndEntered, g_dndDropped); stopApp(); break; default: stopApp(); break; } ++g_step; } // --- Promise-exit modes: declare, then die with the promise unrendered --------------- int
int app.runPromiseExit(bool hard)
runPromiseExit
(bool
(parameter) bool hard
hard
)
{ g_pb = NSPasteboard.
NSPasteboard.generalPasteboard
generalPasteboard
();
auto
_error_ types
types
= NSMutableArray.
NSMutableArray.array
array
();
types.
types.addObject
addObject
(nsstr("public.utf8-plain-text"));
immutable
_error_ cc
cc
= g_pb.
g_pb.declareTypes
declareTypes
(types, g_owner);
instr("clip_offer", "mode=promise_exit formats=[public.utf8-plain-text] change_count=%ld provider_called=%d", cc, g_provideCalls); if (hard) { instr("exit", "kind=_exit_2 provider_called=%d note=promise_unrendered", g_provideCalls); _exit(2); // no atexit, no ObjC teardown — the source vanishes } instr("exit", "kind=return_from_main provider_called=%d", g_provideCalls); return 0; // normal exit: does anything render the promise on the way out? } int
int D main()
main
()
{ g_auto = getenv("WSI_AUTO_EXIT") !is null; const(char)*
_error_ mode
mode
= getenv("WSI_MODE");
instrInit("APPKIT_F16"); instr("init_start", "auto_exit=%d mode=%s", g_auto ? 1 : 0, mode !is null ? mode : "scripted"); if (CGMainDisplayID() == 0) { printf("SKIP: no macOS window server (CGMainDisplayID == 0)\n"); return 0; } logSessionLockState(); auto
_error_ pool
pool
= autoreleasepool_push();
scope (exit) autoreleasepool_pop(pool); g_app = NSApplication.
NSApplication.sharedApplication
sharedApplication
();
g_app.
g_app.setActivationPolicy
setActivationPolicy
(NSApplicationActivationPolicyRegular);
g_owner = PBOwner.
PBOwner.alloc
alloc
().
PBOwner.alloc().init
init
();
if (mode !is null && strcmp(mode, "promise-exit-return") == 0) return runPromiseExit(false); if (mode !is null && strcmp(mode, "promise-exit-hard") == 0) return runPromiseExit(true); immutable
_error_ contentRect
contentRect
= NSRect(NSPoint(120, 120), NSSize(480, 320));
g_win = PlainWindow.
PlainWindow.alloc
alloc
().
PlainWindow.alloc().initWithContentRect
initWithContentRect
(contentRect,
NSWindowStyleMaskTitled, NSBackingStoreBuffered, false); g_win.
g_win.setTitle
setTitle
(nsstr("wsi-f16-clipboard-dnd"));
g_win.
g_win.setReleasedWhenClosed
setReleasedWhenClosed
(false);
g_view = DropView.
DropView.alloc
alloc
().
DropView.alloc().initWithFrame
initWithFrame
(NSRect(NSPoint(0, 0), contentRect.
contentRect.size
size
));
auto
_error_ dndTypes
dndTypes
= NSMutableArray.
NSMutableArray.array
array
();
dndTypes.
dndTypes.addObject
addObject
(nsstr("public.file-url"));
dndTypes.
dndTypes.addObject
addObject
(nsstr("public.utf8-plain-text"));
g_view.
g_view.registerForDraggedTypes
registerForDraggedTypes
(dndTypes);
instr("dnd_register", "types=[public.file-url,public.utf8-plain-text]"); g_win.
g_win.setContentView
setContentView
(g_view);
g_win.
g_win.makeKeyAndOrderFront
makeKeyAndOrderFront
(null);
instr("window_created", "win_num=%ld", g_win.
g_win.windowNumber
windowNumber
());
g_pb = NSPasteboard.
NSPasteboard.generalPasteboard
generalPasteboard
();
NSTimer.
NSTimer.scheduledTimerWithTimeInterval
scheduledTimerWithTimeInterval
(0.3, g_owner, SEL.register("tick:"), null, true);
instr("step", "name=NSApp_run"); g_app.
g_app.run
run
();
instr("loop_exit", "steps=%d", g_step); return 0; }