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
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
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
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
> 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
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
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