js/xpconnect/idl/nsIXPCScriptable.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/xpconnect/idl/nsIXPCScriptable.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,182 @@
     1.4 +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + *
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#include "nsISupports.idl"
    1.11 +#include "nsIClassInfo.idl"
    1.12 +
    1.13 +%{C++
    1.14 +#ifdef XP_WIN
    1.15 +#undef GetClassName
    1.16 +#endif
    1.17 +
    1.18 +#include "js/TypeDecls.h"
    1.19 +
    1.20 +struct JSFreeOp;
    1.21 +%}
    1.22 +
    1.23 +interface nsIXPConnectWrappedNative;
    1.24 +
    1.25 +[ptr] native JSContextPtr(JSContext);
    1.26 +[ptr] native JSObjectPtr(JSObject);
    1.27 +[ptr] native JSValPtr(JS::Value);
    1.28 +[ptr] native JSFreeOpPtr(JSFreeOp);
    1.29 +[ref] native JSCallArgsRef(const JS::CallArgs);
    1.30 +
    1.31 +/**
    1.32 + * Note: This is not really an XPCOM interface.  For example, callers must
    1.33 + * guarantee that they set the *_retval of the various methods that return a
    1.34 + * boolean to PR_TRUE before making the call.  Implementations may skip writing
    1.35 + * to *_retval unless they want to return PR_FALSE.
    1.36 + */
    1.37 +[uuid(9bae4ff5-5618-4ccd-b106-8e21e3fb64d3)]
    1.38 +interface nsIXPCScriptable : nsISupports
    1.39 +{
    1.40 +    /* bitflags used for 'flags' (only 32 bits available!) */
    1.41 +
    1.42 +    const uint32_t WANT_PRECREATE                   = 1 <<  0;
    1.43 +    const uint32_t WANT_CREATE                      = 1 <<  1;
    1.44 +    const uint32_t WANT_POSTCREATE                  = 1 <<  2;
    1.45 +    const uint32_t WANT_ADDPROPERTY                 = 1 <<  3;
    1.46 +    const uint32_t WANT_DELPROPERTY                 = 1 <<  4;
    1.47 +    const uint32_t WANT_GETPROPERTY                 = 1 <<  5;
    1.48 +    const uint32_t WANT_SETPROPERTY                 = 1 <<  6;
    1.49 +    const uint32_t WANT_ENUMERATE                   = 1 <<  7;
    1.50 +    const uint32_t WANT_NEWENUMERATE                = 1 <<  8;
    1.51 +    const uint32_t WANT_NEWRESOLVE                  = 1 <<  9;
    1.52 +    const uint32_t WANT_CONVERT                     = 1 << 10;
    1.53 +    const uint32_t WANT_FINALIZE                    = 1 << 11;
    1.54 +    // unused bit here!
    1.55 +    const uint32_t WANT_CALL                        = 1 << 13;
    1.56 +    const uint32_t WANT_CONSTRUCT                   = 1 << 14;
    1.57 +    const uint32_t WANT_HASINSTANCE                 = 1 << 15;
    1.58 +    // Unused bit here!
    1.59 +    const uint32_t USE_JSSTUB_FOR_ADDPROPERTY       = 1 << 17;
    1.60 +    const uint32_t USE_JSSTUB_FOR_DELPROPERTY       = 1 << 18;
    1.61 +    const uint32_t USE_JSSTUB_FOR_SETPROPERTY       = 1 << 19;
    1.62 +    const uint32_t DONT_ENUM_STATIC_PROPS           = 1 << 20;
    1.63 +    const uint32_t DONT_ENUM_QUERY_INTERFACE        = 1 << 21;
    1.64 +    const uint32_t DONT_ASK_INSTANCE_FOR_SCRIPTABLE = 1 << 22;
    1.65 +    const uint32_t CLASSINFO_INTERFACES_ONLY        = 1 << 23;
    1.66 +    const uint32_t ALLOW_PROP_MODS_DURING_RESOLVE   = 1 << 24;
    1.67 +    const uint32_t ALLOW_PROP_MODS_TO_PROTOTYPE     = 1 << 25;
    1.68 +    const uint32_t IS_GLOBAL_OBJECT                 = 1 << 26;
    1.69 +    const uint32_t DONT_REFLECT_INTERFACE_NAMES     = 1 << 27;
    1.70 +    // Unused bit here!
    1.71 +    const uint32_t WANT_OUTER_OBJECT                = 1 << 29;
    1.72 +
    1.73 +    // The high order bit is RESERVED for consumers of these flags. 
    1.74 +    // No implementor of this interface should ever return flags 
    1.75 +    // with this bit set.
    1.76 +    const uint32_t RESERVED                         = 1 << 31;
    1.77 +
    1.78 +    readonly attribute string   className;
    1.79 +    [notxpcom,nostdcall] uint32_t getScriptableFlags();
    1.80 +
    1.81 +    void   preCreate(in nsISupports nativeObj, in JSContextPtr cx,
    1.82 +                     in JSObjectPtr globalObj, out JSObjectPtr parentObj);
    1.83 +
    1.84 +    void   create(in nsIXPConnectWrappedNative wrapper,
    1.85 +                  in JSContextPtr cx, in JSObjectPtr obj);
    1.86 +
    1.87 +    // Both methods here are protected by WANT_POSTCREATE. If you want to do
    1.88 +    // something after a wrapper is created, there's a good chance you also
    1.89 +    // want to do something when the wrapper is transplanted to a new
    1.90 +    // compartment.
    1.91 +    void   postCreate(in nsIXPConnectWrappedNative wrapper,
    1.92 +                      in JSContextPtr cx, in JSObjectPtr obj);
    1.93 +
    1.94 +    void postTransplant(in nsIXPConnectWrappedNative wrapper,
    1.95 +                        in JSContextPtr cx, in JSObjectPtr obj);
    1.96 +
    1.97 +    boolean addProperty(in nsIXPConnectWrappedNative wrapper,
    1.98 +                       in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
    1.99 +                       in JSValPtr vp);
   1.100 +
   1.101 +    boolean delProperty(in nsIXPConnectWrappedNative wrapper,
   1.102 +                       in JSContextPtr cx, in JSObjectPtr obj, in jsid id);
   1.103 +
   1.104 +    // The returnCode should be set to NS_SUCCESS_I_DID_SOMETHING if
   1.105 +    // this method does something.
   1.106 +    boolean getProperty(in nsIXPConnectWrappedNative wrapper,
   1.107 +                       in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
   1.108 +                       in JSValPtr vp);
   1.109 +
   1.110 +    // The returnCode should be set to NS_SUCCESS_I_DID_SOMETHING if
   1.111 +    // this method does something.
   1.112 +    boolean setProperty(in nsIXPConnectWrappedNative wrapper,
   1.113 +                       in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
   1.114 +                       in JSValPtr vp);
   1.115 +
   1.116 +    boolean enumerate(in nsIXPConnectWrappedNative wrapper,
   1.117 +                     in JSContextPtr cx, in JSObjectPtr obj);
   1.118 +
   1.119 +    boolean newEnumerate(in nsIXPConnectWrappedNative wrapper,
   1.120 +                        in JSContextPtr cx, in JSObjectPtr obj,
   1.121 +                        in uint32_t enum_op, in JSValPtr statep, out jsid idp);
   1.122 +
   1.123 +    boolean newResolve(in nsIXPConnectWrappedNative wrapper,
   1.124 +                      in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
   1.125 +                      out JSObjectPtr objp);
   1.126 +
   1.127 +    boolean convert(in nsIXPConnectWrappedNative wrapper,
   1.128 +                   in JSContextPtr cx, in JSObjectPtr obj,
   1.129 +                   in uint32_t type, in JSValPtr vp);
   1.130 +
   1.131 +    void   finalize(in nsIXPConnectWrappedNative wrapper,
   1.132 +                    in JSFreeOpPtr fop, in JSObjectPtr obj);
   1.133 +
   1.134 +    boolean call(in nsIXPConnectWrappedNative wrapper,
   1.135 +                in JSContextPtr cx, in JSObjectPtr obj,
   1.136 +                in JSCallArgsRef args);
   1.137 +
   1.138 +    boolean construct(in nsIXPConnectWrappedNative wrapper,
   1.139 +                     in JSContextPtr cx, in JSObjectPtr obj,
   1.140 +                     in JSCallArgsRef args);
   1.141 +
   1.142 +    boolean hasInstance(in nsIXPConnectWrappedNative wrapper,
   1.143 +                       in JSContextPtr cx, in JSObjectPtr obj,
   1.144 +                       in jsval val, out boolean bp);
   1.145 +
   1.146 +    JSObjectPtr outerObject(in nsIXPConnectWrappedNative wrapper,
   1.147 +                            in JSContextPtr cx, in JSObjectPtr obj);
   1.148 +
   1.149 +    void postCreatePrototype(in JSContextPtr cx, in JSObjectPtr proto);
   1.150 +};
   1.151 +
   1.152 +%{ C++
   1.153 +
   1.154 +#include "nsAutoPtr.h"
   1.155 +
   1.156 +#define NS_XPCCLASSINFO_IID \
   1.157 +{ 0x9a5b0342, 0x0f70, 0x4d31, \
   1.158 + { 0xb7, 0xd7, 0x29, 0x68, 0xa5, 0x70, 0x4b, 0xd8 } }
   1.159 +
   1.160 +class NS_NO_VTABLE nsXPCClassInfo : public nsIClassInfo,
   1.161 +                                    public nsIXPCScriptable
   1.162 +{
   1.163 +public:
   1.164 +  NS_DECLARE_STATIC_IID_ACCESSOR(NS_XPCCLASSINFO_IID)
   1.165 +
   1.166 +  NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
   1.167 +  NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
   1.168 +
   1.169 +  virtual void PreserveWrapper(nsISupports *aNative) = 0;
   1.170 +
   1.171 +  virtual uint32_t GetInterfacesBitmap() = 0;
   1.172 +};
   1.173 +
   1.174 +NS_DEFINE_STATIC_IID_ACCESSOR(nsXPCClassInfo, NS_XPCCLASSINFO_IID)
   1.175 +
   1.176 +inline
   1.177 +nsresult
   1.178 +CallQueryInterface(nsISupports* aSourcePtr,
   1.179 +                   nsRefPtrGetterAddRefs<nsXPCClassInfo> aDestPtr)
   1.180 +{
   1.181 +  return CallQueryInterface(aSourcePtr,
   1.182 +                            static_cast<nsXPCClassInfo**>(aDestPtr));
   1.183 +}
   1.184 +
   1.185 +%}

mercurial