Re: [MacRuby-devel] Porting Cocoa OpenGL sample code

2009-03-06 Thread Brian Chapados
I'm not sure what's happening with the pointer to an array of longs in the first case. It looks like the Pointer is being created, but there is no way to assign/retrieve values? p = Pointer.new_with_type('^L') p.assign([1,2,3]) p[0][1] # => 2 I think the reason that this works is that rb_objc_rv

Re: [MacRuby-devel] Porting Cocoa OpenGL sample code

2009-02-27 Thread Julien Jassaud
Brian, Thanks for the very detailed answer. This tremendously helps. I am now having problems with arrays, though. I try to make a pointer to an array of 32 longs, like this : >> p = Pointer.new_with_type('[32L]') => # >> p[0] ArgumentError: can't convert C/Objective-C value `0x80052ae40' o

Re: [MacRuby-devel] Porting Cocoa OpenGL sample code

2009-02-25 Thread Laurent Sansonetti
That's a pretty good idea. I tried to make the Pointer class as simple (and stupid) as possible but we might need some convenience APIs on top of it, for those not familiar with the Objective-C encoding types. Here is an API proposal based on Brian's snippet... thoughts? class Pointer def

Re: [MacRuby-devel] Porting Cocoa OpenGL sample code

2009-02-25 Thread Matt Aimonetti
Thanks Brian for the detailed explanation. I wonder if your Pointer extension shouldn't be merged into HotCocoa or MacRuby itself. What do you guys think? - Matt On Wed, Feb 25, 2009 at 12:43 PM, Brian Chapados wrote: >> Can you explain: "^{_CGLRendererInfoObject=}"? is that some secret >> inca

Re: [MacRuby-devel] Porting Cocoa OpenGL sample code

2009-02-25 Thread Brian Chapados
> Can you explain: "^{_CGLRendererInfoObject=}"? is that some secret > incantation only known by the MacRuby/Obj overlords? Yes, it is actually a 7th level spell: 'Encode Structure'. To learn it, you must study the ancient tome: http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCRuntim

Re: [MacRuby-devel] Porting Cocoa OpenGL sample code

2009-02-25 Thread Matt Aimonetti
Brian, what's up with this syntax: info = Pointer.new_with_type("^{_CGLRendererInfoObject=}") Can you explain: "^{_CGLRendererInfoObject=}"? is that some secret incantation only known by the MacRuby/Obj overlords? Thanks, - Matt On Wed, Feb 25, 2009 at 10:13 AM, Brian Chapados wrote: > CGLRen

Re: [MacRuby-devel] Porting Cocoa OpenGL sample code

2009-02-25 Thread Brian Chapados
CGLRendererInfo is a pointer to a struct: typedef struct _CGLRendererInfoObject *CGLRendererInfoObj; try creating a pointer to void or to the struct: info = Pointer.new_with_type("^v") # void *info; or info = Pointer.new_with_type("^{_CGLRendererInfoObject=}") # CGLRendererInfo *info I th

[MacRuby-devel] Porting Cocoa OpenGL sample code

2009-02-25 Thread Julien Jassaud
Hello, I am trying to port the Cocoa OpenGL sample to MacRuby and encountered a few problems. First, I can't access some constants defined in an enum in GLTypes.h. Do I need to port those constants to ruby by hand ? Is that related to gen_bridge_metadata ? Second, I need to use CGLQue