Functions implementing the generic calling conventions are always global functions (or static class methods), that take as parameter a pointer to an asIScriptGeneric interface and returns void.
void MyGenericFunction(asIScriptGeneric *gen) { // Code to extract arguments from the generic // interface and to execute the real function ... }
Functions using the generic calling convention can be registered anywhere the script engine is expecting global functions or class methods (except where explicitly written otherwise).
Writing the functions for the generic calling convention requires extracting each argument from the AngelScript stack, and then manually giving the return value back. For that reason it may be a desired to use the automatic wrapper functions rather than writing the functions yourself.
If the function you're implementing represents a class method, the pointer to the object instance should be obtained with a call to GetObject.
Note that the asIScriptGeneric interface is the owner of any references it returns with these calls, so you should not release these references manually. If you want to store a reference to an object received from the generic interface, you need to call AddRef on that object to avoid invalidating the reference when the function returns.
It is also possible to use the GetAddressOfReturnLocation method to obtain the address of the memory where the return value will be stored. The memory is not initialized, so you should use the placement new operator to initialize this memory with a call to the constructor. This also works for primitive types, which makes this ideal for template implementations, such as that in the automatic wrapper functions.