зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1271653 - Implement a C++ interface for proto and className;r=jimb
This commit is contained in:
Родитель
a1804c7b1e
Коммит
8de72f868e
|
@ -1118,6 +1118,8 @@ Debugger::wrapDebuggeeValue(JSContext* cx, MutableHandleValue vp)
|
|||
bool
|
||||
Debugger::wrapDebuggeeObject(JSContext* cx, MutableHandleObject obj)
|
||||
{
|
||||
MOZ_ASSERT(obj);
|
||||
|
||||
if (obj->is<JSFunction>()) {
|
||||
MOZ_ASSERT(!IsInternalFunctionObject(*obj));
|
||||
RootedFunction fun(cx, &obj->as<JSFunction>());
|
||||
|
@ -7870,33 +7872,26 @@ DebuggerObject_construct(JSContext* cx, unsigned argc, Value* vp)
|
|||
static bool
|
||||
DebuggerObject_getProto(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
THIS_DEBUGOBJECT_OWNER_REFERENT(cx, argc, vp, "get proto", args, dbg, refobj);
|
||||
RootedObject proto(cx);
|
||||
{
|
||||
AutoCompartment ac(cx, refobj);
|
||||
if (!GetPrototype(cx, refobj, &proto))
|
||||
return false;
|
||||
}
|
||||
RootedValue protov(cx, ObjectOrNullValue(proto));
|
||||
if (!dbg->wrapDebuggeeValue(cx, &protov))
|
||||
THIS_DEBUGOBJECT(cx, argc, vp, "get proto", args, object)
|
||||
|
||||
RootedObject result(cx);
|
||||
if (!DebuggerObject::getPrototypeOf(cx, object, &result))
|
||||
return false;
|
||||
args.rval().set(protov);
|
||||
|
||||
args.rval().setObjectOrNull(result);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
DebuggerObject_getClass(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
THIS_DEBUGOBJECT_REFERENT(cx, argc, vp, "get class", args, refobj);
|
||||
const char* className;
|
||||
{
|
||||
AutoCompartment ac(cx, refobj);
|
||||
className = GetObjectClassName(cx, refobj);
|
||||
}
|
||||
JSAtom* str = Atomize(cx, className, strlen(className));
|
||||
if (!str)
|
||||
THIS_DEBUGOBJECT(cx, argc, vp, "get class", args, object)
|
||||
|
||||
RootedString result(cx);
|
||||
if (!DebuggerObject::className(cx, object, &result))
|
||||
return false;
|
||||
args.rval().setString(str);
|
||||
|
||||
args.rval().setString(result);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -8849,6 +8844,26 @@ DebuggerObject::create(JSContext* cx, HandleObject proto, HandleObject referent,
|
|||
return &object;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
DebuggerObject::className(JSContext* cx, Handle<DebuggerObject*> object,
|
||||
MutableHandleString result)
|
||||
{
|
||||
RootedObject referent(cx, object->referent());
|
||||
|
||||
const char* className;
|
||||
{
|
||||
AutoCompartment ac(cx, referent);
|
||||
className = GetObjectClassName(cx, referent);
|
||||
}
|
||||
|
||||
JSAtom* str = Atomize(cx, className, strlen(className));
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
result.set(str);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
DebuggerObject::isBoundFunction(JSContext* cx, Handle<DebuggerObject*> object)
|
||||
{
|
||||
|
@ -8939,6 +8954,24 @@ DebuggerObject::isFrozen(JSContext* cx, Handle<DebuggerObject*> object, bool& re
|
|||
return TestIntegrityLevel(cx, referent, IntegrityLevel::Frozen, &result);
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
DebuggerObject::getPrototypeOf(JSContext* cx, Handle<DebuggerObject*> object,
|
||||
MutableHandleObject result)
|
||||
{
|
||||
RootedObject referent(cx, object->referent());
|
||||
Debugger* dbg = object->owner();
|
||||
|
||||
RootedObject proto(cx);
|
||||
{
|
||||
AutoCompartment ac(cx, referent);
|
||||
if (!GetPrototype(cx, referent, &proto))
|
||||
return false;
|
||||
}
|
||||
|
||||
result.set(proto);
|
||||
return !result || dbg->wrapDebuggeeObject(cx, result);
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
DebuggerObject::getOwnPropertyNames(JSContext* cx, Handle<DebuggerObject*> object,
|
||||
MutableHandle<IdVector> result)
|
||||
|
|
|
@ -1051,6 +1051,8 @@ class DebuggerObject : public NativeObject
|
|||
static DebuggerObject* create(JSContext* cx, HandleObject proto, HandleObject obj,
|
||||
HandleNativeObject debugger);
|
||||
|
||||
static bool className(JSContext* cx, Handle<DebuggerObject*> object,
|
||||
MutableHandleString result);
|
||||
static bool isBoundFunction(JSContext* cx, Handle<DebuggerObject*> object);
|
||||
static bool boundTargetFunction(JSContext* cx, Handle<DebuggerObject*> object,
|
||||
MutableHandleObject result);
|
||||
|
@ -1062,6 +1064,8 @@ class DebuggerObject : public NativeObject
|
|||
static bool isExtensible(JSContext* cx, Handle<DebuggerObject*> object, bool& result);
|
||||
static bool isSealed(JSContext* cx, Handle<DebuggerObject*> object, bool& result);
|
||||
static bool isFrozen(JSContext* cx, Handle<DebuggerObject*> object, bool& result);
|
||||
static bool getPrototypeOf(JSContext* cx, Handle<DebuggerObject*> object,
|
||||
MutableHandleObject result);
|
||||
static bool getOwnPropertyNames(JSContext* cx, Handle<DebuggerObject*> object,
|
||||
MutableHandle<IdVector> result);
|
||||
static bool getOwnPropertySymbols(JSContext* cx, Handle<DebuggerObject*> object,
|
||||
|
|
Загрузка…
Ссылка в новой задаче