Adds implicit conversion from constString -> String in angelscript.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
3fb32c33ec
commit
d779c7cbfe
|
@ -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 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 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 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) {
|
void ConstStringRegister::Register(asIScriptEngine* engine) {
|
||||||
auto r = engine->RegisterObjectType("constString", sizeof(ArbUt::StringView),
|
auto r = engine->RegisterObjectType("constString", sizeof(ArbUt::StringView),
|
||||||
|
@ -52,4 +53,8 @@ void ConstStringRegister::Register(asIScriptEngine* engine) {
|
||||||
asFUNCTIONPR(ImplConstStringHashConv, (const ArbUt::StringView&), uint32_t),
|
asFUNCTIONPR(ImplConstStringHashConv, (const ArbUt::StringView&), uint32_t),
|
||||||
asCALL_CDECL_OBJFIRST);
|
asCALL_CDECL_OBJFIRST);
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("constString", "string opImplConv()",
|
||||||
|
asFUNCTIONPR(ImplConstStringStringConv, (const ArbUt::StringView&), std::string),
|
||||||
|
asCALL_CDECL_OBJFIRST);
|
||||||
|
Ensure(r >= 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue