1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2026-01-20 22:24:38 +01:00

Minor adjustments to Sqrat types. Improved shared pointers to use less heap allocations for counters.

This commit is contained in:
Sandu Liviu Catalin
2017-02-21 21:19:10 +02:00
parent 6909e46125
commit 178b30bb20
3 changed files with 383 additions and 268 deletions

View File

@@ -814,7 +814,7 @@ struct LightObj {
/// \return Squirrel object
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual HSQOBJECT GetObject() const {
HSQOBJECT GetObject() const {
return mObj;
}
@@ -824,7 +824,7 @@ struct LightObj {
/// \return Squirrel object
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual HSQOBJECT& GetObject() {
HSQOBJECT& GetObject() {
return mObj;
}
@@ -836,6 +836,16 @@ struct LightObj {
return mObj;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Gets the Squirrel VM for this Object (copy)
///
/// \return Squirrel VM associated with the Object
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inline HSQUIRRELVM GetVM() const {
return DefaultVM::Get();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Sets the LightObj to null (removing its references to underlying Squirrel objects)
///
@@ -847,6 +857,23 @@ struct LightObj {
sq_resetobject(&mObj);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Binds a Table or Class to the object (can be used to facilitate namespaces)
///
/// \param name The key in the table being assigned a Table or Class
/// \param obj Table or Class that is being placed in the table
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Bind(const SQChar* name, LightObj& obj) {
HSQUIRRELVM vm = DefaultVM::Get();
sq_pushobject(vm, mObj);
sq_pushstring(vm, name, -1);
sq_pushobject(vm, obj.mObj);
sq_newslot(vm, -3, false);
sq_pop(vm,1); // pop table
}
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////