[MacRuby-devel] [MacRuby] #733: Proc as callback function for CoreAudio(AudioDeviceCreateIOProcID) isn't called
MacRuby
ruby-noreply at macosforge.org
Wed Jun 2 13:10:43 PDT 2010
#733: Proc as callback function for CoreAudio(AudioDeviceCreateIOProcID) isn't
called
-----------------------------------+----------------------------------------
Reporter: nagachika00@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: blocker | Milestone:
Component: MacRuby | Keywords:
-----------------------------------+----------------------------------------
Comment(by martinlagardette@…):
Replying to [comment:2 nagachika00@…]:
> Did you mean that MacRuby cannot make callback Proc Object for function
pointer returned from last argument of AudioDeviceCreateIOProcID()?
> [...]
> So I think CoreAudio can call Ruby Proc object via stub callback
function passed to second argument. Is this my misconception?
I'm not sure I understand exactly what you're asking, so let me know if
I'm not correctly answering:
In its current implementation, when calling Obj-C / C methods, MacRuby
converts ruby values (Fixnum, Strings, etc.) to C values (long, char *,
etc.). When the needed C value is a function pointer, it will check if the
argument is a Proc. If it is, it creates a "trampoline" function that will
be passed to the C function, and the trampoline function simply "calls"
(executes) the Proc.
However, the contrary is not implemented. Aka, if a function returns a
function pointer, or take a pointer to a function pointer, MacRuby does
not know, yet, how to take this function pointer and make it a Ruby value
(ideally a Proc). That is the current problem. When you pass the Pointer
to the `AudioDeviceCreateIOProcID`, the pointer is filled with a function
pointer. However, once the function returns, MacRuby has to translate this
pointer to function pointer to some ruby value that can be used. And for
now, we don't know how to do that :-).
> If I want to distribute my MacRuby Application, can I include modified
version of BridgeSupport file with it, and let MacRuby use it instead of
system's one?
You can load custom bridge support files, I guess you could do that before
loading the framework (if I remember correctly, similar bridgesupport
files are not loaded twice). I'll need to make sure though, but I think
it's possible.
--
Ticket URL: <http://www.macruby.org/trac/ticket/733#comment:3>
MacRuby <http://macruby.org/>
More information about the MacRuby-devel
mailing list