Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM SVGUnitTypes.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "SVGUnitTypesBinding.h"
4 : #include "WrapperFactory.h"
5 : #include "mozilla/OwningNonNull.h"
6 : #include "mozilla/dom/BindingUtils.h"
7 : #include "mozilla/dom/DOMJSClass.h"
8 : #include "mozilla/dom/NonRefcountedDOMObject.h"
9 : #include "mozilla/dom/XrayExpandoClass.h"
10 :
11 : namespace mozilla {
12 : namespace dom {
13 :
14 : namespace SVGUnitTypesBinding {
15 :
16 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
17 : #if defined(__clang__)
18 : #pragma clang diagnostic push
19 : #pragma clang diagnostic ignored "-Wmissing-braces"
20 : #endif
21 : static const ConstantSpec sConstants_specs[] = {
22 : { "SVG_UNIT_TYPE_UNKNOWN", JS::Int32Value(0) },
23 : { "SVG_UNIT_TYPE_USERSPACEONUSE", JS::Int32Value(1) },
24 : { "SVG_UNIT_TYPE_OBJECTBOUNDINGBOX", JS::Int32Value(2) },
25 : { 0, JS::UndefinedValue() }
26 : };
27 : #if defined(__clang__)
28 : #pragma clang diagnostic pop
29 : #endif
30 :
31 :
32 : // Can't be const because the pref-enabled boolean needs to be writable
33 : static Prefable<const ConstantSpec> sConstants[] = {
34 : { nullptr, &sConstants_specs[0] },
35 : { nullptr, nullptr }
36 : };
37 :
38 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
39 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
40 : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
41 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
42 :
43 :
44 : static uint16_t sNativeProperties_sortedPropertyIndices[3];
45 : static PropertyInfo sNativeProperties_propertyInfos[3];
46 :
47 : static const NativePropertiesN<1> sNativeProperties = {
48 : false, 0,
49 : false, 0,
50 : false, 0,
51 : false, 0,
52 : false, 0,
53 : false, 0,
54 : true, 0 /* sConstants */,
55 : -1,
56 : 3,
57 : sNativeProperties_sortedPropertyIndices,
58 : {
59 : { sConstants, &sNativeProperties_propertyInfos[0] }
60 : }
61 : };
62 : static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
63 : "We have a property info count that is oversized");
64 :
65 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
66 : {
67 : "Function",
68 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
69 : &sBoringInterfaceObjectClassClassOps,
70 : JS_NULL_CLASS_SPEC,
71 : JS_NULL_CLASS_EXT,
72 : &sInterfaceObjectClassObjectOps
73 : },
74 : eInterface,
75 : false,
76 : prototypes::id::_ID_Count,
77 : 0,
78 : sNativePropertyHooks,
79 : "function SVGUnitTypes() {\n [native code]\n}",
80 : JS::GetRealmFunctionPrototype
81 : };
82 :
83 : JSObject*
84 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
85 : {
86 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
87 : }
88 :
89 : const NativePropertyHooks sNativePropertyHooks[] = { {
90 : nullptr,
91 : nullptr,
92 : nullptr,
93 : { sNativeProperties.Upcast(), nullptr },
94 : prototypes::id::_ID_Count,
95 : constructors::id::SVGUnitTypes,
96 : nullptr,
97 : &DefaultXrayExpandoObjectClass
98 : } };
99 :
100 : void
101 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
102 : {
103 0 : JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
104 0 : if (!constructorProto) {
105 0 : return;
106 : }
107 :
108 : static bool sIdsInited = false;
109 0 : if (!sIdsInited && NS_IsMainThread()) {
110 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
111 0 : return;
112 : }
113 0 : sIdsInited = true;
114 : }
115 :
116 0 : JS::Heap<JSObject*>* protoCache = nullptr;
117 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGUnitTypes);
118 0 : dom::CreateInterfaceObjects(aCx, aGlobal, nullptr,
119 : nullptr, protoCache,
120 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
121 : interfaceCache,
122 : sNativeProperties.Upcast(),
123 : nullptr,
124 : "SVGUnitTypes", aDefineOnGlobal,
125 : nullptr,
126 0 : false);
127 : }
128 :
129 : JS::Handle<JSObject*>
130 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
131 : {
132 : /* Get the interface object for this class. This will create the object as
133 : needed. */
134 :
135 : /* Make sure our global is sane. Hopefully we can remove this sometime */
136 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
137 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
138 0 : return nullptr;
139 : }
140 :
141 : /* Check to see whether the interface objects are already installed */
142 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
143 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::SVGUnitTypes)) {
144 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
145 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
146 : }
147 :
148 : /*
149 : * The object might _still_ be null, but that's OK.
150 : *
151 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
152 : * traced by TraceProtoAndIfaceCache() and its contents are never
153 : * changed after they have been set.
154 : *
155 : * Calling address() avoids the read read barrier that does gray
156 : * unmarking, but it's not possible for the object to be gray here.
157 : */
158 :
159 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::SVGUnitTypes);
160 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
161 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
162 : }
163 :
164 : JSObject*
165 0 : GetConstructorObject(JSContext* aCx)
166 : {
167 0 : return GetConstructorObjectHandle(aCx);
168 : }
169 :
170 : } // namespace SVGUnitTypesBinding
171 :
172 :
173 :
174 : } // namespace dom
175 : } // namespace mozilla
|