Hi Mark,
> Ah, that does work, and seems to have worked for a number of other things I
> am trying to do.
>
> The only problem now is when I have something like
>
> value = Pointer.new '^v' # pointer to pointer to void
> AXUIElementCopyAttributeValue mail_object, 'AXHidden', value
>
> In this case I am using it right now, it will be returning a boolean, but
> when I try to dereference it like
>
> puts value[0][0] # => 120
>
> it gives me a Fixnum, and then I can keep trying things like
>
> puts value[0][1] # => 104
> puts value[0][10000] # => 0
>
> And I seem to get nowhere.
>
> Is there a way to cast the data back into the type I want it to be? Or am I
> doing something dumb?
Looks like this function has the following declaration:
extern AXError AXUIElementCopyAttributeValue (AXUIElementRef element,
CFStringRef attribute, CFTypeRef *value);
So, the 3rd argument is is a CF object returned by reference.
You should be able to do the following then:
ptr = Pointer.new(:id)
AXUIElementCopyAttributeValue(mail_object, 'AXHidden', ptr)
value = ptr[0]
To reply to your other question, it is possible to cast the type of a Pointer
object, using the #cast! method. Sometimes this is useful when you get a void
pointer from a native API and want to cast it into something more useful. But
you should be careful, MacRuby will not prevent you from doing bad casts.
Laurent
_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel