mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-01-19 03:57:14 +01:00
Update sqratLightObj.h
This commit is contained in:
parent
3e0280a3c4
commit
34159d1662
@ -152,6 +152,29 @@ struct LightObj {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// Constructs a LightObj from a C++ instance only if that instance exists. Otherwise, null is beings used.
|
||||||
|
///
|
||||||
|
/// \param instance Pointer to a C++ class instance that has been bound already
|
||||||
|
/// \param v VM that the object will exist in
|
||||||
|
///
|
||||||
|
/// \tparam T Type of instance
|
||||||
|
///
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template<class T>
|
||||||
|
explicit LightObj(T* instance, std::nullptr_t, HSQUIRRELVM vm = SqVM()) {
|
||||||
|
// Preserve the stack state
|
||||||
|
const StackGuard sg(vm);
|
||||||
|
// Push the instance on the stack
|
||||||
|
ClassType<T>::PushInstance(vm, instance, nullptr);
|
||||||
|
// Attempt to retrieve it
|
||||||
|
if (SQ_FAILED(sq_getstackobj(vm, -1, &mObj))) {
|
||||||
|
sq_resetobject(&mObj);
|
||||||
|
} else {
|
||||||
|
sq_addref(vm, &mObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// Constructs a LightObj from a C++ type
|
/// Constructs a LightObj from a C++ type
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user