< Day Day Up > |
The C-level extensibility API consists of the following functions: typedef JSBool (*JSNative)(JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval)Description This function signature describes C-level implementations of JavaScript functions in the following situations:
The function returns JS_TRUE if successful; JS_FALSE otherwise. If the function returns JS_FALSE, the current script stops executing and an error message appears. JSBool JS_DefineFunction()Description This function registers a C-level function with the JavaScript interpreter in Dreamweaver. After the JS_DefineFunction() function registers the C-level function that you specify in the call argument, you can invoke it in a JavaScript script by referring to it with the name that you specify in the name argument. The name is case-sensitive. Typically, this function is called from the MM_Init() function, which Dreamweaver calls during startup. Arguments char *name, JSNative call, unsigned int nargs
Returns A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure. char *JS_ValueToString()Description This function extracts a function argument from a jsval structure, converts it to a string, if possible, and passes the converted value back to the caller. NOTE Do not modify the returned buffer pointer or you might corrupt the data structures of the JavaScript interpreter. To change the string, you must copy the characters into another buffer and create a new JavaScript string. Arguments JSContext *cx, jsval v, unsigned int *pLength
Returns A pointer that points to a null-terminated string if successful or to a null value on failure. The calling routine must not free this string when it finishes. JSBool JS_ValueToInteger()Description This function extracts a function argument from a jsval structure, converts it to an integer (if possible), and passes the converted value back to the caller. Arguments JSContext *cx, jsval v, long *lp
Returns A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure. JSBool JS_ValueToDouble()Description This function extracts a function argument from a jsval structure, converts it to a double (if possible), and passes the converted value back to the caller. Arguments JSContext *cx, jsval v, double *dp
Returns A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure. JSBool JS_ValueToBoolean()Description This function extracts a function argument from a jsval structure, converts it to a Boolean value (if possible), and passes the converted value back to the caller. Arguments JSContext *cx, jsval v, JSBool *bp
Returns A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure. JSBool JS_ValueToObject()Description This function extracts a function argument from a jsval structure, converts it to an object (if possible), and passes the converted value back to the caller. If the object is an array, use JS_GetArrayLength() and JS_GetElement() to read its contents. Arguments JSContext *cx, jsval v, JSObject **op
Returns A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure. JSBool JS_StringToValue()Description This function stores a string return value in a jsval structure. It allocates a new JavaScript string object. Arguments JSContext *cx, char *bytes, size_t sz, jsval *vp
Returns A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure. JSBool JS_DoubleToValue()Description This function stores a floating-point number return value in a jsval structure. Arguments JSContext *cx, double dv, jsval *vp
Returns A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure. JSVal JS_BooleanToValue()Description This function stores a Boolean return value in a jsval structure. Arguments JSBool bv
Returns A JSVal structure that contains the Boolean value that passes to the function as an argument. JSVal JS_IntegerToValue()Description This function converts a long integer value to JSVal structure. Arguments lv
Returns A JSVal structure that contains the integer that was passed to the function as an argument. JSVal JS_ObjectToValue()Description This function stores an object return value in a JSVal. Use JS_ NewArrayObject() to create an array object; use JS_SetElement() to define its contents. Arguments JSObject *obj
Returns A JSVal structure that contains the object that you passed to the function as an argument. char *JS_ObjectType()Description Given an object reference, the JS_ObjectType() function returns the class name of the object. For example, if the object is a DOM object, the function returns "Document". If the object is a node in the document, the function returns "Element". For an array object, the function returns "Array". NOTE Do not modify the returned buffer pointer or you might corrupt the data structures of the JavaScript interpreter. Arguments JSObject *obj
Returns A pointer to a null-terminated string. The caller should not free this string when it finishes. JSObject *JS_NewArrayObject()Description This function creates a new object that contains an array of JSVals. Arguments JSContext *cx, unsigned int length, jsval *v
Returns A pointer to a new array object or the value null upon failure. long JS_GetArrayLength()Description Given a pointer to an array object, this function gets the number of elements in the array. Arguments JSContext *cx, JSObject *obj
Returns The number of elements in the array or -1 upon failure. JSBool JS_GetElement()Description This function reads a single element of an array object. Arguments JSContext *cx, JSObject *obj, unsigned int index, jsval *v
Returns A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure. JSBool JS_SetElement()Description This function writes a single element of an array object. Arguments JSContext *cx, JSObject *obj, unsigned int index, jsval *v
Returns A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure. JSBool JS_ExecuteScript()Description This function compiles and executes a JavaScript string. If the script generates a return value, it returns in *rval. Arguments JSContext *cx, JSObject *obj, char *script, unsigned int sz, jsval *rval
Returns A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure. JSBool JS_ReportError()Description This function describes the reason for a script error. Call this function before returning the value JS_FALSE for a script error to give the user information about why the script failed (for example, "wrong number of arguments"). Arguments JSContext *cx, char *error, size_t sz
Returns A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure. |
< Day Day Up > |