🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

CScriptArray accepts object type that is not its own

Started by
1 comment, last by WitchLord 9 years, 3 months ago

I create a CScriptArray in my code like this:


asIObjectType* pType = m_pScriptEngine->GetObjectTypeByName( "string" );
CScriptArray* pArray = CScriptArray::Create( pType );

The array accepts the type without checking if it's actually an array type, or if it even has a valid subtype.

The string stored in the array behaves as it should because i set the contents in C++, and is not directly accessed by script code,

however its destructor is not called, which is to be expected.

Should there be a script exception set and/or null pointer returned if the array type is invalid, or should i simply be more cautious about how i instantiate arrays?

Advertisement

Well, you will always need to be cautious to use the correct object type when creating the array objects.

However, I will definitely add a sanity check on the informed object type, so you will not have to discover the problem the hard way. Thanks for bringing this up. :)

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

I've added an assert in the CScriptArray constructor to verify the object type in revision 2148.

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