Members - Reputation: 122
Posted 25 August 2004 - 02:56 AM
Posted 25 August 2004 - 03:15 AM
pThis = new MyClass;
Moderators - Reputation: 4411
Posted 25 August 2004 - 05:36 AM
Since you registered the constructor behaviour function as a class method you should use the following format:
engine->RegisterObjectBehaviour("MyClass", asBEHAVE_CONSTRUCT, "void f()", asMETHOD(MyClass, Construct), asCALL_THISCALL);
If you want to use a global function instead of a class method you'd use the following way:
void MyClass_Construct(MyClass *pThis)
engine->RegisterObjectBehaviour("MyClass", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(MyClass_Construct), asCALL_CDECL_OBJLAST);
The difference is the calling convention. With the object method AS will pass the object pointer in ECX, which will be accessed with the 'this' pointer. With the global function AS will pass the object pointer as the last parameter (in this case the only one) on the stack.
You can freely use either asCALL_THISCALL or asCALL_CDECL_OBJLAST anywhere an object method is expected, i.e. for some of the RegisterObjectBehaviour() calls, and RegisterObjectMethod().
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game