Fixes narray::Length not being a property in angelscript.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2021-09-25 18:33:12 +02:00
parent 9fd88f6192
commit 1e10d25dbd
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
2 changed files with 11 additions and 2 deletions

View File

@ -35,7 +35,7 @@ public:
Ensure(engine->RegisterObjectBehaviour("narray<T>", asBEHAVE_RELEASE, "void f()",
asMETHOD(NativeArray, Release), asCALL_THISCALL));
Ensure(engine->RegisterObjectMethod("narray<T>", "uint64 Length() const", asMETHOD(NativeArray, Length),
Ensure(engine->RegisterObjectMethod("narray<T>", "uint64 get_Length() const property", asMETHOD(NativeArray, Length),
asCALL_THISCALL) >= 0);
Ensure(engine->RegisterObjectMethod("narray<T>", "const T@ At(uint64 index) const", asMETHOD(NativeArray, At),
asCALL_THISCALL) >= 0);

View File

@ -11,14 +11,17 @@
static std::unordered_map<const char*, const char*> _scripts = std::unordered_map<const char*, const char*>{
AS_CLASS(blankScript, ),
AS_CLASS(initializeScript, R"(
uint64 length = 0;
bool boolValue = false;
int64 intValue = 0;
constString stringValue;
void OnInitialize(const narray<EffectParameter@>@ parameters) override {
length = parameters.Length;
boolValue = parameters[0].AsBool();
intValue = parameters[1].AsInt();
stringValue = parameters[2].AsString();
}
uint64 GetLength() { return length; }
bool GetBoolValue() { return boolValue; }
int64 GetIntValue() { return intValue; }
constString GetStringValue() { return stringValue; }
@ -138,8 +141,14 @@ TEST_CASE("Invoke OnInitialize script function") {
script->OnInitialize(parameters);
auto ctxPool = script->GetContextPool();
auto ctx = ctxPool->RequestContext();
auto ctx = ctxPool->RequestContext();
script->PrepareMethod("GetLength"_cnc, ctx);
REQUIRE(ctx->Execute() == asEXECUTION_FINISHED);
REQUIRE_EQ((uint64_t)ctx->GetReturnQWord(), 3);
ctxPool->ReturnContextToPool(ctx);
ctx = ctxPool->RequestContext();
script->PrepareMethod("GetBoolValue"_cnc, ctx);
REQUIRE(ctx->Execute() == asEXECUTION_FINISHED);
REQUIRE((bool)ctx->GetReturnDWord());