ejSetGlobalFunction | GoAhead JavaScript API | GoAhead EMF |
Binds a JavaScript function name to a C function
#include "ej.h" int ejSetGlobalFunction(int eid, char_t *name, int (*fn)(int eid, void *handle, int argc, char_t **argv));
eid | JavaScript interpreter handle |
name | Name of the function to define |
fn | C function to invoke |
The ejSetGlobalFunction procedure defines a JavaScript function. When the function named by name is called, from JavaScript, the function defined by fn in C is called.
When fn is called, the JavaScript parameters are passed in via argc and argv as a list of pointers to arguments. Use ejArgs to parse the arguments array.
Returns 0 if successful. Returns -1 on errors.
int myfunc(int eid, void *handle, int argc, char_t **argv); ejSetGlobalFunction(int eid, "myfunc", myfunc);