1 /* see copyright notice in squirrel.h */
5 struct SQUserData : SQDelegable
7 SQUserData(SQSharedState *ss){ _uiRef = 0; _delegate = 0; _hook = NULL; INIT_CHAIN(); ADD_TO_CHAIN(&_ss(this)->_gc_chain, this); }
10 REMOVE_FROM_CHAIN(&_ss(this)->_gc_chain, this);
13 static SQUserData* Create(SQSharedState *ss, int size)
15 SQUserData* ud = (SQUserData*)SQ_MALLOC(sizeof(SQUserData)+(size-1));
16 new (ud) SQUserData(ss);
21 #ifndef NO_GARBAGE_COLLECTOR
22 void Mark(SQCollectable **chain);
23 void Finalize(){SetDelegate(NULL);}
26 if (_hook) _hook(_val,_size);
27 int tsize = _size - 1;
29 SQ_FREE(this, sizeof(SQUserData) + tsize);
31 void SetDelegate(SQTable *mt)
33 if (mt) __ObjAddRef(mt);
34 __ObjRelease(_delegate);
41 unsigned int _typetag;
45 #endif //_SQUSERDATA_H_