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