Reverts memory alignment thing in ConstString, as it appears to cause issues down the line
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2022-04-01 12:09:35 +02:00
parent da5fe90601
commit 673bd58b88
3 changed files with 24 additions and 17 deletions

View File

@@ -1,36 +1,37 @@
#include "ConstString.hpp"
#include <Arbutils/Ensure.hpp>
#include <Arbutils/StringView.hpp>
#include <Arbutils/Ensure.hpp>
static ArbUt::StringView* ConstructConstString() { return new ArbUt::StringView(); }
static ArbUt::StringView* ConstructConstStringFromStd(const std::string& s) {
return new ArbUt::StringView(s.c_str(), s.length());
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 ArbUt::StringView* CopyConstructConstString(ArbUt::StringView* other) {
return new ArbUt::StringView(*other);
static void CopyConstructConstString(void* self, const ArbUt::StringView& other) {
new (self) ArbUt::StringView(other);
}
static void DestructConstString(ArbUt::StringView* self) { delete self; }
static void DestructConstString(void* self) { ((ArbUt::StringView*)self)->~StringView(); }
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), asOBJ_SCOPED | asOBJ_REF);
auto r = engine->RegisterObjectType("constString", sizeof(ArbUt::StringView),
asOBJ_VALUE | asGetTypeTraits<ArbUt::StringView>());
Ensure(r >= 0);
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_FACTORY, "constString@ f()",
asFUNCTION(ConstructConstString), asCALL_CDECL);
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructConstString),
asCALL_CDECL_OBJFIRST);
Ensure(r >= 0);
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_FACTORY, "constString@ f(const string &in s)",
asFUNCTION(ConstructConstStringFromStd), asCALL_CDECL);
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_CONSTRUCT, "void f(const string &in s)",
asFUNCTION(ConstructConstStringFromStd), asCALL_CDECL_OBJFIRST);
Ensure(r >= 0);
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_FACTORY, "constString@ f(const constString &in)",
asFUNCTION(CopyConstructConstString), asCALL_CDECL);
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_CONSTRUCT, "void f(const constString &in)",
asFUNCTION(CopyConstructConstString), asCALL_CDECL_OBJFIRST);
Ensure(r >= 0);
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_RELEASE, "void f()", asFUNCTION(DestructConstString),
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(DestructConstString),
asCALL_CDECL_OBJFIRST);
Ensure(r >= 0);