28 #if !defined(_SCRAT_TABLE_H_)
29 #define _SCRAT_TABLE_H_
34 #include "sqratObject.h"
35 #include "sqratFunction.h"
36 #include "sqratGlobalMethods.h"
86 sq_pushstring(vm, name, -1);
88 sq_newslot(vm, -3,
false);
103 sq_pushstring(vm, name, -1);
104 sq_newclosure(vm, func, 0);
105 sq_newslot(vm, -3,
false);
123 BindValue<V>(name, val,
false);
140 BindValue<V>(index, val,
false);
157 BindInstance<V>(name, val,
false);
174 BindInstance<V>(index, val,
false);
191 BindFunc(name, &method,
sizeof(method), SqGlobalFunc(method));
211 BindOverload(name, &method,
sizeof(method), SqGlobalOverloadedFunc(method), SqOverloadFunc(method), SqGetArgCount(method));
228 template <
typename T>
231 sq_pushobject(vm, obj);
232 sq_pushstring(vm, name, -1);
233 #if !defined (SCRAT_NO_ERROR_CHECKING)
234 if (SQ_FAILED(sq_get(vm, -2))) {
243 #if !defined (SCRAT_NO_ERROR_CHECKING)
266 template <
typename T>
269 sq_pushobject(vm, obj);
270 sq_pushinteger(vm, index);
271 #if !defined (SCRAT_NO_ERROR_CHECKING)
272 if (SQ_FAILED(sq_get(vm, -2))) {
281 #if !defined (SCRAT_NO_ERROR_CHECKING)
302 sq_pushstring(vm, name, -1);
303 #if !defined (SCRAT_NO_ERROR_CHECKING)
304 if(SQ_FAILED(sq_get(vm, -2))) {
308 SQObjectType value_type = sq_gettype(vm, -1);
309 if (value_type != OT_CLOSURE && value_type != OT_NATIVECLOSURE) {
316 sq_getstackobj(vm, -1, &funcObj);
333 sq_pushinteger(vm, index);
334 #if !defined (SCRAT_NO_ERROR_CHECKING)
335 if(SQ_FAILED(sq_get(vm, -2))) {
339 SQObjectType value_type = sq_gettype(vm, -1);
340 if (value_type != OT_CLOSURE && value_type != OT_NATIVECLOSURE) {
347 sq_getstackobj(vm, -1, &funcObj);
378 sq_getstackobj(vm,-1,&obj);
417 sq_pushroottable(vm);
418 sq_getstackobj(vm,-1,&obj);
438 sq_pushregistrytable(v);
439 sq_getstackobj(vm,-1,&obj);
463 Var(HSQUIRRELVM vm, SQInteger idx) {
465 sq_resetobject(&obj);
466 sq_getstackobj(vm,idx,&obj);
468 #if !defined (SCRAT_NO_ERROR_CHECKING)
469 SQObjectType value_type = sq_gettype(vm, idx);
470 if (value_type != OT_TABLE) {
485 sq_resetobject(&obj);
487 sq_pushobject(vm,obj);
509 Var(HSQUIRRELVM vm, SQInteger idx) {
511 sq_resetobject(&obj);
512 sq_getstackobj(vm,idx,&obj);
513 value =
Table(obj, vm);
514 #if !defined (SCRAT_NO_ERROR_CHECKING)
515 SQObjectType value_type = sq_gettype(vm, idx);
516 if (value_type != OT_TABLE) {
532 sq_resetobject(&obj);
534 sq_pushobject(vm,obj);
static HSQUIRRELVM Get()
Definition: sqratUtil.h:92
Table value
The actual value of get operations.
Definition: sqratTable.h:451
TableBase & SetValue(const SQChar *name, const V &val)
Definition: sqratTable.h:122
void Bind(const SQChar *name, Object &obj)
Definition: sqratTable.h:84
RootTable(HSQUIRRELVM v=DefaultVM::Get())
Definition: sqratTable.h:416
T value
The actual value of get operations.
Definition: sqratTypes.h:152
Table value
The actual value of get operations.
Definition: sqratTable.h:497
Definition: sqratTypes.h:150
static string FormatTypeError(HSQUIRRELVM vm, SQInteger idx, const string &expectedType)
Definition: sqratUtil.h:149
SharedPtr< T > GetValue(const SQChar *name)
Definition: sqratTable.h:229
TableBase(const Object &obj)
Definition: sqratTable.h:61
Definition: sqratTable.h:407
Table()
Definition: sqratTable.h:367
TableBase & SquirrelFunc(const SQChar *name, SQFUNCTION func)
Definition: sqratTable.h:101
Represents a function in Squirrel.
Definition: sqratFunction.h:40
TableBase & Overload(const SQChar *name, F method)
Definition: sqratTable.h:210
Table(HSQOBJECT o, HSQUIRRELVM v=DefaultVM::Get())
Definition: sqratTable.h:399
Definition: sqratUtil.h:291
TableBase(HSQOBJECT o, HSQUIRRELVM v=DefaultVM::Get())
Definition: sqratTable.h:71
virtual HSQOBJECT GetObject() const
Definition: sqratObject.h:182
TableBase & SetValue(const SQInteger index, const V &val)
Definition: sqratTable.h:139
Function GetFunction(const SQChar *name)
Definition: sqratTable.h:299
RegistryTable(HSQUIRRELVM v=DefaultVM::Get())
Definition: sqratTable.h:437
Definition: sqratObject.h:48
static Error & Instance()
Definition: sqratUtil.h:134
void Throw(HSQUIRRELVM vm, const string &err)
Definition: sqratUtil.h:210
The base class for Table that implements almost all of its functionality.
Definition: sqratTable.h:43
TableBase & SetInstance(const SQInteger index, V *val)
Definition: sqratTable.h:173
Var(HSQUIRRELVM vm, SQInteger idx)
Definition: sqratTable.h:509
Represents a table in Squirrel.
Definition: sqratTable.h:357
Var(HSQUIRRELVM vm, SQInteger idx)
Definition: sqratTable.h:463
Definition: sqratTable.h:428
static void push(HSQUIRRELVM vm, Table value)
Definition: sqratTable.h:530
Function GetFunction(const SQInteger index)
Definition: sqratTable.h:330
static void push(HSQUIRRELVM vm, const Table &value)
Definition: sqratTable.h:483
TableBase & SetInstance(const SQChar *name, V *val)
Definition: sqratTable.h:156
Table(const Object &obj)
Definition: sqratTable.h:389
TableBase(HSQUIRRELVM v=DefaultVM::Get())
Definition: sqratTable.h:52
Table(HSQUIRRELVM v)
Definition: sqratTable.h:376
SharedPtr< T > GetValue(int index)
Definition: sqratTable.h:267
TableBase & Func(const SQChar *name, F method)
Definition: sqratTable.h:190