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