Commits

ms2ger  committed d41431e

Cleanup up to XPCNativeScriptableFlags.

  • Participants
  • Parent commits 71a425a

Comments (0)

Files changed (3)

File XPCNativeInterface

 diff --git a/js/xpconnect/src/XPCCallContext.cpp b/js/xpconnect/src/XPCCallContext.cpp
 --- a/js/xpconnect/src/XPCCallContext.cpp
 +++ b/js/xpconnect/src/XPCCallContext.cpp
-@@ -39,16 +39,17 @@
-  * ***** END LICENSE BLOCK ***** */
- 
+@@ -41,16 +41,17 @@
  /* Call context. */
  
  #include "XPCCallContext.h"
  
+ #include "mozilla/Util.h"
+ 
  #include "nsXPConnect.h"
  #include "XPCContext.h"
 +#include "XPCNativeInterface.h"
  #include "XPCReadableJSStringWrapper.h"
  #include "XPCWrappedNativeTearOff.h"
  
+ using namespace mozilla;
+ 
  XPCCallContext::XPCCallContext(XPCContext::LangType callerLanguage,
-                                JSContext* cx    /* = nsnull    */,
-                                JSObject* obj    /* = nsnull    */,
 diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp
 --- a/js/xpconnect/src/XPCComponents.cpp
 +++ b/js/xpconnect/src/XPCComponents.cpp
-@@ -45,16 +45,17 @@
+@@ -47,16 +47,17 @@
  #include "nsXPConnect.h"
  #include "PrincipalHolder.h"
  #include "WrapperFactory.h"
  #include "XPCNativeSet.h"
  #include "xpcprivate.h"
  
+ #include "jshash.h"
+ 
  /***************************************************************************/
  // static shared...
  
- // Note this is returning the bit pattern of the first part of the nsID, not
- // the pointer to the nsID.
 diff --git a/js/xpconnect/src/XPCNativeInterface.h b/js/xpconnect/src/XPCNativeInterface.h
 new file mode 100644
 --- /dev/null
 +++ b/js/xpconnect/src/XPCNativeInterface.h
-@@ -0,0 +1,84 @@
+@@ -0,0 +1,98 @@
++/* This Source Code Form is subject to the terms of the Mozilla Public
++ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
++ * You can obtain one at http://mozilla.org/MPL/2.0/. */
++
 +#ifndef XPCNativeInterface_h
 +#define XPCNativeInterface_h
 +
++#include "mozilla/Attributes.h"
++
 +#include "nsIInterfaceInfo.h"
 +#include "XPCNativeMember.h"
 +
 +class XPCNativeInterface
 +{
 +public:
-+    static XPCNativeInterface* GetNewOrUsed(XPCCallContext& ccx,
-+                                            const nsIID* iid);
-+    static XPCNativeInterface* GetNewOrUsed(XPCCallContext& ccx,
-+                                            nsIInterfaceInfo* info);
-+    static XPCNativeInterface* GetNewOrUsed(XPCCallContext& ccx,
-+                                            const char* name);
-+    static XPCNativeInterface* GetISupports(XPCCallContext& ccx);
++    static XPCNativeInterface *GetNewOrUsed(XPCCallContext &ccx,
++                                            const nsIID *iid);
++    static XPCNativeInterface *GetNewOrUsed(XPCCallContext &ccx,
++                                            nsIInterfaceInfo *info);
++    static XPCNativeInterface *GetNewOrUsed(XPCCallContext &ccx,
++                                            const char *name);
++    static XPCNativeInterface *GetISupports(XPCCallContext &ccx);
 +
-+    inline nsIInterfaceInfo* GetInterfaceInfo() const {return mInfo.get();}
-+    inline jsid              GetName()          const {return mName;}
++    inline nsIInterfaceInfo *GetInterfaceInfo() const {return mInfo.get();}
++    inline jsid GetName() const {return mName;}
 +
-+    inline const nsIID* GetIID() const;
-+    inline const char*  GetNameString() const;
-+    inline XPCNativeMember* FindMember(jsid name) const;
++    inline const nsIID *GetIID() const;
++    inline const char * GetNameString() const;
++    inline XPCNativeMember *FindMember(jsid name) const;
 +
-+    inline JSBool HasAncestor(const nsIID* iid) const;
++    inline JSBool HasAncestor(const nsIID *iid) const;
 +
 +    PRUint16 GetMemberCount() const
-+        {NS_ASSERTION(!IsMarked(), "bad"); return mMemberCount;}
-+    XPCNativeMember* GetMemberAt(PRUint16 i)
-+        {NS_ASSERTION(i < mMemberCount, "bad index"); return &mMembers[i];}
++    {
++        NS_ASSERTION(!IsMarked(), "bad");
++        return mMemberCount;
++    }
++    XPCNativeMember *GetMemberAt(PRUint16 i)
++    {
++        NS_ASSERTION(i < mMemberCount, "bad index");
++        return &mMembers[i];
++    }
 +
 +    void DebugDump(PRInt16 depth);
 +
 +
 +    void Mark()     {mMemberCount |= XPC_NATIVE_IFACE_MARK_FLAG;}
 +    void Unmark()   {mMemberCount &= ~XPC_NATIVE_IFACE_MARK_FLAG;}
-+    JSBool IsMarked() const
++    bool IsMarked() const
 +                    {return 0 != (mMemberCount & XPC_NATIVE_IFACE_MARK_FLAG);}
 +
 +    // NOP. This is just here to make the AutoMarkingPtr code compile.
-+    inline void TraceJS(JSTracer* trc) {}
-+    inline void AutoTrace(JSTracer* trc) {}
++    inline void TraceJS(JSTracer *trc) {}
++    inline void AutoTrace(JSTracer *trc) {}
 +
-+    static void DestroyInstance(XPCNativeInterface* inst);
++    static void DestroyInstance(XPCNativeInterface *inst);
 +
 +    size_t SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf);
 +
 +protected:
-+    static XPCNativeInterface* NewInstance(XPCCallContext& ccx,
-+                                           nsIInterfaceInfo* aInfo);
++    static XPCNativeInterface *NewInstance(XPCCallContext &ccx,
++                                           nsIInterfaceInfo *aInfo);
 +
-+    XPCNativeInterface();   // not implemented
-+    XPCNativeInterface(nsIInterfaceInfo* aInfo, jsid aName)
++    XPCNativeInterface() MOZ_DELETE;
++    XPCNativeInterface(nsIInterfaceInfo *aInfo, jsid aName)
 +        : mInfo(aInfo), mName(aName), mMemberCount(0)
-+                          {MOZ_COUNT_CTOR(XPCNativeInterface);}
++    {
++        MOZ_COUNT_CTOR(XPCNativeInterface);
++    }
 +    ~XPCNativeInterface() {MOZ_COUNT_DTOR(XPCNativeInterface);}
 +
-+    void* operator new(size_t, void* p) CPP_THROW_NEW {return p;}
++    void *operator new(size_t, void *p) CPP_THROW_NEW {return p;}
 +
-+    XPCNativeInterface(const XPCNativeInterface& r); // not implemented
-+    XPCNativeInterface& operator= (const XPCNativeInterface& r); // not implemented
++    XPCNativeInterface(const XPCNativeInterface &r) MOZ_DELETE;
++    XPCNativeInterface &operator= (const XPCNativeInterface &r) MOZ_DELETE;
 +
 +private:
 +    nsCOMPtr<nsIInterfaceInfo> mInfo;
-+    jsid                       mName;
-+    PRUint16          mMemberCount;
-+    XPCNativeMember   mMembers[1]; // always last - object sized for array
++    jsid mName;
++    PRUint16 mMemberCount;
++    XPCNativeMember mMembers[1]; // always last - object sized for array
 +};
 +
 +#endif // XPCNativeInterface_h
 diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h
 --- a/js/xpconnect/src/xpcprivate.h
 +++ b/js/xpconnect/src/xpcprivate.h
-@@ -150,17 +150,17 @@
+@@ -148,17 +148,17 @@
  #include "XPCNativeSet.h"
  #include "XPCLock.h"
  #include "nsXPConnect.h"
  
  #if defined(DEBUG_jband) || defined(DEBUG_jst) || defined(DEBUG_dbradley) || defined(DEBUG_shaver_no) || defined(DEBUG_timeless)
  #define DEBUG_xpc_hacker
-@@ -446,85 +446,16 @@ enum WrapperType {
+@@ -442,85 +442,16 @@ enum WrapperType {
      COW             = 1 << 4,
      SOW             = 1 << 5
  };

File XPCNativeScriptableFlags

 new file mode 100644
 --- /dev/null
 +++ b/js/xpconnect/src/XPCNativeScriptableFlags.h
-@@ -0,0 +1,80 @@
+@@ -0,0 +1,88 @@
++/* This Source Code Form is subject to the terms of the Mozilla Public
++ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
++ * You can obtain one at http://mozilla.org/MPL/2.0/. */
++
 +#ifndef XPCNativeScriptableFlags_h
 +#define XPCNativeScriptableFlags_h
 +
++#include "mozilla/StdInt.h"
++
 +#include "nsIXPCScriptable.h"
 +
 +#include "jstypes.h"
 +    uint32_t mFlags;
 +
 +public:
-+
 +    XPCNativeScriptableFlags(uint32_t flags = 0) : mFlags(flags) {}
 +
 +    uint32_t GetFlags() const {return mFlags & ~XPC_WN_SJSFLAGS_MARK_FLAG;}
 +
 +    operator uint32_t() const {return GetFlags();}
 +
-+    XPCNativeScriptableFlags(const XPCNativeScriptableFlags& r)
-+        {mFlags = r.GetFlags();}
++    XPCNativeScriptableFlags(const XPCNativeScriptableFlags &r)
++    {
++        mFlags = r.GetFlags();
++    }
 +
-+    XPCNativeScriptableFlags& operator= (const XPCNativeScriptableFlags& r)
-+        {mFlags = r.GetFlags(); return *this;}
++    XPCNativeScriptableFlags &operator= (const XPCNativeScriptableFlags &r)
++    {
++        mFlags = r.GetFlags();
++        return *this;
++    }
 +
-+    void Mark()       {mFlags |= XPC_WN_SJSFLAGS_MARK_FLAG;}
-+    void Unmark()     {mFlags &= ~XPC_WN_SJSFLAGS_MARK_FLAG;}
-+    JSBool IsMarked() const {return 0 != (mFlags & XPC_WN_SJSFLAGS_MARK_FLAG);}
++    void Mark() {mFlags |= XPC_WN_SJSFLAGS_MARK_FLAG;}
++    void Unmark() {mFlags &= ~XPC_WN_SJSFLAGS_MARK_FLAG;}
++    bool IsMarked() const {return 0 != (mFlags & XPC_WN_SJSFLAGS_MARK_FLAG);}
 +
 +#ifdef GET_IT
 +#undef GET_IT
 +#endif
 +#define GET_IT(f_) const {return 0 != (mFlags & nsIXPCScriptable:: f_ );}
 +
-+    JSBool WantPreCreate()                GET_IT(WANT_PRECREATE)
-+    JSBool WantCreate()                   GET_IT(WANT_CREATE)
-+    JSBool WantPostCreate()               GET_IT(WANT_POSTCREATE)
-+    JSBool WantAddProperty()              GET_IT(WANT_ADDPROPERTY)
-+    JSBool WantDelProperty()              GET_IT(WANT_DELPROPERTY)
-+    JSBool WantGetProperty()              GET_IT(WANT_GETPROPERTY)
-+    JSBool WantSetProperty()              GET_IT(WANT_SETPROPERTY)
-+    JSBool WantEnumerate()                GET_IT(WANT_ENUMERATE)
-+    JSBool WantNewEnumerate()             GET_IT(WANT_NEWENUMERATE)
-+    JSBool WantNewResolve()               GET_IT(WANT_NEWRESOLVE)
-+    JSBool WantConvert()                  GET_IT(WANT_CONVERT)
-+    JSBool WantFinalize()                 GET_IT(WANT_FINALIZE)
-+    JSBool WantCheckAccess()              GET_IT(WANT_CHECKACCESS)
-+    JSBool WantCall()                     GET_IT(WANT_CALL)
-+    JSBool WantConstruct()                GET_IT(WANT_CONSTRUCT)
-+    JSBool WantHasInstance()              GET_IT(WANT_HASINSTANCE)
-+    JSBool WantTrace()                    GET_IT(WANT_TRACE)
-+    JSBool WantEquality()                 GET_IT(WANT_EQUALITY)
-+    JSBool WantOuterObject()              GET_IT(WANT_OUTER_OBJECT)
-+    JSBool UseJSStubForAddProperty()      GET_IT(USE_JSSTUB_FOR_ADDPROPERTY)
-+    JSBool UseJSStubForDelProperty()      GET_IT(USE_JSSTUB_FOR_DELPROPERTY)
-+    JSBool UseJSStubForSetProperty()      GET_IT(USE_JSSTUB_FOR_SETPROPERTY)
-+    JSBool DontEnumStaticProps()          GET_IT(DONT_ENUM_STATIC_PROPS)
-+    JSBool DontEnumQueryInterface()       GET_IT(DONT_ENUM_QUERY_INTERFACE)
-+    JSBool DontAskInstanceForScriptable() GET_IT(DONT_ASK_INSTANCE_FOR_SCRIPTABLE)
-+    JSBool ClassInfoInterfacesOnly()      GET_IT(CLASSINFO_INTERFACES_ONLY)
-+    JSBool AllowPropModsDuringResolve()   GET_IT(ALLOW_PROP_MODS_DURING_RESOLVE)
-+    JSBool AllowPropModsToPrototype()     GET_IT(ALLOW_PROP_MODS_TO_PROTOTYPE)
-+    JSBool DontSharePrototype()           GET_IT(DONT_SHARE_PROTOTYPE)
-+    JSBool DontReflectInterfaceNames()    GET_IT(DONT_REFLECT_INTERFACE_NAMES)
-+    JSBool UseStubEqualityHook()          GET_IT(USE_STUB_EQUALITY_HOOK)
++    bool WantPreCreate()                GET_IT(WANT_PRECREATE)
++    bool WantCreate()                   GET_IT(WANT_CREATE)
++    bool WantPostCreate()               GET_IT(WANT_POSTCREATE)
++    bool WantAddProperty()              GET_IT(WANT_ADDPROPERTY)
++    bool WantDelProperty()              GET_IT(WANT_DELPROPERTY)
++    bool WantGetProperty()              GET_IT(WANT_GETPROPERTY)
++    bool WantSetProperty()              GET_IT(WANT_SETPROPERTY)
++    bool WantEnumerate()                GET_IT(WANT_ENUMERATE)
++    bool WantNewEnumerate()             GET_IT(WANT_NEWENUMERATE)
++    bool WantNewResolve()               GET_IT(WANT_NEWRESOLVE)
++    bool WantConvert()                  GET_IT(WANT_CONVERT)
++    bool WantFinalize()                 GET_IT(WANT_FINALIZE)
++    bool WantCheckAccess()              GET_IT(WANT_CHECKACCESS)
++    bool WantCall()                     GET_IT(WANT_CALL)
++    bool WantConstruct()                GET_IT(WANT_CONSTRUCT)
++    bool WantHasInstance()              GET_IT(WANT_HASINSTANCE)
++    bool WantEquality()                 GET_IT(WANT_EQUALITY)
++    bool WantOuterObject()              GET_IT(WANT_OUTER_OBJECT)
++    bool UseJSStubForAddProperty()      GET_IT(USE_JSSTUB_FOR_ADDPROPERTY)
++    bool UseJSStubForDelProperty()      GET_IT(USE_JSSTUB_FOR_DELPROPERTY)
++    bool UseJSStubForSetProperty()      GET_IT(USE_JSSTUB_FOR_SETPROPERTY)
++    bool DontEnumStaticProps()          GET_IT(DONT_ENUM_STATIC_PROPS)
++    bool DontEnumQueryInterface()       GET_IT(DONT_ENUM_QUERY_INTERFACE)
++    bool DontAskInstanceForScriptable() GET_IT(DONT_ASK_INSTANCE_FOR_SCRIPTABLE)
++    bool ClassInfoInterfacesOnly()      GET_IT(CLASSINFO_INTERFACES_ONLY)
++    bool AllowPropModsDuringResolve()   GET_IT(ALLOW_PROP_MODS_DURING_RESOLVE)
++    bool AllowPropModsToPrototype()     GET_IT(ALLOW_PROP_MODS_TO_PROTOTYPE)
++    bool DontReflectInterfaceNames()    GET_IT(DONT_REFLECT_INTERFACE_NAMES)
++    bool UseStubEqualityHook()          GET_IT(USE_STUB_EQUALITY_HOOK)
 +
 +#undef GET_IT
 +};
   *
   * ***** END LICENSE BLOCK ***** */
  
- /* Possibly shared proto object for XPCWrappedNative. */
+ /* Shared proto object for XPCWrappedNative. */
  
  #include "XPCCallContext.h"
  #include "XPCLock.h"
 diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h
 --- a/js/xpconnect/src/xpcprivate.h
 +++ b/js/xpconnect/src/xpcprivate.h
-@@ -151,16 +151,17 @@
+@@ -149,16 +149,17 @@
  #include "XPCLock.h"
  #include "nsXPConnect.h"
  #include "XPCJSRuntime.h"
  
  #if defined(DEBUG_jband) || defined(DEBUG_jst) || defined(DEBUG_dbradley) || defined(DEBUG_shaver_no) || defined(DEBUG_timeless)
  #define DEBUG_xpc_hacker
-@@ -445,90 +446,16 @@ enum WrapperType {
+@@ -441,88 +442,16 @@ enum WrapperType {
      XOW             = 1 << 3,
      COW             = 1 << 4,
      SOW             = 1 << 5
 -    JSBool WantCall()                     GET_IT(WANT_CALL)
 -    JSBool WantConstruct()                GET_IT(WANT_CONSTRUCT)
 -    JSBool WantHasInstance()              GET_IT(WANT_HASINSTANCE)
--    JSBool WantTrace()                    GET_IT(WANT_TRACE)
 -    JSBool WantEquality()                 GET_IT(WANT_EQUALITY)
 -    JSBool WantOuterObject()              GET_IT(WANT_OUTER_OBJECT)
 -    JSBool UseJSStubForAddProperty()      GET_IT(USE_JSSTUB_FOR_ADDPROPERTY)
 -    JSBool ClassInfoInterfacesOnly()      GET_IT(CLASSINFO_INTERFACES_ONLY)
 -    JSBool AllowPropModsDuringResolve()   GET_IT(ALLOW_PROP_MODS_DURING_RESOLVE)
 -    JSBool AllowPropModsToPrototype()     GET_IT(ALLOW_PROP_MODS_TO_PROTOTYPE)
--    JSBool DontSharePrototype()           GET_IT(DONT_SHARE_PROTOTYPE)
 -    JSBool DontReflectInterfaceNames()    GET_IT(DONT_REFLECT_INTERFACE_NAMES)
 -    JSBool UseStubEqualityHook()          GET_IT(USE_STUB_EQUALITY_HOOK)
 -

File XPCNativeSetKey

 +#include "XPCNativeSetKey.h"
  #include "xpcprivate.h"
  
+ #include "jshash.h"
+ 
  /***************************************************************************/
  // static shared...
  
  // Note this is returning the bit pattern of the first part of the nsID, not
- // the pointer to the nsID.
- 
 diff --git a/js/xpconnect/src/XPCMaps.h b/js/xpconnect/src/XPCMaps.h
 --- a/js/xpconnect/src/XPCMaps.h
 +++ b/js/xpconnect/src/XPCMaps.h
 new file mode 100644
 --- /dev/null
 +++ b/js/xpconnect/src/XPCNativeSetKey.h
-@@ -0,0 +1,58 @@
+@@ -0,0 +1,63 @@
++/* This Source Code Form is subject to the terms of the Mozilla Public
++ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
++ * You can obtain one at http://mozilla.org/MPL/2.0/. */
++
 +#ifndef XPCNativeSetKey_h
 +#define XPCNativeSetKey_h
 +
 +class XPCNativeSetKey
 +{
 +public:
-+    XPCNativeSetKey(XPCNativeSet*       aBaseSet  = nsnull,
-+                    XPCNativeInterface* aAddition = nsnull,
-+                    PRUint16            aPosition = 0)
++    XPCNativeSetKey(XPCNativeSet *aBaseSet  = NULL,
++                    XPCNativeInterface *aAddition = NULL,
++                    PRUint16 aPosition = 0)
 +        : mIsAKey(IS_A_KEY), mPosition(aPosition), mBaseSet(aBaseSet)
-+        , mAddition(aAddition) {}
++        , mAddition(aAddition)
++    {}
 +    ~XPCNativeSetKey() {}
 +
-+    XPCNativeSet*           GetBaseSet()  const {return mBaseSet;}
-+    XPCNativeInterface*     GetAddition() const {return mAddition;}
-+    PRUint16                GetPosition() const {return mPosition;}
++    XPCNativeSet *GetBaseSet() const {return mBaseSet;}
++    XPCNativeInterface *GetAddition() const {return mAddition;}
++    PRUint16 GetPosition() const {return mPosition;}
 +
 +    // This is a fun little hack...
 +    // We build these keys only on the stack. We use them for lookup in
 +    // virtual methods and their first data member is a PRUint16. We are
 +    // confident that XPCNativeSet->mMemberCount will never be 0xffff.
 +
-+    JSBool                  IsAKey() const {return mIsAKey == IS_A_KEY;}
++    bool IsAKey() const {return mIsAKey == IS_A_KEY;}
 +
 +    enum {IS_A_KEY = 0xffff};
 +
 +    // Allow shallow copy
 +
 +private:
-+    PRUint16                mIsAKey;    // must be first data member
-+    PRUint16                mPosition;
-+    XPCNativeSet*           mBaseSet;
-+    XPCNativeInterface*     mAddition;
++    PRUint16 mIsAKey;    // must be first data member
++    PRUint16 mPosition;
++    XPCNativeSet *mBaseSet;
++    XPCNativeInterface *mAddition;
 +};
 +
 +#endif // XPCNativeSetKey_h
 diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h
 --- a/js/xpconnect/src/xpcprivate.h
 +++ b/js/xpconnect/src/xpcprivate.h
-@@ -446,67 +446,16 @@ enum WrapperType {
+@@ -442,67 +442,16 @@ enum WrapperType {
      COW             = 1 << 4,
      SOW             = 1 << 5
  };