Advertisement

Loading bytecode fails when combining namespace and shared virtual method.

Started by May 28, 2018 09:22 AM
4 comments, last by WitchLord 6 years, 5 months ago

	{
		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.

Thanks. I'll look into this one too.

It is definitely related to the external shared classes, though I'm not sure it is the same as the problem you reported earlier (and already fixed in revision 2505). I have a feeling it is more related to the other problem you reported with the lambda functions.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement

Thank you always.
I checked this problem at revision 2506, but unfortunately it was not solved.

Indeed. I'm still investigating this problem.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I've fixed this in revision 2508.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement