Преглед изворни кода

Added new member to SQRegFunction a bool to indicate if the function should be registered as static.
Added new functions to the api like the ones added before to registrytable but now on roottable.

mingodad пре 13 година
родитељ
комит
b170a57626
2 измењених фајлова са 24 додато и 0 уклоњено
  1. 3 0
      include/squirrel.h
  2. 21 0
      squirrel/sqapi.cpp

+ 3 - 0
include/squirrel.h

@@ -312,6 +312,7 @@ typedef struct tagSQRegFunction{
 	SQFUNCTION f;
 	SQFUNCTION f;
 	SQInteger nparamscheck;
 	SQInteger nparamscheck;
 	const SQChar *typemask;
 	const SQChar *typemask;
+	SQBool isStatic;
 }SQRegFunction;
 }SQRegFunction;
 
 
 typedef struct tagSQFunctionInfo {
 typedef struct tagSQFunctionInfo {
@@ -409,6 +410,8 @@ SQUIRREL_API SQRESULT sq_setbyhandle(HSQUIRRELVM v,SQInteger idx,const HSQMEMBER
 
 
 /*object manipulation*/
 /*object manipulation*/
 SQUIRREL_API void sq_pushroottable(HSQUIRRELVM v);
 SQUIRREL_API void sq_pushroottable(HSQUIRRELVM v);
+SQUIRREL_API SQRESULT sq_getonroottable(HSQUIRRELVM v);
+SQUIRREL_API SQRESULT sq_setonroottable(HSQUIRRELVM v);
 SQUIRREL_API void sq_pushregistrytable(HSQUIRRELVM v);
 SQUIRREL_API void sq_pushregistrytable(HSQUIRRELVM v);
 SQUIRREL_API SQRESULT sq_getonregistrytable(HSQUIRRELVM v);
 SQUIRREL_API SQRESULT sq_getonregistrytable(HSQUIRRELVM v);
 SQUIRREL_API SQRESULT sq_setonregistrytable(HSQUIRRELVM v);
 SQUIRREL_API SQRESULT sq_setonregistrytable(HSQUIRRELVM v);

+ 21 - 0
squirrel/sqapi.cpp

@@ -508,6 +508,27 @@ void sq_pushroottable(HSQUIRRELVM v)
 	v->Push(v->_roottable);
 	v->Push(v->_roottable);
 }
 }
 
 
+SQRESULT sq_getonroottable(HSQUIRRELVM v)
+{
+    SQObjectPtr &obj = v->GetUp(-1);
+	if(_table(v->_roottable)->Get(obj,obj))
+		return SQ_OK;
+	v->Pop();
+	return SQ_ERROR;
+}
+
+SQRESULT sq_setonroottable(HSQUIRRELVM v)
+{
+    SQObjectPtr &key = v->GetUp(-2);
+	if(type(key) == OT_NULL) {
+		v->Pop(2);
+		return sq_throwerror(v, _SC("null key"));
+	}
+    _table(v->_roottable)->NewSlot(key, v->GetUp(-1));
+    v->Pop(2);
+    return SQ_OK;
+}
+
 void sq_pushregistrytable(HSQUIRRELVM v)
 void sq_pushregistrytable(HSQUIRRELVM v)
 {
 {
 	v->Push(_ss(v)->_registry);
 	v->Push(_ss(v)->_registry);