On 14-Sep-07, at 7:12 AM, Alfred Van Hoek wrote:

>
> On Sep 13, 2007, at 9:31 PM, Norman Palardy wrote:
>
>> Basically
>>      dim pc as PluginClass
>>      dim pi as RBClassThatImplementsTheInterface
>>
>>      pi = new RBClassThatImplementsTheInterface
>>
>>      pc = new PluginClass(pi)
>>
>> in my plugin I have code that hangs on to the instance and locks it
>> like
>>
>>      void ConstructorWithParams ( REALobject instance, REALobject
>> iFuncsProvider )
>>      
>>      {
>>              
>>              ClassData (Class, instance, data, local);
>>      
>>              REALLockObject(iFuncsProvider) ;
>>      
>>              local->iFuncsProvider = iFuncsProvider ;
>>      
>>      }
>
>
> Not sure what you do here. I guess you would want to use
> "RBClassThatImplementsTheInterface" as a registration of a
> PluginClass that implements the interface.
>
> When you call
>
>       Boolean  SomeFunc(data *instance)
>       {
>               Boolean (*func)(void);
>               func = ( Boolean(*)(void) )
>                               REALInterfaceRoutine (instance->iFuncsProvider,
>                               "iFunctions", "SomeFunc() as Boolean");
>               if (! func)
>                       return false;
>       
>               return func();
>       }
>
> the instance variable to call the interface on, should be on the
> PluginClass instance and not on the "iFuncsProvider", because the
> user, the caller, of PluginClass had indicated that PluginClass
> promised to implement the methods defined in the interface (I suppose
> that as a given).

The plugin class takes another class as a set of callbacks

The user has to create a class that implements the interface the  
plugin defines (call this the callbacks)
The "callbacks" have to conform to an interface the plugin also defines

Then when they create a new instance of the class the plugin defines  
they have to pass their callbacks as part of the constructor

        dim pc as PluginClass // the plugin class that requires the call backs
        dim pi as myCallbacks // <<<<< the users callbacks

        pi = new myCallbacks

        pc = new PluginClass(pi)

in the plugin I have this code to hang on to the object reference to  
the users callbacks

        void ConstructorWithParams ( REALobject instance, REALobject  
iFuncsProvider )
        {
                
                ClassData (Class, instance, data, local);
        
                REALLockObject(iFuncsProvider) ;
        
                local->iFuncsProvider = iFuncsProvider ;
        
        }

so it seems like my class should be hanging on to the reference to  
the users callback instance so it won't disappear when it goes out of  
scope

But when I go to call one their functions I can't seem to get a valid  
function pointer to their implementations of the methods

So far no luck


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

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to