contents   index   previous   next



WRAPPER TABLE METHODS AND OBJECT

 

What follows is a description of each of the methods and objects you can use in a wrapper table and what each does.

 

syntax:

SE.NUMLITERAL(name,string,vflags)

description:

Create a variable in the current base object with the given name and the given value. The string passed must be parsable as a floating point number. The flags of the variable are set to the vflags value. The allowable flags are:

SE.DEFAULT No special attributes

SE.READONLY The member is read-only and cannot be modified.

SE.DONTENUM The member should not be enumerated when a script uses for..in.

SE.DONTDELETE The member cannot be deleted using the JavaScript delete operator.

 

syntax:

SE.INTEGER(name,number,vflags)

description:

Create a variable in the current base object with the given name and the given value. Identical to SE.NUMLITERAL, except an integer value is given.

 

syntax:

SE.STRING(name,string,vflags)

description:

Very similar to SE.NUMLITERAL, except the variable is set to a string value.

 

syntax:

SE.INOBJECT(name,vflags)

description:

The given name is treated as an object, and if the name is not currently an object, it is turned into one. The object has its flags set to the vflags value. Finally, that object is the new base for all names until an SE.END_OBJECT is found.

 

syntax:

SE.END_OBJECT

description:

Undoes the SE.INOBJECT above so all names are derived from the base before the SE.INOBJECT took effect.

 

syntax:

SE.FUNCTION(name,func,min_args,max_args,

            func_flags,var_flags)

description:

Declares a wrapper function. The parameters are the function's name, the function itself (a wrapper function), the minimum and maximum number of arguments, the function flags, and the variable flags.

The overloaded second parameter (the wrapper function) differs depending on how the wrapper function is actually defined. If the wrapper function was defined using the inner class method, then the second parameter will be the class that implements the SEWrapper interface. If the wrapper function was defined using the reflection method, the second parameter is a String representing the name of the method.

Using the example print wrapper function from above, this is how we would add the function to the library table:

/* Inner class method */

SE.FUNCTION(“myPrint”, print(), 1, 1, SE.DEFAULT),

 

/* Reflection method */

SE.FUNCTION(“myPrint”, “print”,1,1,SE.DEFAULT),

 

The maximum number of arguments can be -1 to specify no limit.

The function flags are one or more from the following:

SE.DEFAULT No special flags.

SE.DYNAUNDEF The object's dynamic callbacks are only called if the object does not already have the member in its internal storage. See Chapter VIII for a complete description of callbacks and this flag.

SE.BYREF Parameters passed to this function are passed by reference, so that any changes to them are reflected in the variables passed as the parameters.

SE.SECURE The function is secure. Only mark a wrapper function as secure if it can not perform any dangerous task. When in doubt, do not make it secure. The general rule is that any access to the system, such as reading a file or calling a system function, makes a function insecure.

SE.KEEP_GLOBAL Normally when a function is executed, the global object in effect when the function was created is used as the global object when the function is executed. With this flag, the current global object is retained whenever the function is executed.

 

syntax:

SE.METHOD(name,func,min_args,max_args,

          func_flags,var_flags)

description:

This is a synonym for SE.FUNCTION.

 

syntax:

SE.CLASS(name,func,min_args,max_args,

         func_flags,var_flags)

description:

This works similarly to SE.FUNCTION in that it adds the given entry as a function. However, as a class, such a function is expected to be used as a constructor. Several additional items are therefore created to facilitate this. First, the function is given a prototype which has the attributes SE.STOCK_ATTRIBS. Second, the prototype is given an _class member with a name equal to the name of the class. Finally, the prototype also gets a constructor member which points back to the class. All of these items are standard for ECMA classes.

After this table entry is finished, the base is moved to the class object so you can add members or use SE.PROTO to add prototype members. This works in the same way SE.INOBJECT works. Use SE.END_CLASS to move back out of the object.

 

syntax:

SE_END_CLASS

description:

Changes the base to its value before the SE.CLASS entry.

 

syntax:

SE.PROTO

description:

Changes the base to the prototype of the current object. This is used to define the methods available to members of the current class. It is identical to:

SE.INOBJECT(“prototype”)

 

syntax:

SE.END_PROTO

description:

Changes the base to its value before the SE.PROTO entry.

 

syntax:

SE.COPY(name,source(String),var_flags)

description:

Acts as an assignment, copying the source value to the given name. It sets the destination flags as well.

 

syntax:

SE.ATTRIB(name,var_flags)

description:

Sets the variable flags on a given name, changing nothing else about it.

 


SELIBRARY INTERFACE