Jump to content
  • Advertisement
Sign in to follow this  
dxj19831029

Function call with arguements

This topic is 3629 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

Currently, when you want to call a function with arguments, you need to do following steps ( if its not correct, can you point me out): * get ID of the method or function * push all its arguements one by one by set SetObject or similar methods. * call execute functions * get the return value. GetReturnByte or similar methods to return the result. can we use ... inside of stdarg.h, to write a function, inside of script, it will get the function declearation and push them on the stack, or do watever script needs to do. My example: define an interface int callFunction(char* functionName ...); The rest of the function should contains: the return Value, and arguments. when we call function bool printf(const string &in); we can do this: engine->callFunction("printf", returnValue, string("how are you")); Is there any technical concern to do this way? Cheers

Share this post


Link to post
Share on other sites
Advertisement
Basically, this can't be done with variadic functions. At least not the way you seem to want to use it. As soon as you try passing a class object to a variadic function, all hell breaks loose. Best case scenario generally involves memory leaks. I've had some success with using boost preprocessor and creating template functions to do this, and C++0x vararg templates can probably handle it more elegantly when the compiler support for it finally becomes widespread.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!