beautypg.com

Adobe Extending Flash Professional CS5 User Manual

Page 553

background image

531

EXTENDING FLASH PROFESSIONAL

C-Level Extensibility

Last updated 5/2/2011

/* long JS_GetArrayLength(JSContext *cx, JSObject *obj) */

#define JS_GetArrayLength(c, o) \

(mmEnv.getArrayLength ? (*(mmEnv.getArrayLength))(c, o) : -1)

/* JSBool JS_GetElement(JSContext *cx, JSObject *obj, jsint idx, jsval *vp) */

#define JS_GetElement(c, o, i, v) \

(mmEnv.getElement ? (*(mmEnv.getElement))(c, o, i, v) : JS_FALSE)

/* JSBool JS_SetElement(JSContext *cx, JSObject *obj, jsint idx, jsval *vp) */

#define JS_SetElement(c, o, i, v) \

(mmEnv.setElement ? (*(mmEnv.setElement))(c, o, i, v) : JS_FALSE)

/* JSBool JS_ExecuteScript(JSContext *cx, JSObject *obj, unsigned short *script,

* unsigned int sz, jsval *rval) */

#define JS_ExecuteScript(c, o, s, z, r) \

(mmEnv.executeScript? (*(mmEnv.executeScript))(c, o, s, z, (LPCTSTR)__FILE__, \

__LINE__, r) : JS_FALSE)

/* JSBool JS_ReportError(JSContext *cx, unsigned short *error, unsigned int sz) */

#define JS_ReportError(c, e, s) \

(mmEnv.reportError? (*(mmEnv.reportError))(c, e, s) : JS_FALSE)

/*****************************************************************************

* Private data types, macros, and globals

****************************************************************************/

typedef struct {

JSObject *libObj;

JSBool (*defineFunction)(JSObject *libObj, unsigned short *name, JSNative call,

unsigned int nargs);

unsigned short *(*valueToString)(JSContext *cx, jsval v, unsigned int *pLength);

unsigned char *(*valueToBytes)(JSContext *cx, jsval v, unsigned int *pLength);

JSBool (*valueToInteger)(JSContext *cx, jsval v, long *lp);

JSBool (*valueToDouble)(JSContext *cx, jsval v, double *dp);

JSBool (*valueToBoolean)(JSContext *cx, jsval v, JSBool *bp);

JSBool (*valueToObject)(JSContext *cx, jsval v, JSObject **op);

JSBool (*stringToValue)(JSContext *cx, unsigned short *b, unsigned int sz, jsval *vp);

JSBool (*bytesToValue)(JSContext *cx, unsigned char *b, unsigned int sz, jsval *vp);

JSBool (*doubleToValue)(JSContext *cx, double dv, jsval *vp);

unsigned short *(*objectType)(JSObject *obj);

JSObject *(*newArrayObject)(JSContext *cx, unsigned int length, jsval *vp);

long (*getArrayLength)(JSContext *cx, JSObject *obj);

JSBool (*getElement)(JSContext *cx, JSObject *obj, unsigned int idx,

jsval *vp);

JSBool (*setElement)(JSContext *cx, JSObject *obj, unsigned int idx,

jsval *vp);

JSBool (*executeScript)(JSContext *cx, JSObject *obj, unsigned short *script,

unsigned int sz, unsigned short *file, unsigned int lineNum, jsval *rval);

JSBool (*reportError)(JSContext *cx, unsigned short *error, unsigned int sz);

} MM_Environment;

extern MM_Environment mmEnv;

// Declare the external entry point and linkage

This manual is related to the following products: