From d779c7cbfefaeab818f11c265220148ca2f9462f Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Thu, 13 May 2021 14:05:14 +0200 Subject: [PATCH] Adds implicit conversion from constString -> String in angelscript. --- src/ScriptResolving/AngelScript/TypeRegistry/ConstString.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/ConstString.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/ConstString.cpp index 6ab96a2..1cf0c6e 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/ConstString.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/ConstString.cpp @@ -11,6 +11,7 @@ static void DestructConstString(void* self) { ((ArbUt::StringView*)self)->~Strin static bool ConstStringEquality(const ArbUt::StringView& a, const ArbUt::StringView& b) { return a == b; } static bool ConstStringStdStringEquality(const ArbUt::StringView& a, const std::string& b) { return a == b; } static uint32_t ImplConstStringHashConv(const ArbUt::StringView& s) { return s.GetHash(); } +static std::string ImplConstStringStringConv(const ArbUt::StringView& s) { return std::string(s.std_str()); } void ConstStringRegister::Register(asIScriptEngine* engine) { auto r = engine->RegisterObjectType("constString", sizeof(ArbUt::StringView), @@ -52,4 +53,8 @@ void ConstStringRegister::Register(asIScriptEngine* engine) { asFUNCTIONPR(ImplConstStringHashConv, (const ArbUt::StringView&), uint32_t), asCALL_CDECL_OBJFIRST); Ensure(r >= 0); + r = engine->RegisterObjectMethod("constString", "string opImplConv()", + asFUNCTIONPR(ImplConstStringStringConv, (const ArbUt::StringView&), std::string), + asCALL_CDECL_OBJFIRST); + Ensure(r >= 0); }