Jump to content
  • Advertisement
Sign in to follow this  
Jason Goepel

Calling a Script Function with Variable Parameter Type

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

I have a function registered as:

engine->RegisterGlobalFunction("void MyFunction(const ?&in)", ..., asCALL_GENERIC);

I would like to call that function from within my application.  I would be happy to either call it with a context:

http://www.angelcode.com/angelscript/sdk/docs/manual/doc_call_script_func.html

 

or to call it directly by creating an asIScriptGenric-compatible object.

 

Calling the function with a context seems to work, but I cannot figure out how to establish the argument's type.

 

I am calling:

context->SetArgAddress(0, &myArg);

but then the call to asIScriptGeneric::GetArgTypeId(0, ...) returns asTYPEID_VOID.

 

It looks like there is a secret "typeid" argument at the next stack position, but the following calls do not work:

context->SetArgAddress(0, &myArg);
context->SetArgDWord(1, myTypeId);

because the function only takes one argument.

 

Should there be a "SetArgTypeId" function, a "SetArgQuestion" function, or am I missing something?

 

Thanks.

 

Share this post


Link to post
Share on other sites
Advertisement

I think you just hit a gap in the solution. I haven't thought about how to call a function with the generic calling convention and variable argument types from the application side. To do this the context would need to have a SetArgAndType() so that you can inform both the value and its type at the same time. I'll have to implement that for a future version.

 

If you instead implement your C++ function using native calling convention you can call it directly. The variable arg ? in AngelScript is represented by a pair of arguments in C++, first a void * to the value and then a int for the typeId.

 

You can take a look at the any add-on or dictionary add-ons to see how to implement these type of functions.

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!