beautypg.com

Jsbool js_valuetoboolean(), Jsbool js_valuetoobject(), Js_valuetoucstring() – Adobe Extending Dreamweaver CS4 User Manual

Page 358

background image

352

EXTENDING DREAMWEAVER CS4

C-level extensibility

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

The cx argument is the opaque

JSContext

pointer that passes to the JavaScript function.

The v argument is the

JSVal

structure from which the Boolean value is to be extracted.

The bp argument is a pointer to a

JSBool

Boolean value. This function stores the converted value in *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

The cx argument is the opaque

JSContext

pointer that passes to the JavaScript function.

The v argument is the

JSVal

structure from which the object is to be extracted.

The op argument is a pointer to a

JSObject

pointer. This function stores the converted value in *op.

Returns
A Boolean value:

JS_TRUE

indicates success;

JS_FALSE

indicates failure.

JS_ValueToUCString()

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. It can corrupt the data structures of the JavaScript interpreter. To
change the string, copy the characters into another buffer and create a JavaScript string.

Arguments
JSContext

*cx

, JSVal

v

, unsigned int

*pLength

The

*cx

argument is the opaque JSContext pointer that passes to the JavaScript function.

The

v

argument is the JSVal structure from which Dreamweaver extracts the string.

This manual is related to the following products: