Advertisement

AngelScript - No Copy Construction for Script Classes

Started by July 09, 2018 12:58 PM
3 comments, last by WitchLord 6 years, 4 months ago

Hello,
I'm using the AngelScript SDK 2.32.0 that is listed on the AngelScript website as latest (http://www.angelcode.com/angelscript/downloads.html).

I find that script copy constructors mentioned in the docs (http://www.angelcode.com/angelscript/sdk/docs/manual/doc_script_class_desc.html) are not called.

I'm trying to use something like "engine->CreateScriptObjectCopy(m_obj, typeInfo);" to create a copy of script object with a copy constructor, but asSTypeBehaviour::copyconstruct is always null and the process defaults to regular construction and assignment.

Even simple script only example like:


Main()
{
	TestClass arg;
	TestClass result = copyTest(arg);
}
class TestClass
{
	TestClass() {}

	TestClass(const TestClass &in other)
	{
		Print("Hello World!");
	}
}
TestClass copyTest(TestClass a)
{
	return a;
}

Does not call the copy construction even once.

 

Would anyone know if this is a known issue and was already solved in some beta build/commit before I go digging into the script parsing code to try fix it myself?

Thanks

Now it is a known issue. :) I'll have this fixed.

Do you have specific need for this to work? Or are you just worried about the optimization?

 

 

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement

Yes, I was aiming to run some logic on copy. Didn't have one specific thing; wanted some debug output on one class, some c++ calls on another and try cloning object handle data on a third

I've implemented this now so the compiler will properly recognize and use the script class' copy constructor. CreateScriptObjectCopy will also do the same.

You can find the changes in revision 2521.

 

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement