1 /* see copyright notice in squirrel.h */
\r
6 #include "sqobject.h"
\r
9 //max number of character for a printed number
\r
10 #define NUMBER_MAX_CHAR 50
\r
16 //return a string obj if exists
\r
17 //so when there is a table query, if the string doesn't exists in the global state
\r
18 //it cannot be in a table so the result will be always null
\r
19 //SQString *get(const SQChar *news);
\r
20 SQString *Add(const SQChar *,int len);
\r
21 void Remove(SQString *);
\r
23 void Resize(int size);
\r
24 void AllocNodes(int size);
\r
25 SQString **_strings;
\r
26 unsigned int _numofslots;
\r
27 unsigned int _slotused;
\r
30 #define ADD_STRING(ss,str,len) ss->_stringtable->Add(str,len)
\r
31 #define REMOVE_STRING(ss,bstr) ss->_stringtable->Remove(bstr)
\r
35 struct SQSharedState
\r
41 SQChar* GetScratchPad(int size);
\r
42 SQInteger GetMetaMethodIdxByName(const SQObjectPtr &name);
\r
43 #ifndef NO_GARBAGE_COLLECTOR
\r
44 int CollectGarbage(SQVM *vm);
\r
45 static void MarkObject(SQObjectPtr &o,SQCollectable **chain);
\r
47 SQObjectPtrVec *_metamethods;
\r
48 SQObjectPtr _metamethodsmap;
\r
49 SQObjectPtrVec *_systemstrings;
\r
50 SQObjectPtrVec *_types;
\r
51 StringTable *_stringtable;
\r
52 SQObjectPtr _refs_table;
\r
53 SQObjectPtr _registry;
\r
54 SQObjectPtr _constructoridx;
\r
55 #ifndef NO_GARBAGE_COLLECTOR
\r
56 SQCollectable *_gc_chain;
\r
58 SQObjectPtr _root_vm;
\r
59 SQObjectPtr _table_default_delegate;
\r
60 static SQRegFunction _table_default_delegate_funcz[];
\r
61 SQObjectPtr _array_default_delegate;
\r
62 static SQRegFunction _array_default_delegate_funcz[];
\r
63 SQObjectPtr _string_default_delegate;
\r
64 static SQRegFunction _string_default_delegate_funcz[];
\r
65 SQObjectPtr _number_default_delegate;
\r
66 static SQRegFunction _number_default_delegate_funcz[];
\r
67 SQObjectPtr _generator_default_delegate;
\r
68 static SQRegFunction _generator_default_delegate_funcz[];
\r
69 SQObjectPtr _closure_default_delegate;
\r
70 static SQRegFunction _closure_default_delegate_funcz[];
\r
71 SQObjectPtr _thread_default_delegate;
\r
72 static SQRegFunction _thread_default_delegate_funcz[];
\r
73 SQObjectPtr _class_default_delegate;
\r
74 static SQRegFunction _class_default_delegate_funcz[];
\r
75 SQObjectPtr _instance_default_delegate;
\r
76 static SQRegFunction _instance_default_delegate_funcz[];
\r
78 SQCOMPILERERROR _compilererrorhandler;
\r
79 SQPRINTFUNCTION _printfunc;
\r
82 SQChar *_scratchpad;
\r
83 int _scratchpadsize;
\r
86 #define _sp(s) (_sharedstate->GetScratchPad(s))
\r
87 #define _spval (_sharedstate->GetScratchPad(-1))
\r
89 #define _table_ddel _table(_sharedstate->_table_default_delegate)
\r
90 #define _array_ddel _table(_sharedstate->_array_default_delegate)
\r
91 #define _string_ddel _table(_sharedstate->_string_default_delegate)
\r
92 #define _number_ddel _table(_sharedstate->_number_default_delegate)
\r
93 #define _generator_ddel _table(_sharedstate->_generator_default_delegate)
\r
94 #define _closure_ddel _table(_sharedstate->_closure_default_delegate)
\r
95 #define _thread_ddel _table(_sharedstate->_thread_default_delegate)
\r
96 #define _class_ddel _table(_sharedstate->_class_default_delegate)
\r
97 #define _instance_ddel _table(_sharedstate->_instance_default_delegate)
\r
99 #ifdef SQUNICODE //rsl REAL STRING LEN
\r
100 #define rsl(l) ((l)<<1)
\r
105 extern SQObjectPtr _null_;
\r
106 extern SQObjectPtr _true_;
\r
107 extern SQObjectPtr _false_;
\r
108 extern SQObjectPtr _one_;
\r
109 extern SQObjectPtr _minusone_;
\r
111 bool CompileTypemask(SQIntVec &res,const SQChar *typemask);
\r
113 void *sq_vm_malloc(unsigned int size);
\r
114 void *sq_vm_realloc(void *p,unsigned int oldsize,unsigned int size);
\r
115 void sq_vm_free(void *p,unsigned int size);
\r
116 #endif //_SQSTATE_H_
\r