Jump to content
  • Advertisement
Sign in to follow this  
iraxef

locate params with default arguments programmatically

This topic is 1768 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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!