On May 30, 2011, at 3:12 PM, Theodore H. Smith wrote:

> The problem is your code, not RBScript. Your code doesn't make sense whether 
> it was in RBScript or normal RB!

Yup, fair enough, it does not constitute a bug but a limitation. I would want 
to maintain a list of RBScript-defined objects, without the added reference 
count. I also don't want to speckle RBScript code with calls like myObject.kill 
as you suggested. Then it is going to look like what we normally would do in 
the plugin, like using REALUnlockObject, which is ok for a plugin, but not for 
RBScript.

As you know, in a plugin you can maintain objects without adding a refcount and 
the destructor of the class will be called so your global list will adjust:

extern REALcontrol ProcessClass;
typedef struct ProcessData
{
        REALcontrolInstance self;
        ProcessData *prev;
        ProcessData *next;
} ProcessData;

ProcessData* gProcessFirst = NULL;
ProcessData* gProcessLast = NULL;

void Process_Constructor(REALcontrolInstance instance)
{
        ControlData(ProcessClass, instance, ProcessData, me);
        
        if (gProcessFirst == nil) {
                gProcessFirst = gProcessLast = me;              
        } else {
                me->next = gProcessFirst;
                gProcessFirst->prev = me;
                gProcessFirst = me;
        }
}
void Process_Destructor(REALcontrolInstance instance)
{
        ControlData(ProcessClass, instance, ProcessData, me);
        if (me->next != nil)
                (*(me->next)).prev = me->prev;
        else gProcessLast = me->prev;
        if (me->prev != nil)
                (*(me->prev)).next = me->next;
        else gProcessFirst = me->next;          
}

If only we could convert an RBScript-defined object to an integer, then it 
would be possible to have an unique signature for the RBScript-defined object, 
we could store it in a list maintained in a plugin or normal RB and when 
necessary cast it back to the RBScript-defined object.

An awkward solution is a global rb-dictionary in the plugin, maintaining a 
key(string-REALobject signature)/value(integer) pair, and an array of 
RBScript-defined objects in RBScript. These 2 lists need to be synchronized, 
and yes in some cases myObject.kill is used at certain places, which is very, 
very awkward indeed. 

Why all this:

I want to be able to use "Isa" and then cast it and call an event 

                                select case GetRBScriptObject(EventObject)
                                        case IsA scrollbar
                                                
scrollbar(GetRBScriptObject(EventObject)).CallEvent()
                                        case IsA Canvas
                                                        dim g as graphics = 
graphics(EventArg1)
                                                        if g <> nil then 
canvas(GetRBScriptObject(EventObject)).CallPaint(g) 
                                                        g.kill()
                                                end if
                                end select

without calling the specific myScrollbar1, myScrollbar2, myScrollbar3 .... or 
myCanvas1-10; it makes the code much smaller, easier to maintain, and 
appealing...

- Alfred Van Hoek
[email protected]
http://web.mac.com/vanhoek



_______________________________________________
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