Bug 1928997: Update tabs icon in Unified Search popup r=desktop-theme-reviewers,daleh...
[gecko.git] / js / xpconnect / public / xpc_make_class.h
blobb00265675ea3a3fc279d44833a40babc6f44d113
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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 #ifndef xpc_make_class_h
8 #define xpc_make_class_h
10 // This file should be used to create JSClass instances for nsIXPCScriptable
11 // instances. This includes any file that uses xpc_map_end.h.
13 #include "xpcpublic.h"
14 #include "mozilla/dom/DOMJSClass.h"
16 bool XPC_WN_MaybeResolvingPropertyStub(JSContext* cx, JS::HandleObject obj,
17 JS::HandleId id, JS::HandleValue v);
18 bool XPC_WN_CannotModifyPropertyStub(JSContext* cx, JS::HandleObject obj,
19 JS::HandleId id, JS::HandleValue v);
21 bool XPC_WN_MaybeResolvingDeletePropertyStub(JSContext* cx,
22 JS::HandleObject obj,
23 JS::HandleId id,
24 JS::ObjectOpResult& result);
25 bool XPC_WN_CannotDeletePropertyStub(JSContext* cx, JS::HandleObject obj,
26 JS::HandleId id,
27 JS::ObjectOpResult& result);
29 bool XPC_WN_Shared_Enumerate(JSContext* cx, JS::HandleObject obj);
31 bool XPC_WN_NewEnumerate(JSContext* cx, JS::HandleObject obj,
32 JS::MutableHandleIdVector properties,
33 bool enumerableOnly);
35 bool XPC_WN_Helper_Resolve(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
36 bool* resolvedp);
38 void XPC_WN_Helper_Finalize(JS::GCContext* gcx, JSObject* obj);
39 void XPC_WN_NoHelper_Finalize(JS::GCContext* gcx, JSObject* obj);
41 bool XPC_WN_Helper_Call(JSContext* cx, unsigned argc, JS::Value* vp);
43 bool XPC_WN_Helper_Construct(JSContext* cx, unsigned argc, JS::Value* vp);
45 void XPCWrappedNative_Trace(JSTracer* trc, JSObject* obj);
47 extern const js::ClassExtension XPC_WN_JSClassExtension;
49 #define XPC_MAKE_CLASS_OPS(_flags) \
50 { \
51 /* addProperty */ \
52 ((_flags) & XPC_SCRIPTABLE_USE_JSSTUB_FOR_ADDPROPERTY) ? nullptr \
53 : ((_flags) & XPC_SCRIPTABLE_ALLOW_PROP_MODS_DURING_RESOLVE) \
54 ? XPC_WN_MaybeResolvingPropertyStub \
55 : XPC_WN_CannotModifyPropertyStub, \
57 /* delProperty */ \
58 ((_flags) & XPC_SCRIPTABLE_USE_JSSTUB_FOR_DELPROPERTY) ? nullptr \
59 : ((_flags) & XPC_SCRIPTABLE_ALLOW_PROP_MODS_DURING_RESOLVE) \
60 ? XPC_WN_MaybeResolvingDeletePropertyStub \
61 : XPC_WN_CannotDeletePropertyStub, \
63 /* enumerate */ \
64 ((_flags) & XPC_SCRIPTABLE_WANT_NEWENUMERATE) \
65 ? nullptr /* We will use newEnumerate set below in this case */ \
66 : XPC_WN_Shared_Enumerate, \
68 /* newEnumerate */ \
69 ((_flags) & XPC_SCRIPTABLE_WANT_NEWENUMERATE) ? XPC_WN_NewEnumerate \
70 : nullptr, \
72 /* resolve */ /* We have to figure out resolve strategy at call time \
73 */ \
74 XPC_WN_Helper_Resolve, \
76 /* mayResolve */ \
77 nullptr, \
79 /* finalize */ \
80 ((_flags) & XPC_SCRIPTABLE_WANT_FINALIZE) ? XPC_WN_Helper_Finalize \
81 : XPC_WN_NoHelper_Finalize, \
83 /* call */ \
84 ((_flags) & XPC_SCRIPTABLE_WANT_CALL) ? XPC_WN_Helper_Call : nullptr, \
86 /* construct */ \
87 ((_flags) & XPC_SCRIPTABLE_WANT_CONSTRUCT) ? XPC_WN_Helper_Construct \
88 : nullptr, \
90 /* trace */ \
91 ((_flags) & XPC_SCRIPTABLE_IS_GLOBAL_OBJECT) ? JS_GlobalObjectTraceHook \
92 : XPCWrappedNative_Trace, \
95 #define XPC_MAKE_CLASS(_name, _flags, _classOps) \
96 { \
97 /* name */ \
98 _name, \
100 /* flags */ \
101 JSCLASS_SLOT0_IS_NSISUPPORTS | JSCLASS_IS_WRAPPED_NATIVE | \
102 JSCLASS_FOREGROUND_FINALIZE | \
103 (((_flags) & XPC_SCRIPTABLE_IS_GLOBAL_OBJECT) \
104 ? XPCONNECT_GLOBAL_FLAGS \
105 : JSCLASS_HAS_RESERVED_SLOTS(1)), \
107 /* cOps */ \
108 _classOps, \
110 /* spec */ \
111 nullptr, \
113 /* ext */ \
114 &XPC_WN_JSClassExtension, \
116 /* oOps */ \
117 nullptr, \
120 #endif