ObjC is certainly wonderful for building language bindings (I'm the author of that code in Tk.jl). Unfortunately, until someone has time to finish polishing/testing #3466 -- it's nearly done if you want to take it over -- we can't send structs as values. -Jameson
(wow, I feel so behind on email right now) On Tue, Feb 4, 2014 at 2:32 PM, <[email protected]> wrote: > I'm playing around with calling some objective-c code in the Mac system > frameworks, because there are a lot of useful goodies in there. I'm > generally having more success than I deserve. Thanks to some code that I > saw in Tk.jl, I am able to send messages to objects, using various > frameworks, and get the right results most of the time. The problem I've run > into is with messages that take a structure as an argument. For example, if > I try to make a window, I define these types (as defined in the Foundation > framework, IIRC). > > immutable NSPoint > x::Cdouble > y::Cdouble > end > > immutable NSSize > w::Cdouble > h::Cdouble > end > > immutable NSRect > point::NSPoint > sz::NSSize > end > string(r::NSRect) = "{$(r.point.x), $(r.point.y)}, {$(r.sz.w), $(r.sz.h)}" > NSRect(x, y, w, h) = NSRect(NSPoint(x, y), NSSize(w, h)) > > Then I create the window like so using something like (based on a comment > from stevenj here): > > window = ccall(:objc_msgSend, Ptr{Void}, (Ptr{Void}, Ptr{Void}, NSRect, > Uint64, Uint64, Int), > > oms(ogc("NSWindow"), "alloc"), msg, NSRect(0, 0, 200, 200), 11, 2, true) > > # `oms(obj, msg, type)` sends a message to object > # `ogc(class)` gets a pointer to an objective-c class > > > Unfortunately, querying the window size gives me garbage: > > @show oms(window, "frame", NSRect) # expect ((0, 0,), (200, 200)) > oms(window,"frame",NSRect) => > NSRect(NSPoint(1.390671161566996e-309,5.432309224866e-312),NSSize(NaN,NaN)) > > > Changing the origin or the dimensions of the rectangle has no effect on the > output, so I can't even sort out if it's an alignment issue. > > > So, a fairly open-ended question, does anyone have any tips for getting this > to work? I've been following issue 3466, does that mean that this is > hopeless (for the moment)?
