Adds implicit conversion from constString -> String in angelscript.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-05-13 14:05:14 +02:00
parent 3fb32c33ec
commit d779c7cbfe
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 5 additions and 0 deletions

View File

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