8 #define UINT_MINUS_ONE (0xFFFFFFFFFFFFFFFF) 10 #define UINT_MINUS_ONE (0xFFFFFFFF) 13 #define SQ_CLOSURESTREAM_HEAD (('S'<<24)|('Q'<<16)|('I'<<8)|('R')) 14 #define SQ_CLOSURESTREAM_PART (('P'<<24)|('A'<<16)|('R'<<8)|('T')) 15 #define SQ_CLOSURESTREAM_TAIL (('T'<<24)|('A'<<16)|('I'<<8)|('L')) 41 #define MM_ADD _SC("_add") 42 #define MM_SUB _SC("_sub") 43 #define MM_MUL _SC("_mul") 44 #define MM_DIV _SC("_div") 45 #define MM_UNM _SC("_unm") 46 #define MM_MODULO _SC("_modulo") 47 #define MM_SET _SC("_set") 48 #define MM_GET _SC("_get") 49 #define MM_TYPEOF _SC("_typeof") 50 #define MM_NEXTI _SC("_nexti") 51 #define MM_CMP _SC("_cmp") 52 #define MM_CALL _SC("_call") 53 #define MM_CLONED _SC("_cloned") 54 #define MM_NEWSLOT _SC("_newslot") 55 #define MM_DELSLOT _SC("_delslot") 56 #define MM_TOSTRING _SC("_tostring") 57 #define MM_NEWMEMBER _SC("_newmember") 58 #define MM_INHERITED _SC("_inherited") 61 #define _CONSTRUCT_VECTOR(type,size,ptr) { \ 62 for(SQInteger n = 0; n < ((SQInteger)size); n++) { \ 63 new (&ptr[n]) type(); \ 67 #define _DESTRUCT_VECTOR(type,size,ptr) { \ 68 for(SQInteger nl = 0; nl < ((SQInteger)size); nl++) { \ 73 #define _COPY_VECTOR(dest,src,size) { \ 74 for(SQInteger _n_ = 0; _n_ < ((SQInteger)size); _n_++) { \ 75 dest[_n_] = src[_n_]; \ 79 #define _NULL_SQOBJECT_VECTOR(vec,size) { \ 80 for(SQInteger _n_ = 0; _n_ < ((SQInteger)size); _n_++) { \ 89 SQUnsignedInteger _uiRef;
94 virtual void Release()=0;
104 #define _realval(o) (sq_type((o)) != OT_WEAKREF?(SQObject)o:_weakref(o)->_obj) 108 #define __AddRef(type,unval) if(ISREFCOUNTED(type)) \ 110 unval.pRefCounted->_uiRef++; \ 113 #define __Release(type,unval) if(ISREFCOUNTED(type) && ((--unval.pRefCounted->_uiRef)==0)) \ 115 unval.pRefCounted->Release(); \ 118 #define __ObjRelease(obj) { \ 121 if((obj)->_uiRef == 0) \ 127 #define __ObjAddRef(obj) { \ 131 #define is_delegable(t) (sq_type(t)&SQOBJECT_DELEGABLE) 132 #define raw_type(obj) _RAW_TYPE((obj)._type) 134 #define _integer(obj) ((obj)._unVal.nInteger) 135 #define _float(obj) ((obj)._unVal.fFloat) 136 #define _string(obj) ((obj)._unVal.pString) 137 #define _table(obj) ((obj)._unVal.pTable) 138 #define _array(obj) ((obj)._unVal.pArray) 139 #define _closure(obj) ((obj)._unVal.pClosure) 140 #define _generator(obj) ((obj)._unVal.pGenerator) 141 #define _nativeclosure(obj) ((obj)._unVal.pNativeClosure) 142 #define _userdata(obj) ((obj)._unVal.pUserData) 143 #define _userpointer(obj) ((obj)._unVal.pUserPointer) 144 #define _thread(obj) ((obj)._unVal.pThread) 145 #define _funcproto(obj) ((obj)._unVal.pFunctionProto) 146 #define _class(obj) ((obj)._unVal.pClass) 147 #define _instance(obj) ((obj)._unVal.pInstance) 148 #define _delegable(obj) ((SQDelegable *)(obj)._unVal.pDelegable) 149 #define _weakref(obj) ((obj)._unVal.pWeakRef) 150 #define _outer(obj) ((obj)._unVal.pOuter) 151 #define _refcounted(obj) ((obj)._unVal.pRefCounted) 152 #define _rawval(obj) ((obj)._unVal.raw) 154 #define _stringval(obj) (obj)._unVal.pString->_val 155 #define _userdataval(obj) ((SQUserPointer)sq_aligning((obj)._unVal.pUserData + 1)) 157 #define tofloat(num) ((sq_type(num)==OT_FLOAT)?_float(num):(SQFloat)_integer(num)) 158 #define tointeger(num) ((sq_type(num)==OT_FLOAT)?(SQInteger)_float(num):_integer(num)) 159 #if defined(SQUSEDOUBLE) && !defined(_SQ64) || !defined(SQUSEDOUBLE) && defined(_SQ64) 162 #define SQ_REFOBJECT_INIT() SQ_OBJECT_RAWINIT() 164 #define SQ_REFOBJECT_INIT() 167 #define _REF_TYPE_DECL(type,_class,sym) \ 168 SQObjectPtr(_class * x) \ 170 SQ_OBJECT_RAWINIT() \ 173 assert(_unVal.pTable); \ 174 _unVal.pRefCounted->_uiRef++; \ 176 inline SQObjectPtr& operator=(_class *x) \ 178 SQObjectType tOldType; \ 179 SQObjectValue unOldVal; \ 183 SQ_REFOBJECT_INIT() \ 185 _unVal.pRefCounted->_uiRef++; \ 186 __Release(tOldType,unOldVal); \ 190 #define _SCALAR_TYPE_DECL(type,_class,sym) \ 191 SQObjectPtr(_class x) \ 193 SQ_OBJECT_RAWINIT() \ 197 inline SQObjectPtr& operator=(_class x) \ 199 __Release(_type,_unVal); \ 201 SQ_OBJECT_RAWINIT() \ 211 _unVal.pUserPointer=NULL;
217 __AddRef(_type,_unVal);
223 __AddRef(_type,_unVal);
225 _REF_TYPE_DECL(OT_TABLE,
SQTable,pTable)
226 _REF_TYPE_DECL(OT_CLASS,
SQClass,pClass)
227 _REF_TYPE_DECL(OT_INSTANCE,
SQInstance,pInstance)
228 _REF_TYPE_DECL(OT_ARRAY,
SQArray,pArray)
229 _REF_TYPE_DECL(OT_CLOSURE,
SQClosure,pClosure)
231 _REF_TYPE_DECL(OT_OUTER,
SQOuter,pOuter)
232 _REF_TYPE_DECL(OT_GENERATOR,
SQGenerator,pGenerator)
233 _REF_TYPE_DECL(OT_STRING,
SQString,pString)
234 _REF_TYPE_DECL(OT_USERDATA,
SQUserData,pUserData)
235 _REF_TYPE_DECL(OT_WEAKREF,
SQWeakRef,pWeakRef)
236 _REF_TYPE_DECL(OT_THREAD,
SQVM,pThread)
239 _SCALAR_TYPE_DECL(OT_INTEGER,SQInteger,nInteger)
240 _SCALAR_TYPE_DECL(OT_FLOAT,SQFloat,fFloat)
241 _SCALAR_TYPE_DECL(OT_USERPOINTER,SQUserPointer,pUserPointer)
247 _unVal.nInteger = bBool?1:0;
251 __Release(_type,_unVal);
254 _unVal.nInteger = b?1:0;
260 __Release(_type,_unVal);
265 SQObjectType tOldType;
271 __AddRef(_type,_unVal);
272 __Release(tOldType,unOldVal);
277 SQObjectType tOldType;
283 __AddRef(_type,_unVal);
284 __Release(tOldType,unOldVal);
289 SQObjectType tOldType = _type;
292 _unVal.raw = (SQRawObjectVal)NULL;
293 __Release(tOldType ,unOldVal);
302 SQObjectType tOldType = a._type;
311 #ifndef NO_GARBAGE_COLLECTOR 312 #define MARK_FLAG 0x80000000 317 virtual SQObjectType GetType()=0;
318 virtual void Release()=0;
321 virtual void Finalize()=0;
327 #define ADD_TO_CHAIN(chain,obj) AddToChain(chain,obj) 328 #define REMOVE_FROM_CHAIN(chain,obj) {if(!(_uiRef&MARK_FLAG))RemoveFromChain(chain,obj);} 329 #define CHAINABLE_OBJ SQCollectable 330 #define INIT_CHAIN() {_next=NULL;_prev=NULL;_sharedstate=ss;} 333 #define ADD_TO_CHAIN(chain,obj) ((void)0) 334 #define REMOVE_FROM_CHAIN(chain,obj) ((void)0) 335 #define CHAINABLE_OBJ SQRefCounted 336 #define INIT_CHAIN() ((void)0) 345 SQUnsignedInteger TranslateIndex(
const SQObjectPtr &idx);
348 const SQChar *GetTypeName(
const SQObjectPtr &obj1);
349 const SQChar *IdType2Name(SQObjectType type);
353 #endif //_SQOBJECT_H_ Definition: sqclosure.h:10
Definition: sqclosure.h:74
Definition: sqobject.h:339
Definition: sqclosure.h:108
Definition: sqobject.h:98
Definition: sqobject.h:87
Definition: squirrel.h:153
Definition: squserdata.h:5
Definition: sqobject.h:205
Definition: squirrel.h:129
Definition: sqstring.h:14
Definition: sqclosure.h:147
Definition: sqfuncproto.h:49
Definition: sqobject.h:313