contents   index   previous   next



Appendix 2: Using Wrapper.jse

 

The wrapper.jse script is a tool that generates ScriptEase wrapper functions to wrap C functions defined in a C header file. This is a quick and easy way to allow scripts to access your application's capabilities.

 

You need a C header that describes all of the functions you'd like to make wrappers for. You may have multiple headers and use wrapper.jse on each individually. Note that each header can include other headers, and those will not be wrapped. For instance, you may include windows.h to get needed defines, and wrapper.jse won't try to write wrappers for lots of Windows functions.

 

If your application relies on any #defines to properly parse its headers, you must provide a file with those defines in it and pass that filename as a parameter. Here is an example file of definitions you might need:

 

// mydefines.h:

#define WIN32 1

#define MY_APP_THINGEE 1

 

to tell wrapper.jse to use it, add the parameter

 

-defines mydefines.h

 

In addition, you need to pass the directories that contain the include files such as

 

-path c:\vc98\include -path c:\myapp\include

 

The only required parameter is your header file to translate. An example call would be:

 

secon32 wrapper.jse -defines mydefs.h -path c:\include example.h

 

The output for this example is the file example_wrappers.c, which you need to add to your application. Finally, you need to add the produced wrappers into your running context. You do this at the same time you add other wrapper libraries using seAddLibTable. Typically this is done in your sePrepareContext callback described in the The seContextParams Structure. See the chapter on "Wrapper functions" for more information on wrapper functions and wrapper libraries. wrapper.jse generates a function for you to call at this point that adds its definitions. First, make sure to tell the compiler about the function by adding at the top of the file:

 

extern void example_add_wrappers(secontext se);

 

and add those wrapper library by calling:

 

example_add_wrappers(se);

 

Note that the name of the function to call and the .c file that implements it is dependent on the name of the header file it was produced from. In this case, example.h produces example_wrappers.c and example_add_wrappers().