THE FUNCTION HEADER
There are two methods used to define wrapper functions in Java, the inner class method and the reflection method. The above example uses the inner class method. The print method in the example creates a new inner class that implements the SEWrapper interface. The SEWrapper interface defines a single public method called wrapperFunction, which is where the code for your wrapper function is placed. The wrapperFunction method takes two parameters, the scripting context and the number of arguments passed to the wrapper function.
The reflection method is a little more straight-forward. You simply define a public method which has the same signature as the wraperFunction method of the SEWrapper interface. For example, we could have defined the above print wrapper function like so:
public void print(SEContext se, int argc)
{
}
Wrapper functions defined using the inner class method as typically faster than those defined using the reflection method, but they also tend to take up more memory. Regardless of how it is defined, a wrapper function returns a void result because it uses the ScriptEase API functions to indicate its return value, which will of course be some ScriptEase value. Therefore, the Java return value is not used for a wrapper function.
Wrapper functions are usually called during an seEval ScriptEase API function call. seEval evaluates a script, and if that script invokes any of your functions that are implemented via a wrapper function, that wrapper function will be called back by ScriptEase. Wrapper functions receives two parameters. The first is the SEContext that is doing the callback. A wrapper function can be added to several contexts and it needs to know which one is doing the callback. You should use this provided context in any calls to ScriptEase API functions inside your wrapper function. You can compare the returned reference against any you might have to determine which context is being called back, but it is frowned upon. It is better to store any needed data along with each context using the SE.SERVICES object and retrieve it in your wrapper function. The second argument is simply a numeric count of the number of ScriptEase parameters passed to your function. ScriptEase wrapper functions can take varying number of arguments depending on how you define them as we will see later. If your wrapper function takes a fixed number of arguments, you can ignore this parameter.