ObjectiveC.jl icon indicating copy to clipboard operation
ObjectiveC.jl copied to clipboard

Add Cocoa wrappers

Open JayKickliter opened this issue 9 years ago • 5 comments

This commented out line is breaking the Cocoa functionality of the package.

Was it because nsrect isn't working? I had to definition to this to get it to work:

nsrect(x, y, w, h) =
  ccall((:nsmakerect, "cocoa"), Ptr{Void}, (Cfloat, Cfloat, Cfloat, Cfloat),
        x, y, w, h)

JayKickliter avatar Jul 11 '15 20:07 JayKickliter

Honestly, I can't remember – it's been a while since I worked on this.

If you want to patch up these issues through a PR you'd be very welcome – otherwise I probably won't get round to it for a while.

MikeInnes avatar Jul 11 '15 20:07 MikeInnes

Ok. I'll see what I can do. Same with the other issue.

JayKickliter avatar Jul 11 '15 20:07 JayKickliter

fwiw, julia v0.4 can call NSMakeRect directly by mirroring the struct layout into julia types, and thus no longer requires the .m shim:

immutable NSPoint
x::Cfloat
y::Cfloat
end
immutable NSSize
width::Cfloat
height::Cfloat
end
immutable NSRect
origin::NSPoint
size::NSSize
end
ccall((:NSMakeRect, "Foundation"), NSRect, (Cfloat, Cfloat, Cfloat, Cfloat), x, y, w, h)

vtjnash avatar Jul 12 '15 04:07 vtjnash

Awesome, this will help us get rid of the last bits of Objective-C code – thanks for providing the example.

One tricky part is that currently method signatures are loaded dynamically. Presumably we'll have to either generate the corresponding types dynamically too, or force type hints for structs. (Perhaps tuples will work in place of immutable types?)

MikeInnes avatar Jul 13 '15 17:07 MikeInnes

As part of #11 I removed the Cocoa wrappers entirely, so if anybody is interested in bringing them back: have a look at the state of the package at commit https://github.com/JuliaInterop/ObjectiveC.jl/tree/22118319da1fb7601d2a3ecefb671ffbb5e57012.

maleadt avatar Mar 08 '23 12:03 maleadt