Skip to content

Commit

Permalink
Codechange: make SQString::Create that supports std::string and use that
Browse files Browse the repository at this point in the history
  • Loading branch information
rubidium42 committed Jun 15, 2023
1 parent 5a7098c commit e505099
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/3rdparty/squirrel/include/squirrel.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars);
SQRESULT sq_setparamscheck(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask);
SQRESULT sq_bindenv(HSQUIRRELVM v,SQInteger idx);
void sq_pushstring(HSQUIRRELVM v,const SQChar *s,SQInteger len);
static inline void sq_pushstring(HSQUIRRELVM v, const std::string &str, SQInteger len = -1) { sq_pushstring(v, str.c_str(), len == -1 ? str.size() : len); }
static inline void sq_pushstring(HSQUIRRELVM v, const std::string &str, SQInteger len = -1) { sq_pushstring(v, str.data(), len == -1 ? str.size() : len); }
void sq_pushfloat(HSQUIRRELVM v,SQFloat f);
void sq_pushinteger(HSQUIRRELVM v,SQInteger n);
void sq_pushbool(HSQUIRRELVM v,SQBool b);
Expand Down
2 changes: 1 addition & 1 deletion src/3rdparty/squirrel/squirrel/sqcompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class SQCompiler
_ss(_vm)->_compilererrorhandler(_vm, compilererror.c_str(), type(_sourcename) == OT_STRING ? _stringval(_sourcename) : "unknown",
_lex._currentline, _lex._currentcolumn);
}
_vm->_lasterror = SQString::Create(_ss(_vm), compilererror.c_str(), -1);
_vm->_lasterror = SQString::Create(_ss(_vm), compilererror);
return false;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/3rdparty/squirrel/squirrel/sqdebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ SQRESULT sq_stackinfos(HSQUIRRELVM v, SQInteger level, SQStackInfos *si)

void SQVM::Raise_Error(const std::string &msg)
{
_lasterror = SQString::Create(_ss(this),msg.c_str(),-1);
_lasterror = SQString::Create(_ss(this),msg);
}

void SQVM::Raise_Error(SQObjectPtr &desc)
Expand All @@ -79,9 +79,9 @@ SQString *SQVM::PrintObjVal(const SQObject &o)
switch(type(o)) {
case OT_STRING: return _string(o);
case OT_INTEGER:
return SQString::Create(_ss(this), fmt::format("{}", _integer(o)).c_str());
return SQString::Create(_ss(this), fmt::format("{}", _integer(o)));
case OT_FLOAT:
return SQString::Create(_ss(this), fmt::format("{:.14g}", _float(o)).c_str());
return SQString::Create(_ss(this), fmt::format("{:.14g}", _float(o)));
default:
return SQString::Create(_ss(this), GetTypeName(o));
}
Expand Down
1 change: 1 addition & 0 deletions src/3rdparty/squirrel/squirrel/sqstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct SQString : public SQRefCounted
~SQString(){}
public:
static SQString *Create(SQSharedState *ss, const SQChar *, SQInteger len = -1 );
static SQString *Create(SQSharedState *ss, const std::string &str) { return Create(ss, str.data(), str.size()); }
SQInteger Next(const SQObjectPtr &refpos, SQObjectPtr &outkey, SQObjectPtr &outval);
void Release();
SQSharedState *_sharedstate;
Expand Down
2 changes: 1 addition & 1 deletion src/3rdparty/squirrel/squirrel/sqvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ void SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res)
default:
str = fmt::format("({} : 0x{:08X})",GetTypeName(o),(size_t)(void*)_rawval(o));
}
res = SQString::Create(_ss(this),str.c_str());
res = SQString::Create(_ss(this),str);
}


Expand Down

0 comments on commit e505099

Please sign in to comment.