{
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