1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Remove duplicate code in Sqrat Var for the the StackStrF type.

This commit is contained in:
Sandu Liviu Catalin 2016-11-17 10:50:40 +02:00
parent 92faaccf06
commit 32061463c0

View File

@ -1021,7 +1021,7 @@ public:
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Used to get and push StackStrF types to and from the stack
/// Used to get and push StackStrF types to and from the stack (StackStrF is always a reference)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<>
struct Var<StackStrF &> {
@ -1055,39 +1055,10 @@ struct Var<StackStrF &> {
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Used to get and push StackStrF types to and from the stack
/// Used to get and push StackStrF types to and from the stack (StackStrF is always a reference)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<>
struct Var<const StackStrF&> {
StackStrF value; ///< The actual value of get operations
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Attempts to get the value off the stack at idx as a string
///
/// \param vm Target VM
/// \param idx Index trying to be read
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Var(HSQUIRRELVM vm, SQInteger idx) : value(vm, idx, false) {
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Called by Sqrat::PushVar to put a string on the stack
///
/// \param vm Target VM
/// \param value Value to push on to the VM's stack
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static void push(HSQUIRRELVM vm, const StackStrF& value) {
if (sq_isstring(value.mObj)) {
sq_pushobject(vm, value.mObj);
} else {
sq_pushstring(vm, value.mPtr, value.mLen);
}
}
};
struct Var<const StackStrF &> : Var<StackStrF &> {Var(HSQUIRRELVM vm, SQInteger idx) : Var<StackStrF &>(vm, idx) {}};
// Non-referencable type definitions
template<class T> struct is_referencable {static const bool value = true;};