Advertisement

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

Started by October 19, 2013 05:17 PM
4 comments, last by zexee 11 years, 1 month ago

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!

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.

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

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

I've fixed the bug in revision 1749.

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

I've added the optional argument includeNamespace to the GetVarDecl method in revision 1751.

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

Thanks!

This topic is closed to new replies.

Advertisement