[MacRuby] #1002: AXUIElement functions won't accept Pointers of type :id
#1002: AXUIElement functions won't accept Pointers of type :id ---------------------------+------------------------------------------------ Reporter: haxie1@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.8 Component: MacRuby | Keywords: ---------------------------+------------------------------------------------ I am working with the Carbon Accessibility API and running into an issue with Pointers. {{{ framework 'ApplicationServices' pid = (Safari's pid) safari = AXUIElementCreateApplication(pid) titlePtr = Pointer.new(:id) err = AXUIElementCopyAttributeValue(safari, "AXTitle", titlePtr) }}} error: TypeError: expected instance of Pointer of type `^v', got `@' Passing: {{{ ... titlePtr = Pointer.new("^v") err = AXUIElementCopyAttributeValue(safari, "AXTitle", titlePtr) }}} returns successfully but titlePtr is nil. Since AXUIElementCopyAttributeValue takes a pointer to a CFTypeRef, shouldn't I be able to pass a Pointer of type :id? I am running the latest MacRuby nightly and have BridgeSupportPreview1 installed. Regards, Kam -- Ticket URL: <http://www.macruby.org/trac/ticket/1002> MacRuby <http://macruby.org/>
#1002: AXUIElement functions won't accept Pointers of type :id ---------------------------+------------------------------------------------ Reporter: haxie1@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.8 Component: MacRuby | Keywords: ---------------------------+------------------------------------------------ Comment(by mrada@…): I've been playing with the Accessibility APIs a lot lately as well. The problem is that right now MacRuby doesn't support void pointers (http://ofps.oreilly.com/titles/9781449380373/ch02.html#_pointers). -- Ticket URL: <http://www.macruby.org/trac/ticket/1002#comment:1> MacRuby <http://macruby.org/>
#1002: AXUIElement functions won't accept Pointers of type :id ---------------------------+------------------------------------------------ Reporter: haxie1@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.8 Component: MacRuby | Keywords: ---------------------------+------------------------------------------------ Comment(by lsansonetti@…): MacRuby will not let you create a void pointer, but it will let you pass any pointer as a void* argument. But here, the function accepts a void** pointer, so it's a different story. What you need to do is create a Pointer to void*, pass it to the API, then cast it back as a pointer to type id. {{{ $ cat t.rb framework 'ApplicationServices' pid = 433 safari = AXUIElementCreateApplication(pid) titlePtr = Pointer.new('^v') err = AXUIElementCopyAttributeValue(safari, "AXTitle", titlePtr) titlePtr.cast!('@') p titlePtr[0] $ ./miniruby t.rb "Safari" }}} I am pondering if MacRuby shouldn't let you pass the :id pointer directly. -- Ticket URL: <http://www.macruby.org/trac/ticket/1002#comment:3> MacRuby <http://macruby.org/>
#1002: AXUIElement functions won't accept Pointers of type :id ---------------------------+------------------------------------------------ Reporter: haxie1@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: MacRuby 0.8 Component: MacRuby | Resolution: fixed Keywords: | ---------------------------+------------------------------------------------ Changes (by lsansonetti@…): * status: new => closed * resolution: => fixed Comment: Okay, I changed MacRuby accordingly in r4955. The following can be used now: {{{ $ cat t.rb framework 'ApplicationServices' pid = 433 safari = AXUIElementCreateApplication(pid) titlePtr = Pointer.new(:id) err = AXUIElementCopyAttributeValue(safari, "AXTitle", titlePtr) p titlePtr[0] $ ./miniruby t.rb "Safari" }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1002#comment:4> MacRuby <http://macruby.org/>
#1002: AXUIElement functions won't accept Pointers of type :id ---------------------------+------------------------------------------------ Reporter: haxie1@… | Owner: lsansonetti@… Type: defect | Status: reopened Priority: blocker | Milestone: MacRuby 0.8 Component: MacRuby | Resolution: Keywords: | ---------------------------+------------------------------------------------ Changes (by mrada@…): * status: closed => reopened * resolution: fixed => Comment: Laurent, I tried your test with the latest nightly build (I downloaded it a couple of minutes ago), but I am still getting an error and not the value of the string. ± cat test.rb framework 'Cocoa' pid = 426 # => current PID of Mail.app for me mail = AXUIElementCreateApplication(pid) ptr = Pointer.new :id ret = AXUIElementCopyAttributeValue(mail, 'AXTitle', ptr) puts ptr[0] Then I get this: ± macruby test.rb /Users/ferrous/test.rb:6:in `<main>': expected instance of Pointer of type `^v', got `@' (TypeError) [1] 42769 exit 1 macruby test.rb -- Ticket URL: <http://www.macruby.org/trac/ticket/1002#comment:5> MacRuby <http://macruby.org/>
#1002: AXUIElement functions won't accept Pointers of type :id ---------------------------+------------------------------------------------ Reporter: haxie1@… | Owner: lsansonetti@… Type: defect | Status: reopened Priority: blocker | Milestone: MacRuby 0.8 Component: MacRuby | Resolution: Keywords: | ---------------------------+------------------------------------------------ Comment(by martinlagardette@…): Can you check your macruby's revision? I think the latest build was built before the patch was commited, but I don't know at what hour they are built. {{{ $> macruby -e 'p MACRUBY_REVISION' "svn revision 4928 from http://svn.macosforge.org/repository/ruby/MacRuby/trunk" }}} If your revision is less than 4955, then you have your answer :P -- Ticket URL: <http://www.macruby.org/trac/ticket/1002#comment:6> MacRuby <http://macruby.org/>
#1002: AXUIElement functions won't accept Pointers of type :id ---------------------------+------------------------------------------------ Reporter: haxie1@… | Owner: lsansonetti@… Type: defect | Status: reopened Priority: blocker | Milestone: MacRuby 0.8 Component: MacRuby | Resolution: Keywords: | ---------------------------+------------------------------------------------ Comment(by mrada@…): Seems you are correct, sorry. I at revision 4954, off by one revision. I'll try again tomorrow. -- Ticket URL: <http://www.macruby.org/trac/ticket/1002#comment:7> MacRuby <http://macruby.org/>
#1002: AXUIElement functions won't accept Pointers of type :id ---------------------------+------------------------------------------------ Reporter: haxie1@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: MacRuby 0.8 Component: MacRuby | Resolution: fixed Keywords: | ---------------------------+------------------------------------------------ Changes (by lsansonetti@…): * status: reopened => closed * resolution: => fixed Comment: Good to know. Re-closing the bug, let us know if it still doesn't work with the next build :) -- Ticket URL: <http://www.macruby.org/trac/ticket/1002#comment:8> MacRuby <http://macruby.org/>
#1002: AXUIElement functions won't accept Pointers of type :id ---------------------------+------------------------------------------------ Reporter: haxie1@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: MacRuby 0.8 Component: MacRuby | Resolution: fixed Keywords: | ---------------------------+------------------------------------------------ Comment(by haxie1@…): Just wanted to drop a quick note and say that this is working now. Huge thank you for fixing this! Regards, kam -- Ticket URL: <http://www.macruby.org/trac/ticket/1002#comment:9> MacRuby <http://macruby.org/>
#1002: AXUIElement functions won't accept Pointers of type :id ---------------------------+------------------------------------------------ Reporter: haxie1@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: MacRuby 0.8 Component: MacRuby | Resolution: fixed Keywords: | ---------------------------+------------------------------------------------ Comment(by mrada@…): Confirmed, the fix works. I've been able to start porting an Objective-C bundle to MacRuby. It was wonderful to just chisel away all the extra code from Objective-C. You've made my day; thanks! -- Ticket URL: <http://www.macruby.org/trac/ticket/1002#comment:10> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby