diff --git a/module/Library/String.cpp b/module/Library/String.cpp index d543d803..30595f17 100644 --- a/module/Library/String.cpp +++ b/module/Library/String.cpp @@ -21,7 +21,7 @@ static LightObj SqLeftStr(SQChar f, Uint32 w, StackStrF & s) // Is the specified width valid? if (!w) { - return _SC(""); // Default to an empty string! + return LightObj(_SC(""), 0); // Default to an empty string! } // Allocate a buffer with the requested width Buffer b(w + 1); // + null terminator @@ -51,7 +51,7 @@ static LightObj SqLeftOffsetStr(SQChar f, Uint32 w, Uint32 o, StackStrF & s) // Is the specified width valid? if (!w) { - return _SC(""); // Default to an empty string! + return LightObj(_SC(""), 0); // Default to an empty string! } // Is the specified offset within width range? else if (o > w) @@ -95,7 +95,7 @@ static LightObj SqRightStr(SQChar f, Uint32 w, StackStrF & s) // Is the specified width valid? if (!w) { - return _SC(""); // Default to an empty string! + return LightObj(_SC(""), 0); // Default to an empty string! } // Allocate a buffer with the requested width Buffer b(w + 1); // + null terminator @@ -134,7 +134,7 @@ static LightObj SqRightOffsetStr(SQChar f, Uint32 w, Uint32 o, StackStrF & s) // Is the specified width valid? if (!w) { - return _SC(""); // Default to an empty string! + return LightObj(_SC(""), 0); // Default to an empty string! } // Is the specified offset within width range? else if (o > w) @@ -178,7 +178,7 @@ static LightObj SqCenterStr(SQChar f, Uint32 w, StackStrF & s) // Is the specified width valid? if (!w) { - return _SC(""); // Default to an empty string! + return LightObj(_SC(""), 0); // Default to an empty string! } // Allocate a buffer with the requested width Buffer b(w + 1); // + null terminator diff --git a/module/Misc/Signal.cpp b/module/Misc/Signal.cpp index a0189a4a..67152f38 100644 --- a/module/Misc/Signal.cpp +++ b/module/Misc/Signal.cpp @@ -1545,7 +1545,7 @@ LightObj Signal::Create(StackStrF & name) { if (e.first == hash) { - return e.second.second.mObj; // Found a match so let's return it + return LightObj{e.second.second.mObj}; // Found a match so let's return it } } // Remember the current stack size @@ -1561,7 +1561,7 @@ LightObj Signal::Create(StackStrF & name) // Grab a reference to the instance created on the stack s_Signals.emplace_back(hash, SignalPair(ptr, Var< LightObj >(SqVM(), -1).value)); // Return the created signal - return s_Signals.back().second.second.mObj; + return LightObj{s_Signals.back().second.second.mObj}; } // ------------------------------------------------------------------------------------------------ diff --git a/sqrat/sqrat/sqratObject.h b/sqrat/sqrat/sqratObject.h index e7a51a89..27a40cae 100644 --- a/sqrat/sqrat/sqratObject.h +++ b/sqrat/sqrat/sqratObject.h @@ -860,7 +860,7 @@ struct LightObj { /// \param o Squirrel object /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LightObj(HSQOBJECT o) : mObj(o) { + explicit LightObj(const HSQOBJECT & o) : mObj(o) { sq_addref(SqVM(), &mObj); } @@ -871,7 +871,7 @@ struct LightObj { /// \param v VM that the object will exist in /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LightObj(SQInteger i, HSQUIRRELVM v = SqVM()) { + explicit LightObj(SQInteger i, HSQUIRRELVM v = SqVM()) { if (SQ_FAILED(sq_getstackobj(v, i, &mObj))) { sq_resetobject(&mObj); } else { @@ -887,7 +887,7 @@ struct LightObj { /// \param v VM that the object will exist in /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LightObj(const SQChar * s, SQInteger l, HSQUIRRELVM v = SqVM()) { + explicit LightObj(const SQChar * s, SQInteger l=-1, HSQUIRRELVM v = SqVM()) { sq_pushstring(v, s, l); if (SQ_FAILED(sq_getstackobj(v, -1, &mObj))) { sq_resetobject(&mObj); @@ -903,7 +903,7 @@ struct LightObj { /// \param so Object to copy /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LightObj(const Object& obj) : mObj(obj.GetObj()) { + explicit LightObj(const Object& obj) : mObj(obj.GetObj()) { if (!sq_isnull(mObj)) { sq_addref(obj.GetVM(), &mObj); } @@ -919,7 +919,7 @@ struct LightObj { /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - LightObj(T* instance, HSQUIRRELVM v = SqVM()) { + explicit LightObj(T* instance, HSQUIRRELVM v = SqVM()) { // Preserve the stack state const StackGuard sg(v); // Push the instance on the stack