Advertisement

Subtypes not always resolved in generic call

Started by March 09, 2018 02:46 PM
5 comments, last by Miss 6 years, 7 months ago

This is more of a question than a bug, I think, but perhaps there could be some flag to work around this.

If I registered a declaration like this:


MwArray<T> &Remove(int index)

It will be able to resolve the "T" type here if I do something like this:


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

But if my declaration doesn't include my template type "T", it will not be resolvable (the subType's name will simply be "T"):


void Remove(int index)

Is there a way to force it to resolve the subtype correctly in the latter case without needlessly returning itself? (It's a viable workaround for me for now, but would be nice to not have to do this.)

I'll look into this. 

This looks to be something that I hadn't thought of when I decided not to generate unique instances of all template class members when no template subtype is involved. I thought I was being smart to avoid the extra memory consumption, but it looks like I was just being dumb. :)

 

 

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

It depends on whether there's much overhead I guess, I'm fine with an option to disable this optimization manually if it's that much of an overhead.

I'll probably combine this with another memory optimization that I had already planned to implement, where the function signature is shared between asCScriptFunctions. This should compensate the overhead needed to create a unique asCScriptFunction for each template instance just to inform the correct object type.

 

 

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 changed the code in revision 2476 to always generate unique functions for template methods to show the correct object type for template instances.

(I haven't implemented the memory optimization yet though, so if anyone sees an increase in memory consumption this is the reason)

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

That's great, thank you!

This topic is closed to new replies.

Advertisement