OK sorry about this edit... I think I figured out my problem. I want to register an object by reference, and I want to call the object's constructor with parameters. I figured out however, that this is not possible without having a default constructor aswell! This is a problem for me, since not all objects have default constructors. When I register the object like this:
r = scriptEngine.RegisterObjectType("Object", 0, asOBJ_REF); assert( r >= 0 );
r = scriptEngine.RegisterObjectBehaviour("Object", asBEHAVE_FACTORY, "Object @f(int)", asFUNCTIONPR(asObjectFactoryInt, (int) , Object*),asCALL_CDECL); assert( r >= 0 );
It doesn't work... it gives me the error:
ERROR: In D:/testscript.as: Data type can't be 'Object' at row: 3 col: 9
However after I add this line:
r = scriptEngine.RegisterObjectBehaviour("Object", asBEHAVE_FACTORY, "Object @f()", asFUNCTION(asObjectFactory),asCALL_CDECL); assert( r >= 0 );
It works. This default constructor however, never gets called... but seems to be required to make the one with parameters, work. Is there anything I can do about this? I can't/don't want to facilitate default constructors for all my objects. Thanks! Kind regards, Wracky.
[Edited by - Wracky on September 6, 2009 7:33:09 AM]