• Advertisement
Sign in to follow this  

locate params with default arguments programmatically

This topic is 1584 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement