Hi Nicolas

In the code below I'm using alloc_root to save the object and function
to call on a gtk callback. You'll notice the absense of free_root(),
that's because gtk_signal_connect is a first time connection and can be
called many times, so i don't want to free the neko callback data on
the first event.

So, the question is, I need to store the alloc_root pointer, and the
best place to do so would be back in the object that's firing the
event, then I can free the alloc_root data when the object is finalised.

So is it ok to wrap alloc_root pointer as an abstract and store it back
in the original object?

thx

bd

-----


void signal_callback(GtkWidget *ptr,void *transfer) {
        value *p = (value *)transfer;
        val_call1(*p,*(p+1));
}

value hxs_signal_connect(value abstractWidget,value event,value
func,value haxeWidget) { val_check(event ,string);
        val_check_function(func,1);

        //value *transfer = (value *)calloc(sizeof(value),2);
        value *transfer = (value *)alloc_root(2);

        *transfer = func;
        *(transfer + 1) = haxeWidget ;

        g_signal_connect(G_OBJECT(val_data(abstractWidget)),
                                        val_string(event),
                                        G_CALLBACK(signal_callback),
                                        transfer);

        return val_true;
}

-- 
http://blackdog-haxe.blogspot.com/
http://www.igameware.com

"It is no measure of health to be well adjusted to a profoundly sick
society." --Jiddu Krishnamurti

-- 
Neko : One VM to run them all
(http://nekovm.org)

Reply via email to