tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsIXPCScriptable.idl (4754B)


      1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
      2 *
      3 * This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "nsISupports.idl"
      8 #include "nsIClassInfo.idl"
      9 
     10 %{C++
     11 #ifdef XP_WIN
     12 #undef GetClassName
     13 #endif
     14 
     15 #include "js/TypeDecls.h"
     16 
     17 namespace JS {
     18 class CallArgs;
     19 }
     20 
     21 %}
     22 
     23 interface nsIXPConnectWrappedNative;
     24 
     25 [ptr] native JSContextPtr(JSContext);
     26 [ptr] native JSObjectPtr(JSObject);
     27 [ptr] native JSValPtr(JS::Value);
     28 [ptr] native JSGCContextPtr(JS::GCContext);
     29 [ref] native JSCallArgsRef(const JS::CallArgs);
     30 [ptr] native JSClassPtr(const JSClass);
     31      native JSMutableHandleIdVector(JS::MutableHandleVector<JS::PropertyKey>);
     32 
     33 %{ C++
     34    // nsIXPCScriptable flags (only 32 bits available!). They are defined via
     35    // #defines so they can be used in #ifndef guards in xpc_map_end.h.
     36 
     37    #define XPC_SCRIPTABLE_WANT_PRECREATE                   (1 <<  0)
     38    // (1 << 1) is unused
     39    // (1 << 2) is unused
     40    // (1 << 3) is unused
     41    #define XPC_SCRIPTABLE_WANT_NEWENUMERATE                (1 <<  4)
     42    #define XPC_SCRIPTABLE_WANT_RESOLVE                     (1 <<  5)
     43    #define XPC_SCRIPTABLE_WANT_FINALIZE                    (1 <<  6)
     44    #define XPC_SCRIPTABLE_WANT_CALL                        (1 <<  7)
     45    #define XPC_SCRIPTABLE_WANT_CONSTRUCT                   (1 <<  8)
     46    #define XPC_SCRIPTABLE_WANT_HASINSTANCE                 (1 <<  9)
     47    #define XPC_SCRIPTABLE_USE_JSSTUB_FOR_ADDPROPERTY       (1 << 10)
     48    #define XPC_SCRIPTABLE_USE_JSSTUB_FOR_DELPROPERTY       (1 << 11)
     49    // (1 << 12) is unused
     50    #define XPC_SCRIPTABLE_DONT_ENUM_QUERY_INTERFACE        (1 << 13)
     51    // (1 << 14) is unused
     52    // (1 << 15) is unused
     53    #define XPC_SCRIPTABLE_ALLOW_PROP_MODS_DURING_RESOLVE   (1 << 16)
     54    // (1 << 17) is unused
     55    #define XPC_SCRIPTABLE_IS_GLOBAL_OBJECT                 (1 << 18)
     56    #define XPC_SCRIPTABLE_DONT_REFLECT_INTERFACE_NAMES     (1 << 19)
     57 %}
     58 
     59 /**
     60 * Note: This is not really an XPCOM interface.  For example, callers must
     61 * guarantee that they set the *_retval of the various methods that return a
     62 * boolean to PR_TRUE before making the call.  Implementations may skip writing
     63 * to *_retval unless they want to return PR_FALSE.
     64 */
     65 [uuid(19b70b26-7c3f-437f-a04a-2a8f9e28b617)]
     66 interface nsIXPCScriptable : nsISupports
     67 {
     68    readonly attribute AUTF8String className;
     69    [notxpcom,nostdcall] uint32_t getScriptableFlags();
     70    [notxpcom,nostdcall] JSClassPtr getJSClass();
     71 
     72    void   preCreate(in nsISupports nativeObj, in JSContextPtr cx,
     73                     in JSObjectPtr globalObj, out JSObjectPtr parentObj);
     74 
     75    boolean newEnumerate(in nsIXPConnectWrappedNative wrapper,
     76                         in JSContextPtr cx, in JSObjectPtr obj,
     77                         in JSMutableHandleIdVector properties,
     78                         in boolean enumerableOnly);
     79 
     80    boolean resolve(in nsIXPConnectWrappedNative wrapper,
     81                    in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
     82                    out boolean resolvedp);
     83 
     84    void   finalize(in nsIXPConnectWrappedNative wrapper,
     85                    in JSGCContextPtr gcx, in JSObjectPtr obj);
     86 
     87    boolean call(in nsIXPConnectWrappedNative wrapper,
     88                 in JSContextPtr cx, in JSObjectPtr obj,
     89                 in JSCallArgsRef args);
     90 
     91    boolean construct(in nsIXPConnectWrappedNative wrapper,
     92                      in JSContextPtr cx, in JSObjectPtr obj,
     93                      in JSCallArgsRef args);
     94 
     95    boolean hasInstance(in nsIXPConnectWrappedNative wrapper,
     96                        in JSContextPtr cx, in JSObjectPtr obj,
     97                        in jsval val, out boolean bp);
     98 
     99 %{ C++
    100    #define GET_IT(f_, c_) \
    101    bool f_() { \
    102        return 0 != (GetScriptableFlags() & XPC_SCRIPTABLE_##c_); \
    103    }
    104 
    105    GET_IT(WantPreCreate,                WANT_PRECREATE)
    106    GET_IT(WantNewEnumerate,             WANT_NEWENUMERATE)
    107    GET_IT(WantResolve,                  WANT_RESOLVE)
    108    GET_IT(WantFinalize,                 WANT_FINALIZE)
    109    GET_IT(WantCall,                     WANT_CALL)
    110    GET_IT(WantConstruct,                WANT_CONSTRUCT)
    111    GET_IT(WantHasInstance,              WANT_HASINSTANCE)
    112    GET_IT(UseJSStubForAddProperty,      USE_JSSTUB_FOR_ADDPROPERTY)
    113    GET_IT(UseJSStubForDelProperty,      USE_JSSTUB_FOR_DELPROPERTY)
    114    GET_IT(DontEnumQueryInterface,       DONT_ENUM_QUERY_INTERFACE)
    115    GET_IT(AllowPropModsDuringResolve,   ALLOW_PROP_MODS_DURING_RESOLVE)
    116    GET_IT(IsGlobalObject,               IS_GLOBAL_OBJECT)
    117    GET_IT(DontReflectInterfaceNames,    DONT_REFLECT_INTERFACE_NAMES)
    118 
    119    #undef GET_IT
    120 %}
    121 };