0

在 SpiderMonkey 中,如何从我的 C 代码中获取 JSObject 的属性值?

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
4

1 回答 1

1

JS_GetProperty()

于 2008-09-20T06:07:17.583 回答