Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

Calling a Script Function with Variable Parameter Type


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 Jason Goepel   Members   -  Reputation: 443

Like
0Likes
Like

Posted 14 October 2013 - 08:05 AM

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.

 



Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3454

Like
0Likes
Like

Posted 14 October 2013 - 09:12 AM

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.


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