contents   index   previous   next



The basic idea behind a wrapper table is that it is a list of wrapper functions to be made available to your scripts. However, wrapper tables have additional capabilities as well. You can define entire object classes using these tables.


Here is a sample wrapper table that includes many of the options that can be used.




   SE_NUMLITERAL( UNISTR("Identification"), UNISTR(“1.03”),

                  SE_DONTENUM )

   SE_STRING( UNISTR("IdentString"), UNISTR("Version 1.03b"),

              SE_DONTENUM )


   /* Move into "Clib" */



      /* SE_METHOD is a synonym for SE_FUNCTION */

      SE_FUNCTION( UNISTR("MyFuncCall"), MyFuncCallWrapper,

                   0, 10, SE_SECURE|SE_BYREF, SE_READONLY )


      SE_CLASS( UNISTR("MyDate"), MyDateWrapper, 0,1,


         /* Stock attributes are DontDelete, ReadOnly,

          * and DontEnum



            SE_FUNCTION( UNISTR("valueOf"), MyDateValueOfWrapper,

                         0, 0, SE_SECURE, SE_STOCK_ATTRIBS )






   /* And why not some stuff in "SElib", note that 'INOBJECT'

    * is always relative to the global object



      SE_FUNCTION( UNISTR("Version"), MyVersionWrapper,

                   0,0, SE_SECURE, SE_STOCK_ATTRIBS )




   /* And demonstrate the last two functions. First we make

    * 'MyLib' a copy of 'Clib'. Then we change the attributes

    * on an existing variable.







As you can see, the table is a list of elements where each element is one of a number of macros such as SE_FUNCTION or SE_CLASS. We will list each individual macro and what it does below. Note that the elements are not separated by commas. The whole table is begun with SE_BEGIN_LIB_TABLE macro and ended with the SE_END_LIB_TABLE macro.


First, some overview. Most macros define something and use a name as the first parameter. For instance, the first element defines a number:


SE_NUMLITERAL( UNISTR("Identification"), UNISTR(“1.03”),

               SE_DONTENUM )


The name parameter follows identical rules for all of the different macros. First, when using string literals, encase them in the UNISTR() macro to ensure compatibility with all ScriptEase builds. When the table is added, these definitions in the macro table are created in the global object. Recall, members of the global object are the global variables of the script. This line therefore declares a new global variable named Identification. As the table is parsed, however, certain entries will cause this base object to change from the global object to some other object. This line is such an entry.




First, it too has a name Clib. Like all other names, it follows the same rules, so it refers to the Clib member of the global object. However, the purpose of the line is to make the named member the new base. Therefore, new names declared after this line are no longer relative to the global object, but rather to the Clib member of the global object. A few lines later, the SE_END_OBJECT macro undoes this, reverting back. This scheme allows a more readable table. It is a simple hierarchical scheme that matches well with the way objects and classes are defined.


There are two conveniences implemented. First, if you specify a name preceeded by global., for instance, the global. means that foo is relative to the global variable and the base is ignored for this entry only. Second, you can use object notation such as For instance, instead of writing:





You could instead write:




When using this notation, the base for further statements is not changed. The Clib. part of it applies only to this particular definition. Also, if the object referred to, in this case Clib, does not already exist or is not an object, it is converted to an object.


Choose the notation in a particular instance that is clearer. If you are going to define more than one item in an object, it is clearer to move into that object using SE_INOBJECT while a single item can be clearer to write out a dot-separated name.