Add angelscript implicit conversion from string to constString.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-07-04 16:13:26 +02:00
parent 7f1bc252ba
commit 665c47aa91
4 changed files with 11 additions and 9 deletions

View File

@@ -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);