I think you forgot to check-in the AngelScriptEngine.cpp file ?
https://github.com/github-MaxCE/pixelgame/tree/master/pixelgame/src
I think you forgot to check-in the AngelScriptEngine.cpp file ?
https://github.com/github-MaxCE/pixelgame/tree/master/pixelgame/src
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
Ok this error replicates whether i do asCALL_CDECL_OBJLAST
or asCALL_CDECL_OBJFIRST
. basically all i managed to debug
I'll try to reproduce the problem and see if I can figure out what is wrong.
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 finally got some time to try this out.
I faced no problem while registering the type olc::vi2d. I'm not sure what caused the problem for you.
The following is the code I used:
engine = asCreateScriptEngine();
engine->SetMessageCallback(asMETHOD(CBufferedOutStream, Callback), &bout, asCALL_THISCALL);
bout.buffer = "";
engine->RegisterGlobalFunction("void assert(bool)", asFUNCTION(Assert), asCALL_GENERIC);
r = engine->RegisterObjectType("vi2d", sizeof(olc::vi2d), asOBJ_VALUE | asOBJ_POD | asGetTypeTraits<olc::vi2d>());
r = engine->RegisterObjectBehaviour("vi2d", asBEHAVE_CONSTRUCT, "void f()", asFUNCTIONPR(v2d_Constructor_def<int>, (void*), void), asCALL_CDECL_OBJLAST);
r = engine->RegisterObjectBehaviour("vi2d", asBEHAVE_CONSTRUCT, "void f(int, int)", asFUNCTIONPR(v2d_Constructor<int>, (int, int, void*), void), asCALL_CDECL_OBJLAST);
r = engine->RegisterObjectBehaviour("vi2d", asBEHAVE_CONSTRUCT, "void f(const vi2d &in)", asFUNCTIONPR(v2d_Constructor_copy<int>, (const olc::v2d_generic<int>&, void*), void), asCALL_CDECL_OBJLAST);
r = engine->RegisterObjectProperty("vi2d", "int x", asOFFSET(olc::vi2d, x));
r = engine->RegisterObjectProperty("vi2d", "int y", asOFFSET(olc::vi2d, y));
r = ExecuteString(engine, "vi2d v(1, 2); vi2d w(v); assert( w.x == 1 && w.y == 2 );");
if (r != asEXECUTION_FINISHED)
TEST_FAILED;
if (bout.buffer != "")
{
PRINTF("%s", bout.buffer.c_str());
TEST_FAILED;
}
engine->ShutDownAndRelease();
Going back to your code (although you already removed it from your project) I see the problem was that you had registered a destructor that tries to delete the memory. But that shouldn't be done, because the constructor doesn't allocate the memory in the first place. The constructor just used placement new to initialize the already allocated memory. Since the destructor calls delete on a pointer that isn't owned by the object, it caused the crash you faced.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game