2020-04-06 18:03:44 +00:00
|
|
|
#include "ConstString.hpp"
|
2020-05-27 15:26:25 +00:00
|
|
|
using ConstString = ArbUt::CaseInsensitiveConstString;
|
2020-04-06 18:03:44 +00:00
|
|
|
|
2020-04-28 12:48:56 +00:00
|
|
|
static void ConstructConstString(void* self) { new (self) ConstString(); }
|
|
|
|
static void CopyConstructConstString(const ConstString& other, void* self) { new (self) ConstString(other); }
|
|
|
|
static void DestructConstString(void* self) { ((ConstString*)self)->~ConstString(); }
|
2020-04-06 18:03:44 +00:00
|
|
|
static bool ConstStringEquality(const ConstString& a, const ConstString& b) { return a == b; }
|
2020-04-07 10:04:23 +00:00
|
|
|
static bool ConstStringStdStringEquality(const ConstString& a, const std::string& b) { return a == b; }
|
|
|
|
static ConstString ImplStdStringConstStringConv(const std::string& s) { return ConstString(s); }
|
|
|
|
static std::string ImplConstStringStdStringConv(const ConstString& s) { return s.std_str(); }
|
|
|
|
static uint32_t ImplConstStringHashConv(const ConstString& s) { return s.GetHash(); }
|
2020-04-06 18:03:44 +00:00
|
|
|
|
|
|
|
void ConstStringRegister::Register(asIScriptEngine* engine) {
|
2020-05-27 15:26:25 +00:00
|
|
|
auto r = engine->RegisterObjectType("constString", sizeof(ArbUt::CaseInsensitiveConstString),
|
2020-04-16 12:25:20 +00:00
|
|
|
asOBJ_VALUE | asOBJ_APP_CLASS_CDAK);
|
2020-04-06 18:03:44 +00:00
|
|
|
Assert(r >= 0);
|
2020-04-07 10:04:23 +00:00
|
|
|
|
|
|
|
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 constString &in)",
|
|
|
|
asFUNCTION(CopyConstructConstString), asCALL_CDECL_OBJLAST);
|
|
|
|
Assert(r >= 0);
|
|
|
|
|
|
|
|
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(DestructConstString),
|
|
|
|
asCALL_CDECL_OBJLAST);
|
|
|
|
Assert(r >= 0);
|
|
|
|
|
2020-04-16 12:25:20 +00:00
|
|
|
r = engine->RegisterObjectMethod("constString", "constString &opAssign(const constString &in)",
|
2020-04-07 10:04:23 +00:00
|
|
|
asMETHODPR(ConstString, operator=,(const ConstString&), ConstString&),
|
|
|
|
asCALL_THISCALL);
|
|
|
|
Assert(r >= 0);
|
|
|
|
|
2020-04-06 18:03:44 +00:00
|
|
|
r = engine->RegisterObjectMethod("constString", "bool opEquals(const constString &in) const",
|
|
|
|
asFUNCTIONPR(ConstStringEquality, (const ConstString&, const ConstString&), bool),
|
|
|
|
asCALL_CDECL_OBJFIRST);
|
|
|
|
Assert(r >= 0);
|
2020-04-07 10:04:23 +00:00
|
|
|
r = engine->RegisterObjectMethod(
|
|
|
|
"constString", "bool opEquals(const string &in) const",
|
|
|
|
asFUNCTIONPR(ConstStringStdStringEquality, (const ConstString&, const std::string&), bool),
|
|
|
|
asCALL_CDECL_OBJFIRST);
|
|
|
|
Assert(r >= 0);
|
|
|
|
|
|
|
|
r = engine->RegisterObjectMethod("string", "constString opImplConv()",
|
|
|
|
asFUNCTIONPR(ImplStdStringConstStringConv, (const std::string&), ConstString),
|
|
|
|
asCALL_CDECL_OBJFIRST);
|
|
|
|
Assert(r >= 0);
|
|
|
|
|
|
|
|
r = engine->RegisterObjectMethod("constString", "string opImplConv()",
|
|
|
|
asFUNCTIONPR(ImplConstStringStdStringConv, (const ConstString&), std::string),
|
|
|
|
asCALL_CDECL_OBJFIRST);
|
|
|
|
Assert(r >= 0);
|
|
|
|
|
|
|
|
r = engine->RegisterObjectMethod("constString", "uint opImplConv()",
|
|
|
|
asFUNCTIONPR(ImplConstStringHashConv, (const ConstString&), uint32_t),
|
|
|
|
asCALL_CDECL_OBJFIRST);
|
|
|
|
Assert(r >= 0);
|
2020-04-06 18:03:44 +00:00
|
|
|
}
|