كيف يمكنني الحصول على قيمة خاصية JSObject من لغة C؟

StackOverflow https://stackoverflow.com/questions/107317

سؤال

في SpiderMonkey، كيف يمكنني الحصول على قيمة خاصية JSObject من داخل كود 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
هل كانت مفيدة؟

المحلول

JS_GetProperty()

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top