locate params with default arguments programmatically

Started by
0 comments, last by WitchLord 10 years, 4 months ago

Is it possible to programmatically locate function parameters which have default arguments?

I have added an assert to ensure that C++ has provided the correct number of arguments to the script function, before calling Execute(). However, if you simply call GetParamCount() on the function pointer, that may say you need e.g. 3 params, and C++ only provided 2... but the last param has a default in script and the function would run... but now I'm going to assert.

Thank you for any tips.

Advertisement

The default arguments are only useable by the compiler, which use them to calculate the value that should be passed in the function parameter.

When a calling a script function from the application you must provide all arguments, even if the function has been declared with default arguments. If you wish to allow the application to call a function without supplying values for the default arguments, then you'd need to parse and compile the default argument expression from the function declaration to compute the value and then call SetArg with that.

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