Advertisement

struggling to get TypeInfo from inside a template member function

Started by January 29, 2023 05:01 PM
2 comments, last by Dragonstorm97 1 year, 10 months ago

Hi all ?

I'm wrapping a class that I cannot alter (Unreal Engine's FScriptArray, as TArray<T>) and need a way to get the typeInfo in method calls.

For TArrays created in script, the constructor I registered caches the TypeInfo in a map from FScriptArray* to TypeInfo*. This works fine as I can just query this map for the info I need in the member calls.

The issue is for FScriptArrays that are created in the application and passed to script. The constructor isn't called on them, so I need another way to get the TypeInfo.

Ideally, I could store what I need in some user data from the template callback, but I need a way to access that user data from member functions.

Does anyone have an idea or tips for this?

You can use asGetActiveContext()->GetSystemFunction()->GetObjectType().

Alternatively if you use the generic calling convention to wrap the class method, you can use the asIScriptGeneric::GetFunction()->GetObjectType().

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

@WitchLord Thanks!
I kept playing around and ended up with exactly that ?

I was going to as if I could rely on the systemfunction for it;

it would be nice if the documentation mentioned how to get the current function and the difference between ctx→GetFunction() vs ctx→GetSystemFunction().

I wanted to avoid the generic calling convention for this one, and it's pefrect.

This topic is closed to new replies.

Advertisement