Bug 1393790 part 1 - Remove JS_STUBGETTER and JS_STUBSETTER. r=jorendorff

This commit is contained in:
Jan de Mooij 2017-08-28 10:39:57 +02:00
parent 69d41d5dfd
commit 3e1a11f41d
17 changed files with 26 additions and 65 deletions

View file

@ -695,8 +695,7 @@ nsDOMClassInfo::Resolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
// window.classname, just fall through and let the JS engine
// return the Object constructor.
if (!::JS_DefinePropertyById(cx, obj, id, desc.value(),
JSPROP_ENUMERATE,
JS_STUBGETTER, JS_STUBSETTER)) {
JSPROP_ENUMERATE)) {
return NS_ERROR_UNEXPECTED;
}
@ -944,8 +943,7 @@ DefineInterfaceConstants(JSContext *cx, JS::Handle<JSObject*> obj, const nsIID *
NS_ENSURE_TRUE(NS_SUCCEEDED(rv), rv);
if (!::JS_DefineProperty(cx, obj, name.get(), v,
JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT,
JS_STUBGETTER, JS_STUBSETTER)) {
JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT)) {
return NS_ERROR_UNEXPECTED;
}
}
@ -1475,8 +1473,7 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
// Per ECMA, the prototype property is {DontEnum, DontDelete, ReadOnly}
if (!JS_WrapValue(cx, &v) ||
!JS_DefineProperty(cx, class_obj, "prototype", v,
JSPROP_PERMANENT | JSPROP_READONLY,
JS_STUBGETTER, JS_STUBSETTER)) {
JSPROP_PERMANENT | JSPROP_READONLY)) {
return NS_ERROR_UNEXPECTED;
}
@ -1757,8 +1754,7 @@ LookupComponentsShim(JSContext *cx, JS::Handle<JSObject*> global,
NS_ENSURE_TRUE(interfaces, NS_ERROR_OUT_OF_MEMORY);
bool ok =
JS_DefineProperty(cx, components, "interfaces", interfaces,
JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY,
JS_STUBGETTER, JS_STUBSETTER);
JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
// Define a bunch of shims from the Ci.nsIDOMFoo to window.Foo for DOM
@ -1780,8 +1776,7 @@ LookupComponentsShim(JSContext *cx, JS::Handle<JSObject*> global,
// Define the shim on the interfaces object.
ok = JS_DefineProperty(cx, interfaces, geckoName, v,
JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY,
JS_STUBGETTER, JS_STUBSETTER);
JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY);
NS_ENSURE_TRUE(ok, NS_ERROR_OUT_OF_MEMORY);
}

View file

@ -14686,8 +14686,7 @@ nsGlobalWindow::RedefineProperty(JSContext* aCx, const char* aPropName,
}
if (!JS_WrapObject(aCx, &thisObj) ||
!JS_DefineProperty(aCx, thisObj, aPropName, aValue, JSPROP_ENUMERATE,
JS_STUBGETTER, JS_STUBSETTER)) {
!JS_DefineProperty(aCx, thisObj, aPropName, aValue, JSPROP_ENUMERATE)) {
aError.Throw(NS_ERROR_FAILURE);
}
}

View file

@ -837,8 +837,7 @@ CreateInterfaceObject(JSContext* cx, JS::Handle<JSObject*> global,
if (!namedConstructor ||
!JS_DefineProperty(cx, namedConstructor, "prototype",
proto,
JSPROP_PERMANENT | JSPROP_READONLY,
JS_STUBGETTER, JS_STUBSETTER) ||
JSPROP_PERMANENT | JSPROP_READONLY) ||
(defineOnGlobal &&
!DefineConstructor(cx, global, namedConstructors->mName,
namedConstructor))) {

View file

@ -905,8 +905,7 @@ GetOrCreateClassObjectMap(JSContext *cx, JS::Handle<JSObject*> scope, const char
// It's not there. Create and define it.
JS::Rooted<JSObject*> map(cx, JS::NewWeakMapObject(cx));
if (!map || !JS_DefineProperty(cx, scope, mapName, map,
JSPROP_PERMANENT | JSPROP_READONLY,
JS_STUBGETTER, JS_STUBSETTER))
JSPROP_PERMANENT | JSPROP_READONLY))
{
return nullptr;
}
@ -1067,8 +1066,7 @@ nsXBLBinding::DoInitJSClass(JSContext *cx,
JSAutoCompartment ac3(cx, holder);
if (!JS_WrapObject(cx, &proto) ||
!JS_DefineUCProperty(cx, holder, aClassName.get(), -1, proto,
JSPROP_READONLY | JSPROP_PERMANENT,
JS_STUBGETTER, JS_STUBSETTER))
JSPROP_READONLY | JSPROP_PERMANENT))
{
return NS_ERROR_OUT_OF_MEMORY;
}

View file

@ -120,8 +120,7 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding,
// Define it as a property on the scopeObject, using the same name used on
// the content side.
bool ok = JS_DefineUCProperty(cx, scopeObject, className, -1, propertyHolder,
JSPROP_PERMANENT | JSPROP_READONLY,
JS_STUBGETTER, JS_STUBSETTER);
JSPROP_PERMANENT | JSPROP_READONLY);
NS_ENSURE_TRUE(ok, NS_ERROR_UNEXPECTED);
} else {
propertyHolder = targetClassObject;

View file

@ -478,8 +478,7 @@ XPCShellEnvironment::Init()
JS::Rooted<Value> privateVal(cx, PrivateValue(this));
if (!JS_DefineProperty(cx, globalObj, "__XPCShellEnvironment",
privateVal,
JSPROP_READONLY | JSPROP_PERMANENT,
JS_STUBGETTER, JS_STUBSETTER) ||
JSPROP_READONLY | JSPROP_PERMANENT) ||
!JS_DefineFunctions(cx, globalObj, gGlobalFunctions) ||
!JS_DefineProfilingFunctions(cx, globalObj))
{

View file

@ -2081,17 +2081,11 @@ ShellAllocationMetadataBuilder::build(JSContext* cx, HandleObject,
static int createdIndex = 0;
createdIndex++;
if (!JS_DefineProperty(cx, obj, "index", createdIndex, 0,
JS_STUBGETTER, JS_STUBSETTER))
{
if (!JS_DefineProperty(cx, obj, "index", createdIndex, 0))
oomUnsafe.crash("ShellAllocationMetadataBuilder::build");
}
if (!JS_DefineProperty(cx, obj, "stack", stack, 0,
JS_STUBGETTER, JS_STUBSETTER))
{
if (!JS_DefineProperty(cx, obj, "stack", stack, 0))
oomUnsafe.crash("ShellAllocationMetadataBuilder::build");
}
int stackIndex = 0;
RootedId id(cx);
@ -2100,11 +2094,8 @@ ShellAllocationMetadataBuilder::build(JSContext* cx, HandleObject,
if (iter.isFunctionFrame() && iter.compartment() == cx->compartment()) {
id = INT_TO_JSID(stackIndex);
RootedObject callee(cx, iter.callee(cx));
if (!JS_DefinePropertyById(cx, stack, id, callee, 0,
JS_STUBGETTER, JS_STUBSETTER))
{
if (!JS_DefinePropertyById(cx, stack, id, callee, 0))
oomUnsafe.crash("ShellAllocationMetadataBuilder::build");
}
stackIndex++;
}
}

View file

@ -2475,8 +2475,7 @@ JS_InitCTypesClass(JSContext* cx, HandleObject global)
return false;
if (!JS_DefineProperty(cx, global, "ctypes", ctypes,
JSPROP_READONLY | JSPROP_PERMANENT,
JS_STUBGETTER, JS_STUBSETTER)){
JSPROP_READONLY | JSPROP_PERMANENT)) {
return false;
}

View file

@ -45,16 +45,14 @@ BEGIN_TEST(testAddPropertyHook)
JS::RootedValue arr(cx, JS::ObjectValue(*obj));
CHECK(JS_DefineProperty(cx, global, "arr", arr,
JSPROP_ENUMERATE,
JS_STUBGETTER, JS_STUBSETTER));
JSPROP_ENUMERATE));
JS::RootedObject arrObj(cx, &arr.toObject());
for (int i = 0; i < ExpectedCount; ++i) {
obj = JS_NewObject(cx, &AddPropertyClass);
CHECK(obj);
CHECK(JS_DefineElement(cx, arrObj, i, obj,
JSPROP_ENUMERATE,
JS_STUBGETTER, JS_STUBSETTER));
JSPROP_ENUMERATE));
}
// Now add a prop to each of the objects, but make sure to do

View file

@ -12,12 +12,11 @@ BEGIN_TEST(testSetProperty_NativeGetterStubSetter)
JS::RootedObject obj(cx, JS_NewPlainObject(cx));
CHECK(obj);
CHECK(JS_DefineProperty(cx, global, "globalProp", obj, JSPROP_ENUMERATE,
JS_STUBGETTER, JS_STUBSETTER));
CHECK(JS_DefineProperty(cx, global, "globalProp", obj, JSPROP_ENUMERATE));
CHECK(JS_DefineProperty(cx, obj, "prop", JS::UndefinedHandleValue,
JSPROP_SHARED | JSPROP_PROPOP_ACCESSORS,
JS_PROPERTYOP_GETTER(NativeGet), JS_STUBSETTER));
JS_PROPERTYOP_GETTER(NativeGet), nullptr));
EXEC("'use strict'; \n"
"var error, passed = false; \n"

View file

@ -2261,10 +2261,6 @@ inline int CheckIsSetterOp(JSSetterOp op);
(static_cast<void>(sizeof(JS::detail::CheckIsSetterOp(v))), \
reinterpret_cast<JSNative>(v))
#define JS_STUBGETTER JS_PROPERTYOP_GETTER(JS_PropertyStub)
#define JS_STUBSETTER JS_PROPERTYOP_SETTER(JS_StrictPropertyStub)
#define JS_PS_ACCESSOR_SPEC(name, getter, setter, flags, extraFlags) \
{ name, uint8_t(JS_CHECK_ACCESSOR_FLAGS(flags) | extraFlags), \
{ { getter, setter } } }

View file

@ -232,9 +232,7 @@ DefineHelpProperty(JSContext* cx, HandleObject obj, const char* prop, const char
RootedAtom atom(cx, Atomize(cx, value, strlen(value)));
if (!atom)
return false;
return JS_DefineProperty(cx, obj, prop, atom,
JSPROP_READONLY | JSPROP_PERMANENT,
JS_STUBGETTER, JS_STUBSETTER);
return JS_DefineProperty(cx, obj, prop, atom, JSPROP_READONLY | JSPROP_PERMANENT);
}
JS_FRIEND_API(bool)

View file

@ -1440,11 +1440,8 @@ js::InitMathClass(JSContext* cx, HandleObject obj)
if (!Math)
return nullptr;
if (!JS_DefineProperty(cx, obj, js_Math_str, Math, JSPROP_RESOLVING,
JS_STUBGETTER, JS_STUBSETTER))
{
if (!JS_DefineProperty(cx, obj, js_Math_str, Math, JSPROP_RESOLVING))
return nullptr;
}
if (!JS_DefineFunctions(cx, Math, math_static_methods))
return nullptr;
if (!JS_DefineConstDoubles(cx, Math, math_constants))

View file

@ -992,11 +992,8 @@ js::InitJSONClass(JSContext* cx, HandleObject obj)
if (!JSON)
return nullptr;
if (!JS_DefineProperty(cx, global, js_JSON_str, JSON, JSPROP_RESOLVING,
JS_STUBGETTER, JS_STUBSETTER))
{
if (!JS_DefineProperty(cx, global, js_JSON_str, JSON, JSPROP_RESOLVING))
return nullptr;
}
if (!JS_DefineFunctions(cx, JSON, json_static_methods))
return nullptr;

View file

@ -261,8 +261,7 @@ RegisterPerfMeasurement(JSContext* cx, HandleObject globalArg)
return 0;
for (const pm_const* c = pm_consts; c->name; c++) {
if (!JS_DefineProperty(cx, ctor, c->name, c->value, PM_CATTRS,
JS_STUBGETTER, JS_STUBSETTER))
if (!JS_DefineProperty(cx, ctor, c->name, c->value, PM_CATTRS))
return 0;
}

View file

@ -831,7 +831,7 @@ js::InitProxyClass(JSContext* cx, HandleObject obj)
if (!JS_DefineFunctions(cx, ctor, static_methods))
return nullptr;
if (!JS_DefineProperty(cx, obj, "Proxy", ctor, JSPROP_RESOLVING, JS_STUBGETTER, JS_STUBSETTER))
if (!JS_DefineProperty(cx, obj, "Proxy", ctor, JSPROP_RESOLVING))
return nullptr;
global->setConstructor(JSProto_Proxy, ObjectValue(*ctor));

View file

@ -433,8 +433,7 @@ ExportFunction(JSContext* cx, HandleValue vfunction, HandleValue vscope, HandleV
// the target.
if (!JSID_IS_VOID(options.defineAs)) {
if (!JS_DefinePropertyById(cx, targetScope, id, rval,
JSPROP_ENUMERATE,
JS_STUBGETTER, JS_STUBSETTER)) {
JSPROP_ENUMERATE)) {
return false;
}
}
@ -480,8 +479,7 @@ CreateObjectIn(JSContext* cx, HandleValue vobj, CreateObjectInOptions& options,
if (define) {
if (!JS_DefinePropertyById(cx, scope, options.defineAs, obj,
JSPROP_ENUMERATE,
JS_STUBGETTER, JS_STUBSETTER))
JSPROP_ENUMERATE))
return false;
}
}