Trying to call a class event via a callback (Real Studio Plugins Mailinglist archive)

Back to the thread list
Previous thread: Question(s) about Failed Assertion
Next thread: vsprintf crashes in Mach-O


macosx and unix paths   -   GOLD
  Trying to call a class event via a callback   -   Dave Addey
   Re: Trying to call a class event via a callback   -   Joseph J. Strout
    Re: Trying to call a class event via a callback   -   Dave Addey

Trying to call a class event via a callback
Date: 21.04.06 17:41 (Fri, 21 Apr 2006 17:41:12 +0100)
From: Dave Addey

Hi there,

I¹m trying to add a new event to a class, and then call that event by
installing a callback (using part of the Mac OS IOKit). I keep finding that
the installation of the callback causes a crash. Is it possible to do this
­ to call a class instance¹s event from within a callback? I never managed
to do this from within REALbasic code, and always ended up having to use a
global module method as the function for the callback to call.

Is this the same case from within a plugin too? If so, is there a way for
me to define a global module method from within the plugin, which would be
called (in RB) by the callback?

I¹m in RB 2006r1, compiling a plugin for Mac OS X MachO.

Dave.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Trying to call a class event via a callback
Date: 21.04.06 17:54 (Fri, 21 Apr 2006 10:54:04 -0600)
From: Joseph J. Strout
At 5:41 PM +0100 4/21/06, Dave Addey wrote:

>I'm trying to add a new event to a class, and then call that event by
>installing a callback (using part of the Mac OS IOKit).

Ow! :) As you found, you can't do that. Events can ONLY be called
from the class where they are defined.

Moreover, how would IOKit know to pass in the object reference that
is any class method's first parameter?

>Is this the same case from within a plugin too? If so, is there a way for
>me to define a global module method from within the plugin, which would be
>called (in RB) by the callback?

Sure, why not? I'm not sure I understand this question. Defining
global methods is demonstrated by most of the plugin samples.

Best,
- Joe

Re: Trying to call a class event via a callback
Date: 21.04.06 18:05 (Fri, 21 Apr 2006 18:05:45 +0100)
From: Dave Addey
Hi Joe,

That makes sense. Here's what I need, then:

I am using an OS API to register a callback in C++ (specifically, for when
HID device events occur), and I need to pass in a function pointer to the
callback registration function. I want this function pointer to point to a
function that an RB user can write custom code for in their REALbasic app.

I've done this before in pure RB code, by creating a module with a
globally-accessible method, and calling the callback creator from RB code
via declares, using "AddressOf theModuleMethod" as the function pointer.
But, I'm not sure how to achieve the same thing from a plugin...

Dave.

> From: "Joseph J. Strout" <<email address removed>>
> Reply-To: REALbasic Plugins <<email address removed>>
> Date: Fri, 21 Apr 2006 10:54:04 -0600
> To: REALbasic Plugins <<email address removed>>
> Subject: Re: Trying to call a class event via a callback
>
> At 5:41 PM +0100 4/21/06, Dave Addey wrote:
>
>> I'm trying to add a new event to a class, and then call that event by
>> installing a callback (using part of the Mac OS IOKit).
>
> Ow! :) As you found, you can't do that. Events can ONLY be called
> from the class where they are defined.
>
> Moreover, how would IOKit know to pass in the object reference that
> is any class method's first parameter?
>
>> Is this the same case from within a plugin too? If so, is there a way for
>> me to define a global module method from within the plugin, which would be
>> called (in RB) by the callback?
>
> Sure, why not? I'm not sure I understand this question. Defining
> global methods is demonstrated by most of the plugin samples.
>
> Best,
> - Joe
>
> --
>
> Joseph J. Strout
> <email address removed>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>