diff --git a/dom/base/WindowNamedPropertiesHandler.h b/dom/base/WindowNamedPropertiesHandler.h index cd0df01c36dc..d4bf7b3ada48 100644 --- a/dom/base/WindowNamedPropertiesHandler.h +++ b/dom/base/WindowNamedPropertiesHandler.h @@ -54,10 +54,10 @@ public: return "WindowProperties"; } - static WindowNamedPropertiesHandler* + static const WindowNamedPropertiesHandler* getInstance() { - static WindowNamedPropertiesHandler instance; + static const WindowNamedPropertiesHandler instance; return &instance; } diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 14f098311462..3b1fb1e72a67 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -660,7 +660,7 @@ public: unsigned flags, JS::MutableHandle vp) MOZ_OVERRIDE; - static nsOuterWindowProxy singleton; + static const nsOuterWindowProxy singleton; protected: nsGlobalWindow* GetWindow(JSObject *proxy) @@ -1015,7 +1015,7 @@ nsOuterWindowProxy::unwatch(JSContext *cx, JS::Handle proxy, return js::UnwatchGuts(cx, proxy, id); } -nsOuterWindowProxy +const nsOuterWindowProxy nsOuterWindowProxy::singleton; class nsChromeOuterWindowProxy : public nsOuterWindowProxy @@ -1025,7 +1025,7 @@ public: virtual const char *className(JSContext *cx, JS::Handle wrapper) MOZ_OVERRIDE; - static nsChromeOuterWindowProxy singleton; + static const nsChromeOuterWindowProxy singleton; }; const char * @@ -1037,7 +1037,7 @@ nsChromeOuterWindowProxy::className(JSContext *cx, return "ChromeWindow"; } -nsChromeOuterWindowProxy +const nsChromeOuterWindowProxy nsChromeOuterWindowProxy::singleton; static JSObject* diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index a710cd28dc8b..3b274438f786 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -10189,11 +10189,11 @@ class CGDOMJSProxyHandler_slice(ClassMethod): class CGDOMJSProxyHandler_getInstance(ClassMethod): def __init__(self): - ClassMethod.__init__(self, "getInstance", "DOMProxyHandler*", [], static=True) + ClassMethod.__init__(self, "getInstance", "const DOMProxyHandler*", [], static=True) def getBody(self): return dedent(""" - static DOMProxyHandler instance; + static const DOMProxyHandler instance; return &instance; """) @@ -10214,6 +10214,15 @@ class CGDOMJSProxyHandler(CGClass): CGDOMJSProxyHandler_finalize(descriptor), CGDOMJSProxyHandler_getInstance(), CGDOMJSProxyHandler_delete(descriptor)] + constructors = [ + ClassConstructor( + [], + bodyInHeader=True, + visibility="public", + explicit=True) + ] + + if descriptor.supportsIndexedProperties(): methods.append(CGDOMJSProxyHandler_slice(descriptor)) if (descriptor.operations['IndexedSetter'] is not None or @@ -10223,6 +10232,7 @@ class CGDOMJSProxyHandler(CGClass): CGClass.__init__(self, 'DOMProxyHandler', bases=[ClassBase('mozilla::dom::DOMProxyHandler')], + constructors=constructors, methods=methods) diff --git a/js/ipc/WrapperOwner.cpp b/js/ipc/WrapperOwner.cpp index ac3609747654..45305bf75612 100644 --- a/js/ipc/WrapperOwner.cpp +++ b/js/ipc/WrapperOwner.cpp @@ -84,10 +84,10 @@ class CPOWProxyHandler : public BaseProxyHandler virtual const char* className(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE; virtual void finalize(JSFreeOp *fop, JSObject *proxy) MOZ_OVERRIDE; - static CPOWProxyHandler singleton; + static const CPOWProxyHandler singleton; }; -CPOWProxyHandler CPOWProxyHandler::singleton; +const CPOWProxyHandler CPOWProxyHandler::singleton; #define FORWARD(call, args) \ WrapperOwner *owner = OwnerOf(proxy); \ diff --git a/js/src/jsproxy.cpp b/js/src/jsproxy.cpp index af044b7d6101..1d5832e14f40 100644 --- a/js/src/jsproxy.cpp +++ b/js/src/jsproxy.cpp @@ -769,7 +769,7 @@ class ScriptedIndirectProxyHandler : public BaseProxyHandler virtual JSString *fun_toString(JSContext *cx, HandleObject proxy, unsigned indent) MOZ_OVERRIDE; virtual bool isScripted() MOZ_OVERRIDE { return true; } - static ScriptedIndirectProxyHandler singleton; + static const ScriptedIndirectProxyHandler singleton; }; /* @@ -1043,7 +1043,7 @@ ScriptedIndirectProxyHandler::fun_toString(JSContext *cx, HandleObject proxy, un return fun_toStringHelper(cx, obj, indent); } -ScriptedIndirectProxyHandler ScriptedIndirectProxyHandler::singleton; +const ScriptedIndirectProxyHandler ScriptedIndirectProxyHandler::singleton; /* Derived class for all scripted direct proxy handlers. */ class ScriptedDirectProxyHandler : public DirectProxyHandler { @@ -1089,7 +1089,7 @@ class ScriptedDirectProxyHandler : public DirectProxyHandler { virtual bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args) MOZ_OVERRIDE; virtual bool isScripted() MOZ_OVERRIDE { return true; } - static ScriptedDirectProxyHandler singleton; + static const ScriptedDirectProxyHandler singleton; }; // This variable exists solely to provide a unique address for use as an identifier. @@ -2089,7 +2089,7 @@ ScriptedDirectProxyHandler::construct(JSContext *cx, HandleObject proxy, const C return true; } -ScriptedDirectProxyHandler ScriptedDirectProxyHandler::singleton; +const ScriptedDirectProxyHandler ScriptedDirectProxyHandler::singleton; #define INVOKE_ON_PROTOTYPE(cx, handler, proxy, protoCall) \ JS_BEGIN_MACRO \ @@ -2845,7 +2845,7 @@ const Class* const js::CallableProxyClassPtr = &ProxyObject::callableClass_; const Class* const js::UncallableProxyClassPtr = &ProxyObject::uncallableClass_; JS_FRIEND_API(JSObject *) -js::NewProxyObject(JSContext *cx, BaseProxyHandler *handler, HandleValue priv, JSObject *proto_, +js::NewProxyObject(JSContext *cx, const BaseProxyHandler *handler, HandleValue priv, JSObject *proto_, JSObject *parent_, const ProxyOptions &options) { return ProxyObject::New(cx, handler, priv, TaggedProto(proto_), parent_, @@ -2853,7 +2853,7 @@ js::NewProxyObject(JSContext *cx, BaseProxyHandler *handler, HandleValue priv, J } void -ProxyObject::renew(JSContext *cx, BaseProxyHandler *handler, Value priv) +ProxyObject::renew(JSContext *cx, const BaseProxyHandler *handler, Value priv) { JS_ASSERT_IF(IsCrossCompartmentWrapper(this), IsDeadProxyObject(this)); JS_ASSERT(getParent() == cx->global()); @@ -2861,7 +2861,7 @@ ProxyObject::renew(JSContext *cx, BaseProxyHandler *handler, Value priv) JS_ASSERT(!getClass()->ext.innerObject); JS_ASSERT(getTaggedProto().isLazy()); - setSlot(HANDLER_SLOT, PrivateValue(handler)); + setHandler(handler); setCrossCompartmentSlot(PRIVATE_SLOT, priv); setSlot(EXTRA_SLOT + 0, UndefinedValue()); setSlot(EXTRA_SLOT + 1, UndefinedValue()); diff --git a/js/src/jsproxy.h b/js/src/jsproxy.h index eeaaf039e2db..13e1f3310d8b 100644 --- a/js/src/jsproxy.h +++ b/js/src/jsproxy.h @@ -121,15 +121,15 @@ class JS_FRIEND_API(BaseProxyHandler) bool hasSecurityPolicy = false); virtual ~BaseProxyHandler(); - bool hasPrototype() { + bool hasPrototype() const { return mHasPrototype; } - bool hasSecurityPolicy() { + bool hasSecurityPolicy() const { return mHasSecurityPolicy; } - inline const void *family() { + inline const void *family() const { return mFamily; } static size_t offsetOfFamily() { @@ -459,7 +459,7 @@ class MOZ_STACK_CLASS ProxyOptions { }; JS_FRIEND_API(JSObject *) -NewProxyObject(JSContext *cx, BaseProxyHandler *handler, HandleValue priv, +NewProxyObject(JSContext *cx, const BaseProxyHandler *handler, HandleValue priv, JSObject *proto, JSObject *parent, const ProxyOptions &options = ProxyOptions()); JSObject * diff --git a/js/src/jswrapper.cpp b/js/src/jswrapper.cpp index b57c74e63c8d..d562cdcf2119 100644 --- a/js/src/jswrapper.cpp +++ b/js/src/jswrapper.cpp @@ -39,7 +39,7 @@ Wrapper::defaultValue(JSContext *cx, HandleObject proxy, JSType hint, MutableHan } JSObject * -Wrapper::New(JSContext *cx, JSObject *obj, JSObject *parent, Wrapper *handler, +Wrapper::New(JSContext *cx, JSObject *obj, JSObject *parent, const Wrapper *handler, const WrapperOptions *options) { JS_ASSERT(parent); @@ -57,7 +57,7 @@ Wrapper::New(JSContext *cx, JSObject *obj, JSObject *parent, Wrapper *handler, } JSObject * -Wrapper::Renew(JSContext *cx, JSObject *existing, JSObject *obj, Wrapper *handler) +Wrapper::Renew(JSContext *cx, JSObject *existing, JSObject *obj, const Wrapper *handler) { JS_ASSERT(!obj->isCallable()); existing->as().renew(cx, handler, ObjectValue(*obj)); @@ -137,8 +137,8 @@ Wrapper::~Wrapper() { } -Wrapper Wrapper::singleton((unsigned)0); -Wrapper Wrapper::singletonWithPrototype((unsigned)0, true); +const Wrapper Wrapper::singleton((unsigned)0); +const Wrapper Wrapper::singletonWithPrototype((unsigned)0, true); JSObject *Wrapper::defaultProto = TaggedProto::LazyProto; /* Compartments. */ @@ -603,7 +603,7 @@ CrossCompartmentWrapper::setPrototypeOf(JSContext *cx, HandleObject wrapper, NOTHING); } -CrossCompartmentWrapper CrossCompartmentWrapper::singleton(0u); +const CrossCompartmentWrapper CrossCompartmentWrapper::singleton(0u); /* Security wrappers. */ @@ -859,7 +859,7 @@ DeadObjectProxy::getPrototypeOf(JSContext *cx, HandleObject proxy, MutableHandle return true; } -DeadObjectProxy DeadObjectProxy::singleton; +const DeadObjectProxy DeadObjectProxy::singleton; const char DeadObjectProxy::sDeadObjectFamily = 0; bool diff --git a/js/src/jswrapper.h b/js/src/jswrapper.h index 8311d8031585..08579732383d 100644 --- a/js/src/jswrapper.h +++ b/js/src/jswrapper.h @@ -68,10 +68,10 @@ class JS_FRIEND_API(Wrapper) : public DirectProxyHandler virtual bool defaultValue(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp) MOZ_OVERRIDE; - static JSObject *New(JSContext *cx, JSObject *obj, JSObject *parent, Wrapper *handler, + static JSObject *New(JSContext *cx, JSObject *obj, JSObject *parent, const Wrapper *handler, const WrapperOptions *options = nullptr); - static JSObject *Renew(JSContext *cx, JSObject *existing, JSObject *obj, Wrapper *handler); + static JSObject *Renew(JSContext *cx, JSObject *existing, JSObject *obj, const Wrapper *handler); static Wrapper *wrapperHandler(JSObject *wrapper); @@ -87,8 +87,8 @@ class JS_FRIEND_API(Wrapper) : public DirectProxyHandler virtual bool finalizeInBackground(Value priv) MOZ_OVERRIDE; - static Wrapper singleton; - static Wrapper singletonWithPrototype; + static const Wrapper singleton; + static const Wrapper singletonWithPrototype; static JSObject *defaultProto; }; @@ -151,8 +151,8 @@ class JS_FRIEND_API(CrossCompartmentWrapper) : public Wrapper virtual bool setPrototypeOf(JSContext *cx, HandleObject proxy, HandleObject proto, bool *bp) MOZ_OVERRIDE; - static CrossCompartmentWrapper singleton; - static CrossCompartmentWrapper singletonWithPrototype; + static const CrossCompartmentWrapper singleton; + static const CrossCompartmentWrapper singletonWithPrototype; }; /* @@ -241,7 +241,7 @@ class JS_FRIEND_API(DeadObjectProxy) : public BaseProxyHandler virtual bool getPrototypeOf(JSContext *cx, HandleObject proxy, MutableHandleObject protop) MOZ_OVERRIDE; - static DeadObjectProxy singleton; + static const DeadObjectProxy singleton; }; extern JSObject * diff --git a/js/src/vm/ProxyObject.cpp b/js/src/vm/ProxyObject.cpp index e8521ee7647a..885f4da9ba41 100644 --- a/js/src/vm/ProxyObject.cpp +++ b/js/src/vm/ProxyObject.cpp @@ -14,7 +14,7 @@ using namespace js; /* static */ ProxyObject * -ProxyObject::New(JSContext *cx, BaseProxyHandler *handler, HandleValue priv, TaggedProto proto_, +ProxyObject::New(JSContext *cx, const BaseProxyHandler *handler, HandleValue priv, TaggedProto proto_, JSObject *parent_, const ProxyOptions &options) { Rooted proto(cx, proto_); @@ -69,9 +69,9 @@ ProxyObject::initCrossCompartmentPrivate(HandleValue priv) } void -ProxyObject::initHandler(BaseProxyHandler *handler) +ProxyObject::initHandler(const BaseProxyHandler *handler) { - initSlot(HANDLER_SLOT, PrivateValue(handler)); + initSlot(HANDLER_SLOT, PrivateValue(const_cast(handler))); } static void @@ -88,7 +88,7 @@ NukeSlot(ProxyObject *proxy, uint32_t slot) } void -ProxyObject::nuke(BaseProxyHandler *handler) +ProxyObject::nuke(const BaseProxyHandler *handler) { /* Allow people to add their own number of reserved slots beyond the expected 4 */ unsigned numSlots = JSCLASS_RESERVED_SLOTS(getClass()); diff --git a/js/src/vm/ProxyObject.h b/js/src/vm/ProxyObject.h index 1060b5cc6ed7..72e88f448901 100644 --- a/js/src/vm/ProxyObject.h +++ b/js/src/vm/ProxyObject.h @@ -23,7 +23,7 @@ class ProxyObject : public JSObject static const uint32_t EXTRA_SLOT = PROXY_EXTRA_SLOT; public: - static ProxyObject *New(JSContext *cx, BaseProxyHandler *handler, HandleValue priv, + static ProxyObject *New(JSContext *cx, const BaseProxyHandler *handler, HandleValue priv, TaggedProto proto_, JSObject *parent_, const ProxyOptions &options); @@ -45,10 +45,10 @@ class ProxyObject : public JSObject return static_cast(GetReservedSlot(this, HANDLER_SLOT).toPrivate()); } - void initHandler(BaseProxyHandler *handler); + void initHandler(const BaseProxyHandler *handler); - void setHandler(BaseProxyHandler *handler) { - SetReservedSlot(this, HANDLER_SLOT, PrivateValue(handler)); + void setHandler(const BaseProxyHandler *handler) { + SetReservedSlot(this, HANDLER_SLOT, PrivateValue(const_cast(handler))); } static size_t offsetOfHandler() { @@ -93,11 +93,11 @@ class ProxyObject : public JSObject public: static unsigned grayLinkSlot(JSObject *obj); - void renew(JSContext *cx, BaseProxyHandler *handler, Value priv); + void renew(JSContext *cx, const BaseProxyHandler *handler, Value priv); static void trace(JSTracer *trc, JSObject *obj); - void nuke(BaseProxyHandler *handler); + void nuke(const BaseProxyHandler *handler); static const Class callableClass_; static const Class uncallableClass_; diff --git a/js/src/vm/ScopeObject.cpp b/js/src/vm/ScopeObject.cpp index 7ea69ba5eace..9dd94ec8bcee 100644 --- a/js/src/vm/ScopeObject.cpp +++ b/js/src/vm/ScopeObject.cpp @@ -1314,7 +1314,7 @@ class DebugScopeProxy : public BaseProxyHandler public: static int family; - static DebugScopeProxy singleton; + static const DebugScopeProxy singleton; DebugScopeProxy() : BaseProxyHandler(&family) {} @@ -1583,7 +1583,7 @@ class DebugScopeProxy : public BaseProxyHandler } /* anonymous namespace */ int DebugScopeProxy::family = 0; -DebugScopeProxy DebugScopeProxy::singleton; +const DebugScopeProxy DebugScopeProxy::singleton; /* static */ DebugScopeObject * DebugScopeObject::create(JSContext *cx, ScopeObject &scope, HandleObject enclosing) diff --git a/js/xpconnect/src/Sandbox.cpp b/js/xpconnect/src/Sandbox.cpp index 2f090e528d50..63e2036bebf1 100644 --- a/js/xpconnect/src/Sandbox.cpp +++ b/js/xpconnect/src/Sandbox.cpp @@ -511,7 +511,7 @@ NS_IMPL_RELEASE(nsXPCComponents_utils_Sandbox) #define XPC_MAP_FLAGS 0 #include "xpc_map_end.h" /* This #undef's the above. */ -xpc::SandboxProxyHandler xpc::sandboxProxyHandler; +const xpc::SandboxProxyHandler xpc::sandboxProxyHandler; bool xpc::IsSandboxPrototypeProxy(JSObject *obj) @@ -575,7 +575,7 @@ xpc::SandboxCallableProxyHandler::call(JSContext *cx, JS::Handle prox return JS::Call(cx, thisVal, func, args, args.rval()); } -xpc::SandboxCallableProxyHandler xpc::sandboxCallableProxyHandler; +const xpc::SandboxCallableProxyHandler xpc::sandboxCallableProxyHandler; /* * Wrap a callable such that if we're called with oldThisObj as the diff --git a/js/xpconnect/wrappers/ChromeObjectWrapper.cpp b/js/xpconnect/wrappers/ChromeObjectWrapper.cpp index b0cd86823d57..272064e7e2ee 100644 --- a/js/xpconnect/wrappers/ChromeObjectWrapper.cpp +++ b/js/xpconnect/wrappers/ChromeObjectWrapper.cpp @@ -21,7 +21,7 @@ namespace xpc { // chromeArray.forEach(..) to Just Work without explicitly listing them in // __exposedProps__. Since proxies don't automatically inherit behavior from // their prototype, we have to instrument the traps to do this manually. -ChromeObjectWrapper ChromeObjectWrapper::singleton; +const ChromeObjectWrapper ChromeObjectWrapper::singleton; using js::assertEnteredPolicy; @@ -32,7 +32,8 @@ AllowedByBase(JSContext *cx, HandleObject wrapper, HandleId id, MOZ_ASSERT(js::Wrapper::wrapperHandler(wrapper) == &ChromeObjectWrapper::singleton); bool bp; - ChromeObjectWrapper *handler = &ChromeObjectWrapper::singleton; + ChromeObjectWrapper *handler = + const_cast(&ChromeObjectWrapper::singleton); return handler->ChromeObjectWrapperBase::enter(cx, wrapper, id, act, &bp); } @@ -56,7 +57,8 @@ PropIsFromStandardPrototype(JSContext *cx, HandleObject wrapper, MOZ_ASSERT(js::Wrapper::wrapperHandler(wrapper) == &ChromeObjectWrapper::singleton); Rooted desc(cx); - ChromeObjectWrapper *handler = &ChromeObjectWrapper::singleton; + ChromeObjectWrapper *handler = + const_cast(&ChromeObjectWrapper::singleton); if (!handler->ChromeObjectWrapperBase::getPropertyDescriptor(cx, wrapper, id, &desc) || !desc.object()) diff --git a/js/xpconnect/wrappers/ChromeObjectWrapper.h b/js/xpconnect/wrappers/ChromeObjectWrapper.h index 78cfa72f9b09..dea95d316ea7 100644 --- a/js/xpconnect/wrappers/ChromeObjectWrapper.h +++ b/js/xpconnect/wrappers/ChromeObjectWrapper.h @@ -51,7 +51,7 @@ class ChromeObjectWrapper : public ChromeObjectWrapperBase // never be anything more to enumerate up the prototype chain. So we can // atually skip these. - static ChromeObjectWrapper singleton; + static const ChromeObjectWrapper singleton; }; } /* namespace xpc */ diff --git a/js/xpconnect/wrappers/FilteringWrapper.cpp b/js/xpconnect/wrappers/FilteringWrapper.cpp index 849d78191188..5b510e904b0f 100644 --- a/js/xpconnect/wrappers/FilteringWrapper.cpp +++ b/js/xpconnect/wrappers/FilteringWrapper.cpp @@ -191,12 +191,12 @@ FilteringWrapper::enter(JSContext *cx, HandleObject wrapper, #define NNXOW FilteringWrapper #define NNXOWC FilteringWrapper #define GO FilteringWrapper -template<> XOW XOW::singleton(0); -template<> DXOW DXOW::singleton(0); -template<> NNXOW NNXOW::singleton(0); -template<> NNXOWC NNXOWC::singleton(0); +template<> const XOW XOW::singleton(0); +template<> const DXOW DXOW::singleton(0); +template<> const NNXOW NNXOW::singleton(0); +template<> const NNXOWC NNXOWC::singleton(0); -template<> GO GO::singleton(0); +template<> const GO GO::singleton(0); template class XOW; template class DXOW; diff --git a/js/xpconnect/wrappers/FilteringWrapper.h b/js/xpconnect/wrappers/FilteringWrapper.h index 9ebd6fe06aa4..090c0c1df0ae 100644 --- a/js/xpconnect/wrappers/FilteringWrapper.h +++ b/js/xpconnect/wrappers/FilteringWrapper.h @@ -47,7 +47,7 @@ class FilteringWrapper : public Base { virtual bool enter(JSContext *cx, JS::Handle wrapper, JS::Handle id, js::Wrapper::Action act, bool *bp) MOZ_OVERRIDE; - static FilteringWrapper singleton; + static const FilteringWrapper singleton; }; } diff --git a/js/xpconnect/wrappers/WaiveXrayWrapper.h b/js/xpconnect/wrappers/WaiveXrayWrapper.h index 760dd0dd40e7..4c5f1af16359 100644 --- a/js/xpconnect/wrappers/WaiveXrayWrapper.h +++ b/js/xpconnect/wrappers/WaiveXrayWrapper.h @@ -38,7 +38,7 @@ class WaiveXrayWrapper : public js::CrossCompartmentWrapper { virtual bool getPrototypeOf(JSContext *cx, JS::Handle wrapper, JS::MutableHandle protop) MOZ_OVERRIDE; - static WaiveXrayWrapper singleton; + static const WaiveXrayWrapper singleton; }; } diff --git a/js/xpconnect/wrappers/WrapperFactory.cpp b/js/xpconnect/wrappers/WrapperFactory.cpp index f1d1e67da55d..cdde4fcb5d2d 100644 --- a/js/xpconnect/wrappers/WrapperFactory.cpp +++ b/js/xpconnect/wrappers/WrapperFactory.cpp @@ -32,13 +32,13 @@ namespace xpc { // transparent wrapper in the origin (non-chrome) compartment. When // an object with that special wrapper applied crosses into chrome, // we know to not apply an X-ray wrapper. -Wrapper XrayWaiver(WrapperFactory::WAIVE_XRAY_WRAPPER_FLAG); +const Wrapper XrayWaiver(WrapperFactory::WAIVE_XRAY_WRAPPER_FLAG); // When objects for which we waived the X-ray wrapper cross into // chrome, we wrap them into a special cross-compartment wrapper // that transitively extends the waiver to all properties we get // off it. -WaiveXrayWrapper WaiveXrayWrapper::singleton(0); +const WaiveXrayWrapper WaiveXrayWrapper::singleton(0); bool WrapperFactory::IsCOW(JSObject *obj) @@ -325,7 +325,7 @@ WrapperFactory::PrepareForWrapping(JSContext *cx, HandleObject scope, #ifdef DEBUG static void -DEBUG_CheckUnwrapSafety(HandleObject obj, js::Wrapper *handler, +DEBUG_CheckUnwrapSafety(HandleObject obj, const js::Wrapper *handler, JSCompartment *origin, JSCompartment *target) { if (AccessCheck::isChrome(target) || xpc::IsUniversalXPConnectEnabled(target)) { @@ -344,7 +344,7 @@ DEBUG_CheckUnwrapSafety(HandleObject obj, js::Wrapper *handler, #define DEBUG_CheckUnwrapSafety(obj, handler, origin, target) {} #endif -static Wrapper * +static const Wrapper * SelectWrapper(bool securityWrapper, bool wantXrays, XrayType xrayType, bool waiveXrays, bool originIsXBLScope) { @@ -420,7 +420,7 @@ WrapperFactory::Rewrap(JSContext *cx, HandleObject existing, HandleObject obj, XrayType xrayType = GetXrayType(obj); bool waiveXrayFlag = flags & WAIVE_XRAY_WRAPPER_FLAG; - Wrapper *wrapper; + const Wrapper *wrapper; CompartmentPrivate *targetdata = EnsureCompartmentPrivate(target); // diff --git a/js/xpconnect/wrappers/WrapperFactory.h b/js/xpconnect/wrappers/WrapperFactory.h index 9a23520a04a7..eb238f746f06 100644 --- a/js/xpconnect/wrappers/WrapperFactory.h +++ b/js/xpconnect/wrappers/WrapperFactory.h @@ -64,7 +64,7 @@ class WrapperFactory { static bool XrayWrapperNotShadowing(JSObject *wrapper, jsid id); }; -extern js::Wrapper XrayWaiver; +extern const js::Wrapper XrayWaiver; } diff --git a/js/xpconnect/wrappers/XrayWrapper.cpp b/js/xpconnect/wrappers/XrayWrapper.cpp index 1e31fcfb58f2..d99fb3dc8d7e 100644 --- a/js/xpconnect/wrappers/XrayWrapper.cpp +++ b/js/xpconnect/wrappers/XrayWrapper.cpp @@ -2575,7 +2575,8 @@ bool XrayWrapper::call(JSContext *cx, HandleObject wrapper, const JS::CallArgs &args) { assertEnteredPolicy(cx, wrapper, JSID_VOID, BaseProxyHandler::CALL); - return Traits::call(cx, wrapper, args, Base::singleton); + // Hard cast the singleton since SecurityWrapper doesn't have one. + return Traits::call(cx, wrapper, args, (js::Wrapper&)Base::singleton); } template @@ -2583,7 +2584,8 @@ bool XrayWrapper::construct(JSContext *cx, HandleObject wrapper, const JS::CallArgs &args) { assertEnteredPolicy(cx, wrapper, JSID_VOID, BaseProxyHandler::CALL); - return Traits::construct(cx, wrapper, args, Base::singleton); + // Hard cast the singleton since SecurityWrapper doesn't have one. + return Traits::construct(cx, wrapper, args, (js::Wrapper&)Base::singleton); } template @@ -2663,27 +2665,27 @@ XrayWrapper::setPrototypeOf(JSContext *cx, JS::HandleObject wrappe */ template<> -PermissiveXrayXPCWN PermissiveXrayXPCWN::singleton(0); +const PermissiveXrayXPCWN PermissiveXrayXPCWN::singleton(0); template class PermissiveXrayXPCWN; template<> -SecurityXrayXPCWN SecurityXrayXPCWN::singleton(0); +const SecurityXrayXPCWN SecurityXrayXPCWN::singleton(0); template class SecurityXrayXPCWN; template<> -PermissiveXrayDOM PermissiveXrayDOM::singleton(0); +const PermissiveXrayDOM PermissiveXrayDOM::singleton(0); template class PermissiveXrayDOM; template<> -SecurityXrayDOM SecurityXrayDOM::singleton(0); +const SecurityXrayDOM SecurityXrayDOM::singleton(0); template class SecurityXrayDOM; template<> -PermissiveXrayJS PermissiveXrayJS::singleton(0); +const PermissiveXrayJS PermissiveXrayJS::singleton(0); template class PermissiveXrayJS; template<> -SCSecurityXrayXPCWN SCSecurityXrayXPCWN::singleton(0); +const SCSecurityXrayXPCWN SCSecurityXrayXPCWN::singleton(0); template class SCSecurityXrayXPCWN; static nsQueryInterface diff --git a/js/xpconnect/wrappers/XrayWrapper.h b/js/xpconnect/wrappers/XrayWrapper.h index 803493bff4d7..e4c6260558e1 100644 --- a/js/xpconnect/wrappers/XrayWrapper.h +++ b/js/xpconnect/wrappers/XrayWrapper.h @@ -111,7 +111,7 @@ class XrayWrapper : public Base { virtual bool setPrototypeOf(JSContext *cx, JS::HandleObject wrapper, JS::HandleObject proto, bool *bp) MOZ_OVERRIDE; - static XrayWrapper singleton; + static const XrayWrapper singleton; private: template @@ -175,7 +175,7 @@ public: JS::MutableHandle vp) MOZ_OVERRIDE; }; -extern SandboxProxyHandler sandboxProxyHandler; +extern const SandboxProxyHandler sandboxProxyHandler; // A proxy handler that lets us wrap callables and invoke them with // the correct this object, while forwarding all other operations down @@ -190,7 +190,7 @@ public: const JS::CallArgs &args) MOZ_OVERRIDE; }; -extern SandboxCallableProxyHandler sandboxCallableProxyHandler; +extern const SandboxCallableProxyHandler sandboxCallableProxyHandler; class AutoSetWrapperNotShadowing; class XPCWrappedNativeXrayTraits;