Jump to content
  • Advertisement

y18a

Member
  • Content Count

    25
  • 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. Indeed, my dirty hacks seem to have not been doing well in other namespaces. I will try to investigate by referring to what you taught me. Normally, It is clearly stated as follows. func(XXX::Left); func(YYY::Right); I only want to use this abbreviated dirty hack when I do an operation to convert it to an integer with a bit operator and cast it to an enumeration type. Actually, I wanted to explicitly state what I omit as follows. enum XXX { Left=1,Center=2,Right=4 }; enum YYY { Left=1,Center=2,Right=4 }; func( XXX(.Left|.Right) ); func( YYY(.Left|.Right) ); func( XXX::Left ); // I do this when not performing bit operation. In this case it is impossible to write dangerous code. ( ex, int Left; etc... ) but, I do not understand enough to do it. So, I compromised.
  2. Thanks for fixing it. All existing code now works. It is the same as the following. I was exhausted because I was heavily using it. float3 v; l = v.length; l = v.length(); By the way, With this revision, I applied the following hack patch again. enum TestEnum { A, B }; auto e = TestEnum(A|B); // e = TestEnum(TestEnum::A|TestEnum::B) I want to make `ep.requireEnumScope` true, but since it becomes redundant, I'm hacking as above. Specifically, I am doing the following hacks. However, there are codes that do not pass well with this. Is there any hint? + if( ns && engine->ep.requireEnumScope && errNode ) + { + asCString parentName(&script->code[errNode->parent->tokenPos], errNode->parent->tokenLength); + asDWORD value = 0; + asCDataType dt; + if( builder->GetEnumValue( parentName.AddressOf(), dt, value, outFunc->objectType ? outFunc->objectType->nameSpace : outFunc->nameSpace) ) + { + outResult->type.SetConstantDW(dt, value); + outResult->symbolNamespace = ns; + return SL_ENUMVAL; + } + } // Is it an enum value? if (ns && !engine->ep.requireEnumScope) {
  3. Thanks for fixing it. Another problem is that if you run the following code in a debug build, it stops with an exception. namespace X { class A { void test() { } }; } X::A A; /* It is the same also as follows. X::A __a; X::A@ get_A() { return __a; } */ namespace X { class Test { void test() { A.test(); } } } Assertion failed: false, file sdk\angelscript\source\as_compiler.cpp, line 9789 Previously, this was able to call `A::test ()`. Also, if you indicate `::A.test()` in the global scope, you can compile normally.
  4. I am sorry, the code I presented was wrong. If it is the following code it will result in an error. namespace X { class A { void test() { } }; } namespace Y { class B : X::A { void test() { A::test(); } }; } Previously, this was also successfully compiled.
  5. namespace X { class A { void test() { } }; class B : A { void test() { A::test(); } }; } Thank you for fixing it. However, after this fix, the above code now causes a compile error. script2.as (8, 7) : ERR : No matching symbol 'A::test' `X::A::test ()` will compile successfully.
  6. { 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
  7. 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
  8. 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;
  9. 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
  10. 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.
  11. Thank you always. I checked this problem at revision 2506, but unfortunately it was not solved.
  12. { 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.
  13. { 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.
  14. { 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
  15. 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(); } }
  • 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!