Unable to get subtype ID from asIScriptGeneric in destructor

Started by
5 comments, last by Miss 2 years, 4 months ago

I have an application where I can not change the layout of a generic container, so I can't add an asITypeInfo* to it, which is also why I am using asIScriptGeneric.

In the asBEHAVE_DESTRUCT behavior, I can't get a valid subtype ID. For example, the following code returns the type “T” instead of the actual subtype.

	asIScriptEngine* engine = gen->GetEngine();
	int typeId = gen->GetObjectTypeId();
	asITypeInfo* type = engine->GetTypeInfoById(typeId);
	int subTypeId = type->GetSubTypeId();
	asITypeInfo* subType = engine->GetTypeInfoById(subTypeId);

This works in other calls (eg. opAssign). Not sure about other behaviors.

In the case of asBEHAVE_DESTRUCT, typeId is 0x10000010 which is the container type itself with the subtype “T”, whereas in opAssign, typeId is 0x10000070 which is the specific container type with the proper subtype.

Is this a limitation in the script engine or a bug?

Advertisement

This looks like a gap on the implementation of templates for value types. When the template instance is generated the instance should get its own copy of the destructor behavior with the correct object id.

I will investigate this.

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

Do you know of a possible workaround? This is kind of a blocking issue for me as right now I can't really avoid any resulting memory leakage from the destructor :(

The only work around I can think of right now is to store the object pointer in a map with the type info when the object is constructed.

But I'll try to find some time to investigate this tomorrow. I think the fix is relatively simple.

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 fixed this now in rev 2755.

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

Awesome! Thank you as always! ?

This topic is closed to new replies.

Advertisement