I did the following with your test and it failed.
#include "utils.h"namespace TestPointer{#define TESTNAME "TestPointer"class ObjectInstance {public: int val; int val2; int val3; void Method() { val=val2=val3=0; }};class ObjectType{public:};static void ObjectFunction(ObjectInstance *obj){}ObjectInstance obj;static ObjectInstance *CreateObjectInstance(ObjectType *type){ return &obj;}ObjectType type;static ObjectType *CreateObjectType(std::string &str){ return &type;}static void FunctionOnObject(ObjectInstance *obj){}static const char *script = "void Test() \n""{ \n"" ObjectInstance*[] c(5); \n"" ObjectType *tbase = CreateObjectType(\"base\"); \n"" uint i; \n"" for( i = 0; i < 5; ++i ) \n"" { \n"" c = CreateObjectInstance(tbase); \n"" c->function(); \n"" c->val = 0; \n"" } \n"" ObjectInstance *obj = c[0]; \n"" FunctionOnObject(c[0]); \n""} \n";bool Test(){ bool fail = false; asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); RegisterStdString(engine); int r; r = engine->RegisterObjectType("ObjectInstance", sizeof(ObjectInstance), asOBJ_CLASS); assert(r>=0); r = engine->RegisterObjectProperty("ObjectInstance", "int val", offsetof(ObjectInstance, val)); assert(r>=0); r = engine->RegisterObjectProperty("ObjectInstance", "int val2", offsetof(ObjectInstance, val)); assert(r>=0); r = engine->RegisterObjectProperty("ObjectInstance", "int val3", offsetof(ObjectInstance, val)); assert(r>=0); r = engine->RegisterObjectMethod("ObjectInstance", "void function()", asFUNCTION(ObjectFunction), asCALL_CDECL_OBJFIRST); assert(r>=0); r = engine->RegisterObjectMethod("ObjectInstance", "void Method()", asMETHOD(ObjectInstance,Method), asCALL_THISCALL); assert(r>=0); r = engine->RegisterObjectType("ObjectType", sizeof(ObjectType), asOBJ_CLASS); assert(r>=0); r = engine->RegisterGlobalFunction("ObjectType *CreateObjectType(string &)", asFUNCTION(CreateObjectType), asCALL_CDECL); assert(r>=0); r = engine->RegisterGlobalFunction("ObjectInstance *CreateObjectInstance(ObjectType *type)", asFUNCTION(CreateObjectInstance), asCALL_CDECL); assert(r>=0); r = engine->RegisterGlobalFunction("void FunctionOnObject(ObjectInstance *)", asFUNCTION(FunctionOnObject), asCALL_CDECL); assert(r>=0); // Register an object. ObjectInstance obj; r = engine->RegisterGlobalProperty("ObjectInstance obj", &obj); assert(r>=0); // Register a pointer to object. ObjectInstance *pnt = &obj; r = engine->RegisterGlobalProperty("ObjectInstance *ptr", &pnt); assert(r>=0); COutStream out; // Function call executed fine when using an object. r = engine->ExecuteString(0, "obj.function(); obj.val = 23;", &out); if( r < 0 ) { printf("%s: ExecuteString() failed %d\n", TESTNAME, r); fail = true; } if( obj.val != 23 ) { printf("%s: failed\n", TESTNAME, r); fail = true; } r = engine->ExecuteString(0, "ptr->function(); ptr->val = 13;", &out); if( r < 0 ) { printf("%s: ExecuteString() failed %d\n", TESTNAME, r); fail = true; } if( obj.val != 13 ) { printf("%s: failed\n", TESTNAME, r); fail = true; } engine->AddScriptSection(0, TESTNAME, script, strlen(script)); r = engine->Build(0, &out); if( r < 0 ) { printf("%s: failed\n", TESTNAME, r); fail = true; } r = engine->ExecuteString(0, "Test()"); if( r < 0 ) { printf("%s: failed\n", TESTNAME, r); fail = true; } engine->Release(); return fail;}}
Note that this is not with the latest WIP. When I try to compile the library there, the WIN32 Debug with ASM VM build fails with the message
c:\angelcode\sdk\angelscript\source\as_context_x86.cpp(131) : error C2248: 'length' : cannot access protected member declared in class 'asCArray<int>' c:\angelcode\sdk\angelscript\source\as_array.h(61) : see declaration of 'length'
I comment out that one line, compile the necessary projects, and run with the version of TestPointer listed here and it dies with the error message
Assertion failed: false, file c:\angelcode\sdk\angelscript\source\as_compiler.cpp, line 1921
... is there any way to get "check here to include your profile signature" to stay selected all the time? That bugs the hell out of me!