Hi Steven,

Here is a correct snippet that works with the exact same bridgesupport file:
framework 'Carbon'
load_bridge_support_file('b.bridgesupport')

ptr = Pointer.new("{ProcessSerialNumber=II}")
GetCurrentProcess(ptr)
p ptr[0].lowLongOfPSN

The idea is that you want to pass a pointer to the structure, and not the sctructure itself to GetCurrentProcess :-)

You can, as you said, do (almost) the same with Cocoa:
framework "AppKit"
info = NSWorkspace.sharedWorkspace.activeApplication
puts "Serial # Low : " + info["NSApplicationProcessSerialNumberLow"].to_s
puts "Serial # High: " + info["NSApplicationProcessSerialNumberHigh"].to_s

However, please note that this will get the current **application** PSN, which, in case you run the script in Terminal, will be Terminal's PSN, not MacRuby's.

-- 
Thibault Martin-Lagardette



On Aug 25, 2010, at 18:20, Steven Parkes wrote:

Hope this helps :-)

Yup. I'm getting the hang of bridgesupport (coming from an MRI FFI world ...)

Any obvious reason why this doesn't seem to work?

<?xml version='1.0'?>
<!DOCTYPE signatures SYSTEM "file://localhost/System/Library/DTDs/BridgeSupport.dtd ">
<signatures version='0.9'>
<struct name='ProcessSerialNumber' type='{ProcessSerialNumber="highLongOfPSN"I"lowLongOfPSN"I}' />
<function name='GetCurrentProcess'>
 <reval type='s' />
 <arg type='^{ProcessSerialNumber=II}' type_modifier='o' />
</function>
</signatures>

load_bridge_support_file(...)
psn = ProcessSerialNumber.new
GetCurrentProcess(psn)
p psn

I don't see the member values getting set the way I expect: they come back as zero, which isn't right. I can see it making the call in gdb and 'o' seems right by the other examples, but?

I know (think?) I can get this information from NSWorkspace ... this was more to test my understanding and prove I could the values back I expect ... but I don't seem to be able to ...
_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel