【问题标题】:How do I get the value of a JSObject property from C?如何从 C 中获取 JSObject 属性的值?
【发布时间】:2010-09-11 13:28:45
【问题描述】:

在 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

【问题讨论】:

    标签: javascript spidermonkey accessor


    【解决方案1】:

    JS_GetProperty()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-21
      • 1970-01-01
      • 2015-12-03
      • 2011-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-17
      相关资源
      最近更新 更多