Hello all,
First, let me describe the behavior I am trying to implement. I have created a custom wrapper around Angelscript functions in order to make calling them easier. One of my wrapper functions handles the "pointer" case (i.e. the user passes a pointer as a parameter). In this situation, Angelscript can either accept this parameter using SetArgObject or SetArgAddress. What I would like to do is try SetArgObject first, and if that fails, then try SetArgAddress. However, the problem I am facing is that if I pass an invalid parameter to the context, it invalidates the entire context, and prepare must be called again in order to use the context again.
I did some digging into the Angelscript code and noticed that before the context actually sets the argument in SetArgObject, it first checks the function to see that the parameter is an object, and if it's not, it returns and error and sets the error code. It would have been nice, however, to know before calling SetArgObject that the call would be rejected, so that I didn't have to invalidate the context. The problem is it seems the data types used by Angelscript to check if the parameter is an object are hidden from the front-facing API.
What I would ideally like is to do the same check that the context does before setting the object to make sure I am passing in a valid object to the context to avoid destroying the current context state. Does anyone know any way to do this, other than modifying Angelscript?
I hope this hasn't been too hard to follow.
P.S. For Andreas: one solution I have come up with is to expose the asCDataType as asIDataType and allow users to query the data types for function parameters in the public asIScriptFunction interface. I would create a new method on asIScriptFunction, like GetDataTypeForVar(int index) which would return an asIDataType. If you are happy with this solution, I can implement it and send you a patch for your approval.