如何从C获取JSObject属性的值? [英] How do I get the value of a JSObject property from C?

查看:202
本文介绍了如何从C获取JSObject属性的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

推荐答案

JS_GetProperty()

JS_GetProperty()

这篇关于如何从C获取JSObject属性的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆