[MacRuby-devel] Pointers for BOOL types

Lachie lachiec at gmail.com
Thu Jan 1 18:37:58 PST 2009


Hey Nic

Cheque it: http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/chapter_7_section_1.html#//apple_ref/doc/uid/TP40008048-CH100-SW1

:lachie
http://smartbomb.com.au
http://www.flickr.com/photos/lachie/



On Fri, Jan 2, 2009 at 1:04 PM, Dr Nic Williams <drnicwilliams at gmail.com> wrote:
> 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
> <vincent.isambart at gmail.com> 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
>> MacRuby-devel at lists.macosforge.org
>> 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
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>


More information about the MacRuby-devel mailing list