Advertisement

There is no copy operator for this type available

Started by June 02, 2010 10:54 AM
1 comment, last by speps 14 years, 6 months ago
Hi,

I have a problem with a custom registered type :
Level (7, 2) : INFO : Compiling void start()Level (9, 9) : ERR  : There is no copy operator for this type available.


Here is my script :
	PhysicsObject@ heart = null;		void start()	{		heart = Level.getObject("i2");	}


Here is the registration of the types in my C++ application :

    // Level    r = engine->RegisterObjectType("LevelType", 0, asOBJ_REF | asOBJ_NOHANDLE); assert(r >= 0);    r = engine->RegisterObjectMethod("LevelType", "PhysicsObject@ getObject(const string ∈)", asMETHOD(Level, getObject), asCALL_THISCALL); assert(r >= 0);    // Singleton    Script::engine()->RegisterGlobalFunction("LevelType& get_Level()", asFUNCTION(Level::instance), asCALL_CDECL);


    // PhysicsObject    r = engine->RegisterObjectType("PhysicsObject", 0, asOBJ_REF); assert(r >= 0);    r = engine->RegisterObjectBehaviour("PhysicsObject", asBEHAVE_ADDREF, "void f()", asMETHOD(PhysicsObject, addRef), asCALL_THISCALL); assert(r >= 0);    r = engine->RegisterObjectBehaviour("PhysicsObject", asBEHAVE_RELEASE, "void f()", asMETHOD(PhysicsObject, release), asCALL_THISCALL); assert(r >= 0);    // ... Properties


I call addRef in getObject before returning the PhysicsObject pointer.

I don't know why it does that because I thought handles were references to objects, why do I need to a copy operator to copy the handle?

Thanks, Remi Gillig.
If you're working with a handle and want to modify the handle itself you need to prefix it with @ to denote the handle rather than whatever the handle is currently referencing. An example from the object handle manual page is:
  object obj;  object@ obj_h;  @obj_h = @obj;
Advertisement
Oh I see now, thanks a lot!

The documentation is neat but could have more small titles or highlight some text for important information or a page frequent errors.

This topic is closed to new replies.

Advertisement