The Squirrel interpreter. See http://www.squirrel-lang.org/

Dependents:   Squirrel

Committer:
jhnwkmn
Date:
Tue Dec 16 10:20:34 2014 +0000
Revision:
0:97a4f8cc534c
Initial import of Squirrel.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jhnwkmn 0:97a4f8cc534c 1 /* see copyright notice in squirrel.h */
jhnwkmn 0:97a4f8cc534c 2 #ifndef _SQUSERDATA_H_
jhnwkmn 0:97a4f8cc534c 3 #define _SQUSERDATA_H_
jhnwkmn 0:97a4f8cc534c 4
jhnwkmn 0:97a4f8cc534c 5 struct SQUserData : SQDelegable
jhnwkmn 0:97a4f8cc534c 6 {
jhnwkmn 0:97a4f8cc534c 7 SQUserData(SQSharedState *ss){ _delegate = 0; _hook = NULL; INIT_CHAIN(); ADD_TO_CHAIN(&_ss(this)->_gc_chain, this); }
jhnwkmn 0:97a4f8cc534c 8 ~SQUserData()
jhnwkmn 0:97a4f8cc534c 9 {
jhnwkmn 0:97a4f8cc534c 10 REMOVE_FROM_CHAIN(&_ss(this)->_gc_chain, this);
jhnwkmn 0:97a4f8cc534c 11 SetDelegate(NULL);
jhnwkmn 0:97a4f8cc534c 12 }
jhnwkmn 0:97a4f8cc534c 13 static SQUserData* Create(SQSharedState *ss, SQInteger size)
jhnwkmn 0:97a4f8cc534c 14 {
jhnwkmn 0:97a4f8cc534c 15 SQUserData* ud = (SQUserData*)SQ_MALLOC(sq_aligning(sizeof(SQUserData))+size);
jhnwkmn 0:97a4f8cc534c 16 new (ud) SQUserData(ss);
jhnwkmn 0:97a4f8cc534c 17 ud->_size = size;
jhnwkmn 0:97a4f8cc534c 18 ud->_typetag = 0;
jhnwkmn 0:97a4f8cc534c 19 return ud;
jhnwkmn 0:97a4f8cc534c 20 }
jhnwkmn 0:97a4f8cc534c 21 #ifndef NO_GARBAGE_COLLECTOR
jhnwkmn 0:97a4f8cc534c 22 void Mark(SQCollectable **chain);
jhnwkmn 0:97a4f8cc534c 23 void Finalize(){SetDelegate(NULL);}
jhnwkmn 0:97a4f8cc534c 24 SQObjectType GetType(){ return OT_USERDATA;}
jhnwkmn 0:97a4f8cc534c 25 #endif
jhnwkmn 0:97a4f8cc534c 26 void Release() {
jhnwkmn 0:97a4f8cc534c 27 if (_hook) _hook((SQUserPointer)sq_aligning(this + 1),_size);
jhnwkmn 0:97a4f8cc534c 28 SQInteger tsize = _size;
jhnwkmn 0:97a4f8cc534c 29 this->~SQUserData();
jhnwkmn 0:97a4f8cc534c 30 SQ_FREE(this, sq_aligning(sizeof(SQUserData)) + tsize);
jhnwkmn 0:97a4f8cc534c 31 }
jhnwkmn 0:97a4f8cc534c 32
jhnwkmn 0:97a4f8cc534c 33
jhnwkmn 0:97a4f8cc534c 34 SQInteger _size;
jhnwkmn 0:97a4f8cc534c 35 SQRELEASEHOOK _hook;
jhnwkmn 0:97a4f8cc534c 36 SQUserPointer _typetag;
jhnwkmn 0:97a4f8cc534c 37 //SQChar _val[1];
jhnwkmn 0:97a4f8cc534c 38 };
jhnwkmn 0:97a4f8cc534c 39
jhnwkmn 0:97a4f8cc534c 40 #endif //_SQUSERDATA_H_