mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-06-16 15:17:13 +02:00
Integrate XML module.
Integrate the XML module into the host plugin and get it to compile.
This commit is contained in:
@ -145,6 +145,36 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Constructs an Object from a C++ type
|
||||
///
|
||||
/// \param t Identity of the type to create.
|
||||
/// \param v VM that the object will exist in.
|
||||
/// \param a Arguments to forward to the type constructor.
|
||||
///
|
||||
/// \tparam T Type of instance
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
template<class T, class... A>
|
||||
Object(SqTypeIdentity< T > SQ_UNUSED_ARG(t), HSQUIRRELVM v, A&&... a) : vm(v), release(true) {
|
||||
// Create the instance and guard it to make sure it gets deleted in case of exceptions
|
||||
DeleteGuard< T > instance(new T(std::forward< A >(a)...));
|
||||
// Preserve the stack state
|
||||
const StackGuard sg(vm);
|
||||
// Push the instance on the stack
|
||||
ClassType<T>::PushInstance(vm, instance);
|
||||
// Attempt to retrieve it
|
||||
if (SQ_FAILED(sq_getstackobj(vm, -1, &obj))) {
|
||||
sq_resetobject(&obj);
|
||||
// nothing to release anymore
|
||||
release = false;
|
||||
} else {
|
||||
sq_addref(vm, &obj);
|
||||
}
|
||||
// Stop guarding the instance
|
||||
instance.Release();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
///
|
||||
@ -815,7 +845,7 @@ struct LightObj {
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Constructs an LightObj from a C++ instance
|
||||
/// Constructs a LightObj from a C++ instance
|
||||
///
|
||||
/// \param instance Pointer to a C++ class instance that has been bound already
|
||||
/// \param v VM that the object will exist in
|
||||
@ -837,6 +867,34 @@ struct LightObj {
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Constructs a LightObj from a C++ type
|
||||
///
|
||||
/// \param t Identity of the type to create.
|
||||
/// \param v VM that the object will exist in.
|
||||
/// \param a Arguments to forward to the type constructor.
|
||||
///
|
||||
/// \tparam T Type of instance
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
template<class T, class... A>
|
||||
LightObj(SqTypeIdentity< T > SQ_UNUSED_ARG(t), HSQUIRRELVM vm, A&&... a) {
|
||||
// Create the instance and guard it to make sure it gets deleted in case of exceptions
|
||||
DeleteGuard< T > instance(new T(std::forward< A >(a)...));
|
||||
// Preserve the stack state
|
||||
const StackGuard sg(vm);
|
||||
// Push the instance on the stack
|
||||
ClassType<T>::PushInstance(vm, instance);
|
||||
// Attempt to retrieve it
|
||||
if (SQ_FAILED(sq_getstackobj(vm, -1, &mObj))) {
|
||||
sq_resetobject(&mObj);
|
||||
} else {
|
||||
sq_addref(vm, &mObj);
|
||||
}
|
||||
// Stop guarding the instance
|
||||
instance.Release();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Constructs an LightObj from a C++ instance wrapped inside a DeleteGuard
|
||||
///
|
||||
|
@ -202,7 +202,10 @@ class WeakPtr;
|
||||
|
||||
/// @endcond
|
||||
|
||||
// Helper class that defines a VM that can be used as a fallback VM in case no other one is given to a piece of code
|
||||
/// Provides the member typedef `type` that names T (i.e., the identity transformation).
|
||||
template< class T > struct SqTypeIdentity { using type = T; };
|
||||
|
||||
/// Helper class that defines a VM that can be used as a fallback VM in case no other one is given to a piece of code
|
||||
class DefaultVM {
|
||||
private:
|
||||
static HSQUIRRELVM& StaticVM() {
|
||||
@ -224,6 +227,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/// Alias for DefaultVM::Get()
|
||||
inline HSQUIRRELVM SqVM() noexcept { return DefaultVM::Get(); }
|
||||
|
||||
#if !defined (SCRAT_NO_ERROR_CHECKING) && !defined (SCRAT_USE_EXCEPTIONS)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// The class that must be used to deal with errors that Sqrat has
|
||||
|
Reference in New Issue
Block a user