beautypg.com

Jsval js_objecttovalue(), Char *js_objecttype(), Jsobject *js_newarrayobject() – Adobe Extending Dreamweaver CS4 User Manual

Page 361

background image

355

EXTENDING DREAMWEAVER CS4

C-level extensibility

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

The obj argument is a pointer to the

JSObject

object that you want to convert to a

JSVal

structure.

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

Typically, this argument is passed in and converted using the

JS_ValueToObject()

function.

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

The cx argument is the opaque

JSContext

pointer that passes to the JavaScript function.

The length argument is the number of elements that the array can hold.

The v argument is an optional pointer to the

JSVals

to be stored in the array. If the return value is not

null

, v is

an array that contains length elements. If the return value is

null

, the initial content of the array object is undefined

and can be set using the

JS_SetElement()

function.

Returns
A pointer to a new array object or the value

null

upon failure.

This manual is related to the following products: