Add angelscript implicit conversion from string to constString.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
#include <Arbutils/StringView.hpp>
|
||||
|
||||
static void ConstructConstString(void* self) { new (self) ArbUt::StringView(); }
|
||||
static void ConstructConstStringFromStd(void* self, const std::string& s) {
|
||||
new (self) ArbUt::StringView(s.c_str(), s.length());
|
||||
}
|
||||
static void CopyConstructConstString(const ArbUt::StringView& other, void* self) {
|
||||
new (self) ArbUt::StringView(other);
|
||||
}
|
||||
@@ -18,6 +21,9 @@ void ConstStringRegister::Register(asIScriptEngine* engine) {
|
||||
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructConstString),
|
||||
asCALL_CDECL_OBJLAST);
|
||||
Assert(r >= 0);
|
||||
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_CONSTRUCT, "void f(const string &in s)",
|
||||
asFUNCTION(ConstructConstStringFromStd), asCALL_CDECL_OBJLAST);
|
||||
Assert(r >= 0);
|
||||
|
||||
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_CONSTRUCT, "void f(const constString &in)",
|
||||
asFUNCTION(CopyConstructConstString), asCALL_CDECL_OBJLAST);
|
||||
|
||||
Reference in New Issue
Block a user