[MacRuby-devel] Getting a pointer to a boxed type
Mark Rada
mrada at marketcircle.com
Thu Dec 2 08:19:44 PST 2010
Yup, that works!
Thanks, Laurent!
On 2010-12-02, at 1:39 AM, Laurent Sansonetti wrote:
> Hi Mark,
>
> I think the following would work:
>
> value = valueOfAttribute attribute
> point_ptr = Pointer.new(CGPoint.type)
> AXValueGetValue( value, KAXValueCGPointType, point_ptr )
> point = point_ptr[0]
>
> Basically, you want to pass a pointer to a CGPoint to the API.
>
> Laurent
>
> On Dec 1, 2010, at 10:16 PM, Mark Rada wrote:
>
>> Hi,
>>
>> With the recent closing of ticket #1002 I have been trying to take a bunch of Objective-C code and write it in MacRuby.
>>
>> One problem that I have run into is with the AXValueGetValue() function in AXValue.h. The last argument to the function is supposed to be the address of a structure to populate; a fragment of that code would look like this:
>>
>> AXValueRef value = (AXValueRef)[self valueOfAttribute:attribute];
>> CGPoint point;
>> AXValueGetValue( value, kAXValueCGPointType, &point );
>> return point;
>>
>> If I wanted to write this in MacRuby I think I would have to do something like this:
>>
>> value = valueOfAttribute attribute
>> point = CGPoint.new
>> AXValueGetValue( value, KAXValueCGPointType, point.address_of )
>> point
>>
>> Except that I have not come across a way to get the address of an object in MacRuby. I have tried the #object_id but then I get errors about the function wanting a Pointer.
>>
>> Is there a way to get a pointer to a specific object or a way to get the address of an object?
>>
>> Thanks,
>> Mark
>>
>> _______________________________________________
>> MacRuby-devel mailing list
>> MacRuby-devel at lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20101202/316c0b24/attachment.html>
More information about the MacRuby-devel
mailing list