1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
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/. */
7 #include
"nsISupports.idl"
8 #include
"nsIClassInfo.idl"
15 #include
"js/TypeDecls.h"
23 interface nsIXPConnectWrappedNative
;
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
>);
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.
37 #define XPC_SCRIPTABLE_WANT_PRECREATE
(1 << 0)
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)
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.
65 [uuid(19b70b26
-7c3f
-437f
-a04a
-2a8f9e28b617
)]
66 interface nsIXPCScriptable
: nsISupports
68 readonly attribute AUTF8String className
;
69 [notxpcom
,nostdcall
] uint32_t getScriptableFlags
();
70 [notxpcom
,nostdcall
] JSClassPtr getJSClass
();
72 void preCreate
(in nsISupports nativeObj
, in JSContextPtr cx
,
73 in JSObjectPtr globalObj
, out JSObjectPtr parentObj
);
75 boolean newEnumerate
(in nsIXPConnectWrappedNative wrapper
,
76 in JSContextPtr cx
, in JSObjectPtr obj
,
77 in JSMutableHandleIdVector properties
,
78 in boolean enumerableOnly
);
80 boolean resolve
(in nsIXPConnectWrappedNative wrapper
,
81 in JSContextPtr cx
, in JSObjectPtr obj
, in jsid
id,
82 out boolean resolvedp
);
84 void finalize
(in nsIXPConnectWrappedNative wrapper
,
85 in JSGCContextPtr gcx
, in JSObjectPtr obj
);
87 boolean call
(in nsIXPConnectWrappedNative wrapper
,
88 in JSContextPtr cx
, in JSObjectPtr obj
,
89 in JSCallArgsRef args
);
91 boolean construct
(in nsIXPConnectWrappedNative wrapper
,
92 in JSContextPtr cx
, in JSObjectPtr obj
,
93 in JSCallArgsRef args
);
95 boolean hasInstance
(in nsIXPConnectWrappedNative wrapper
,
96 in JSContextPtr cx
, in JSObjectPtr obj
,
97 in jsval val
, out boolean bp
);
100 #define GET_IT
(f_
, c_
) \
102 return
0 != (GetScriptableFlags
() & XPC_SCRIPTABLE_##c_
); \
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
)