Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


- - - - -

locate params with default arguments programmatically


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 iraxef   Members   -  Reputation: 399

Like
0Likes
Like

Posted 19 December 2013 - 12:04 PM

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.



Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3453

Like
0Likes
Like

Posted 19 December 2013 - 12:57 PM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS