diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/NativeArray.hpp b/src/ScriptResolving/AngelScript/TypeRegistry/NativeArray.hpp index cf9f55e..e6b9624 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/NativeArray.hpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/NativeArray.hpp @@ -35,7 +35,7 @@ public: Ensure(engine->RegisterObjectBehaviour("narray", asBEHAVE_RELEASE, "void f()", asMETHOD(NativeArray, Release), asCALL_THISCALL)); - Ensure(engine->RegisterObjectMethod("narray", "uint64 Length() const", asMETHOD(NativeArray, Length), + Ensure(engine->RegisterObjectMethod("narray", "uint64 get_Length() const property", asMETHOD(NativeArray, Length), asCALL_THISCALL) >= 0); Ensure(engine->RegisterObjectMethod("narray", "const T@ At(uint64 index) const", asMETHOD(NativeArray, At), asCALL_THISCALL) >= 0); diff --git a/tests/ScriptTests/BaseScriptClassTests.cpp b/tests/ScriptTests/BaseScriptClassTests.cpp index e6d0d01..6635dd9 100644 --- a/tests/ScriptTests/BaseScriptClassTests.cpp +++ b/tests/ScriptTests/BaseScriptClassTests.cpp @@ -11,14 +11,17 @@ static std::unordered_map _scripts = std::unordered_map{ AS_CLASS(blankScript, ), AS_CLASS(initializeScript, R"( +uint64 length = 0; bool boolValue = false; int64 intValue = 0; constString stringValue; void OnInitialize(const narray@ 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());