Advertisement

Register Parameter Names

Started by September 17, 2013 07:08 PM
0 comments, last by WitchLord 11 years, 2 months ago

I'm am writing an AngelScript Intelli-sense for my application, and it would be really nice if I could set a flag in the engine to have the parameters of functions and methods be remembered and returned with the asIScriptFunction::GetDeclaration function. So, if I call:


engine->RegisterObjectMethod("Matrix", "void SetSize(int nRows, int nCols)",
    asMETHODPR(Matrix, SetSize, (int,int), void), asCALL_THISCALL);

Then making the following call on a pointer to that function:


func->GetDeclaration(true,false);

would return the following string:


"void Matrix::SetSize(int nRows, int nCols)"

Anyway, that would be very convenient for me. I think the only way for me to presently get this functionality would be to save the declaration string I use in the function's UserData and access it instead of calling GetDeclaration, correct?

Thanks!

Yes, AngelScript doesn't store the name of the parameters for registered functions as it is not something that is needed by the engine.

You can use the user data in the function object to store the parameter names if you wish.

Example:

 
const char *decl = "void SetSize(int nRows, int nCols)";
r = engine->RegisterObjectMethod("Matrix", decl,
    asMETHODPR(Matrix, SetSize, (int,int), void), asCALL_THISCALL);
if( r > 0 )
{
   asIScriptFunction *func = engine->GetFunctionById(r);
   func->SetUserData(decl);
}

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

This topic is closed to new replies.

Advertisement