зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1271653 - Implement a C++ interface for name/displayName;r=jimb
This commit is contained in:
Родитель
8de72f868e
Коммит
a8745145ea
|
@ -7906,44 +7906,42 @@ DebuggerObject_getCallable(JSContext* cx, unsigned argc, Value* vp)
|
|||
static bool
|
||||
DebuggerObject_getName(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
THIS_DEBUGOBJECT_OWNER_REFERENT(cx, argc, vp, "get name", args, dbg, obj);
|
||||
if (!obj->is<JSFunction>()) {
|
||||
THIS_DEBUGOBJECT(cx, argc, vp, "get name", args, object)
|
||||
|
||||
if (!DebuggerObject::isFunction(cx, object)) {
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
JSString* name = obj->as<JSFunction>().name();
|
||||
if (!name) {
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
RootedValue namev(cx, StringValue(name));
|
||||
if (!dbg->wrapDebuggeeValue(cx, &namev))
|
||||
RootedString result(cx);
|
||||
if (!DebuggerObject::name(cx, object, &result))
|
||||
return false;
|
||||
args.rval().set(namev);
|
||||
|
||||
if (result)
|
||||
args.rval().setString(result);
|
||||
else
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
DebuggerObject_getDisplayName(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
THIS_DEBUGOBJECT_OWNER_REFERENT(cx, argc, vp, "get display name", args, dbg, obj);
|
||||
if (!obj->is<JSFunction>()) {
|
||||
THIS_DEBUGOBJECT(cx, argc, vp, "get displayName", args, object)
|
||||
|
||||
if (!DebuggerObject::isFunction(cx, object)) {
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
JSString* name = obj->as<JSFunction>().displayAtom();
|
||||
if (!name) {
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
RootedValue namev(cx, StringValue(name));
|
||||
if (!dbg->wrapDebuggeeValue(cx, &namev))
|
||||
RootedString result(cx);
|
||||
if (!DebuggerObject::displayName(cx, object, &result))
|
||||
return false;
|
||||
args.rval().set(namev);
|
||||
|
||||
if (result)
|
||||
args.rval().setString(result);
|
||||
else
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -8844,6 +8842,14 @@ DebuggerObject::create(JSContext* cx, HandleObject proto, HandleObject referent,
|
|||
return &object;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
DebuggerObject::isFunction(JSContext* cx, Handle<DebuggerObject*> object)
|
||||
{
|
||||
RootedObject referent(cx, object->referent());
|
||||
|
||||
return referent->is<JSFunction>();
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
DebuggerObject::className(JSContext* cx, Handle<DebuggerObject*> object,
|
||||
MutableHandleString result)
|
||||
|
@ -8864,6 +8870,29 @@ DebuggerObject::className(JSContext* cx, Handle<DebuggerObject*> object,
|
|||
return true;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
DebuggerObject::name(JSContext* cx, Handle<DebuggerObject*> object, MutableHandleString result)
|
||||
{
|
||||
MOZ_ASSERT(DebuggerObject::isFunction(cx, object));
|
||||
|
||||
RootedFunction referent(cx, &object->referent()->as<JSFunction>());
|
||||
|
||||
result.set(referent->name());
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
DebuggerObject::displayName(JSContext* cx, Handle<DebuggerObject*> object,
|
||||
MutableHandleString result)
|
||||
{
|
||||
MOZ_ASSERT(DebuggerObject::isFunction(cx, object));
|
||||
|
||||
RootedFunction referent(cx, &object->referent()->as<JSFunction>());
|
||||
|
||||
result.set(referent->displayAtom());
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
DebuggerObject::isBoundFunction(JSContext* cx, Handle<DebuggerObject*> object)
|
||||
{
|
||||
|
|
|
@ -1051,8 +1051,12 @@ class DebuggerObject : public NativeObject
|
|||
static DebuggerObject* create(JSContext* cx, HandleObject proto, HandleObject obj,
|
||||
HandleNativeObject debugger);
|
||||
|
||||
static bool isFunction(JSContext* cx, Handle<DebuggerObject*> object);
|
||||
static bool className(JSContext* cx, Handle<DebuggerObject*> object,
|
||||
MutableHandleString result);
|
||||
static bool name(JSContext* cx, Handle<DebuggerObject*> object, MutableHandleString result);
|
||||
static bool displayName(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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче