[MacRuby-devel] Understanding Pointer objects
Mark Rada
mrada at marketcircle.com
Sun Oct 24 14:22:49 PDT 2010
Hey,
Thanks for the response. It has helped, but I am still confused a bit by you stating that none of the types are supported but that I can still dereference a pointer.
I have now been able to dereference some pointers, but not pointers to pointers. Is that what you meant?
In these cases I guess I will have to create an objective-c wrapper. I found an entry on the MacRuby site about creating bundles which I think is a good solution.
Thanks for the pointers,
Mark
Sent from my iDevice
On 2010-10-24, at 3:06, Matt Aimonetti <mattaimonetti at gmail.com> wrote:
> You can set pointers using:
>
> Pointer.new_with_type and using one of the following types: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html#//apple_ref/doc/uid/TP40008048-CH100-SW1
> Note, that not none of the types are supported.
>
> Here is some more information: http://jonathan.waddilove.net/macruby_pointers.html
>
> To dereference a pointer, simply get its value:
>
> pointer = Pointer.new_with_type("f")
> pointer.assign(3.2)
> pointer's value = pointer[0]
>
> I'll soon update my book draft with a section on pointers.
>
> - Matt
>
>
> On Sat, Oct 23, 2010 at 10:04 PM, Mark Rada <mrada at marketcircle.com> wrote:
> Hi,
>
> I've been trying to play with using the Accessibility API to do some automated testing.
>
> >From what I have researched, I have to use some C functions that often need a reference passed to the them.
>
> I am at a loss when trying to deal with Pointer objects. I've tried playing with them and googling it, but I just cannot figure out how to turn a pointer into a more useful type or to get what I want out of them.
>
> For example, I can start like this:
>
> framework 'Cocoa'
>
> unless AXAPIEnabled() # only works if I include the parenthesis
> puts 'Please enable Access for Assistive Devices first'
> exit 2
> end
>
> mail = NSRunningApplication.runningApplicationsWithBundleIdentifier('com.apple.Mail').first
> mail_object = AXUIElementCreateApplication mail.processIdentifier
>
> names = Pointer.new :object
>
> AXUIElementCopyAttributeNames mail_object, names
>
>
> But then how do I get the values out of the names pointer? For reference, I found the functions in AXUIElement.h.
>
>
> 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/20101024/f28d47fe/attachment.html>
More information about the MacRuby-devel
mailing list