Jump to content
  • Advertisement
MrFloat

AngelScript - No Copy Construction for Script Classes

This topic is 490 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement

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?

 

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!