Sign in to follow this  
sulbon

[Q] Howto register function with variable number of argument ?

Recommended Posts

Hi. Recently I got a problem implementing function with variable number of arguments. For example

[code]
In Angelscript:
int nA, nB;
float fC;
Print( nA );
.....
Print(nB, fC, 'HaHa' );
[/code]
In this case, there should be multiple c++ implementations of function "Print". This is not good.

It seems that the "asCALL_GENERIC" and "asIScriptGeneric" are meant to deal with this problem, but I still have problem with registering the function. RegisterGlobalFunction (or RegisterObjectMethod) still reqires a full list of parameter definitions. In one word, asCALL_GENERIC still does not allow runtime argument identification.

The question is if I want to do this trick, which way should I go?

PS: Sorry for my poor English.

Share this post


Link to post
Share on other sites
I haven't implemented support for functions with variable number of arguments yet, it's on my to-do list though. The only way of doing it right now is to register different versions of the function. They could all point to the same generic function though so the function doesn't actually have to be implemented multiple times.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this