How do I get the value of a JSObject property from

2019-06-12 16:50发布

In SpiderMonkey, how do I get the value of a property of a JSObject from within my C code?

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

1条回答
太酷不给撩
2楼-- · 2019-06-12 17:26

JS_GetProperty()

查看更多
登录 后发表回答