Jump to content
  • Advertisement

y18a

Member
  • Content count

    20
  • Joined

  • Last visited

Community Reputation

0 Neutral

About y18a

  • Rank
    Member

Personal Information

  • Role
    Programmer
  • Interests
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. { engine = asCreateScriptEngine(); engine->SetMessageCallback(asMETHOD(CBufferedOutStream, Callback), &bout, asCALL_THISCALL); bout.buffer = ""; mod = engine->GetModule("test", asGM_ALWAYS_CREATE); mod->AddScriptSection( "test", "namespace X { shared float A() {return 0.f;} }" "namespace Y { shared float A() {return 0.f;} }" "void test() {" " float v;" " v = Y::A();" "}"); r = mod->Build(); if (r < 0) TEST_FAILED; CBytecodeStream bc1("test"); r = mod->SaveByteCode(&bc1); assert(r >= 0); if (r < 0) TEST_FAILED; mod = engine->GetModule("test", asGM_ALWAYS_CREATE); r = mod->LoadByteCode(&bc1); if (r < 0) TEST_FAILED; if (bout.buffer != "") { PRINTF("%s", bout.buffer.c_str()); TEST_FAILED; } engine->ShutDownAndRelease(); } When you execute the above, it becomes as follows. (0, 0) : Error : LoadByteCode failed. The bytecode is invalid. Number of bytes read from stream: 146
  2. Thanks!, However it seems that another problem has occurred. dictionary d1; d1.set('a', dictionary = {{'aa', 1}, {'ab', 2}}); Executing the above code will result in the following. Assertion failed: tempVariables.GetLength() == 0, file ...\sdk\angelscript\source\as_compiler.cpp, line 1165
  3. y18a

    Refcounting in opCast

    external shared class A; A@ a = cast<A>(GetA()); With the revision of rev 2509, when there is initialization of the global variable as described above, it outputs and stops as follows. Assertion failed: tempVariables.Exists(offset), file j:\home\src\angelscript\sdk\angelscript\source\as_compiler.cpp, line 5333 The following is a fragment of the test code executed. #include "../../../add_on/scriptany/scriptany.h" ...snip... static void CScriptAny_Cast(void *ref, int refTypeId, void *x) { if(!((CScriptAny*)x)->Retrieve(ref, refTypeId)) { asIScriptContext *ctx = asGetActiveContext(); if( ctx ) ctx->SetException("Illegal conversion"); } } static void *GetA() { return nullptr; } bool Test() { ...snip... RegisterScriptAny(engine); r = engine->RegisterObjectMethod("any", "void opCast(?&out)", asFUNCTION(CScriptAny_Cast), asCALL_CDECL_OBJLAST); assert( r >= 0 ); r = engine->RegisterGlobalFunction( "any@ GetA()" , asFUNCTION(GetA) , asCALL_CDECL ); if (r < 0) TEST_FAILED; mod = engine->GetModule("test", asGM_ALWAYS_CREATE); mod->AddScriptSection("test", "shared class A {" "};" ); r = mod->Build(); if (r < 0) TEST_FAILED; asIScriptModule *mod2 = engine->GetModule("test2", asGM_ALWAYS_CREATE); mod2->AddScriptSection("test", "external shared class A;" "A@ a = cast<A>(GetA());" ); r = mod2->Build(); if (r < 0) TEST_FAILED;
  4. This problem only occurs when `asEP_DISALLOW_VALUE_ASSIGN_FOR_REF_TYPE` is enabled. engine->SetEngineProperty(asEP_DISALLOW_VALUE_ASSIGN_FOR_REF_TYPE, 1); First of all, set as above. void main() { dictionary d2 = {{'a', dictionary = {{'aa', 1}, {'ab', 2}}}, {'b', dictionary = {{'ba', 1}, {'bb', 2}}}}; auto d2a = cast<dictionary>(d2['a']); print("d2a.getSize:" + d2a.getSize() + "\n"); } Next, when you execute the above, the result is as follows. >asrun.exe script2.as d2a.getSize:0
  5. It seems that trouble occurs with the code which was originally working. I have not examined it in detail, but if you make the following corrections, the problem will not occur. if (func2->funcType == asFUNC_VIRTUAL) func2 = ot->virtualFunctionTable[func2->vfTableIdx]; if (func->IsSignatureEqual(func2)) { func->DestroyHalfCreated(); func = func2; + savedFunctions[savedFunctions.GetLength()-1] = func2; // as this is an existing function it shouldn't be translated as if just loaded dontTranslate.Insert(func2, true); I do not understand it much, I am not confident because it is a patch by intuition.
  6. Thank you always. I checked this problem at revision 2506, but unfortunately it was not solved.
  7. { engine = asCreateScriptEngine(); engine->SetMessageCallback(asMETHOD(CBufferedOutStream, Callback), &bout, asCALL_THISCALL); bout.buffer = ""; mod = engine->GetModule("test", asGM_ALWAYS_CREATE); mod->AddScriptSection("test", "namespace X {" "shared class A" "{" "}" "shared class B : A" "{" " void bar() {}" "}}" ); r = mod->Build(); if (r < 0) TEST_FAILED; asIScriptModule *mod2 = engine->GetModule("test2", asGM_ALWAYS_CREATE); mod2->AddScriptSection("test", "namespace X {" "external shared class A;" "external shared class B;" "}" "namespace Y {" "class Test : X::A" "{" " X::B b;" " void foo() { b.bar(); }" "}}" ); r = mod2->Build(); if (r < 0) TEST_FAILED; CBytecodeStream bc1("test"); r = mod->SaveByteCode(&bc1); assert(r >= 0); if (r < 0) TEST_FAILED; CBytecodeStream bc2("test2"); r = mod2->SaveByteCode(&bc2); assert(r >= 0); if (r < 0) TEST_FAILED; mod2->Discard(); // game loop for (unsigned i = 0; i < 10; ++i) { engine->GarbageCollect(); // run DeleteDiscardedModules(); } mod2 = engine->GetModule("test2", asGM_ALWAYS_CREATE); r = mod2->LoadByteCode(&bc2); if (r < 0) TEST_FAILED; if (bout.buffer != "") { PRINTF("%s", bout.buffer.c_str()); TEST_FAILED; } engine->ShutDownAndRelease(); } When you execute the above, the following will be output. (0, 0) : Error : LoadByteCode failed. The bytecode is invalid. Number of bytes read from stream: 255 Similar to this case, it seems that problems will occur with virtual method restore this time.
  8. { engine = asCreateScriptEngine(); engine->SetMessageCallback(asMETHOD(CBufferedOutStream, Callback), &bout, asCALL_THISCALL); bout.buffer = ""; mod = engine->GetModule("test", asGM_ALWAYS_CREATE); mod->AddScriptSection("test", "namespace X {" "shared class A" "{" " A()" " {}" "}};" ); r = mod->Build(); if (r < 0) TEST_FAILED; asIScriptModule *mod2 = engine->GetModule("test2", asGM_ALWAYS_CREATE); mod2->AddScriptSection("test", "namespace X {" "external shared class A;" "}" "namespace Y {" "class Test : X::A" "{" " Test() {}" "}};" ); r = mod2->Build(); if (r < 0) TEST_FAILED; CBytecodeStream bc1("test"); r = mod->SaveByteCode(&bc1); assert(r >= 0); if (r < 0) TEST_FAILED; CBytecodeStream bc2("test2"); r = mod2->SaveByteCode(&bc2); assert(r >= 0); if (r < 0) TEST_FAILED; #if 0 engine->ShutDownAndRelease(); engine = asCreateScriptEngine(); engine->SetMessageCallback(asMETHOD(CBufferedOutStream, Callback), &bout, asCALL_THISCALL); mod = engine->GetModule("test", asGM_ALWAYS_CREATE); r = mod->LoadByteCode(&bc1); if (r < 0) TEST_FAILED; #else mod2->Discard(); // game loop for(unsigned i = 0; i < 10; ++i) { engine->GarbageCollect(); // run DeleteDiscardedModules(); } #endif mod2 = engine->GetModule("test2", asGM_ALWAYS_CREATE); r = mod2->LoadByteCode(&bc2); if (r < 0) TEST_FAILED; if (bout.buffer != "") { PRINTF("%s", bout.buffer.c_str()); TEST_FAILED; } engine->ShutDownAndRelease(); } When the above is executed, the following error is output. (0, 0) : Error : LoadByteCode failed. The bytecode is invalid. Number of bytes read from stream: 140 In the above example, while sharing module resides, we test that one module is recompiled into bytecode and from then on it is read. By the way, you can read it normally after calling ShutDownAndRelease.
  9. { engine = asCreateScriptEngine(); engine->SetMessageCallback(asMETHOD(CBufferedOutStream, Callback), &bout, asCALL_THISCALL); bout.buffer = ""; mod = engine->GetModule("test", asGM_ALWAYS_CREATE); mod->AddScriptSection("test", "shared funcdef void TestFunc();" "shared class TestBase" "{" " void callfn(TestFunc@ fn)" " {" " }" " void test()" " {" " callfn( function() { } );" " } " "};" ); r = mod->Build(); if (r < 0) TEST_FAILED; asIScriptModule *mod2 = engine->GetModule("test2", asGM_ALWAYS_CREATE); mod2->AddScriptSection("test", "external shared funcdef void TestFunc();" "external shared class TestBase;" "class Test : TestBase" "{" "};" ); r = mod2->Build(); if (r < 0) TEST_FAILED; CBytecodeStream bc1("test"); r = mod->SaveByteCode(&bc1); assert(r >= 0); if (r < 0) TEST_FAILED; CBytecodeStream bc2("test2"); r = mod2->SaveByteCode(&bc2); assert(r >= 0); if (r < 0) TEST_FAILED; engine->ShutDownAndRelease(); engine = asCreateScriptEngine(); engine->SetMessageCallback(asMETHOD(CBufferedOutStream, Callback), &bout, asCALL_THISCALL); mod = engine->GetModule("test", asGM_ALWAYS_CREATE); r = mod->LoadByteCode(&bc1); if (r < 0) TEST_FAILED; mod2 = engine->GetModule("test2", asGM_ALWAYS_CREATE); r = mod2->LoadByteCode(&bc2); if (r < 0) TEST_FAILED; if (bout.buffer != "") { PRINTF("%s", bout.buffer.c_str()); TEST_FAILED; } engine->ShutDownAndRelease(); } When preparing and executing the above code, it stops with the following error. (0, 0) : Error : LoadByteCode failed. The bytecode is invalid. Number of bytes read from stream: 287
  10. namespace A { class X { X() { print("X()"); } } } void X() { auto test = A::X(); } void main() { X(); } When preparing and executing the above, we output the following. >asrun.exe script2.as script2.as (10, 1) : INFO : Compiling void X() script2.as (12, 8) : ERR : Data type can't be 'void' script2.as (0, 0) : ERR : Script failed to build auto test = A::X(); The reason for doing this is because it really is `class@ X`. Also, if executed from another namespace as follows, it will be executed normally. namespace A { class X { X() { print("X()"); } } } namespace B { void X() { auto test = A::X(); } }
  11. Oh, sorry, There was a lack of confirmation.
  12. void main() { array<int> hoge = { 1, 2, }; print("" + hoge.length() + "\n") ; } Prepare the above and execute it. $ ./asrun.exe script2.as 3 It is expected to be 2, but 3 will be returned. `array` uses `scriptarray addon`.
  13. namespace test { enum ETest { A, B } class CTest { CTest(const ETest v = ETest::A) {} } } void main() { test::CTest a; } Prepare the above code and execute it. > asrun.exe script2.as script2.as (15, 1) : INFO : Compiling void main() default arg (1, 1) : ERR : Unknown scope 'ETest' script2.as (17, 15) : ERR : Failed while compiling default arg for parameter 0 in function 'test::CTest@ CTest(const test::ETest = ETest :: A)' Abnormally ends after outputting the above. Describing the namespace as below will compile successfully. CTest(const ETest v = test::ETest::A) {}
  14. y18a

    Leak occurs when "shared class" exists.

    asCScriptFunction::~asCScriptFunction() { // Dummy functions that are allocated on the stack are not reference counted asASSERT( funcType == asFUNC_DUMMY || (externalRefCount.get() == 0 && internalRefCount.get() == 0) ); + printf(" + destruct %s\n", name.AddressOf());fflush(stdout); First of all, prepare as above. static const char *script1 = "shared class X { } \n" "X@ x = X();" ; static const char *script2 = "shared class X { }; \n" "void test() { \n" "} \n" ; bool Test() { bool fail = false; int r; CBufferedOutStream out; asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); engine->SetMessageCallback(asMETHOD(CBufferedOutStream, Callback), &out, asCALL_THISCALL); asIScriptModule *mod = engine->GetModule("Module1", asGM_ALWAYS_CREATE); mod->AddScriptSection("Script1", script1, strlen(script1), 0); mod->Build(); out.buffer = ""; mod = engine->GetModule("Module2", asGM_ALWAYS_CREATE); mod->AddScriptSection("Script2", script2, strlen(script2), 0); r = mod->Build(); if( r < 0 ) TEST_FAILED; if( out.buffer != "" ) TEST_FAILED; // discard `Module2` mod->Discard(); // game loop for(unsigned i = 0; i < 10; ++i) { engine->GarbageCollect(); // run DeleteDiscardedModules(); PRINTF("."); } PRINTF("gameloop done.\n"); engine->Release(); // Success return fail; } And then execute the above. ..........gameloop done. + destruct test The result will be as above. This indicates that `void test ()` was not deleted until the game loop terminated. + destruct test ..........gameloop done. Applying a patch to `asCModule :: HasExternalReferences` will result in the above.
  15. Leak occurs when "shared class" exists. `destructor` of asIScriptFunction will not be called, so I investigated it, I applied the following patch and improved it. bool asCModule::HasExternalReferences(bool shuttingDown) : : for( asUINT n = 0; n < classTypes.GetLength(); n++ ) if( classTypes[n] && classTypes[n]->externalRefCount.get() ) { + asCObjectType *type = classTypes[n]; + if( type->IsShared() ) + continue; .... Should I also check below? if( engine->FindNewOwnerForSharedType(type, this) != this )
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!