2008-09-20 11 views
0

Dans SpiderMonkey, comment obtenir la valeur d'une propriété d'un JSObject à partir de mon code C?Comment obtenir la valeur d'une propriété JSObject à partir de C?

static JSBool 
JSD_getter(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) 
{ 
    jsval js_id; 
    JS_GetProperty(cx, obj, "id", &js_id); // js_id has JavaScript type 
    int c_id; 
    JS_ValueToInt32(cx, js_id, &c_id); // Now, c_id contains the actual value 
}          // of obj.id, as a C native type 

Répondre

1

JS_GetProperty()

Questions connexes