有人问如何从 c 获取 JSObject 属性的值。这对我有点帮助。
但是,有谁知道如何从 c 中获取对象的当前 JavaScript 名称?
例子:
var foo={prop:'bar'};
然后在某个地方,例如在 jsapi.cpp 中:
JS_somemethod(JSContext *cx, JSObject *obj){
//how do i get the name 'foo' (or the current alias) here if *obj points to the foo (or whatever alias name) object?
}
谢谢提示和答案!