Ah, thanks. I've looked thought the src now, and it seems _C_ID and _C_BOOL might correspond to "@" and "B" but I can't find where they are defined; not in macruby src nor in Cocoa Dev Documentation.
Where is the list of available Pointer types + their character code? Cheers Nic On Fri, Jan 2, 2009 at 10:15 AM, Vincent Isambart <[email protected]> wrote: >> The following doesn't work: >> >> framework 'Cocoa' >> p1 = Pointer.new_with_type('@') >> p1.assign(false) >> p1[0] == false # => false, but should be true >> >> Then I figured I should be able to pass BOOL to -new_with_type as it >> is the data type, but BOOL isn't recognised. > > The type for bool is upper case B. If you replace @ with B in your > example it works fine. > > Just a little warning about pointers: they tend to forget their type > if you read the value returned by a function twice. Do not try to read > more than once their value (just store the value returned by #[] in a > Ruby variable). However, reusing the same pointer in multiple calls > seems to work fine. > For example the following code: > # rects was retuned by NSLayoutManager#rectArrayForCharacterRange > puts rects[0] > puts rects[0] > > Displays: > #<NSRect origin=#<NSPoint x=5.0 y=0.0> size=#<NSSize width=0.0 height=19.0>> > xxxxx.rb:222:in `[]': unrecognized octype `?_?' (RuntimeError) > _______________________________________________ > MacRuby-devel mailing list > [email protected] > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel > -- Dr Nic Williams iPhone and Rails consultants - http://mocra.com Fun with iPhone/Ruby/Rails/Javascript - http://drnicwilliams.com * Surf Report for iPhone - http://mocra.com/projects/surfreport/ * _______________________________________________ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
