Download The Ch Language Environment SDK User's Guide
Transcript
Chapter A: Functions for Dynamically Loaded Library — <ch.h> Ch CallFuncByNameVar Ch CallFuncByNameVar Synopsis #include <ch.h> int Ch CallFuncByNameVar(ChInterp t interp, const char *name, void *retval, void *arglist); Purpose Call a Ch function by its name from the C address space. Return Value This function returns CH OK on success, CH ERROR on failure, CH ABORT when Ch Abort() in Embedded Ch was called. Parameters interp A Ch interpreter. name The name of the called function. retval The address to store the return value of the called function. arglist The argument list for the function. Description The function Ch CallFuncByNameVar() calls a Ch function by its name from the C address space. The function name can be a function located in one of function files specified by the function file path fpath. For a generic function, its regular function version with a function prototype will be used. For example, for function sin(), the regular function double sin(double); will be used if sin is the function name for Ch CallFuncByNameVar(). The return value of the called function in the Ch space is passed back by argument retval. The argument retval contains the address to store the returned value of the called function. In case that the function returns a computational array, it contains the address to store the elements of the returned array. The arguments of the called function are passed in the fourth argument arglis. The argument arglis is built dynamically using functions Ch VarArgsAddArg(), Ch VarArgsAddArgExpr(), and Ch VarArgsCreate(). Later, it shall be deleted by function Ch VarArgsDelete(). Example See examples in reference for Ch VarArgsAddArg() and Ch VarArgsAddArgExpr(). See Also Ch CallFuncByAddr(), Ch CallFuncByAddrv(), Ch CallFuncByName(), Ch CallFuncByNamev(), Ch GlobalSymbolAddrByName(), Ch VarArgsAddArg(), Ch VarArgsAddArgExpr(), Ch VarArgsCreate(), Ch VarArgsDelete(). 294