#3 Add new type (userdatapointer)

closed
None
1
2003-11-11
2003-11-08
No

In some situations when embedding Squirrel
"userdata" type is not very eficient: when I use
manually created objects or imported via API (ex.
ActiveX in windows). In this case using another
buffer with only one pointer inside is not very clean.

I suggest to use special type "userdatapointer".
This type is very close to "userdata" type but
instead of allocating data by VM this type has only
pointer with two functions - addref and release, all
specified in native language.

Inside engine this may be implemented as using
structure

struct UserDataPointer {
void* data;
void (*addref)(HSQUIRRELVM, void*);
void (*release)(HSQUIRRELVM, void*);
};

This structure can be embeded into object structure
or pointer to it can be holded inside.

Next this allow future optimization of VM code to
make code very efficient.

Discussion

  • Logged In: YES
    user_id=660246

    I see your point but adding this into the object structure
    would double average the object size. I think is too heavy.
    You can have the same behaviour with a userdata and a
    release_hook.

     
    • priority: 5 --> 1
    • assigned_to: nobody --> fagiano
    • status: open --> closed