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
,
24 JS::ObjectOpResult
& result
);
25 bool XPC_WN_CannotDeletePropertyStub(JSContext
* cx
, JS::HandleObject obj
,
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
,
35 bool XPC_WN_Helper_Resolve(JSContext
* cx
, JS::HandleObject obj
, JS::HandleId id
,
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) \
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, \
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, \
64 ((_flags) & XPC_SCRIPTABLE_WANT_NEWENUMERATE) \
65 ? nullptr /* We will use newEnumerate set below in this case */ \
66 : XPC_WN_Shared_Enumerate, \
69 ((_flags) & XPC_SCRIPTABLE_WANT_NEWENUMERATE) ? XPC_WN_NewEnumerate \
72 /* resolve */ /* We have to figure out resolve strategy at call time \
74 XPC_WN_Helper_Resolve, \
80 ((_flags) & XPC_SCRIPTABLE_WANT_FINALIZE) ? XPC_WN_Helper_Finalize \
81 : XPC_WN_NoHelper_Finalize, \
84 ((_flags) & XPC_SCRIPTABLE_WANT_CALL) ? XPC_WN_Helper_Call : nullptr, \
87 ((_flags) & XPC_SCRIPTABLE_WANT_CONSTRUCT) ? XPC_WN_Helper_Construct \
91 ((_flags) & XPC_SCRIPTABLE_IS_GLOBAL_OBJECT) ? JS_GlobalObjectTraceHook \
92 : XPCWrappedNative_Trace, \
95 #define XPC_MAKE_CLASS(_name, _flags, _classOps) \
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)), \
114 &XPC_WN_JSClassExtension, \