Sign in to follow this  
zexee

How to get the full declaration of a local variable in context

Recommended Posts

Hi, I want to get the full declaration (something like: const namespace::array<object> a;) of a local variable in context.

 

I tried function->GetVarDecl(), but it does not full (no namespace, no <object>). I know namespace can be found in engine->GetObjectTypeById()->GetNamespace(), and const can be found in function->GetVarDecl() but how to get the template subtype?

 

Since the template subtype can also be a template and have const and reference/handle, it seems to be a iterative process to get the full declaration. Is there a simple way to do that?

 

Thanks in advance!

Share this post


Link to post
Share on other sites

I'll need to change asIScriptFunction::GetVarDecl to add an optional argument to include the namespace in the typenames.

 

For now you can use the asIScriptEngine::GetTypeDeclaration method and pass it the typeId of the variable (obtained with asIScriptFunction::GetVar).

 

 

The GetVarDecl and GetTypeDeclaration should give a proper declaration for template types, you shouldn't have to do this by yourself. If that is not happening it must be a bug in the library.

Share this post


Link to post
Share on other sites

That's great! Then I found a bug that GetVarDecl and GetTypeDeclaration does not work on template specializations. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this