/work/obj-fuzz/dom/bindings/WebGLRenderingContextBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM WebGLRenderingContext.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AtomList.h" |
4 | | #include "WebGLActiveInfo.h" |
5 | | #include "WebGLBuffer.h" |
6 | | #include "WebGLContext.h" |
7 | | #include "WebGLExtensions.h" |
8 | | #include "WebGLFramebuffer.h" |
9 | | #include "WebGLProgram.h" |
10 | | #include "WebGLQuery.h" |
11 | | #include "WebGLRenderbuffer.h" |
12 | | #include "WebGLRenderingContextBinding.h" |
13 | | #include "WebGLShader.h" |
14 | | #include "WebGLShaderPrecisionFormat.h" |
15 | | #include "WebGLTexture.h" |
16 | | #include "WebGLUniformLocation.h" |
17 | | #include "WebGLVertexArray.h" |
18 | | #include "WrapperFactory.h" |
19 | | #include "jsapi.h" |
20 | | #include "jsfriendapi.h" |
21 | | #include "mozilla/OwningNonNull.h" |
22 | | #include "mozilla/dom/BindingUtils.h" |
23 | | #include "mozilla/dom/DOMJSClass.h" |
24 | | #include "mozilla/dom/HTMLCanvasElement.h" |
25 | | #include "mozilla/dom/HTMLImageElement.h" |
26 | | #include "mozilla/dom/HTMLVideoElement.h" |
27 | | #include "mozilla/dom/ImageBitmap.h" |
28 | | #include "mozilla/dom/ImageData.h" |
29 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
30 | | #include "mozilla/dom/Nullable.h" |
31 | | #include "mozilla/dom/OffscreenCanvas.h" |
32 | | #include "mozilla/dom/PrimitiveConversions.h" |
33 | | #include "mozilla/dom/ScriptSettings.h" |
34 | | #include "mozilla/dom/SimpleGlobalObject.h" |
35 | | #include "mozilla/dom/TypedArray.h" |
36 | | #include "mozilla/dom/UnionConversions.h" |
37 | | #include "mozilla/dom/XrayExpandoClass.h" |
38 | | #include "nsContentUtils.h" |
39 | | |
40 | | namespace mozilla { |
41 | | namespace dom { |
42 | | |
43 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
44 | | using namespace mozilla::dom::binding_detail; |
45 | | |
46 | | |
47 | | namespace WebGLPowerPreferenceValues { |
48 | | extern const EnumEntry strings[4] = { |
49 | | {"default", 7}, |
50 | | {"low-power", 9}, |
51 | | {"high-performance", 16}, |
52 | | { nullptr, 0 } |
53 | | }; |
54 | | } // namespace WebGLPowerPreferenceValues |
55 | | |
56 | | bool |
57 | | ToJSValue(JSContext* aCx, WebGLPowerPreference aArgument, JS::MutableHandle<JS::Value> aValue) |
58 | 0 | { |
59 | 0 | MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(WebGLPowerPreferenceValues::strings)); |
60 | 0 | JSString* resultStr = |
61 | 0 | JS_NewStringCopyN(aCx, WebGLPowerPreferenceValues::strings[uint32_t(aArgument)].value, |
62 | 0 | WebGLPowerPreferenceValues::strings[uint32_t(aArgument)].length); |
63 | 0 | if (!resultStr) { |
64 | 0 | return false; |
65 | 0 | } |
66 | 0 | aValue.setString(resultStr); |
67 | 0 | return true; |
68 | 0 | } |
69 | | |
70 | | |
71 | | void |
72 | | ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningHTMLCanvasElementOrOffscreenCanvas& aUnion, const char* aName, uint32_t aFlags) |
73 | 0 | { |
74 | 0 | if (aUnion.IsHTMLCanvasElement()) { |
75 | 0 | ImplCycleCollectionTraverse(aCallback, aUnion.GetAsHTMLCanvasElement(), "mHTMLCanvasElement", aFlags); |
76 | 0 | } else if (aUnion.IsOffscreenCanvas()) { |
77 | 0 | ImplCycleCollectionTraverse(aCallback, aUnion.GetAsOffscreenCanvas(), "mOffscreenCanvas", aFlags); |
78 | 0 | } |
79 | 0 | } |
80 | | |
81 | | |
82 | | void |
83 | | ImplCycleCollectionUnlink(OwningHTMLCanvasElementOrOffscreenCanvas& aUnion) |
84 | 0 | { |
85 | 0 | aUnion.Uninit(); |
86 | 0 | } |
87 | | |
88 | | |
89 | | bool |
90 | | Float32ArrayOrUnrestrictedFloatSequence::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const |
91 | 0 | { |
92 | 0 | switch (mType) { |
93 | 0 | case eUninitialized: { |
94 | 0 | return false; |
95 | 0 | break; |
96 | 0 | } |
97 | 0 | case eFloat32Array: { |
98 | 0 | rval.setObject(*mValue.mFloat32Array.Value().Obj()); |
99 | 0 | if (!MaybeWrapNonDOMObjectValue(cx, rval)) { |
100 | 0 | return false; |
101 | 0 | } |
102 | 0 | return true; |
103 | 0 | break; |
104 | 0 | } |
105 | 0 | case eUnrestrictedFloatSequence: { |
106 | 0 |
|
107 | 0 | uint32_t length = mValue.mUnrestrictedFloatSequence.Value().Length(); |
108 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
109 | 0 | if (!returnArray) { |
110 | 0 | return false; |
111 | 0 | } |
112 | 0 | // Scope for 'tmp' |
113 | 0 | { |
114 | 0 | JS::Rooted<JS::Value> tmp(cx); |
115 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
116 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
117 | 0 | // are different ways to succeed at wrapping the object. |
118 | 0 | do { |
119 | 0 | tmp.set(JS_NumberValue(double(mValue.mUnrestrictedFloatSequence.Value()[sequenceIdx0]))); |
120 | 0 | break; |
121 | 0 | } while (false); |
122 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
123 | 0 | JSPROP_ENUMERATE)) { |
124 | 0 | return false; |
125 | 0 | } |
126 | 0 | } |
127 | 0 | } |
128 | 0 | rval.setObject(*returnArray); |
129 | 0 | return true; |
130 | 0 | break; |
131 | 0 | } |
132 | 0 | default: { |
133 | 0 | return false; |
134 | 0 | break; |
135 | 0 | } |
136 | 0 | } |
137 | 0 | |
138 | 0 | return false; |
139 | 0 | } |
140 | | |
141 | | |
142 | | Float32Array& |
143 | | OwningFloat32ArrayOrUnrestrictedFloatSequence::RawSetAsFloat32Array() |
144 | 0 | { |
145 | 0 | if (mType == eFloat32Array) { |
146 | 0 | return mValue.mFloat32Array.Value(); |
147 | 0 | } |
148 | 0 | MOZ_ASSERT(mType == eUninitialized); |
149 | 0 | mType = eFloat32Array; |
150 | 0 | return mValue.mFloat32Array.SetValue(); |
151 | 0 | } |
152 | | |
153 | | Float32Array& |
154 | | OwningFloat32ArrayOrUnrestrictedFloatSequence::SetAsFloat32Array() |
155 | 0 | { |
156 | 0 | if (mType == eFloat32Array) { |
157 | 0 | return mValue.mFloat32Array.Value(); |
158 | 0 | } |
159 | 0 | Uninit(); |
160 | 0 | mType = eFloat32Array; |
161 | 0 | return mValue.mFloat32Array.SetValue(); |
162 | 0 | } |
163 | | |
164 | | bool |
165 | | OwningFloat32ArrayOrUnrestrictedFloatSequence::TrySetToFloat32Array(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl) |
166 | 0 | { |
167 | 0 | tryNext = false; |
168 | 0 | { // scope for memberSlot |
169 | 0 | Float32Array& memberSlot = RawSetAsFloat32Array(); |
170 | 0 | if (!memberSlot.Init(&value.toObject())) { |
171 | 0 | DestroyFloat32Array(); |
172 | 0 | tryNext = true; |
173 | 0 | return true; |
174 | 0 | } |
175 | 0 | } |
176 | 0 | return true; |
177 | 0 | } |
178 | | |
179 | | void |
180 | | OwningFloat32ArrayOrUnrestrictedFloatSequence::DestroyFloat32Array() |
181 | 0 | { |
182 | 0 | MOZ_ASSERT(IsFloat32Array(), "Wrong type!"); |
183 | 0 | mValue.mFloat32Array.Destroy(); |
184 | 0 | mType = eUninitialized; |
185 | 0 | } |
186 | | |
187 | | |
188 | | |
189 | | |
190 | | Sequence<float>& |
191 | | OwningFloat32ArrayOrUnrestrictedFloatSequence::RawSetAsUnrestrictedFloatSequence() |
192 | 0 | { |
193 | 0 | if (mType == eUnrestrictedFloatSequence) { |
194 | 0 | return mValue.mUnrestrictedFloatSequence.Value(); |
195 | 0 | } |
196 | 0 | MOZ_ASSERT(mType == eUninitialized); |
197 | 0 | mType = eUnrestrictedFloatSequence; |
198 | 0 | return mValue.mUnrestrictedFloatSequence.SetValue(); |
199 | 0 | } |
200 | | |
201 | | Sequence<float>& |
202 | | OwningFloat32ArrayOrUnrestrictedFloatSequence::SetAsUnrestrictedFloatSequence() |
203 | 0 | { |
204 | 0 | if (mType == eUnrestrictedFloatSequence) { |
205 | 0 | return mValue.mUnrestrictedFloatSequence.Value(); |
206 | 0 | } |
207 | 0 | Uninit(); |
208 | 0 | mType = eUnrestrictedFloatSequence; |
209 | 0 | return mValue.mUnrestrictedFloatSequence.SetValue(); |
210 | 0 | } |
211 | | |
212 | | bool |
213 | | OwningFloat32ArrayOrUnrestrictedFloatSequence::TrySetToUnrestrictedFloatSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl) |
214 | 0 | { |
215 | 0 | tryNext = false; |
216 | 0 | { // scope for memberSlot |
217 | 0 | Sequence<float>& memberSlot = RawSetAsUnrestrictedFloatSequence(); |
218 | 0 | JS::ForOfIterator iter(cx); |
219 | 0 | if (!iter.init(value, JS::ForOfIterator::AllowNonIterable)) { |
220 | 0 | return false; |
221 | 0 | } |
222 | 0 | if (!iter.valueIsIterable()) { |
223 | 0 | DestroyUnrestrictedFloatSequence(); |
224 | 0 | tryNext = true; |
225 | 0 | return true; |
226 | 0 | } |
227 | 0 | Sequence<float> &arr = memberSlot; |
228 | 0 | JS::Rooted<JS::Value> temp(cx); |
229 | 0 | while (true) { |
230 | 0 | bool done; |
231 | 0 | if (!iter.next(&temp, &done)) { |
232 | 0 | return false; |
233 | 0 | } |
234 | 0 | if (done) { |
235 | 0 | break; |
236 | 0 | } |
237 | 0 | float* slotPtr = arr.AppendElement(mozilla::fallible); |
238 | 0 | if (!slotPtr) { |
239 | 0 | JS_ReportOutOfMemory(cx); |
240 | 0 | return false; |
241 | 0 | } |
242 | 0 | float& slot = *slotPtr; |
243 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, temp, &slot)) { |
244 | 0 | return false; |
245 | 0 | } |
246 | 0 | } |
247 | 0 | } |
248 | 0 | return true; |
249 | 0 | } |
250 | | |
251 | | void |
252 | | OwningFloat32ArrayOrUnrestrictedFloatSequence::DestroyUnrestrictedFloatSequence() |
253 | 0 | { |
254 | 0 | MOZ_ASSERT(IsUnrestrictedFloatSequence(), "Wrong type!"); |
255 | 0 | mValue.mUnrestrictedFloatSequence.Destroy(); |
256 | 0 | mType = eUninitialized; |
257 | 0 | } |
258 | | |
259 | | |
260 | | |
261 | | |
262 | | void |
263 | | OwningFloat32ArrayOrUnrestrictedFloatSequence::Uninit() |
264 | | { |
265 | | switch (mType) { |
266 | | case eUninitialized: { |
267 | | break; |
268 | | } |
269 | | case eFloat32Array: { |
270 | | DestroyFloat32Array(); |
271 | | break; |
272 | | } |
273 | | case eUnrestrictedFloatSequence: { |
274 | | DestroyUnrestrictedFloatSequence(); |
275 | | break; |
276 | | } |
277 | | } |
278 | | } |
279 | | |
280 | | bool |
281 | | OwningFloat32ArrayOrUnrestrictedFloatSequence::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const |
282 | 0 | { |
283 | 0 | switch (mType) { |
284 | 0 | case eUninitialized: { |
285 | 0 | return false; |
286 | 0 | break; |
287 | 0 | } |
288 | 0 | case eFloat32Array: { |
289 | 0 | rval.setObject(*mValue.mFloat32Array.Value().Obj()); |
290 | 0 | if (!MaybeWrapNonDOMObjectValue(cx, rval)) { |
291 | 0 | return false; |
292 | 0 | } |
293 | 0 | return true; |
294 | 0 | break; |
295 | 0 | } |
296 | 0 | case eUnrestrictedFloatSequence: { |
297 | 0 |
|
298 | 0 | uint32_t length = mValue.mUnrestrictedFloatSequence.Value().Length(); |
299 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
300 | 0 | if (!returnArray) { |
301 | 0 | return false; |
302 | 0 | } |
303 | 0 | // Scope for 'tmp' |
304 | 0 | { |
305 | 0 | JS::Rooted<JS::Value> tmp(cx); |
306 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
307 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
308 | 0 | // are different ways to succeed at wrapping the object. |
309 | 0 | do { |
310 | 0 | tmp.set(JS_NumberValue(double(mValue.mUnrestrictedFloatSequence.Value()[sequenceIdx0]))); |
311 | 0 | break; |
312 | 0 | } while (false); |
313 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
314 | 0 | JSPROP_ENUMERATE)) { |
315 | 0 | return false; |
316 | 0 | } |
317 | 0 | } |
318 | 0 | } |
319 | 0 | rval.setObject(*returnArray); |
320 | 0 | return true; |
321 | 0 | break; |
322 | 0 | } |
323 | 0 | default: { |
324 | 0 | return false; |
325 | 0 | break; |
326 | 0 | } |
327 | 0 | } |
328 | 0 | |
329 | 0 | return false; |
330 | 0 | } |
331 | | |
332 | | void |
333 | | OwningFloat32ArrayOrUnrestrictedFloatSequence::TraceUnion(JSTracer* trc) |
334 | | { |
335 | | switch (mType) { |
336 | | case eFloat32Array: { |
337 | | mValue.mFloat32Array.Value().TraceSelf(trc); |
338 | | break; |
339 | | } |
340 | | default: { |
341 | | break; |
342 | | } |
343 | | } |
344 | | } |
345 | | |
346 | | |
347 | | bool |
348 | | HTMLCanvasElementOrOffscreenCanvas::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const |
349 | 0 | { |
350 | 0 | switch (mType) { |
351 | 0 | case eUninitialized: { |
352 | 0 | return false; |
353 | 0 | break; |
354 | 0 | } |
355 | 0 | case eHTMLCanvasElement: { |
356 | 0 | if (!GetOrCreateDOMReflector(cx, mValue.mHTMLCanvasElement.Value(), rval)) { |
357 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
358 | 0 | return false; |
359 | 0 | } |
360 | 0 | return true; |
361 | 0 | break; |
362 | 0 | } |
363 | 0 | case eOffscreenCanvas: { |
364 | 0 | if (!GetOrCreateDOMReflector(cx, mValue.mOffscreenCanvas.Value(), rval)) { |
365 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
366 | 0 | return false; |
367 | 0 | } |
368 | 0 | return true; |
369 | 0 | break; |
370 | 0 | } |
371 | 0 | default: { |
372 | 0 | return false; |
373 | 0 | break; |
374 | 0 | } |
375 | 0 | } |
376 | 0 | |
377 | 0 | return false; |
378 | 0 | } |
379 | | |
380 | | |
381 | | OwningNonNull<mozilla::dom::HTMLCanvasElement>& |
382 | | OwningHTMLCanvasElementOrOffscreenCanvas::RawSetAsHTMLCanvasElement() |
383 | 0 | { |
384 | 0 | if (mType == eHTMLCanvasElement) { |
385 | 0 | return mValue.mHTMLCanvasElement.Value(); |
386 | 0 | } |
387 | 0 | MOZ_ASSERT(mType == eUninitialized); |
388 | 0 | mType = eHTMLCanvasElement; |
389 | 0 | return mValue.mHTMLCanvasElement.SetValue(); |
390 | 0 | } |
391 | | |
392 | | OwningNonNull<mozilla::dom::HTMLCanvasElement>& |
393 | | OwningHTMLCanvasElementOrOffscreenCanvas::SetAsHTMLCanvasElement() |
394 | 0 | { |
395 | 0 | if (mType == eHTMLCanvasElement) { |
396 | 0 | return mValue.mHTMLCanvasElement.Value(); |
397 | 0 | } |
398 | 0 | Uninit(); |
399 | 0 | mType = eHTMLCanvasElement; |
400 | 0 | return mValue.mHTMLCanvasElement.SetValue(); |
401 | 0 | } |
402 | | |
403 | | bool |
404 | | OwningHTMLCanvasElementOrOffscreenCanvas::TrySetToHTMLCanvasElement(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl) |
405 | 0 | { |
406 | 0 | tryNext = false; |
407 | 0 | { // scope for memberSlot |
408 | 0 | OwningNonNull<mozilla::dom::HTMLCanvasElement>& memberSlot = RawSetAsHTMLCanvasElement(); |
409 | 0 | static_assert(IsRefcounted<mozilla::dom::HTMLCanvasElement>::value, "We can only store refcounted classes.");{ |
410 | 0 | nsresult rv = UnwrapObject<prototypes::id::HTMLCanvasElement, mozilla::dom::HTMLCanvasElement>(value, memberSlot); |
411 | 0 | if (NS_FAILED(rv)) { |
412 | 0 | DestroyHTMLCanvasElement(); |
413 | 0 | tryNext = true; |
414 | 0 | return true; |
415 | 0 | } |
416 | 0 | } |
417 | 0 | } |
418 | 0 | return true; |
419 | 0 | } |
420 | | |
421 | | void |
422 | | OwningHTMLCanvasElementOrOffscreenCanvas::DestroyHTMLCanvasElement() |
423 | 0 | { |
424 | 0 | MOZ_ASSERT(IsHTMLCanvasElement(), "Wrong type!"); |
425 | 0 | mValue.mHTMLCanvasElement.Destroy(); |
426 | 0 | mType = eUninitialized; |
427 | 0 | } |
428 | | |
429 | | |
430 | | |
431 | | |
432 | | OwningNonNull<mozilla::dom::OffscreenCanvas>& |
433 | | OwningHTMLCanvasElementOrOffscreenCanvas::RawSetAsOffscreenCanvas() |
434 | 0 | { |
435 | 0 | if (mType == eOffscreenCanvas) { |
436 | 0 | return mValue.mOffscreenCanvas.Value(); |
437 | 0 | } |
438 | 0 | MOZ_ASSERT(mType == eUninitialized); |
439 | 0 | mType = eOffscreenCanvas; |
440 | 0 | return mValue.mOffscreenCanvas.SetValue(); |
441 | 0 | } |
442 | | |
443 | | OwningNonNull<mozilla::dom::OffscreenCanvas>& |
444 | | OwningHTMLCanvasElementOrOffscreenCanvas::SetAsOffscreenCanvas() |
445 | 0 | { |
446 | 0 | if (mType == eOffscreenCanvas) { |
447 | 0 | return mValue.mOffscreenCanvas.Value(); |
448 | 0 | } |
449 | 0 | Uninit(); |
450 | 0 | mType = eOffscreenCanvas; |
451 | 0 | return mValue.mOffscreenCanvas.SetValue(); |
452 | 0 | } |
453 | | |
454 | | bool |
455 | | OwningHTMLCanvasElementOrOffscreenCanvas::TrySetToOffscreenCanvas(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl) |
456 | 0 | { |
457 | 0 | tryNext = false; |
458 | 0 | { // scope for memberSlot |
459 | 0 | OwningNonNull<mozilla::dom::OffscreenCanvas>& memberSlot = RawSetAsOffscreenCanvas(); |
460 | 0 | static_assert(IsRefcounted<mozilla::dom::OffscreenCanvas>::value, "We can only store refcounted classes.");{ |
461 | 0 | nsresult rv = UnwrapObject<prototypes::id::OffscreenCanvas, mozilla::dom::OffscreenCanvas>(value, memberSlot); |
462 | 0 | if (NS_FAILED(rv)) { |
463 | 0 | DestroyOffscreenCanvas(); |
464 | 0 | tryNext = true; |
465 | 0 | return true; |
466 | 0 | } |
467 | 0 | } |
468 | 0 | } |
469 | 0 | return true; |
470 | 0 | } |
471 | | |
472 | | void |
473 | | OwningHTMLCanvasElementOrOffscreenCanvas::DestroyOffscreenCanvas() |
474 | 0 | { |
475 | 0 | MOZ_ASSERT(IsOffscreenCanvas(), "Wrong type!"); |
476 | 0 | mValue.mOffscreenCanvas.Destroy(); |
477 | 0 | mType = eUninitialized; |
478 | 0 | } |
479 | | |
480 | | |
481 | | |
482 | | |
483 | | void |
484 | | OwningHTMLCanvasElementOrOffscreenCanvas::Uninit() |
485 | | { |
486 | | switch (mType) { |
487 | | case eUninitialized: { |
488 | | break; |
489 | | } |
490 | | case eHTMLCanvasElement: { |
491 | | DestroyHTMLCanvasElement(); |
492 | | break; |
493 | | } |
494 | | case eOffscreenCanvas: { |
495 | | DestroyOffscreenCanvas(); |
496 | | break; |
497 | | } |
498 | | } |
499 | | } |
500 | | |
501 | | bool |
502 | | OwningHTMLCanvasElementOrOffscreenCanvas::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const |
503 | 0 | { |
504 | 0 | switch (mType) { |
505 | 0 | case eUninitialized: { |
506 | 0 | return false; |
507 | 0 | break; |
508 | 0 | } |
509 | 0 | case eHTMLCanvasElement: { |
510 | 0 | if (!GetOrCreateDOMReflector(cx, mValue.mHTMLCanvasElement.Value(), rval)) { |
511 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
512 | 0 | return false; |
513 | 0 | } |
514 | 0 | return true; |
515 | 0 | break; |
516 | 0 | } |
517 | 0 | case eOffscreenCanvas: { |
518 | 0 | if (!GetOrCreateDOMReflector(cx, mValue.mOffscreenCanvas.Value(), rval)) { |
519 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
520 | 0 | return false; |
521 | 0 | } |
522 | 0 | return true; |
523 | 0 | break; |
524 | 0 | } |
525 | 0 | default: { |
526 | 0 | return false; |
527 | 0 | break; |
528 | 0 | } |
529 | 0 | } |
530 | 0 | |
531 | 0 | return false; |
532 | 0 | } |
533 | | |
534 | | void |
535 | | OwningHTMLCanvasElementOrOffscreenCanvas::TraceUnion(JSTracer* trc) |
536 | 0 | { |
537 | 0 | } |
538 | | |
539 | | OwningHTMLCanvasElementOrOffscreenCanvas& |
540 | | OwningHTMLCanvasElementOrOffscreenCanvas::operator=(const OwningHTMLCanvasElementOrOffscreenCanvas& aOther) |
541 | 0 | { |
542 | 0 | switch (aOther.mType) { |
543 | 0 | case eUninitialized: { |
544 | 0 | MOZ_ASSERT(mType == eUninitialized, |
545 | 0 | "We need to destroy ourselves?"); |
546 | 0 | break; |
547 | 0 | } |
548 | 0 | case eHTMLCanvasElement: { |
549 | 0 | SetAsHTMLCanvasElement() = aOther.GetAsHTMLCanvasElement(); |
550 | 0 | break; |
551 | 0 | } |
552 | 0 | case eOffscreenCanvas: { |
553 | 0 | SetAsOffscreenCanvas() = aOther.GetAsOffscreenCanvas(); |
554 | 0 | break; |
555 | 0 | } |
556 | 0 | } |
557 | 0 | return *this; |
558 | 0 | } |
559 | | |
560 | | |
561 | | bool |
562 | | Int32ArrayOrLongSequence::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const |
563 | 0 | { |
564 | 0 | switch (mType) { |
565 | 0 | case eUninitialized: { |
566 | 0 | return false; |
567 | 0 | break; |
568 | 0 | } |
569 | 0 | case eInt32Array: { |
570 | 0 | rval.setObject(*mValue.mInt32Array.Value().Obj()); |
571 | 0 | if (!MaybeWrapNonDOMObjectValue(cx, rval)) { |
572 | 0 | return false; |
573 | 0 | } |
574 | 0 | return true; |
575 | 0 | break; |
576 | 0 | } |
577 | 0 | case eLongSequence: { |
578 | 0 |
|
579 | 0 | uint32_t length = mValue.mLongSequence.Value().Length(); |
580 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
581 | 0 | if (!returnArray) { |
582 | 0 | return false; |
583 | 0 | } |
584 | 0 | // Scope for 'tmp' |
585 | 0 | { |
586 | 0 | JS::Rooted<JS::Value> tmp(cx); |
587 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
588 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
589 | 0 | // are different ways to succeed at wrapping the object. |
590 | 0 | do { |
591 | 0 | tmp.setInt32(int32_t(mValue.mLongSequence.Value()[sequenceIdx0])); |
592 | 0 | break; |
593 | 0 | } while (false); |
594 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
595 | 0 | JSPROP_ENUMERATE)) { |
596 | 0 | return false; |
597 | 0 | } |
598 | 0 | } |
599 | 0 | } |
600 | 0 | rval.setObject(*returnArray); |
601 | 0 | return true; |
602 | 0 | break; |
603 | 0 | } |
604 | 0 | default: { |
605 | 0 | return false; |
606 | 0 | break; |
607 | 0 | } |
608 | 0 | } |
609 | 0 | |
610 | 0 | return false; |
611 | 0 | } |
612 | | |
613 | | |
614 | | Int32Array& |
615 | | OwningInt32ArrayOrLongSequence::RawSetAsInt32Array() |
616 | 0 | { |
617 | 0 | if (mType == eInt32Array) { |
618 | 0 | return mValue.mInt32Array.Value(); |
619 | 0 | } |
620 | 0 | MOZ_ASSERT(mType == eUninitialized); |
621 | 0 | mType = eInt32Array; |
622 | 0 | return mValue.mInt32Array.SetValue(); |
623 | 0 | } |
624 | | |
625 | | Int32Array& |
626 | | OwningInt32ArrayOrLongSequence::SetAsInt32Array() |
627 | 0 | { |
628 | 0 | if (mType == eInt32Array) { |
629 | 0 | return mValue.mInt32Array.Value(); |
630 | 0 | } |
631 | 0 | Uninit(); |
632 | 0 | mType = eInt32Array; |
633 | 0 | return mValue.mInt32Array.SetValue(); |
634 | 0 | } |
635 | | |
636 | | bool |
637 | | OwningInt32ArrayOrLongSequence::TrySetToInt32Array(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl) |
638 | 0 | { |
639 | 0 | tryNext = false; |
640 | 0 | { // scope for memberSlot |
641 | 0 | Int32Array& memberSlot = RawSetAsInt32Array(); |
642 | 0 | if (!memberSlot.Init(&value.toObject())) { |
643 | 0 | DestroyInt32Array(); |
644 | 0 | tryNext = true; |
645 | 0 | return true; |
646 | 0 | } |
647 | 0 | } |
648 | 0 | return true; |
649 | 0 | } |
650 | | |
651 | | void |
652 | | OwningInt32ArrayOrLongSequence::DestroyInt32Array() |
653 | 0 | { |
654 | 0 | MOZ_ASSERT(IsInt32Array(), "Wrong type!"); |
655 | 0 | mValue.mInt32Array.Destroy(); |
656 | 0 | mType = eUninitialized; |
657 | 0 | } |
658 | | |
659 | | |
660 | | |
661 | | |
662 | | Sequence<int32_t>& |
663 | | OwningInt32ArrayOrLongSequence::RawSetAsLongSequence() |
664 | 0 | { |
665 | 0 | if (mType == eLongSequence) { |
666 | 0 | return mValue.mLongSequence.Value(); |
667 | 0 | } |
668 | 0 | MOZ_ASSERT(mType == eUninitialized); |
669 | 0 | mType = eLongSequence; |
670 | 0 | return mValue.mLongSequence.SetValue(); |
671 | 0 | } |
672 | | |
673 | | Sequence<int32_t>& |
674 | | OwningInt32ArrayOrLongSequence::SetAsLongSequence() |
675 | 0 | { |
676 | 0 | if (mType == eLongSequence) { |
677 | 0 | return mValue.mLongSequence.Value(); |
678 | 0 | } |
679 | 0 | Uninit(); |
680 | 0 | mType = eLongSequence; |
681 | 0 | return mValue.mLongSequence.SetValue(); |
682 | 0 | } |
683 | | |
684 | | bool |
685 | | OwningInt32ArrayOrLongSequence::TrySetToLongSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl) |
686 | 0 | { |
687 | 0 | tryNext = false; |
688 | 0 | { // scope for memberSlot |
689 | 0 | Sequence<int32_t>& memberSlot = RawSetAsLongSequence(); |
690 | 0 | JS::ForOfIterator iter(cx); |
691 | 0 | if (!iter.init(value, JS::ForOfIterator::AllowNonIterable)) { |
692 | 0 | return false; |
693 | 0 | } |
694 | 0 | if (!iter.valueIsIterable()) { |
695 | 0 | DestroyLongSequence(); |
696 | 0 | tryNext = true; |
697 | 0 | return true; |
698 | 0 | } |
699 | 0 | Sequence<int32_t> &arr = memberSlot; |
700 | 0 | JS::Rooted<JS::Value> temp(cx); |
701 | 0 | while (true) { |
702 | 0 | bool done; |
703 | 0 | if (!iter.next(&temp, &done)) { |
704 | 0 | return false; |
705 | 0 | } |
706 | 0 | if (done) { |
707 | 0 | break; |
708 | 0 | } |
709 | 0 | int32_t* slotPtr = arr.AppendElement(mozilla::fallible); |
710 | 0 | if (!slotPtr) { |
711 | 0 | JS_ReportOutOfMemory(cx); |
712 | 0 | return false; |
713 | 0 | } |
714 | 0 | int32_t& slot = *slotPtr; |
715 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, temp, &slot)) { |
716 | 0 | return false; |
717 | 0 | } |
718 | 0 | } |
719 | 0 | } |
720 | 0 | return true; |
721 | 0 | } |
722 | | |
723 | | void |
724 | | OwningInt32ArrayOrLongSequence::DestroyLongSequence() |
725 | 0 | { |
726 | 0 | MOZ_ASSERT(IsLongSequence(), "Wrong type!"); |
727 | 0 | mValue.mLongSequence.Destroy(); |
728 | 0 | mType = eUninitialized; |
729 | 0 | } |
730 | | |
731 | | |
732 | | |
733 | | |
734 | | void |
735 | | OwningInt32ArrayOrLongSequence::Uninit() |
736 | | { |
737 | | switch (mType) { |
738 | | case eUninitialized: { |
739 | | break; |
740 | | } |
741 | | case eInt32Array: { |
742 | | DestroyInt32Array(); |
743 | | break; |
744 | | } |
745 | | case eLongSequence: { |
746 | | DestroyLongSequence(); |
747 | | break; |
748 | | } |
749 | | } |
750 | | } |
751 | | |
752 | | bool |
753 | | OwningInt32ArrayOrLongSequence::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const |
754 | 0 | { |
755 | 0 | switch (mType) { |
756 | 0 | case eUninitialized: { |
757 | 0 | return false; |
758 | 0 | break; |
759 | 0 | } |
760 | 0 | case eInt32Array: { |
761 | 0 | rval.setObject(*mValue.mInt32Array.Value().Obj()); |
762 | 0 | if (!MaybeWrapNonDOMObjectValue(cx, rval)) { |
763 | 0 | return false; |
764 | 0 | } |
765 | 0 | return true; |
766 | 0 | break; |
767 | 0 | } |
768 | 0 | case eLongSequence: { |
769 | 0 |
|
770 | 0 | uint32_t length = mValue.mLongSequence.Value().Length(); |
771 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
772 | 0 | if (!returnArray) { |
773 | 0 | return false; |
774 | 0 | } |
775 | 0 | // Scope for 'tmp' |
776 | 0 | { |
777 | 0 | JS::Rooted<JS::Value> tmp(cx); |
778 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
779 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
780 | 0 | // are different ways to succeed at wrapping the object. |
781 | 0 | do { |
782 | 0 | tmp.setInt32(int32_t(mValue.mLongSequence.Value()[sequenceIdx0])); |
783 | 0 | break; |
784 | 0 | } while (false); |
785 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
786 | 0 | JSPROP_ENUMERATE)) { |
787 | 0 | return false; |
788 | 0 | } |
789 | 0 | } |
790 | 0 | } |
791 | 0 | rval.setObject(*returnArray); |
792 | 0 | return true; |
793 | 0 | break; |
794 | 0 | } |
795 | 0 | default: { |
796 | 0 | return false; |
797 | 0 | break; |
798 | 0 | } |
799 | 0 | } |
800 | 0 | |
801 | 0 | return false; |
802 | 0 | } |
803 | | |
804 | | void |
805 | | OwningInt32ArrayOrLongSequence::TraceUnion(JSTracer* trc) |
806 | | { |
807 | | switch (mType) { |
808 | | case eInt32Array: { |
809 | | mValue.mInt32Array.Value().TraceSelf(trc); |
810 | | break; |
811 | | } |
812 | | default: { |
813 | | break; |
814 | | } |
815 | | } |
816 | | } |
817 | | |
818 | | |
819 | | |
820 | | WebGLContextAttributes::WebGLContextAttributes() |
821 | 0 | { |
822 | 0 | // Safe to pass a null context if we pass a null value |
823 | 0 | Init(nullptr, JS::NullHandleValue); |
824 | 0 | } |
825 | | |
826 | | |
827 | | |
828 | | bool |
829 | | WebGLContextAttributes::InitIds(JSContext* cx, WebGLContextAttributesAtoms* atomsCache) |
830 | 0 | { |
831 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
832 | 0 |
|
833 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
834 | 0 | // uninitialized. |
835 | 0 | if (!atomsCache->stencil_id.init(cx, "stencil") || |
836 | 0 | !atomsCache->preserveDrawingBuffer_id.init(cx, "preserveDrawingBuffer") || |
837 | 0 | !atomsCache->premultipliedAlpha_id.init(cx, "premultipliedAlpha") || |
838 | 0 | !atomsCache->powerPreference_id.init(cx, "powerPreference") || |
839 | 0 | !atomsCache->failIfMajorPerformanceCaveat_id.init(cx, "failIfMajorPerformanceCaveat") || |
840 | 0 | !atomsCache->depth_id.init(cx, "depth") || |
841 | 0 | !atomsCache->antialias_id.init(cx, "antialias") || |
842 | 0 | !atomsCache->alpha_id.init(cx, "alpha")) { |
843 | 0 | return false; |
844 | 0 | } |
845 | 0 | return true; |
846 | 0 | } |
847 | | |
848 | | bool |
849 | | WebGLContextAttributes::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
850 | 0 | { |
851 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
852 | 0 | // Since in that case we will not have to do any property gets |
853 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
854 | 0 | // checkers by static analysis tools |
855 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
856 | 0 | WebGLContextAttributesAtoms* atomsCache = nullptr; |
857 | 0 | if (cx) { |
858 | 0 | atomsCache = GetAtomCache<WebGLContextAttributesAtoms>(cx); |
859 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
860 | 0 | return false; |
861 | 0 | } |
862 | 0 | } |
863 | 0 | |
864 | 0 | if (!IsConvertibleToDictionary(val)) { |
865 | 0 | return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription); |
866 | 0 | } |
867 | 0 | |
868 | 0 | bool isNull = val.isNullOrUndefined(); |
869 | 0 | // We only need these if !isNull, in which case we have |cx|. |
870 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
871 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
872 | 0 | if (!isNull) { |
873 | 0 | MOZ_ASSERT(cx); |
874 | 0 | object.emplace(cx, &val.toObject()); |
875 | 0 | temp.emplace(cx); |
876 | 0 | } |
877 | 0 | if (!isNull) { |
878 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->alpha_id, temp.ptr())) { |
879 | 0 | return false; |
880 | 0 | } |
881 | 0 | } |
882 | 0 | if (!isNull && !temp->isUndefined()) { |
883 | 0 | mAlpha.Construct(); |
884 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mAlpha.Value()))) { |
885 | 0 | return false; |
886 | 0 | } |
887 | 0 | mIsAnyMemberPresent = true; |
888 | 0 | } |
889 | 0 |
|
890 | 0 | if (!isNull) { |
891 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->antialias_id, temp.ptr())) { |
892 | 0 | return false; |
893 | 0 | } |
894 | 0 | } |
895 | 0 | if (!isNull && !temp->isUndefined()) { |
896 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mAntialias)) { |
897 | 0 | return false; |
898 | 0 | } |
899 | 0 | } else { |
900 | 0 | mAntialias = true; |
901 | 0 | } |
902 | 0 | mIsAnyMemberPresent = true; |
903 | 0 |
|
904 | 0 | if (!isNull) { |
905 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->depth_id, temp.ptr())) { |
906 | 0 | return false; |
907 | 0 | } |
908 | 0 | } |
909 | 0 | if (!isNull && !temp->isUndefined()) { |
910 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mDepth)) { |
911 | 0 | return false; |
912 | 0 | } |
913 | 0 | } else { |
914 | 0 | mDepth = true; |
915 | 0 | } |
916 | 0 | mIsAnyMemberPresent = true; |
917 | 0 |
|
918 | 0 | if (!isNull) { |
919 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->failIfMajorPerformanceCaveat_id, temp.ptr())) { |
920 | 0 | return false; |
921 | 0 | } |
922 | 0 | } |
923 | 0 | if (!isNull && !temp->isUndefined()) { |
924 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mFailIfMajorPerformanceCaveat)) { |
925 | 0 | return false; |
926 | 0 | } |
927 | 0 | } else { |
928 | 0 | mFailIfMajorPerformanceCaveat = false; |
929 | 0 | } |
930 | 0 | mIsAnyMemberPresent = true; |
931 | 0 |
|
932 | 0 | if (!isNull) { |
933 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->powerPreference_id, temp.ptr())) { |
934 | 0 | return false; |
935 | 0 | } |
936 | 0 | } |
937 | 0 | if (!isNull && !temp->isUndefined()) { |
938 | 0 | { |
939 | 0 | int index; |
940 | 0 | if (!FindEnumStringIndex<true>(cx, temp.ref(), WebGLPowerPreferenceValues::strings, "WebGLPowerPreference", "'powerPreference' member of WebGLContextAttributes", &index)) { |
941 | 0 | return false; |
942 | 0 | } |
943 | 0 | MOZ_ASSERT(index >= 0); |
944 | 0 | mPowerPreference = static_cast<WebGLPowerPreference>(index); |
945 | 0 | } |
946 | 0 | } else { |
947 | 0 | mPowerPreference = WebGLPowerPreference::Default; |
948 | 0 | } |
949 | 0 | mIsAnyMemberPresent = true; |
950 | 0 |
|
951 | 0 | if (!isNull) { |
952 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->premultipliedAlpha_id, temp.ptr())) { |
953 | 0 | return false; |
954 | 0 | } |
955 | 0 | } |
956 | 0 | if (!isNull && !temp->isUndefined()) { |
957 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mPremultipliedAlpha)) { |
958 | 0 | return false; |
959 | 0 | } |
960 | 0 | } else { |
961 | 0 | mPremultipliedAlpha = true; |
962 | 0 | } |
963 | 0 | mIsAnyMemberPresent = true; |
964 | 0 |
|
965 | 0 | if (!isNull) { |
966 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->preserveDrawingBuffer_id, temp.ptr())) { |
967 | 0 | return false; |
968 | 0 | } |
969 | 0 | } |
970 | 0 | if (!isNull && !temp->isUndefined()) { |
971 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mPreserveDrawingBuffer)) { |
972 | 0 | return false; |
973 | 0 | } |
974 | 0 | } else { |
975 | 0 | mPreserveDrawingBuffer = false; |
976 | 0 | } |
977 | 0 | mIsAnyMemberPresent = true; |
978 | 0 |
|
979 | 0 | if (!isNull) { |
980 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->stencil_id, temp.ptr())) { |
981 | 0 | return false; |
982 | 0 | } |
983 | 0 | } |
984 | 0 | if (!isNull && !temp->isUndefined()) { |
985 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mStencil)) { |
986 | 0 | return false; |
987 | 0 | } |
988 | 0 | } else { |
989 | 0 | mStencil = false; |
990 | 0 | } |
991 | 0 | mIsAnyMemberPresent = true; |
992 | 0 | return true; |
993 | 0 | } |
994 | | |
995 | | bool |
996 | | WebGLContextAttributes::Init(const nsAString& aJSON) |
997 | 0 | { |
998 | 0 | AutoJSAPI jsapi; |
999 | 0 | JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail); |
1000 | 0 | if (!cleanGlobal) { |
1001 | 0 | return false; |
1002 | 0 | } |
1003 | 0 | if (!jsapi.Init(cleanGlobal)) { |
1004 | 0 | return false; |
1005 | 0 | } |
1006 | 0 | JSContext* cx = jsapi.cx(); |
1007 | 0 | JS::Rooted<JS::Value> json(cx); |
1008 | 0 | bool ok = ParseJSON(cx, aJSON, &json); |
1009 | 0 | NS_ENSURE_TRUE(ok, false); |
1010 | 0 | return Init(cx, json); |
1011 | 0 | } |
1012 | | |
1013 | | bool |
1014 | | WebGLContextAttributes::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
1015 | 0 | { |
1016 | 0 | WebGLContextAttributesAtoms* atomsCache = GetAtomCache<WebGLContextAttributesAtoms>(cx); |
1017 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
1018 | 0 | return false; |
1019 | 0 | } |
1020 | 0 | |
1021 | 0 | JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx)); |
1022 | 0 | if (!obj) { |
1023 | 0 | return false; |
1024 | 0 | } |
1025 | 0 | rval.set(JS::ObjectValue(*obj)); |
1026 | 0 |
|
1027 | 0 | if (mAlpha.WasPassed()) { |
1028 | 0 | do { |
1029 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1030 | 0 | JS::Rooted<JS::Value> temp(cx); |
1031 | 0 | bool const & currentValue = mAlpha.InternalValue(); |
1032 | 0 | temp.setBoolean(currentValue); |
1033 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->alpha_id, temp, JSPROP_ENUMERATE)) { |
1034 | 0 | return false; |
1035 | 0 | } |
1036 | 0 | break; |
1037 | 0 | } while(false); |
1038 | 0 | } |
1039 | 0 |
|
1040 | 0 | do { |
1041 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1042 | 0 | JS::Rooted<JS::Value> temp(cx); |
1043 | 0 | bool const & currentValue = mAntialias; |
1044 | 0 | temp.setBoolean(currentValue); |
1045 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->antialias_id, temp, JSPROP_ENUMERATE)) { |
1046 | 0 | return false; |
1047 | 0 | } |
1048 | 0 | break; |
1049 | 0 | } while(false); |
1050 | 0 |
|
1051 | 0 | do { |
1052 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1053 | 0 | JS::Rooted<JS::Value> temp(cx); |
1054 | 0 | bool const & currentValue = mDepth; |
1055 | 0 | temp.setBoolean(currentValue); |
1056 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->depth_id, temp, JSPROP_ENUMERATE)) { |
1057 | 0 | return false; |
1058 | 0 | } |
1059 | 0 | break; |
1060 | 0 | } while(false); |
1061 | 0 |
|
1062 | 0 | do { |
1063 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1064 | 0 | JS::Rooted<JS::Value> temp(cx); |
1065 | 0 | bool const & currentValue = mFailIfMajorPerformanceCaveat; |
1066 | 0 | temp.setBoolean(currentValue); |
1067 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->failIfMajorPerformanceCaveat_id, temp, JSPROP_ENUMERATE)) { |
1068 | 0 | return false; |
1069 | 0 | } |
1070 | 0 | break; |
1071 | 0 | } while(false); |
1072 | 0 |
|
1073 | 0 | do { |
1074 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1075 | 0 | JS::Rooted<JS::Value> temp(cx); |
1076 | 0 | WebGLPowerPreference const & currentValue = mPowerPreference; |
1077 | 0 | if (!ToJSValue(cx, currentValue, &temp)) { |
1078 | 0 | return false; |
1079 | 0 | } |
1080 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->powerPreference_id, temp, JSPROP_ENUMERATE)) { |
1081 | 0 | return false; |
1082 | 0 | } |
1083 | 0 | break; |
1084 | 0 | } while(false); |
1085 | 0 |
|
1086 | 0 | do { |
1087 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1088 | 0 | JS::Rooted<JS::Value> temp(cx); |
1089 | 0 | bool const & currentValue = mPremultipliedAlpha; |
1090 | 0 | temp.setBoolean(currentValue); |
1091 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->premultipliedAlpha_id, temp, JSPROP_ENUMERATE)) { |
1092 | 0 | return false; |
1093 | 0 | } |
1094 | 0 | break; |
1095 | 0 | } while(false); |
1096 | 0 |
|
1097 | 0 | do { |
1098 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1099 | 0 | JS::Rooted<JS::Value> temp(cx); |
1100 | 0 | bool const & currentValue = mPreserveDrawingBuffer; |
1101 | 0 | temp.setBoolean(currentValue); |
1102 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->preserveDrawingBuffer_id, temp, JSPROP_ENUMERATE)) { |
1103 | 0 | return false; |
1104 | 0 | } |
1105 | 0 | break; |
1106 | 0 | } while(false); |
1107 | 0 |
|
1108 | 0 | do { |
1109 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
1110 | 0 | JS::Rooted<JS::Value> temp(cx); |
1111 | 0 | bool const & currentValue = mStencil; |
1112 | 0 | temp.setBoolean(currentValue); |
1113 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->stencil_id, temp, JSPROP_ENUMERATE)) { |
1114 | 0 | return false; |
1115 | 0 | } |
1116 | 0 | break; |
1117 | 0 | } while(false); |
1118 | 0 |
|
1119 | 0 | return true; |
1120 | 0 | } |
1121 | | |
1122 | | bool |
1123 | | WebGLContextAttributes::ToJSON(nsAString& aJSON) const |
1124 | 0 | { |
1125 | 0 | AutoJSAPI jsapi; |
1126 | 0 | jsapi.Init(); |
1127 | 0 | JSContext *cx = jsapi.cx(); |
1128 | 0 | // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here |
1129 | 0 | // because we'll only be creating objects, in ways that have no |
1130 | 0 | // side-effects, followed by a call to JS::ToJSONMaybeSafely, |
1131 | 0 | // which likewise guarantees no side-effects for the sorts of |
1132 | 0 | // things we will pass it. |
1133 | 0 | JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal()); |
1134 | 0 | JS::Rooted<JS::Value> val(cx); |
1135 | 0 | if (!ToObjectInternal(cx, &val)) { |
1136 | 0 | return false; |
1137 | 0 | } |
1138 | 0 | JS::Rooted<JSObject*> obj(cx, &val.toObject()); |
1139 | 0 | return StringifyToJSON(cx, obj, aJSON); |
1140 | 0 | } |
1141 | | |
1142 | | void |
1143 | | WebGLContextAttributes::TraceDictionary(JSTracer* trc) |
1144 | 0 | { |
1145 | 0 | } |
1146 | | |
1147 | | WebGLContextAttributes& |
1148 | | WebGLContextAttributes::operator=(const WebGLContextAttributes& aOther) |
1149 | 0 | { |
1150 | 0 | DictionaryBase::operator=(aOther); |
1151 | 0 | mAlpha.Reset(); |
1152 | 0 | if (aOther.mAlpha.WasPassed()) { |
1153 | 0 | mAlpha.Construct(aOther.mAlpha.Value()); |
1154 | 0 | } |
1155 | 0 | mAntialias = aOther.mAntialias; |
1156 | 0 | mDepth = aOther.mDepth; |
1157 | 0 | mFailIfMajorPerformanceCaveat = aOther.mFailIfMajorPerformanceCaveat; |
1158 | 0 | mPowerPreference = aOther.mPowerPreference; |
1159 | 0 | mPremultipliedAlpha = aOther.mPremultipliedAlpha; |
1160 | 0 | mPreserveDrawingBuffer = aOther.mPreserveDrawingBuffer; |
1161 | 0 | mStencil = aOther.mStencil; |
1162 | 0 | return *this; |
1163 | 0 | } |
1164 | | |
1165 | | namespace binding_detail { |
1166 | | } // namespace binding_detail |
1167 | | |
1168 | | |
1169 | | namespace ANGLE_instanced_arrays_Binding { |
1170 | | |
1171 | | MOZ_CAN_RUN_SCRIPT static bool |
1172 | | drawArraysInstancedANGLE(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionInstancedArrays* self, const JSJitMethodCallArgs& args) |
1173 | 0 | { |
1174 | 0 | AUTO_PROFILER_LABEL_FAST("ANGLE_instanced_arrays.drawArraysInstancedANGLE", DOM, cx); |
1175 | 0 |
|
1176 | 0 | if (MOZ_UNLIKELY(args.length() < 4)) { |
1177 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ANGLE_instanced_arrays.drawArraysInstancedANGLE"); |
1178 | 0 | } |
1179 | 0 | uint32_t arg0; |
1180 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
1181 | 0 | return false; |
1182 | 0 | } |
1183 | 0 | int32_t arg1; |
1184 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
1185 | 0 | return false; |
1186 | 0 | } |
1187 | 0 | int32_t arg2; |
1188 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
1189 | 0 | return false; |
1190 | 0 | } |
1191 | 0 | int32_t arg3; |
1192 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[3], &arg3)) { |
1193 | 0 | return false; |
1194 | 0 | } |
1195 | 0 | self->DrawArraysInstancedANGLE(arg0, arg1, arg2, arg3); |
1196 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1197 | 0 | args.rval().setUndefined(); |
1198 | 0 | return true; |
1199 | 0 | } |
1200 | | |
1201 | | static const JSJitInfo drawArraysInstancedANGLE_methodinfo = { |
1202 | | { (JSJitGetterOp)drawArraysInstancedANGLE }, |
1203 | | { prototypes::id::ANGLE_instanced_arrays }, |
1204 | | { PrototypeTraits<prototypes::id::ANGLE_instanced_arrays>::Depth }, |
1205 | | JSJitInfo::Method, |
1206 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1207 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1208 | | false, /* isInfallible. False in setters. */ |
1209 | | false, /* isMovable. Not relevant for setters. */ |
1210 | | false, /* isEliminatable. Not relevant for setters. */ |
1211 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1212 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1213 | | false, /* isTypedMethod. Only relevant for methods. */ |
1214 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1215 | | }; |
1216 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1217 | | static_assert(0 < 1, "There is no slot for us"); |
1218 | | |
1219 | | MOZ_CAN_RUN_SCRIPT static bool |
1220 | | drawElementsInstancedANGLE(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionInstancedArrays* self, const JSJitMethodCallArgs& args) |
1221 | 0 | { |
1222 | 0 | AUTO_PROFILER_LABEL_FAST("ANGLE_instanced_arrays.drawElementsInstancedANGLE", DOM, cx); |
1223 | 0 |
|
1224 | 0 | if (MOZ_UNLIKELY(args.length() < 5)) { |
1225 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ANGLE_instanced_arrays.drawElementsInstancedANGLE"); |
1226 | 0 | } |
1227 | 0 | uint32_t arg0; |
1228 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
1229 | 0 | return false; |
1230 | 0 | } |
1231 | 0 | int32_t arg1; |
1232 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
1233 | 0 | return false; |
1234 | 0 | } |
1235 | 0 | uint32_t arg2; |
1236 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) { |
1237 | 0 | return false; |
1238 | 0 | } |
1239 | 0 | int64_t arg3; |
1240 | 0 | if (!ValueToPrimitive<int64_t, eDefault>(cx, args[3], &arg3)) { |
1241 | 0 | return false; |
1242 | 0 | } |
1243 | 0 | int32_t arg4; |
1244 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) { |
1245 | 0 | return false; |
1246 | 0 | } |
1247 | 0 | self->DrawElementsInstancedANGLE(arg0, arg1, arg2, arg3, arg4); |
1248 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1249 | 0 | args.rval().setUndefined(); |
1250 | 0 | return true; |
1251 | 0 | } |
1252 | | |
1253 | | static const JSJitInfo drawElementsInstancedANGLE_methodinfo = { |
1254 | | { (JSJitGetterOp)drawElementsInstancedANGLE }, |
1255 | | { prototypes::id::ANGLE_instanced_arrays }, |
1256 | | { PrototypeTraits<prototypes::id::ANGLE_instanced_arrays>::Depth }, |
1257 | | JSJitInfo::Method, |
1258 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1259 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1260 | | false, /* isInfallible. False in setters. */ |
1261 | | false, /* isMovable. Not relevant for setters. */ |
1262 | | false, /* isEliminatable. Not relevant for setters. */ |
1263 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1264 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1265 | | false, /* isTypedMethod. Only relevant for methods. */ |
1266 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1267 | | }; |
1268 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1269 | | static_assert(0 < 1, "There is no slot for us"); |
1270 | | |
1271 | | MOZ_CAN_RUN_SCRIPT static bool |
1272 | | vertexAttribDivisorANGLE(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionInstancedArrays* self, const JSJitMethodCallArgs& args) |
1273 | 0 | { |
1274 | 0 | AUTO_PROFILER_LABEL_FAST("ANGLE_instanced_arrays.vertexAttribDivisorANGLE", DOM, cx); |
1275 | 0 |
|
1276 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
1277 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ANGLE_instanced_arrays.vertexAttribDivisorANGLE"); |
1278 | 0 | } |
1279 | 0 | uint32_t arg0; |
1280 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
1281 | 0 | return false; |
1282 | 0 | } |
1283 | 0 | uint32_t arg1; |
1284 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
1285 | 0 | return false; |
1286 | 0 | } |
1287 | 0 | self->VertexAttribDivisorANGLE(arg0, arg1); |
1288 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1289 | 0 | args.rval().setUndefined(); |
1290 | 0 | return true; |
1291 | 0 | } |
1292 | | |
1293 | | static const JSJitInfo vertexAttribDivisorANGLE_methodinfo = { |
1294 | | { (JSJitGetterOp)vertexAttribDivisorANGLE }, |
1295 | | { prototypes::id::ANGLE_instanced_arrays }, |
1296 | | { PrototypeTraits<prototypes::id::ANGLE_instanced_arrays>::Depth }, |
1297 | | JSJitInfo::Method, |
1298 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1299 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1300 | | false, /* isInfallible. False in setters. */ |
1301 | | false, /* isMovable. Not relevant for setters. */ |
1302 | | false, /* isEliminatable. Not relevant for setters. */ |
1303 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1304 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1305 | | false, /* isTypedMethod. Only relevant for methods. */ |
1306 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1307 | | }; |
1308 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1309 | | static_assert(0 < 1, "There is no slot for us"); |
1310 | | |
1311 | | static bool |
1312 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
1313 | 0 | { |
1314 | 0 | mozilla::WebGLExtensionInstancedArrays* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionInstancedArrays>(obj); |
1315 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
1316 | 0 | // obviously can't preserve if we're not initialized. |
1317 | 0 | if (self && self->GetWrapperPreserveColor()) { |
1318 | 0 | PreserveWrapper(self); |
1319 | 0 | } |
1320 | 0 | return true; |
1321 | 0 | } |
1322 | | |
1323 | | static void |
1324 | | _finalize(js::FreeOp* fop, JSObject* obj) |
1325 | 0 | { |
1326 | 0 | mozilla::WebGLExtensionInstancedArrays* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionInstancedArrays>(obj); |
1327 | 0 | if (self) { |
1328 | 0 | ClearWrapper(self, self, obj); |
1329 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionInstancedArrays>(self); |
1330 | 0 | } |
1331 | 0 | } |
1332 | | |
1333 | | static size_t |
1334 | | _objectMoved(JSObject* obj, JSObject* old) |
1335 | 0 | { |
1336 | 0 | mozilla::WebGLExtensionInstancedArrays* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionInstancedArrays>(obj); |
1337 | 0 | if (self) { |
1338 | 0 | UpdateWrapper(self, self, obj, old); |
1339 | 0 | } |
1340 | 0 |
|
1341 | 0 | return 0; |
1342 | 0 | } |
1343 | | |
1344 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1345 | | #if defined(__clang__) |
1346 | | #pragma clang diagnostic push |
1347 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1348 | | #endif |
1349 | | static const JSFunctionSpec sMethods_specs[] = { |
1350 | | JS_FNSPEC("drawArraysInstancedANGLE", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&drawArraysInstancedANGLE_methodinfo), 4, JSPROP_ENUMERATE, nullptr), |
1351 | | JS_FNSPEC("drawElementsInstancedANGLE", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&drawElementsInstancedANGLE_methodinfo), 5, JSPROP_ENUMERATE, nullptr), |
1352 | | JS_FNSPEC("vertexAttribDivisorANGLE", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&vertexAttribDivisorANGLE_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
1353 | | JS_FS_END |
1354 | | }; |
1355 | | #if defined(__clang__) |
1356 | | #pragma clang diagnostic pop |
1357 | | #endif |
1358 | | |
1359 | | |
1360 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
1361 | | { nullptr, &sMethods_specs[0] }, |
1362 | | { nullptr, nullptr } |
1363 | | }; |
1364 | | |
1365 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1366 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1367 | | static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1368 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1369 | | |
1370 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1371 | | #if defined(__clang__) |
1372 | | #pragma clang diagnostic push |
1373 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1374 | | #endif |
1375 | | static const ConstantSpec sConstants_specs[] = { |
1376 | | { "VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE", JS::NumberValue(35070U) }, |
1377 | | { 0, JS::UndefinedValue() } |
1378 | | }; |
1379 | | #if defined(__clang__) |
1380 | | #pragma clang diagnostic pop |
1381 | | #endif |
1382 | | |
1383 | | |
1384 | | static const Prefable<const ConstantSpec> sConstants[] = { |
1385 | | { nullptr, &sConstants_specs[0] }, |
1386 | | { nullptr, nullptr } |
1387 | | }; |
1388 | | |
1389 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1390 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1391 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1392 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1393 | | |
1394 | | |
1395 | | static uint16_t sNativeProperties_sortedPropertyIndices[4]; |
1396 | | static PropertyInfo sNativeProperties_propertyInfos[4]; |
1397 | | |
1398 | | static const NativePropertiesN<2> sNativeProperties = { |
1399 | | false, 0, |
1400 | | false, 0, |
1401 | | true, 0 /* sMethods */, |
1402 | | false, 0, |
1403 | | false, 0, |
1404 | | false, 0, |
1405 | | true, 1 /* sConstants */, |
1406 | | -1, |
1407 | | 4, |
1408 | | sNativeProperties_sortedPropertyIndices, |
1409 | | { |
1410 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
1411 | | { sConstants, &sNativeProperties_propertyInfos[3] } |
1412 | | } |
1413 | | }; |
1414 | | static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
1415 | | "We have a property info count that is oversized"); |
1416 | | |
1417 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
1418 | | { |
1419 | | "ANGLE_instanced_arraysPrototype", |
1420 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
1421 | | JS_NULL_CLASS_OPS, |
1422 | | JS_NULL_CLASS_SPEC, |
1423 | | JS_NULL_CLASS_EXT, |
1424 | | JS_NULL_OBJECT_OPS |
1425 | | }, |
1426 | | eInterfacePrototype, |
1427 | | false, |
1428 | | prototypes::id::ANGLE_instanced_arrays, |
1429 | | PrototypeTraits<prototypes::id::ANGLE_instanced_arrays>::Depth, |
1430 | | sNativePropertyHooks, |
1431 | | "[object ANGLE_instanced_arraysPrototype]", |
1432 | | JS::GetRealmObjectPrototype |
1433 | | }; |
1434 | | |
1435 | | static const js::ClassOps sClassOps = { |
1436 | | _addProperty, /* addProperty */ |
1437 | | nullptr, /* delProperty */ |
1438 | | nullptr, /* enumerate */ |
1439 | | nullptr, /* newEnumerate */ |
1440 | | nullptr, /* resolve */ |
1441 | | nullptr, /* mayResolve */ |
1442 | | _finalize, /* finalize */ |
1443 | | nullptr, /* call */ |
1444 | | nullptr, /* hasInstance */ |
1445 | | nullptr, /* construct */ |
1446 | | nullptr, /* trace */ |
1447 | | }; |
1448 | | |
1449 | | static const js::ClassExtension sClassExtension = { |
1450 | | nullptr, /* weakmapKeyDelegateOp */ |
1451 | | _objectMoved /* objectMovedOp */ |
1452 | | }; |
1453 | | |
1454 | | static const DOMJSClass sClass = { |
1455 | | { "ANGLE_instanced_arrays", |
1456 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
1457 | | &sClassOps, |
1458 | | JS_NULL_CLASS_SPEC, |
1459 | | &sClassExtension, |
1460 | | JS_NULL_OBJECT_OPS |
1461 | | }, |
1462 | | { prototypes::id::ANGLE_instanced_arrays, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
1463 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionInstancedArrays >::value, |
1464 | | sNativePropertyHooks, |
1465 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionInstancedArrays>::Get, |
1466 | | GetProtoObjectHandle, |
1467 | | GetCCParticipant<mozilla::WebGLExtensionInstancedArrays>::Get() |
1468 | | }; |
1469 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
1470 | | "Must have the right minimal number of reserved slots."); |
1471 | | static_assert(1 >= 1, |
1472 | | "Must have enough reserved slots."); |
1473 | | |
1474 | | const JSClass* |
1475 | | GetJSClass() |
1476 | 0 | { |
1477 | 0 | return sClass.ToJSClass(); |
1478 | 0 | } |
1479 | | |
1480 | | bool |
1481 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionInstancedArrays* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
1482 | 0 | { |
1483 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionInstancedArrays>::value, |
1484 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
1485 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionInstancedArrays*>(aObject) == |
1486 | 0 | reinterpret_cast<mozilla::WebGLExtensionInstancedArrays*>(aObject), |
1487 | 0 | "Multiple inheritance for mozilla::WebGLExtensionInstancedArrays is broken."); |
1488 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
1489 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
1490 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
1491 | 0 | "You should probably not be using Wrap() directly; use " |
1492 | 0 | "GetOrCreateDOMReflector instead"); |
1493 | 0 |
|
1494 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
1495 | 0 | "nsISupports must be on our primary inheritance chain"); |
1496 | 0 |
|
1497 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
1498 | 0 | if (!global) { |
1499 | 0 | return false; |
1500 | 0 | } |
1501 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
1502 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
1503 | 0 |
|
1504 | 0 | // That might have ended up wrapping us already, due to the wonders |
1505 | 0 | // of XBL. Check for that, and bail out as needed. |
1506 | 0 | aReflector.set(aCache->GetWrapper()); |
1507 | 0 | if (aReflector) { |
1508 | | #ifdef DEBUG |
1509 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
1510 | | #endif // DEBUG |
1511 | | return true; |
1512 | 0 | } |
1513 | 0 |
|
1514 | 0 | JSAutoRealm ar(aCx, global); |
1515 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
1516 | 0 | if (!canonicalProto) { |
1517 | 0 | return false; |
1518 | 0 | } |
1519 | 0 | JS::Rooted<JSObject*> proto(aCx); |
1520 | 0 | if (aGivenProto) { |
1521 | 0 | proto = aGivenProto; |
1522 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
1523 | 0 | // coming in, we changed compartments to that of "parent" so may need |
1524 | 0 | // to wrap the proto here. |
1525 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
1526 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
1527 | 0 | return false; |
1528 | 0 | } |
1529 | 0 | } |
1530 | 0 | } else { |
1531 | 0 | proto = canonicalProto; |
1532 | 0 | } |
1533 | 0 |
|
1534 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionInstancedArrays> creator(aCx); |
1535 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
1536 | 0 | if (!aReflector) { |
1537 | 0 | return false; |
1538 | 0 | } |
1539 | 0 | |
1540 | 0 | aCache->SetWrapper(aReflector); |
1541 | 0 | creator.InitializationSucceeded(); |
1542 | 0 |
|
1543 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
1544 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
1545 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
1546 | 0 | // otherwise we won't be able to properly recreate it later, since |
1547 | 0 | // we won't know what proto to use. Note that we don't check |
1548 | 0 | // aGivenProto here, since it's entirely possible (and even |
1549 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
1550 | 0 | // same as canonicalProto. |
1551 | 0 | if (proto != canonicalProto) { |
1552 | 0 | PreserveWrapper(aObject); |
1553 | 0 | } |
1554 | 0 |
|
1555 | 0 | return true; |
1556 | 0 | } |
1557 | | |
1558 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
1559 | | nullptr, |
1560 | | nullptr, |
1561 | | nullptr, |
1562 | | { sNativeProperties.Upcast(), nullptr }, |
1563 | | prototypes::id::ANGLE_instanced_arrays, |
1564 | | constructors::id::_ID_Count, |
1565 | | nullptr, |
1566 | | &DefaultXrayExpandoObjectClass |
1567 | | } }; |
1568 | | |
1569 | | void |
1570 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
1571 | 0 | { |
1572 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
1573 | 0 | if (!parentProto) { |
1574 | 0 | return; |
1575 | 0 | } |
1576 | 0 | |
1577 | 0 | static bool sIdsInited = false; |
1578 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
1579 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
1580 | 0 | return; |
1581 | 0 | } |
1582 | 0 | sIdsInited = true; |
1583 | 0 | } |
1584 | 0 |
|
1585 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::ANGLE_instanced_arrays); |
1586 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
1587 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
1588 | 0 | &sPrototypeClass.mBase, protoCache, |
1589 | 0 | nullptr, |
1590 | 0 | nullptr, nullptr, 0, nullptr, |
1591 | 0 | interfaceCache, |
1592 | 0 | sNativeProperties.Upcast(), |
1593 | 0 | nullptr, |
1594 | 0 | nullptr, aDefineOnGlobal, |
1595 | 0 | nullptr, |
1596 | 0 | false); |
1597 | 0 | } |
1598 | | |
1599 | | } // namespace ANGLE_instanced_arrays_Binding |
1600 | | |
1601 | | |
1602 | | |
1603 | | namespace EXT_blend_minmax_Binding { |
1604 | | |
1605 | | static bool |
1606 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
1607 | 0 | { |
1608 | 0 | mozilla::WebGLExtensionBlendMinMax* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionBlendMinMax>(obj); |
1609 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
1610 | 0 | // obviously can't preserve if we're not initialized. |
1611 | 0 | if (self && self->GetWrapperPreserveColor()) { |
1612 | 0 | PreserveWrapper(self); |
1613 | 0 | } |
1614 | 0 | return true; |
1615 | 0 | } |
1616 | | |
1617 | | static void |
1618 | | _finalize(js::FreeOp* fop, JSObject* obj) |
1619 | 0 | { |
1620 | 0 | mozilla::WebGLExtensionBlendMinMax* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionBlendMinMax>(obj); |
1621 | 0 | if (self) { |
1622 | 0 | ClearWrapper(self, self, obj); |
1623 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionBlendMinMax>(self); |
1624 | 0 | } |
1625 | 0 | } |
1626 | | |
1627 | | static size_t |
1628 | | _objectMoved(JSObject* obj, JSObject* old) |
1629 | 0 | { |
1630 | 0 | mozilla::WebGLExtensionBlendMinMax* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionBlendMinMax>(obj); |
1631 | 0 | if (self) { |
1632 | 0 | UpdateWrapper(self, self, obj, old); |
1633 | 0 | } |
1634 | 0 |
|
1635 | 0 | return 0; |
1636 | 0 | } |
1637 | | |
1638 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1639 | | #if defined(__clang__) |
1640 | | #pragma clang diagnostic push |
1641 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1642 | | #endif |
1643 | | static const ConstantSpec sConstants_specs[] = { |
1644 | | { "MIN_EXT", JS::NumberValue(32775U) }, |
1645 | | { "MAX_EXT", JS::NumberValue(32776U) }, |
1646 | | { 0, JS::UndefinedValue() } |
1647 | | }; |
1648 | | #if defined(__clang__) |
1649 | | #pragma clang diagnostic pop |
1650 | | #endif |
1651 | | |
1652 | | |
1653 | | static const Prefable<const ConstantSpec> sConstants[] = { |
1654 | | { nullptr, &sConstants_specs[0] }, |
1655 | | { nullptr, nullptr } |
1656 | | }; |
1657 | | |
1658 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1659 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1660 | | static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1661 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1662 | | |
1663 | | |
1664 | | static uint16_t sNativeProperties_sortedPropertyIndices[2]; |
1665 | | static PropertyInfo sNativeProperties_propertyInfos[2]; |
1666 | | |
1667 | | static const NativePropertiesN<1> sNativeProperties = { |
1668 | | false, 0, |
1669 | | false, 0, |
1670 | | false, 0, |
1671 | | false, 0, |
1672 | | false, 0, |
1673 | | false, 0, |
1674 | | true, 0 /* sConstants */, |
1675 | | -1, |
1676 | | 2, |
1677 | | sNativeProperties_sortedPropertyIndices, |
1678 | | { |
1679 | | { sConstants, &sNativeProperties_propertyInfos[0] } |
1680 | | } |
1681 | | }; |
1682 | | static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
1683 | | "We have a property info count that is oversized"); |
1684 | | |
1685 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
1686 | | { |
1687 | | "EXT_blend_minmaxPrototype", |
1688 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
1689 | | JS_NULL_CLASS_OPS, |
1690 | | JS_NULL_CLASS_SPEC, |
1691 | | JS_NULL_CLASS_EXT, |
1692 | | JS_NULL_OBJECT_OPS |
1693 | | }, |
1694 | | eInterfacePrototype, |
1695 | | false, |
1696 | | prototypes::id::EXT_blend_minmax, |
1697 | | PrototypeTraits<prototypes::id::EXT_blend_minmax>::Depth, |
1698 | | sNativePropertyHooks, |
1699 | | "[object EXT_blend_minmaxPrototype]", |
1700 | | JS::GetRealmObjectPrototype |
1701 | | }; |
1702 | | |
1703 | | static const js::ClassOps sClassOps = { |
1704 | | _addProperty, /* addProperty */ |
1705 | | nullptr, /* delProperty */ |
1706 | | nullptr, /* enumerate */ |
1707 | | nullptr, /* newEnumerate */ |
1708 | | nullptr, /* resolve */ |
1709 | | nullptr, /* mayResolve */ |
1710 | | _finalize, /* finalize */ |
1711 | | nullptr, /* call */ |
1712 | | nullptr, /* hasInstance */ |
1713 | | nullptr, /* construct */ |
1714 | | nullptr, /* trace */ |
1715 | | }; |
1716 | | |
1717 | | static const js::ClassExtension sClassExtension = { |
1718 | | nullptr, /* weakmapKeyDelegateOp */ |
1719 | | _objectMoved /* objectMovedOp */ |
1720 | | }; |
1721 | | |
1722 | | static const DOMJSClass sClass = { |
1723 | | { "EXT_blend_minmax", |
1724 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
1725 | | &sClassOps, |
1726 | | JS_NULL_CLASS_SPEC, |
1727 | | &sClassExtension, |
1728 | | JS_NULL_OBJECT_OPS |
1729 | | }, |
1730 | | { prototypes::id::EXT_blend_minmax, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
1731 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionBlendMinMax >::value, |
1732 | | sNativePropertyHooks, |
1733 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionBlendMinMax>::Get, |
1734 | | GetProtoObjectHandle, |
1735 | | GetCCParticipant<mozilla::WebGLExtensionBlendMinMax>::Get() |
1736 | | }; |
1737 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
1738 | | "Must have the right minimal number of reserved slots."); |
1739 | | static_assert(1 >= 1, |
1740 | | "Must have enough reserved slots."); |
1741 | | |
1742 | | const JSClass* |
1743 | | GetJSClass() |
1744 | 0 | { |
1745 | 0 | return sClass.ToJSClass(); |
1746 | 0 | } |
1747 | | |
1748 | | bool |
1749 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionBlendMinMax* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
1750 | 0 | { |
1751 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionBlendMinMax>::value, |
1752 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
1753 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionBlendMinMax*>(aObject) == |
1754 | 0 | reinterpret_cast<mozilla::WebGLExtensionBlendMinMax*>(aObject), |
1755 | 0 | "Multiple inheritance for mozilla::WebGLExtensionBlendMinMax is broken."); |
1756 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
1757 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
1758 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
1759 | 0 | "You should probably not be using Wrap() directly; use " |
1760 | 0 | "GetOrCreateDOMReflector instead"); |
1761 | 0 |
|
1762 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
1763 | 0 | "nsISupports must be on our primary inheritance chain"); |
1764 | 0 |
|
1765 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
1766 | 0 | if (!global) { |
1767 | 0 | return false; |
1768 | 0 | } |
1769 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
1770 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
1771 | 0 |
|
1772 | 0 | // That might have ended up wrapping us already, due to the wonders |
1773 | 0 | // of XBL. Check for that, and bail out as needed. |
1774 | 0 | aReflector.set(aCache->GetWrapper()); |
1775 | 0 | if (aReflector) { |
1776 | | #ifdef DEBUG |
1777 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
1778 | | #endif // DEBUG |
1779 | | return true; |
1780 | 0 | } |
1781 | 0 |
|
1782 | 0 | JSAutoRealm ar(aCx, global); |
1783 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
1784 | 0 | if (!canonicalProto) { |
1785 | 0 | return false; |
1786 | 0 | } |
1787 | 0 | JS::Rooted<JSObject*> proto(aCx); |
1788 | 0 | if (aGivenProto) { |
1789 | 0 | proto = aGivenProto; |
1790 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
1791 | 0 | // coming in, we changed compartments to that of "parent" so may need |
1792 | 0 | // to wrap the proto here. |
1793 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
1794 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
1795 | 0 | return false; |
1796 | 0 | } |
1797 | 0 | } |
1798 | 0 | } else { |
1799 | 0 | proto = canonicalProto; |
1800 | 0 | } |
1801 | 0 |
|
1802 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionBlendMinMax> creator(aCx); |
1803 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
1804 | 0 | if (!aReflector) { |
1805 | 0 | return false; |
1806 | 0 | } |
1807 | 0 | |
1808 | 0 | aCache->SetWrapper(aReflector); |
1809 | 0 | creator.InitializationSucceeded(); |
1810 | 0 |
|
1811 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
1812 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
1813 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
1814 | 0 | // otherwise we won't be able to properly recreate it later, since |
1815 | 0 | // we won't know what proto to use. Note that we don't check |
1816 | 0 | // aGivenProto here, since it's entirely possible (and even |
1817 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
1818 | 0 | // same as canonicalProto. |
1819 | 0 | if (proto != canonicalProto) { |
1820 | 0 | PreserveWrapper(aObject); |
1821 | 0 | } |
1822 | 0 |
|
1823 | 0 | return true; |
1824 | 0 | } |
1825 | | |
1826 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
1827 | | nullptr, |
1828 | | nullptr, |
1829 | | nullptr, |
1830 | | { sNativeProperties.Upcast(), nullptr }, |
1831 | | prototypes::id::EXT_blend_minmax, |
1832 | | constructors::id::_ID_Count, |
1833 | | nullptr, |
1834 | | &DefaultXrayExpandoObjectClass |
1835 | | } }; |
1836 | | |
1837 | | void |
1838 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
1839 | 0 | { |
1840 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
1841 | 0 | if (!parentProto) { |
1842 | 0 | return; |
1843 | 0 | } |
1844 | 0 | |
1845 | 0 | static bool sIdsInited = false; |
1846 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
1847 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
1848 | 0 | return; |
1849 | 0 | } |
1850 | 0 | sIdsInited = true; |
1851 | 0 | } |
1852 | 0 |
|
1853 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::EXT_blend_minmax); |
1854 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
1855 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
1856 | 0 | &sPrototypeClass.mBase, protoCache, |
1857 | 0 | nullptr, |
1858 | 0 | nullptr, nullptr, 0, nullptr, |
1859 | 0 | interfaceCache, |
1860 | 0 | sNativeProperties.Upcast(), |
1861 | 0 | nullptr, |
1862 | 0 | nullptr, aDefineOnGlobal, |
1863 | 0 | nullptr, |
1864 | 0 | false); |
1865 | 0 | } |
1866 | | |
1867 | | } // namespace EXT_blend_minmax_Binding |
1868 | | |
1869 | | |
1870 | | |
1871 | | namespace EXT_color_buffer_half_float_Binding { |
1872 | | |
1873 | | static bool |
1874 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
1875 | 0 | { |
1876 | 0 | mozilla::WebGLExtensionColorBufferHalfFloat* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionColorBufferHalfFloat>(obj); |
1877 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
1878 | 0 | // obviously can't preserve if we're not initialized. |
1879 | 0 | if (self && self->GetWrapperPreserveColor()) { |
1880 | 0 | PreserveWrapper(self); |
1881 | 0 | } |
1882 | 0 | return true; |
1883 | 0 | } |
1884 | | |
1885 | | static void |
1886 | | _finalize(js::FreeOp* fop, JSObject* obj) |
1887 | 0 | { |
1888 | 0 | mozilla::WebGLExtensionColorBufferHalfFloat* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionColorBufferHalfFloat>(obj); |
1889 | 0 | if (self) { |
1890 | 0 | ClearWrapper(self, self, obj); |
1891 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionColorBufferHalfFloat>(self); |
1892 | 0 | } |
1893 | 0 | } |
1894 | | |
1895 | | static size_t |
1896 | | _objectMoved(JSObject* obj, JSObject* old) |
1897 | 0 | { |
1898 | 0 | mozilla::WebGLExtensionColorBufferHalfFloat* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionColorBufferHalfFloat>(obj); |
1899 | 0 | if (self) { |
1900 | 0 | UpdateWrapper(self, self, obj, old); |
1901 | 0 | } |
1902 | 0 |
|
1903 | 0 | return 0; |
1904 | 0 | } |
1905 | | |
1906 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1907 | | #if defined(__clang__) |
1908 | | #pragma clang diagnostic push |
1909 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1910 | | #endif |
1911 | | static const ConstantSpec sConstants_specs[] = { |
1912 | | { "RGBA16F_EXT", JS::NumberValue(34842U) }, |
1913 | | { "RGB16F_EXT", JS::NumberValue(34843U) }, |
1914 | | { "FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT", JS::NumberValue(33297U) }, |
1915 | | { "UNSIGNED_NORMALIZED_EXT", JS::NumberValue(35863U) }, |
1916 | | { 0, JS::UndefinedValue() } |
1917 | | }; |
1918 | | #if defined(__clang__) |
1919 | | #pragma clang diagnostic pop |
1920 | | #endif |
1921 | | |
1922 | | |
1923 | | static const Prefable<const ConstantSpec> sConstants[] = { |
1924 | | { nullptr, &sConstants_specs[0] }, |
1925 | | { nullptr, nullptr } |
1926 | | }; |
1927 | | |
1928 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1929 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1930 | | static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1931 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1932 | | |
1933 | | |
1934 | | static uint16_t sNativeProperties_sortedPropertyIndices[4]; |
1935 | | static PropertyInfo sNativeProperties_propertyInfos[4]; |
1936 | | |
1937 | | static const NativePropertiesN<1> sNativeProperties = { |
1938 | | false, 0, |
1939 | | false, 0, |
1940 | | false, 0, |
1941 | | false, 0, |
1942 | | false, 0, |
1943 | | false, 0, |
1944 | | true, 0 /* sConstants */, |
1945 | | -1, |
1946 | | 4, |
1947 | | sNativeProperties_sortedPropertyIndices, |
1948 | | { |
1949 | | { sConstants, &sNativeProperties_propertyInfos[0] } |
1950 | | } |
1951 | | }; |
1952 | | static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
1953 | | "We have a property info count that is oversized"); |
1954 | | |
1955 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
1956 | | { |
1957 | | "EXT_color_buffer_half_floatPrototype", |
1958 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
1959 | | JS_NULL_CLASS_OPS, |
1960 | | JS_NULL_CLASS_SPEC, |
1961 | | JS_NULL_CLASS_EXT, |
1962 | | JS_NULL_OBJECT_OPS |
1963 | | }, |
1964 | | eInterfacePrototype, |
1965 | | false, |
1966 | | prototypes::id::EXT_color_buffer_half_float, |
1967 | | PrototypeTraits<prototypes::id::EXT_color_buffer_half_float>::Depth, |
1968 | | sNativePropertyHooks, |
1969 | | "[object EXT_color_buffer_half_floatPrototype]", |
1970 | | JS::GetRealmObjectPrototype |
1971 | | }; |
1972 | | |
1973 | | static const js::ClassOps sClassOps = { |
1974 | | _addProperty, /* addProperty */ |
1975 | | nullptr, /* delProperty */ |
1976 | | nullptr, /* enumerate */ |
1977 | | nullptr, /* newEnumerate */ |
1978 | | nullptr, /* resolve */ |
1979 | | nullptr, /* mayResolve */ |
1980 | | _finalize, /* finalize */ |
1981 | | nullptr, /* call */ |
1982 | | nullptr, /* hasInstance */ |
1983 | | nullptr, /* construct */ |
1984 | | nullptr, /* trace */ |
1985 | | }; |
1986 | | |
1987 | | static const js::ClassExtension sClassExtension = { |
1988 | | nullptr, /* weakmapKeyDelegateOp */ |
1989 | | _objectMoved /* objectMovedOp */ |
1990 | | }; |
1991 | | |
1992 | | static const DOMJSClass sClass = { |
1993 | | { "EXT_color_buffer_half_float", |
1994 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
1995 | | &sClassOps, |
1996 | | JS_NULL_CLASS_SPEC, |
1997 | | &sClassExtension, |
1998 | | JS_NULL_OBJECT_OPS |
1999 | | }, |
2000 | | { prototypes::id::EXT_color_buffer_half_float, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
2001 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionColorBufferHalfFloat >::value, |
2002 | | sNativePropertyHooks, |
2003 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionColorBufferHalfFloat>::Get, |
2004 | | GetProtoObjectHandle, |
2005 | | GetCCParticipant<mozilla::WebGLExtensionColorBufferHalfFloat>::Get() |
2006 | | }; |
2007 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
2008 | | "Must have the right minimal number of reserved slots."); |
2009 | | static_assert(1 >= 1, |
2010 | | "Must have enough reserved slots."); |
2011 | | |
2012 | | const JSClass* |
2013 | | GetJSClass() |
2014 | 0 | { |
2015 | 0 | return sClass.ToJSClass(); |
2016 | 0 | } |
2017 | | |
2018 | | bool |
2019 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionColorBufferHalfFloat* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
2020 | 0 | { |
2021 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionColorBufferHalfFloat>::value, |
2022 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
2023 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionColorBufferHalfFloat*>(aObject) == |
2024 | 0 | reinterpret_cast<mozilla::WebGLExtensionColorBufferHalfFloat*>(aObject), |
2025 | 0 | "Multiple inheritance for mozilla::WebGLExtensionColorBufferHalfFloat is broken."); |
2026 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
2027 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
2028 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
2029 | 0 | "You should probably not be using Wrap() directly; use " |
2030 | 0 | "GetOrCreateDOMReflector instead"); |
2031 | 0 |
|
2032 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
2033 | 0 | "nsISupports must be on our primary inheritance chain"); |
2034 | 0 |
|
2035 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
2036 | 0 | if (!global) { |
2037 | 0 | return false; |
2038 | 0 | } |
2039 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
2040 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
2041 | 0 |
|
2042 | 0 | // That might have ended up wrapping us already, due to the wonders |
2043 | 0 | // of XBL. Check for that, and bail out as needed. |
2044 | 0 | aReflector.set(aCache->GetWrapper()); |
2045 | 0 | if (aReflector) { |
2046 | | #ifdef DEBUG |
2047 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
2048 | | #endif // DEBUG |
2049 | | return true; |
2050 | 0 | } |
2051 | 0 |
|
2052 | 0 | JSAutoRealm ar(aCx, global); |
2053 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
2054 | 0 | if (!canonicalProto) { |
2055 | 0 | return false; |
2056 | 0 | } |
2057 | 0 | JS::Rooted<JSObject*> proto(aCx); |
2058 | 0 | if (aGivenProto) { |
2059 | 0 | proto = aGivenProto; |
2060 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
2061 | 0 | // coming in, we changed compartments to that of "parent" so may need |
2062 | 0 | // to wrap the proto here. |
2063 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
2064 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
2065 | 0 | return false; |
2066 | 0 | } |
2067 | 0 | } |
2068 | 0 | } else { |
2069 | 0 | proto = canonicalProto; |
2070 | 0 | } |
2071 | 0 |
|
2072 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionColorBufferHalfFloat> creator(aCx); |
2073 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
2074 | 0 | if (!aReflector) { |
2075 | 0 | return false; |
2076 | 0 | } |
2077 | 0 | |
2078 | 0 | aCache->SetWrapper(aReflector); |
2079 | 0 | creator.InitializationSucceeded(); |
2080 | 0 |
|
2081 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
2082 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
2083 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
2084 | 0 | // otherwise we won't be able to properly recreate it later, since |
2085 | 0 | // we won't know what proto to use. Note that we don't check |
2086 | 0 | // aGivenProto here, since it's entirely possible (and even |
2087 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
2088 | 0 | // same as canonicalProto. |
2089 | 0 | if (proto != canonicalProto) { |
2090 | 0 | PreserveWrapper(aObject); |
2091 | 0 | } |
2092 | 0 |
|
2093 | 0 | return true; |
2094 | 0 | } |
2095 | | |
2096 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
2097 | | nullptr, |
2098 | | nullptr, |
2099 | | nullptr, |
2100 | | { sNativeProperties.Upcast(), nullptr }, |
2101 | | prototypes::id::EXT_color_buffer_half_float, |
2102 | | constructors::id::_ID_Count, |
2103 | | nullptr, |
2104 | | &DefaultXrayExpandoObjectClass |
2105 | | } }; |
2106 | | |
2107 | | void |
2108 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
2109 | 0 | { |
2110 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
2111 | 0 | if (!parentProto) { |
2112 | 0 | return; |
2113 | 0 | } |
2114 | 0 | |
2115 | 0 | static bool sIdsInited = false; |
2116 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
2117 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
2118 | 0 | return; |
2119 | 0 | } |
2120 | 0 | sIdsInited = true; |
2121 | 0 | } |
2122 | 0 |
|
2123 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::EXT_color_buffer_half_float); |
2124 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
2125 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
2126 | 0 | &sPrototypeClass.mBase, protoCache, |
2127 | 0 | nullptr, |
2128 | 0 | nullptr, nullptr, 0, nullptr, |
2129 | 0 | interfaceCache, |
2130 | 0 | sNativeProperties.Upcast(), |
2131 | 0 | nullptr, |
2132 | 0 | nullptr, aDefineOnGlobal, |
2133 | 0 | nullptr, |
2134 | 0 | false); |
2135 | 0 | } |
2136 | | |
2137 | | } // namespace EXT_color_buffer_half_float_Binding |
2138 | | |
2139 | | |
2140 | | |
2141 | | namespace EXT_disjoint_timer_query_Binding { |
2142 | | |
2143 | | MOZ_CAN_RUN_SCRIPT static bool |
2144 | | createQueryEXT(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionDisjointTimerQuery* self, const JSJitMethodCallArgs& args) |
2145 | 0 | { |
2146 | 0 | AUTO_PROFILER_LABEL_FAST("EXT_disjoint_timer_query.createQueryEXT", DOM, cx); |
2147 | 0 |
|
2148 | 0 | auto result(StrongOrRawPtr<mozilla::WebGLQuery>(self->CreateQueryEXT())); |
2149 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2150 | 0 | if (!result) { |
2151 | 0 | args.rval().setNull(); |
2152 | 0 | return true; |
2153 | 0 | } |
2154 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
2155 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
2156 | 0 | return false; |
2157 | 0 | } |
2158 | 0 | return true; |
2159 | 0 | } |
2160 | | |
2161 | | static const JSJitInfo createQueryEXT_methodinfo = { |
2162 | | { (JSJitGetterOp)createQueryEXT }, |
2163 | | { prototypes::id::EXT_disjoint_timer_query }, |
2164 | | { PrototypeTraits<prototypes::id::EXT_disjoint_timer_query>::Depth }, |
2165 | | JSJitInfo::Method, |
2166 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2167 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
2168 | | false, /* isInfallible. False in setters. */ |
2169 | | false, /* isMovable. Not relevant for setters. */ |
2170 | | false, /* isEliminatable. Not relevant for setters. */ |
2171 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2172 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2173 | | false, /* isTypedMethod. Only relevant for methods. */ |
2174 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2175 | | }; |
2176 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2177 | | static_assert(0 < 1, "There is no slot for us"); |
2178 | | |
2179 | | MOZ_CAN_RUN_SCRIPT static bool |
2180 | | deleteQueryEXT(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionDisjointTimerQuery* self, const JSJitMethodCallArgs& args) |
2181 | 0 | { |
2182 | 0 | AUTO_PROFILER_LABEL_FAST("EXT_disjoint_timer_query.deleteQueryEXT", DOM, cx); |
2183 | 0 |
|
2184 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
2185 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "EXT_disjoint_timer_query.deleteQueryEXT"); |
2186 | 0 | } |
2187 | 0 | mozilla::WebGLQuery* arg0; |
2188 | 0 | if (args[0].isObject()) { |
2189 | 0 | { |
2190 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLQuery, mozilla::WebGLQuery>(args[0], arg0); |
2191 | 0 | if (NS_FAILED(rv)) { |
2192 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of EXT_disjoint_timer_query.deleteQueryEXT", "WebGLQuery"); |
2193 | 0 | return false; |
2194 | 0 | } |
2195 | 0 | } |
2196 | 0 | } else if (args[0].isNullOrUndefined()) { |
2197 | 0 | arg0 = nullptr; |
2198 | 0 | } else { |
2199 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of EXT_disjoint_timer_query.deleteQueryEXT"); |
2200 | 0 | return false; |
2201 | 0 | } |
2202 | 0 | self->DeleteQueryEXT(MOZ_KnownLive(Constify(arg0))); |
2203 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2204 | 0 | args.rval().setUndefined(); |
2205 | 0 | return true; |
2206 | 0 | } |
2207 | | |
2208 | | static const JSJitInfo deleteQueryEXT_methodinfo = { |
2209 | | { (JSJitGetterOp)deleteQueryEXT }, |
2210 | | { prototypes::id::EXT_disjoint_timer_query }, |
2211 | | { PrototypeTraits<prototypes::id::EXT_disjoint_timer_query>::Depth }, |
2212 | | JSJitInfo::Method, |
2213 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2214 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
2215 | | false, /* isInfallible. False in setters. */ |
2216 | | false, /* isMovable. Not relevant for setters. */ |
2217 | | false, /* isEliminatable. Not relevant for setters. */ |
2218 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2219 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2220 | | false, /* isTypedMethod. Only relevant for methods. */ |
2221 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2222 | | }; |
2223 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2224 | | static_assert(0 < 1, "There is no slot for us"); |
2225 | | |
2226 | | MOZ_CAN_RUN_SCRIPT static bool |
2227 | | isQueryEXT(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionDisjointTimerQuery* self, const JSJitMethodCallArgs& args) |
2228 | 0 | { |
2229 | 0 | AUTO_PROFILER_LABEL_FAST("EXT_disjoint_timer_query.isQueryEXT", DOM, cx); |
2230 | 0 |
|
2231 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
2232 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "EXT_disjoint_timer_query.isQueryEXT"); |
2233 | 0 | } |
2234 | 0 | mozilla::WebGLQuery* arg0; |
2235 | 0 | if (args[0].isObject()) { |
2236 | 0 | { |
2237 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLQuery, mozilla::WebGLQuery>(args[0], arg0); |
2238 | 0 | if (NS_FAILED(rv)) { |
2239 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of EXT_disjoint_timer_query.isQueryEXT", "WebGLQuery"); |
2240 | 0 | return false; |
2241 | 0 | } |
2242 | 0 | } |
2243 | 0 | } else if (args[0].isNullOrUndefined()) { |
2244 | 0 | arg0 = nullptr; |
2245 | 0 | } else { |
2246 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of EXT_disjoint_timer_query.isQueryEXT"); |
2247 | 0 | return false; |
2248 | 0 | } |
2249 | 0 | bool result(self->IsQueryEXT(MOZ_KnownLive(Constify(arg0)))); |
2250 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2251 | 0 | args.rval().setBoolean(result); |
2252 | 0 | return true; |
2253 | 0 | } |
2254 | | |
2255 | | static const JSJitInfo isQueryEXT_methodinfo = { |
2256 | | { (JSJitGetterOp)isQueryEXT }, |
2257 | | { prototypes::id::EXT_disjoint_timer_query }, |
2258 | | { PrototypeTraits<prototypes::id::EXT_disjoint_timer_query>::Depth }, |
2259 | | JSJitInfo::Method, |
2260 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2261 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
2262 | | false, /* isInfallible. False in setters. */ |
2263 | | false, /* isMovable. Not relevant for setters. */ |
2264 | | false, /* isEliminatable. Not relevant for setters. */ |
2265 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2266 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2267 | | false, /* isTypedMethod. Only relevant for methods. */ |
2268 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2269 | | }; |
2270 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2271 | | static_assert(0 < 1, "There is no slot for us"); |
2272 | | |
2273 | | MOZ_CAN_RUN_SCRIPT static bool |
2274 | | beginQueryEXT(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionDisjointTimerQuery* self, const JSJitMethodCallArgs& args) |
2275 | 0 | { |
2276 | 0 | AUTO_PROFILER_LABEL_FAST("EXT_disjoint_timer_query.beginQueryEXT", DOM, cx); |
2277 | 0 |
|
2278 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
2279 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "EXT_disjoint_timer_query.beginQueryEXT"); |
2280 | 0 | } |
2281 | 0 | uint32_t arg0; |
2282 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
2283 | 0 | return false; |
2284 | 0 | } |
2285 | 0 | NonNull<mozilla::WebGLQuery> arg1; |
2286 | 0 | if (args[1].isObject()) { |
2287 | 0 | { |
2288 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLQuery, mozilla::WebGLQuery>(args[1], arg1); |
2289 | 0 | if (NS_FAILED(rv)) { |
2290 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of EXT_disjoint_timer_query.beginQueryEXT", "WebGLQuery"); |
2291 | 0 | return false; |
2292 | 0 | } |
2293 | 0 | } |
2294 | 0 | } else { |
2295 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of EXT_disjoint_timer_query.beginQueryEXT"); |
2296 | 0 | return false; |
2297 | 0 | } |
2298 | 0 | self->BeginQueryEXT(arg0, MOZ_KnownLive(NonNullHelper(arg1))); |
2299 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2300 | 0 | args.rval().setUndefined(); |
2301 | 0 | return true; |
2302 | 0 | } |
2303 | | |
2304 | | static const JSJitInfo beginQueryEXT_methodinfo = { |
2305 | | { (JSJitGetterOp)beginQueryEXT }, |
2306 | | { prototypes::id::EXT_disjoint_timer_query }, |
2307 | | { PrototypeTraits<prototypes::id::EXT_disjoint_timer_query>::Depth }, |
2308 | | JSJitInfo::Method, |
2309 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2310 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
2311 | | false, /* isInfallible. False in setters. */ |
2312 | | false, /* isMovable. Not relevant for setters. */ |
2313 | | false, /* isEliminatable. Not relevant for setters. */ |
2314 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2315 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2316 | | false, /* isTypedMethod. Only relevant for methods. */ |
2317 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2318 | | }; |
2319 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2320 | | static_assert(0 < 1, "There is no slot for us"); |
2321 | | |
2322 | | MOZ_CAN_RUN_SCRIPT static bool |
2323 | | endQueryEXT(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionDisjointTimerQuery* self, const JSJitMethodCallArgs& args) |
2324 | 0 | { |
2325 | 0 | AUTO_PROFILER_LABEL_FAST("EXT_disjoint_timer_query.endQueryEXT", DOM, cx); |
2326 | 0 |
|
2327 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
2328 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "EXT_disjoint_timer_query.endQueryEXT"); |
2329 | 0 | } |
2330 | 0 | uint32_t arg0; |
2331 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
2332 | 0 | return false; |
2333 | 0 | } |
2334 | 0 | self->EndQueryEXT(arg0); |
2335 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2336 | 0 | args.rval().setUndefined(); |
2337 | 0 | return true; |
2338 | 0 | } |
2339 | | |
2340 | | static const JSJitInfo endQueryEXT_methodinfo = { |
2341 | | { (JSJitGetterOp)endQueryEXT }, |
2342 | | { prototypes::id::EXT_disjoint_timer_query }, |
2343 | | { PrototypeTraits<prototypes::id::EXT_disjoint_timer_query>::Depth }, |
2344 | | JSJitInfo::Method, |
2345 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2346 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
2347 | | false, /* isInfallible. False in setters. */ |
2348 | | false, /* isMovable. Not relevant for setters. */ |
2349 | | false, /* isEliminatable. Not relevant for setters. */ |
2350 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2351 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2352 | | false, /* isTypedMethod. Only relevant for methods. */ |
2353 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2354 | | }; |
2355 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2356 | | static_assert(0 < 1, "There is no slot for us"); |
2357 | | |
2358 | | MOZ_CAN_RUN_SCRIPT static bool |
2359 | | queryCounterEXT(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionDisjointTimerQuery* self, const JSJitMethodCallArgs& args) |
2360 | 0 | { |
2361 | 0 | AUTO_PROFILER_LABEL_FAST("EXT_disjoint_timer_query.queryCounterEXT", DOM, cx); |
2362 | 0 |
|
2363 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
2364 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "EXT_disjoint_timer_query.queryCounterEXT"); |
2365 | 0 | } |
2366 | 0 | NonNull<mozilla::WebGLQuery> arg0; |
2367 | 0 | if (args[0].isObject()) { |
2368 | 0 | { |
2369 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLQuery, mozilla::WebGLQuery>(args[0], arg0); |
2370 | 0 | if (NS_FAILED(rv)) { |
2371 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of EXT_disjoint_timer_query.queryCounterEXT", "WebGLQuery"); |
2372 | 0 | return false; |
2373 | 0 | } |
2374 | 0 | } |
2375 | 0 | } else { |
2376 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of EXT_disjoint_timer_query.queryCounterEXT"); |
2377 | 0 | return false; |
2378 | 0 | } |
2379 | 0 | uint32_t arg1; |
2380 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
2381 | 0 | return false; |
2382 | 0 | } |
2383 | 0 | self->QueryCounterEXT(MOZ_KnownLive(NonNullHelper(arg0)), arg1); |
2384 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2385 | 0 | args.rval().setUndefined(); |
2386 | 0 | return true; |
2387 | 0 | } |
2388 | | |
2389 | | static const JSJitInfo queryCounterEXT_methodinfo = { |
2390 | | { (JSJitGetterOp)queryCounterEXT }, |
2391 | | { prototypes::id::EXT_disjoint_timer_query }, |
2392 | | { PrototypeTraits<prototypes::id::EXT_disjoint_timer_query>::Depth }, |
2393 | | JSJitInfo::Method, |
2394 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2395 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
2396 | | false, /* isInfallible. False in setters. */ |
2397 | | false, /* isMovable. Not relevant for setters. */ |
2398 | | false, /* isEliminatable. Not relevant for setters. */ |
2399 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2400 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2401 | | false, /* isTypedMethod. Only relevant for methods. */ |
2402 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2403 | | }; |
2404 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2405 | | static_assert(0 < 1, "There is no slot for us"); |
2406 | | |
2407 | | MOZ_CAN_RUN_SCRIPT static bool |
2408 | | getQueryEXT(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionDisjointTimerQuery* self, const JSJitMethodCallArgs& args) |
2409 | 0 | { |
2410 | 0 | AUTO_PROFILER_LABEL_FAST("EXT_disjoint_timer_query.getQueryEXT", DOM, cx); |
2411 | 0 |
|
2412 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
2413 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "EXT_disjoint_timer_query.getQueryEXT"); |
2414 | 0 | } |
2415 | 0 | uint32_t arg0; |
2416 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
2417 | 0 | return false; |
2418 | 0 | } |
2419 | 0 | uint32_t arg1; |
2420 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
2421 | 0 | return false; |
2422 | 0 | } |
2423 | 0 | JS::Rooted<JS::Value> result(cx); |
2424 | 0 | self->GetQueryEXT(cx, arg0, arg1, &result); |
2425 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2426 | 0 | JS::ExposeValueToActiveJS(result); |
2427 | 0 | args.rval().set(result); |
2428 | 0 | if (!MaybeWrapValue(cx, args.rval())) { |
2429 | 0 | return false; |
2430 | 0 | } |
2431 | 0 | return true; |
2432 | 0 | } |
2433 | | |
2434 | | static const JSJitInfo getQueryEXT_methodinfo = { |
2435 | | { (JSJitGetterOp)getQueryEXT }, |
2436 | | { prototypes::id::EXT_disjoint_timer_query }, |
2437 | | { PrototypeTraits<prototypes::id::EXT_disjoint_timer_query>::Depth }, |
2438 | | JSJitInfo::Method, |
2439 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2440 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
2441 | | false, /* isInfallible. False in setters. */ |
2442 | | false, /* isMovable. Not relevant for setters. */ |
2443 | | false, /* isEliminatable. Not relevant for setters. */ |
2444 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2445 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2446 | | false, /* isTypedMethod. Only relevant for methods. */ |
2447 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2448 | | }; |
2449 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2450 | | static_assert(0 < 1, "There is no slot for us"); |
2451 | | |
2452 | | MOZ_CAN_RUN_SCRIPT static bool |
2453 | | getQueryObjectEXT(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionDisjointTimerQuery* self, const JSJitMethodCallArgs& args) |
2454 | 0 | { |
2455 | 0 | AUTO_PROFILER_LABEL_FAST("EXT_disjoint_timer_query.getQueryObjectEXT", DOM, cx); |
2456 | 0 |
|
2457 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
2458 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "EXT_disjoint_timer_query.getQueryObjectEXT"); |
2459 | 0 | } |
2460 | 0 | NonNull<mozilla::WebGLQuery> arg0; |
2461 | 0 | if (args[0].isObject()) { |
2462 | 0 | { |
2463 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLQuery, mozilla::WebGLQuery>(args[0], arg0); |
2464 | 0 | if (NS_FAILED(rv)) { |
2465 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of EXT_disjoint_timer_query.getQueryObjectEXT", "WebGLQuery"); |
2466 | 0 | return false; |
2467 | 0 | } |
2468 | 0 | } |
2469 | 0 | } else { |
2470 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of EXT_disjoint_timer_query.getQueryObjectEXT"); |
2471 | 0 | return false; |
2472 | 0 | } |
2473 | 0 | uint32_t arg1; |
2474 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
2475 | 0 | return false; |
2476 | 0 | } |
2477 | 0 | JS::Rooted<JS::Value> result(cx); |
2478 | 0 | self->GetQueryObjectEXT(cx, MOZ_KnownLive(NonNullHelper(arg0)), arg1, &result); |
2479 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
2480 | 0 | JS::ExposeValueToActiveJS(result); |
2481 | 0 | args.rval().set(result); |
2482 | 0 | if (!MaybeWrapValue(cx, args.rval())) { |
2483 | 0 | return false; |
2484 | 0 | } |
2485 | 0 | return true; |
2486 | 0 | } |
2487 | | |
2488 | | static const JSJitInfo getQueryObjectEXT_methodinfo = { |
2489 | | { (JSJitGetterOp)getQueryObjectEXT }, |
2490 | | { prototypes::id::EXT_disjoint_timer_query }, |
2491 | | { PrototypeTraits<prototypes::id::EXT_disjoint_timer_query>::Depth }, |
2492 | | JSJitInfo::Method, |
2493 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
2494 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
2495 | | false, /* isInfallible. False in setters. */ |
2496 | | false, /* isMovable. Not relevant for setters. */ |
2497 | | false, /* isEliminatable. Not relevant for setters. */ |
2498 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
2499 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
2500 | | false, /* isTypedMethod. Only relevant for methods. */ |
2501 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
2502 | | }; |
2503 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
2504 | | static_assert(0 < 1, "There is no slot for us"); |
2505 | | |
2506 | | static bool |
2507 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
2508 | 0 | { |
2509 | 0 | mozilla::WebGLExtensionDisjointTimerQuery* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionDisjointTimerQuery>(obj); |
2510 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
2511 | 0 | // obviously can't preserve if we're not initialized. |
2512 | 0 | if (self && self->GetWrapperPreserveColor()) { |
2513 | 0 | PreserveWrapper(self); |
2514 | 0 | } |
2515 | 0 | return true; |
2516 | 0 | } |
2517 | | |
2518 | | static void |
2519 | | _finalize(js::FreeOp* fop, JSObject* obj) |
2520 | 0 | { |
2521 | 0 | mozilla::WebGLExtensionDisjointTimerQuery* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionDisjointTimerQuery>(obj); |
2522 | 0 | if (self) { |
2523 | 0 | ClearWrapper(self, self, obj); |
2524 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionDisjointTimerQuery>(self); |
2525 | 0 | } |
2526 | 0 | } |
2527 | | |
2528 | | static size_t |
2529 | | _objectMoved(JSObject* obj, JSObject* old) |
2530 | 0 | { |
2531 | 0 | mozilla::WebGLExtensionDisjointTimerQuery* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionDisjointTimerQuery>(obj); |
2532 | 0 | if (self) { |
2533 | 0 | UpdateWrapper(self, self, obj, old); |
2534 | 0 | } |
2535 | 0 |
|
2536 | 0 | return 0; |
2537 | 0 | } |
2538 | | |
2539 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
2540 | | #if defined(__clang__) |
2541 | | #pragma clang diagnostic push |
2542 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
2543 | | #endif |
2544 | | static const JSFunctionSpec sMethods_specs[] = { |
2545 | | JS_FNSPEC("createQueryEXT", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createQueryEXT_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
2546 | | JS_FNSPEC("deleteQueryEXT", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&deleteQueryEXT_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
2547 | | JS_FNSPEC("isQueryEXT", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&isQueryEXT_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
2548 | | JS_FNSPEC("beginQueryEXT", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&beginQueryEXT_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
2549 | | JS_FNSPEC("endQueryEXT", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&endQueryEXT_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
2550 | | JS_FNSPEC("queryCounterEXT", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&queryCounterEXT_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
2551 | | JS_FNSPEC("getQueryEXT", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getQueryEXT_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
2552 | | JS_FNSPEC("getQueryObjectEXT", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getQueryObjectEXT_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
2553 | | JS_FS_END |
2554 | | }; |
2555 | | #if defined(__clang__) |
2556 | | #pragma clang diagnostic pop |
2557 | | #endif |
2558 | | |
2559 | | |
2560 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
2561 | | { nullptr, &sMethods_specs[0] }, |
2562 | | { nullptr, nullptr } |
2563 | | }; |
2564 | | |
2565 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
2566 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
2567 | | static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
2568 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
2569 | | |
2570 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
2571 | | #if defined(__clang__) |
2572 | | #pragma clang diagnostic push |
2573 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
2574 | | #endif |
2575 | | static const ConstantSpec sConstants_specs[] = { |
2576 | | { "QUERY_COUNTER_BITS_EXT", JS::NumberValue(34916U) }, |
2577 | | { "CURRENT_QUERY_EXT", JS::NumberValue(34917U) }, |
2578 | | { "QUERY_RESULT_EXT", JS::NumberValue(34918U) }, |
2579 | | { "QUERY_RESULT_AVAILABLE_EXT", JS::NumberValue(34919U) }, |
2580 | | { "TIME_ELAPSED_EXT", JS::NumberValue(35007U) }, |
2581 | | { "TIMESTAMP_EXT", JS::NumberValue(36392U) }, |
2582 | | { "GPU_DISJOINT_EXT", JS::NumberValue(36795U) }, |
2583 | | { 0, JS::UndefinedValue() } |
2584 | | }; |
2585 | | #if defined(__clang__) |
2586 | | #pragma clang diagnostic pop |
2587 | | #endif |
2588 | | |
2589 | | |
2590 | | static const Prefable<const ConstantSpec> sConstants[] = { |
2591 | | { nullptr, &sConstants_specs[0] }, |
2592 | | { nullptr, nullptr } |
2593 | | }; |
2594 | | |
2595 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
2596 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
2597 | | static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
2598 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
2599 | | |
2600 | | |
2601 | | static uint16_t sNativeProperties_sortedPropertyIndices[15]; |
2602 | | static PropertyInfo sNativeProperties_propertyInfos[15]; |
2603 | | |
2604 | | static const NativePropertiesN<2> sNativeProperties = { |
2605 | | false, 0, |
2606 | | false, 0, |
2607 | | true, 0 /* sMethods */, |
2608 | | false, 0, |
2609 | | false, 0, |
2610 | | false, 0, |
2611 | | true, 1 /* sConstants */, |
2612 | | -1, |
2613 | | 15, |
2614 | | sNativeProperties_sortedPropertyIndices, |
2615 | | { |
2616 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
2617 | | { sConstants, &sNativeProperties_propertyInfos[8] } |
2618 | | } |
2619 | | }; |
2620 | | static_assert(15 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
2621 | | "We have a property info count that is oversized"); |
2622 | | |
2623 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
2624 | | { |
2625 | | "EXT_disjoint_timer_queryPrototype", |
2626 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
2627 | | JS_NULL_CLASS_OPS, |
2628 | | JS_NULL_CLASS_SPEC, |
2629 | | JS_NULL_CLASS_EXT, |
2630 | | JS_NULL_OBJECT_OPS |
2631 | | }, |
2632 | | eInterfacePrototype, |
2633 | | false, |
2634 | | prototypes::id::EXT_disjoint_timer_query, |
2635 | | PrototypeTraits<prototypes::id::EXT_disjoint_timer_query>::Depth, |
2636 | | sNativePropertyHooks, |
2637 | | "[object EXT_disjoint_timer_queryPrototype]", |
2638 | | JS::GetRealmObjectPrototype |
2639 | | }; |
2640 | | |
2641 | | static const js::ClassOps sClassOps = { |
2642 | | _addProperty, /* addProperty */ |
2643 | | nullptr, /* delProperty */ |
2644 | | nullptr, /* enumerate */ |
2645 | | nullptr, /* newEnumerate */ |
2646 | | nullptr, /* resolve */ |
2647 | | nullptr, /* mayResolve */ |
2648 | | _finalize, /* finalize */ |
2649 | | nullptr, /* call */ |
2650 | | nullptr, /* hasInstance */ |
2651 | | nullptr, /* construct */ |
2652 | | nullptr, /* trace */ |
2653 | | }; |
2654 | | |
2655 | | static const js::ClassExtension sClassExtension = { |
2656 | | nullptr, /* weakmapKeyDelegateOp */ |
2657 | | _objectMoved /* objectMovedOp */ |
2658 | | }; |
2659 | | |
2660 | | static const DOMJSClass sClass = { |
2661 | | { "EXT_disjoint_timer_query", |
2662 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
2663 | | &sClassOps, |
2664 | | JS_NULL_CLASS_SPEC, |
2665 | | &sClassExtension, |
2666 | | JS_NULL_OBJECT_OPS |
2667 | | }, |
2668 | | { prototypes::id::EXT_disjoint_timer_query, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
2669 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionDisjointTimerQuery >::value, |
2670 | | sNativePropertyHooks, |
2671 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionDisjointTimerQuery>::Get, |
2672 | | GetProtoObjectHandle, |
2673 | | GetCCParticipant<mozilla::WebGLExtensionDisjointTimerQuery>::Get() |
2674 | | }; |
2675 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
2676 | | "Must have the right minimal number of reserved slots."); |
2677 | | static_assert(1 >= 1, |
2678 | | "Must have enough reserved slots."); |
2679 | | |
2680 | | const JSClass* |
2681 | | GetJSClass() |
2682 | 0 | { |
2683 | 0 | return sClass.ToJSClass(); |
2684 | 0 | } |
2685 | | |
2686 | | bool |
2687 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionDisjointTimerQuery* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
2688 | 0 | { |
2689 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionDisjointTimerQuery>::value, |
2690 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
2691 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionDisjointTimerQuery*>(aObject) == |
2692 | 0 | reinterpret_cast<mozilla::WebGLExtensionDisjointTimerQuery*>(aObject), |
2693 | 0 | "Multiple inheritance for mozilla::WebGLExtensionDisjointTimerQuery is broken."); |
2694 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
2695 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
2696 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
2697 | 0 | "You should probably not be using Wrap() directly; use " |
2698 | 0 | "GetOrCreateDOMReflector instead"); |
2699 | 0 |
|
2700 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
2701 | 0 | "nsISupports must be on our primary inheritance chain"); |
2702 | 0 |
|
2703 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
2704 | 0 | if (!global) { |
2705 | 0 | return false; |
2706 | 0 | } |
2707 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
2708 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
2709 | 0 |
|
2710 | 0 | // That might have ended up wrapping us already, due to the wonders |
2711 | 0 | // of XBL. Check for that, and bail out as needed. |
2712 | 0 | aReflector.set(aCache->GetWrapper()); |
2713 | 0 | if (aReflector) { |
2714 | | #ifdef DEBUG |
2715 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
2716 | | #endif // DEBUG |
2717 | | return true; |
2718 | 0 | } |
2719 | 0 |
|
2720 | 0 | JSAutoRealm ar(aCx, global); |
2721 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
2722 | 0 | if (!canonicalProto) { |
2723 | 0 | return false; |
2724 | 0 | } |
2725 | 0 | JS::Rooted<JSObject*> proto(aCx); |
2726 | 0 | if (aGivenProto) { |
2727 | 0 | proto = aGivenProto; |
2728 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
2729 | 0 | // coming in, we changed compartments to that of "parent" so may need |
2730 | 0 | // to wrap the proto here. |
2731 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
2732 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
2733 | 0 | return false; |
2734 | 0 | } |
2735 | 0 | } |
2736 | 0 | } else { |
2737 | 0 | proto = canonicalProto; |
2738 | 0 | } |
2739 | 0 |
|
2740 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionDisjointTimerQuery> creator(aCx); |
2741 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
2742 | 0 | if (!aReflector) { |
2743 | 0 | return false; |
2744 | 0 | } |
2745 | 0 | |
2746 | 0 | aCache->SetWrapper(aReflector); |
2747 | 0 | creator.InitializationSucceeded(); |
2748 | 0 |
|
2749 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
2750 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
2751 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
2752 | 0 | // otherwise we won't be able to properly recreate it later, since |
2753 | 0 | // we won't know what proto to use. Note that we don't check |
2754 | 0 | // aGivenProto here, since it's entirely possible (and even |
2755 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
2756 | 0 | // same as canonicalProto. |
2757 | 0 | if (proto != canonicalProto) { |
2758 | 0 | PreserveWrapper(aObject); |
2759 | 0 | } |
2760 | 0 |
|
2761 | 0 | return true; |
2762 | 0 | } |
2763 | | |
2764 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
2765 | | nullptr, |
2766 | | nullptr, |
2767 | | nullptr, |
2768 | | { sNativeProperties.Upcast(), nullptr }, |
2769 | | prototypes::id::EXT_disjoint_timer_query, |
2770 | | constructors::id::_ID_Count, |
2771 | | nullptr, |
2772 | | &DefaultXrayExpandoObjectClass |
2773 | | } }; |
2774 | | |
2775 | | void |
2776 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
2777 | 0 | { |
2778 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
2779 | 0 | if (!parentProto) { |
2780 | 0 | return; |
2781 | 0 | } |
2782 | 0 | |
2783 | 0 | static bool sIdsInited = false; |
2784 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
2785 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
2786 | 0 | return; |
2787 | 0 | } |
2788 | 0 | sIdsInited = true; |
2789 | 0 | } |
2790 | 0 |
|
2791 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::EXT_disjoint_timer_query); |
2792 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
2793 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
2794 | 0 | &sPrototypeClass.mBase, protoCache, |
2795 | 0 | nullptr, |
2796 | 0 | nullptr, nullptr, 0, nullptr, |
2797 | 0 | interfaceCache, |
2798 | 0 | sNativeProperties.Upcast(), |
2799 | 0 | nullptr, |
2800 | 0 | nullptr, aDefineOnGlobal, |
2801 | 0 | nullptr, |
2802 | 0 | false); |
2803 | 0 | } |
2804 | | |
2805 | | } // namespace EXT_disjoint_timer_query_Binding |
2806 | | |
2807 | | |
2808 | | |
2809 | | namespace EXT_frag_depth_Binding { |
2810 | | |
2811 | | static bool |
2812 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
2813 | 0 | { |
2814 | 0 | mozilla::WebGLExtensionFragDepth* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionFragDepth>(obj); |
2815 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
2816 | 0 | // obviously can't preserve if we're not initialized. |
2817 | 0 | if (self && self->GetWrapperPreserveColor()) { |
2818 | 0 | PreserveWrapper(self); |
2819 | 0 | } |
2820 | 0 | return true; |
2821 | 0 | } |
2822 | | |
2823 | | static void |
2824 | | _finalize(js::FreeOp* fop, JSObject* obj) |
2825 | 0 | { |
2826 | 0 | mozilla::WebGLExtensionFragDepth* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionFragDepth>(obj); |
2827 | 0 | if (self) { |
2828 | 0 | ClearWrapper(self, self, obj); |
2829 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionFragDepth>(self); |
2830 | 0 | } |
2831 | 0 | } |
2832 | | |
2833 | | static size_t |
2834 | | _objectMoved(JSObject* obj, JSObject* old) |
2835 | 0 | { |
2836 | 0 | mozilla::WebGLExtensionFragDepth* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionFragDepth>(obj); |
2837 | 0 | if (self) { |
2838 | 0 | UpdateWrapper(self, self, obj, old); |
2839 | 0 | } |
2840 | 0 |
|
2841 | 0 | return 0; |
2842 | 0 | } |
2843 | | |
2844 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
2845 | | { |
2846 | | "EXT_frag_depthPrototype", |
2847 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
2848 | | JS_NULL_CLASS_OPS, |
2849 | | JS_NULL_CLASS_SPEC, |
2850 | | JS_NULL_CLASS_EXT, |
2851 | | JS_NULL_OBJECT_OPS |
2852 | | }, |
2853 | | eInterfacePrototype, |
2854 | | false, |
2855 | | prototypes::id::EXT_frag_depth, |
2856 | | PrototypeTraits<prototypes::id::EXT_frag_depth>::Depth, |
2857 | | sNativePropertyHooks, |
2858 | | "[object EXT_frag_depthPrototype]", |
2859 | | JS::GetRealmObjectPrototype |
2860 | | }; |
2861 | | |
2862 | | static const js::ClassOps sClassOps = { |
2863 | | _addProperty, /* addProperty */ |
2864 | | nullptr, /* delProperty */ |
2865 | | nullptr, /* enumerate */ |
2866 | | nullptr, /* newEnumerate */ |
2867 | | nullptr, /* resolve */ |
2868 | | nullptr, /* mayResolve */ |
2869 | | _finalize, /* finalize */ |
2870 | | nullptr, /* call */ |
2871 | | nullptr, /* hasInstance */ |
2872 | | nullptr, /* construct */ |
2873 | | nullptr, /* trace */ |
2874 | | }; |
2875 | | |
2876 | | static const js::ClassExtension sClassExtension = { |
2877 | | nullptr, /* weakmapKeyDelegateOp */ |
2878 | | _objectMoved /* objectMovedOp */ |
2879 | | }; |
2880 | | |
2881 | | static const DOMJSClass sClass = { |
2882 | | { "EXT_frag_depth", |
2883 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
2884 | | &sClassOps, |
2885 | | JS_NULL_CLASS_SPEC, |
2886 | | &sClassExtension, |
2887 | | JS_NULL_OBJECT_OPS |
2888 | | }, |
2889 | | { prototypes::id::EXT_frag_depth, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
2890 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionFragDepth >::value, |
2891 | | sNativePropertyHooks, |
2892 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionFragDepth>::Get, |
2893 | | GetProtoObjectHandle, |
2894 | | GetCCParticipant<mozilla::WebGLExtensionFragDepth>::Get() |
2895 | | }; |
2896 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
2897 | | "Must have the right minimal number of reserved slots."); |
2898 | | static_assert(1 >= 1, |
2899 | | "Must have enough reserved slots."); |
2900 | | |
2901 | | const JSClass* |
2902 | | GetJSClass() |
2903 | 0 | { |
2904 | 0 | return sClass.ToJSClass(); |
2905 | 0 | } |
2906 | | |
2907 | | bool |
2908 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionFragDepth* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
2909 | 0 | { |
2910 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionFragDepth>::value, |
2911 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
2912 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionFragDepth*>(aObject) == |
2913 | 0 | reinterpret_cast<mozilla::WebGLExtensionFragDepth*>(aObject), |
2914 | 0 | "Multiple inheritance for mozilla::WebGLExtensionFragDepth is broken."); |
2915 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
2916 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
2917 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
2918 | 0 | "You should probably not be using Wrap() directly; use " |
2919 | 0 | "GetOrCreateDOMReflector instead"); |
2920 | 0 |
|
2921 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
2922 | 0 | "nsISupports must be on our primary inheritance chain"); |
2923 | 0 |
|
2924 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
2925 | 0 | if (!global) { |
2926 | 0 | return false; |
2927 | 0 | } |
2928 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
2929 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
2930 | 0 |
|
2931 | 0 | // That might have ended up wrapping us already, due to the wonders |
2932 | 0 | // of XBL. Check for that, and bail out as needed. |
2933 | 0 | aReflector.set(aCache->GetWrapper()); |
2934 | 0 | if (aReflector) { |
2935 | | #ifdef DEBUG |
2936 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
2937 | | #endif // DEBUG |
2938 | | return true; |
2939 | 0 | } |
2940 | 0 |
|
2941 | 0 | JSAutoRealm ar(aCx, global); |
2942 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
2943 | 0 | if (!canonicalProto) { |
2944 | 0 | return false; |
2945 | 0 | } |
2946 | 0 | JS::Rooted<JSObject*> proto(aCx); |
2947 | 0 | if (aGivenProto) { |
2948 | 0 | proto = aGivenProto; |
2949 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
2950 | 0 | // coming in, we changed compartments to that of "parent" so may need |
2951 | 0 | // to wrap the proto here. |
2952 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
2953 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
2954 | 0 | return false; |
2955 | 0 | } |
2956 | 0 | } |
2957 | 0 | } else { |
2958 | 0 | proto = canonicalProto; |
2959 | 0 | } |
2960 | 0 |
|
2961 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionFragDepth> creator(aCx); |
2962 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
2963 | 0 | if (!aReflector) { |
2964 | 0 | return false; |
2965 | 0 | } |
2966 | 0 | |
2967 | 0 | aCache->SetWrapper(aReflector); |
2968 | 0 | creator.InitializationSucceeded(); |
2969 | 0 |
|
2970 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
2971 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
2972 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
2973 | 0 | // otherwise we won't be able to properly recreate it later, since |
2974 | 0 | // we won't know what proto to use. Note that we don't check |
2975 | 0 | // aGivenProto here, since it's entirely possible (and even |
2976 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
2977 | 0 | // same as canonicalProto. |
2978 | 0 | if (proto != canonicalProto) { |
2979 | 0 | PreserveWrapper(aObject); |
2980 | 0 | } |
2981 | 0 |
|
2982 | 0 | return true; |
2983 | 0 | } |
2984 | | |
2985 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
2986 | | nullptr, |
2987 | | nullptr, |
2988 | | nullptr, |
2989 | | { nullptr, nullptr }, |
2990 | | prototypes::id::EXT_frag_depth, |
2991 | | constructors::id::_ID_Count, |
2992 | | nullptr, |
2993 | | &DefaultXrayExpandoObjectClass |
2994 | | } }; |
2995 | | |
2996 | | void |
2997 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
2998 | 0 | { |
2999 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
3000 | 0 | if (!parentProto) { |
3001 | 0 | return; |
3002 | 0 | } |
3003 | 0 | |
3004 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::EXT_frag_depth); |
3005 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
3006 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
3007 | 0 | &sPrototypeClass.mBase, protoCache, |
3008 | 0 | nullptr, |
3009 | 0 | nullptr, nullptr, 0, nullptr, |
3010 | 0 | interfaceCache, |
3011 | 0 | nullptr, |
3012 | 0 | nullptr, |
3013 | 0 | nullptr, aDefineOnGlobal, |
3014 | 0 | nullptr, |
3015 | 0 | false); |
3016 | 0 | } |
3017 | | |
3018 | | } // namespace EXT_frag_depth_Binding |
3019 | | |
3020 | | |
3021 | | |
3022 | | namespace EXT_sRGB_Binding { |
3023 | | |
3024 | | static bool |
3025 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
3026 | 0 | { |
3027 | 0 | mozilla::WebGLExtensionSRGB* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionSRGB>(obj); |
3028 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
3029 | 0 | // obviously can't preserve if we're not initialized. |
3030 | 0 | if (self && self->GetWrapperPreserveColor()) { |
3031 | 0 | PreserveWrapper(self); |
3032 | 0 | } |
3033 | 0 | return true; |
3034 | 0 | } |
3035 | | |
3036 | | static void |
3037 | | _finalize(js::FreeOp* fop, JSObject* obj) |
3038 | 0 | { |
3039 | 0 | mozilla::WebGLExtensionSRGB* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionSRGB>(obj); |
3040 | 0 | if (self) { |
3041 | 0 | ClearWrapper(self, self, obj); |
3042 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionSRGB>(self); |
3043 | 0 | } |
3044 | 0 | } |
3045 | | |
3046 | | static size_t |
3047 | | _objectMoved(JSObject* obj, JSObject* old) |
3048 | 0 | { |
3049 | 0 | mozilla::WebGLExtensionSRGB* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionSRGB>(obj); |
3050 | 0 | if (self) { |
3051 | 0 | UpdateWrapper(self, self, obj, old); |
3052 | 0 | } |
3053 | 0 |
|
3054 | 0 | return 0; |
3055 | 0 | } |
3056 | | |
3057 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
3058 | | #if defined(__clang__) |
3059 | | #pragma clang diagnostic push |
3060 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
3061 | | #endif |
3062 | | static const ConstantSpec sConstants_specs[] = { |
3063 | | { "SRGB_EXT", JS::NumberValue(35904U) }, |
3064 | | { "SRGB_ALPHA_EXT", JS::NumberValue(35906U) }, |
3065 | | { "SRGB8_ALPHA8_EXT", JS::NumberValue(35907U) }, |
3066 | | { "FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT", JS::NumberValue(33296U) }, |
3067 | | { 0, JS::UndefinedValue() } |
3068 | | }; |
3069 | | #if defined(__clang__) |
3070 | | #pragma clang diagnostic pop |
3071 | | #endif |
3072 | | |
3073 | | |
3074 | | static const Prefable<const ConstantSpec> sConstants[] = { |
3075 | | { nullptr, &sConstants_specs[0] }, |
3076 | | { nullptr, nullptr } |
3077 | | }; |
3078 | | |
3079 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
3080 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
3081 | | static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
3082 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
3083 | | |
3084 | | |
3085 | | static uint16_t sNativeProperties_sortedPropertyIndices[4]; |
3086 | | static PropertyInfo sNativeProperties_propertyInfos[4]; |
3087 | | |
3088 | | static const NativePropertiesN<1> sNativeProperties = { |
3089 | | false, 0, |
3090 | | false, 0, |
3091 | | false, 0, |
3092 | | false, 0, |
3093 | | false, 0, |
3094 | | false, 0, |
3095 | | true, 0 /* sConstants */, |
3096 | | -1, |
3097 | | 4, |
3098 | | sNativeProperties_sortedPropertyIndices, |
3099 | | { |
3100 | | { sConstants, &sNativeProperties_propertyInfos[0] } |
3101 | | } |
3102 | | }; |
3103 | | static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
3104 | | "We have a property info count that is oversized"); |
3105 | | |
3106 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
3107 | | { |
3108 | | "EXT_sRGBPrototype", |
3109 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
3110 | | JS_NULL_CLASS_OPS, |
3111 | | JS_NULL_CLASS_SPEC, |
3112 | | JS_NULL_CLASS_EXT, |
3113 | | JS_NULL_OBJECT_OPS |
3114 | | }, |
3115 | | eInterfacePrototype, |
3116 | | false, |
3117 | | prototypes::id::EXT_sRGB, |
3118 | | PrototypeTraits<prototypes::id::EXT_sRGB>::Depth, |
3119 | | sNativePropertyHooks, |
3120 | | "[object EXT_sRGBPrototype]", |
3121 | | JS::GetRealmObjectPrototype |
3122 | | }; |
3123 | | |
3124 | | static const js::ClassOps sClassOps = { |
3125 | | _addProperty, /* addProperty */ |
3126 | | nullptr, /* delProperty */ |
3127 | | nullptr, /* enumerate */ |
3128 | | nullptr, /* newEnumerate */ |
3129 | | nullptr, /* resolve */ |
3130 | | nullptr, /* mayResolve */ |
3131 | | _finalize, /* finalize */ |
3132 | | nullptr, /* call */ |
3133 | | nullptr, /* hasInstance */ |
3134 | | nullptr, /* construct */ |
3135 | | nullptr, /* trace */ |
3136 | | }; |
3137 | | |
3138 | | static const js::ClassExtension sClassExtension = { |
3139 | | nullptr, /* weakmapKeyDelegateOp */ |
3140 | | _objectMoved /* objectMovedOp */ |
3141 | | }; |
3142 | | |
3143 | | static const DOMJSClass sClass = { |
3144 | | { "EXT_sRGB", |
3145 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
3146 | | &sClassOps, |
3147 | | JS_NULL_CLASS_SPEC, |
3148 | | &sClassExtension, |
3149 | | JS_NULL_OBJECT_OPS |
3150 | | }, |
3151 | | { prototypes::id::EXT_sRGB, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
3152 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionSRGB >::value, |
3153 | | sNativePropertyHooks, |
3154 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionSRGB>::Get, |
3155 | | GetProtoObjectHandle, |
3156 | | GetCCParticipant<mozilla::WebGLExtensionSRGB>::Get() |
3157 | | }; |
3158 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
3159 | | "Must have the right minimal number of reserved slots."); |
3160 | | static_assert(1 >= 1, |
3161 | | "Must have enough reserved slots."); |
3162 | | |
3163 | | const JSClass* |
3164 | | GetJSClass() |
3165 | 0 | { |
3166 | 0 | return sClass.ToJSClass(); |
3167 | 0 | } |
3168 | | |
3169 | | bool |
3170 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionSRGB* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
3171 | 0 | { |
3172 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionSRGB>::value, |
3173 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
3174 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionSRGB*>(aObject) == |
3175 | 0 | reinterpret_cast<mozilla::WebGLExtensionSRGB*>(aObject), |
3176 | 0 | "Multiple inheritance for mozilla::WebGLExtensionSRGB is broken."); |
3177 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
3178 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
3179 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
3180 | 0 | "You should probably not be using Wrap() directly; use " |
3181 | 0 | "GetOrCreateDOMReflector instead"); |
3182 | 0 |
|
3183 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
3184 | 0 | "nsISupports must be on our primary inheritance chain"); |
3185 | 0 |
|
3186 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
3187 | 0 | if (!global) { |
3188 | 0 | return false; |
3189 | 0 | } |
3190 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
3191 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
3192 | 0 |
|
3193 | 0 | // That might have ended up wrapping us already, due to the wonders |
3194 | 0 | // of XBL. Check for that, and bail out as needed. |
3195 | 0 | aReflector.set(aCache->GetWrapper()); |
3196 | 0 | if (aReflector) { |
3197 | | #ifdef DEBUG |
3198 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
3199 | | #endif // DEBUG |
3200 | | return true; |
3201 | 0 | } |
3202 | 0 |
|
3203 | 0 | JSAutoRealm ar(aCx, global); |
3204 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
3205 | 0 | if (!canonicalProto) { |
3206 | 0 | return false; |
3207 | 0 | } |
3208 | 0 | JS::Rooted<JSObject*> proto(aCx); |
3209 | 0 | if (aGivenProto) { |
3210 | 0 | proto = aGivenProto; |
3211 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
3212 | 0 | // coming in, we changed compartments to that of "parent" so may need |
3213 | 0 | // to wrap the proto here. |
3214 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
3215 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
3216 | 0 | return false; |
3217 | 0 | } |
3218 | 0 | } |
3219 | 0 | } else { |
3220 | 0 | proto = canonicalProto; |
3221 | 0 | } |
3222 | 0 |
|
3223 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionSRGB> creator(aCx); |
3224 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
3225 | 0 | if (!aReflector) { |
3226 | 0 | return false; |
3227 | 0 | } |
3228 | 0 | |
3229 | 0 | aCache->SetWrapper(aReflector); |
3230 | 0 | creator.InitializationSucceeded(); |
3231 | 0 |
|
3232 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
3233 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
3234 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
3235 | 0 | // otherwise we won't be able to properly recreate it later, since |
3236 | 0 | // we won't know what proto to use. Note that we don't check |
3237 | 0 | // aGivenProto here, since it's entirely possible (and even |
3238 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
3239 | 0 | // same as canonicalProto. |
3240 | 0 | if (proto != canonicalProto) { |
3241 | 0 | PreserveWrapper(aObject); |
3242 | 0 | } |
3243 | 0 |
|
3244 | 0 | return true; |
3245 | 0 | } |
3246 | | |
3247 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
3248 | | nullptr, |
3249 | | nullptr, |
3250 | | nullptr, |
3251 | | { sNativeProperties.Upcast(), nullptr }, |
3252 | | prototypes::id::EXT_sRGB, |
3253 | | constructors::id::_ID_Count, |
3254 | | nullptr, |
3255 | | &DefaultXrayExpandoObjectClass |
3256 | | } }; |
3257 | | |
3258 | | void |
3259 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
3260 | 0 | { |
3261 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
3262 | 0 | if (!parentProto) { |
3263 | 0 | return; |
3264 | 0 | } |
3265 | 0 | |
3266 | 0 | static bool sIdsInited = false; |
3267 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
3268 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
3269 | 0 | return; |
3270 | 0 | } |
3271 | 0 | sIdsInited = true; |
3272 | 0 | } |
3273 | 0 |
|
3274 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::EXT_sRGB); |
3275 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
3276 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
3277 | 0 | &sPrototypeClass.mBase, protoCache, |
3278 | 0 | nullptr, |
3279 | 0 | nullptr, nullptr, 0, nullptr, |
3280 | 0 | interfaceCache, |
3281 | 0 | sNativeProperties.Upcast(), |
3282 | 0 | nullptr, |
3283 | 0 | nullptr, aDefineOnGlobal, |
3284 | 0 | nullptr, |
3285 | 0 | false); |
3286 | 0 | } |
3287 | | |
3288 | | } // namespace EXT_sRGB_Binding |
3289 | | |
3290 | | |
3291 | | |
3292 | | namespace EXT_shader_texture_lod_Binding { |
3293 | | |
3294 | | static bool |
3295 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
3296 | 0 | { |
3297 | 0 | mozilla::WebGLExtensionShaderTextureLod* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionShaderTextureLod>(obj); |
3298 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
3299 | 0 | // obviously can't preserve if we're not initialized. |
3300 | 0 | if (self && self->GetWrapperPreserveColor()) { |
3301 | 0 | PreserveWrapper(self); |
3302 | 0 | } |
3303 | 0 | return true; |
3304 | 0 | } |
3305 | | |
3306 | | static void |
3307 | | _finalize(js::FreeOp* fop, JSObject* obj) |
3308 | 0 | { |
3309 | 0 | mozilla::WebGLExtensionShaderTextureLod* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionShaderTextureLod>(obj); |
3310 | 0 | if (self) { |
3311 | 0 | ClearWrapper(self, self, obj); |
3312 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionShaderTextureLod>(self); |
3313 | 0 | } |
3314 | 0 | } |
3315 | | |
3316 | | static size_t |
3317 | | _objectMoved(JSObject* obj, JSObject* old) |
3318 | 0 | { |
3319 | 0 | mozilla::WebGLExtensionShaderTextureLod* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionShaderTextureLod>(obj); |
3320 | 0 | if (self) { |
3321 | 0 | UpdateWrapper(self, self, obj, old); |
3322 | 0 | } |
3323 | 0 |
|
3324 | 0 | return 0; |
3325 | 0 | } |
3326 | | |
3327 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
3328 | | { |
3329 | | "EXT_shader_texture_lodPrototype", |
3330 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
3331 | | JS_NULL_CLASS_OPS, |
3332 | | JS_NULL_CLASS_SPEC, |
3333 | | JS_NULL_CLASS_EXT, |
3334 | | JS_NULL_OBJECT_OPS |
3335 | | }, |
3336 | | eInterfacePrototype, |
3337 | | false, |
3338 | | prototypes::id::EXT_shader_texture_lod, |
3339 | | PrototypeTraits<prototypes::id::EXT_shader_texture_lod>::Depth, |
3340 | | sNativePropertyHooks, |
3341 | | "[object EXT_shader_texture_lodPrototype]", |
3342 | | JS::GetRealmObjectPrototype |
3343 | | }; |
3344 | | |
3345 | | static const js::ClassOps sClassOps = { |
3346 | | _addProperty, /* addProperty */ |
3347 | | nullptr, /* delProperty */ |
3348 | | nullptr, /* enumerate */ |
3349 | | nullptr, /* newEnumerate */ |
3350 | | nullptr, /* resolve */ |
3351 | | nullptr, /* mayResolve */ |
3352 | | _finalize, /* finalize */ |
3353 | | nullptr, /* call */ |
3354 | | nullptr, /* hasInstance */ |
3355 | | nullptr, /* construct */ |
3356 | | nullptr, /* trace */ |
3357 | | }; |
3358 | | |
3359 | | static const js::ClassExtension sClassExtension = { |
3360 | | nullptr, /* weakmapKeyDelegateOp */ |
3361 | | _objectMoved /* objectMovedOp */ |
3362 | | }; |
3363 | | |
3364 | | static const DOMJSClass sClass = { |
3365 | | { "EXT_shader_texture_lod", |
3366 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
3367 | | &sClassOps, |
3368 | | JS_NULL_CLASS_SPEC, |
3369 | | &sClassExtension, |
3370 | | JS_NULL_OBJECT_OPS |
3371 | | }, |
3372 | | { prototypes::id::EXT_shader_texture_lod, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
3373 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionShaderTextureLod >::value, |
3374 | | sNativePropertyHooks, |
3375 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionShaderTextureLod>::Get, |
3376 | | GetProtoObjectHandle, |
3377 | | GetCCParticipant<mozilla::WebGLExtensionShaderTextureLod>::Get() |
3378 | | }; |
3379 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
3380 | | "Must have the right minimal number of reserved slots."); |
3381 | | static_assert(1 >= 1, |
3382 | | "Must have enough reserved slots."); |
3383 | | |
3384 | | const JSClass* |
3385 | | GetJSClass() |
3386 | 0 | { |
3387 | 0 | return sClass.ToJSClass(); |
3388 | 0 | } |
3389 | | |
3390 | | bool |
3391 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionShaderTextureLod* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
3392 | 0 | { |
3393 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionShaderTextureLod>::value, |
3394 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
3395 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionShaderTextureLod*>(aObject) == |
3396 | 0 | reinterpret_cast<mozilla::WebGLExtensionShaderTextureLod*>(aObject), |
3397 | 0 | "Multiple inheritance for mozilla::WebGLExtensionShaderTextureLod is broken."); |
3398 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
3399 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
3400 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
3401 | 0 | "You should probably not be using Wrap() directly; use " |
3402 | 0 | "GetOrCreateDOMReflector instead"); |
3403 | 0 |
|
3404 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
3405 | 0 | "nsISupports must be on our primary inheritance chain"); |
3406 | 0 |
|
3407 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
3408 | 0 | if (!global) { |
3409 | 0 | return false; |
3410 | 0 | } |
3411 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
3412 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
3413 | 0 |
|
3414 | 0 | // That might have ended up wrapping us already, due to the wonders |
3415 | 0 | // of XBL. Check for that, and bail out as needed. |
3416 | 0 | aReflector.set(aCache->GetWrapper()); |
3417 | 0 | if (aReflector) { |
3418 | | #ifdef DEBUG |
3419 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
3420 | | #endif // DEBUG |
3421 | | return true; |
3422 | 0 | } |
3423 | 0 |
|
3424 | 0 | JSAutoRealm ar(aCx, global); |
3425 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
3426 | 0 | if (!canonicalProto) { |
3427 | 0 | return false; |
3428 | 0 | } |
3429 | 0 | JS::Rooted<JSObject*> proto(aCx); |
3430 | 0 | if (aGivenProto) { |
3431 | 0 | proto = aGivenProto; |
3432 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
3433 | 0 | // coming in, we changed compartments to that of "parent" so may need |
3434 | 0 | // to wrap the proto here. |
3435 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
3436 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
3437 | 0 | return false; |
3438 | 0 | } |
3439 | 0 | } |
3440 | 0 | } else { |
3441 | 0 | proto = canonicalProto; |
3442 | 0 | } |
3443 | 0 |
|
3444 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionShaderTextureLod> creator(aCx); |
3445 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
3446 | 0 | if (!aReflector) { |
3447 | 0 | return false; |
3448 | 0 | } |
3449 | 0 | |
3450 | 0 | aCache->SetWrapper(aReflector); |
3451 | 0 | creator.InitializationSucceeded(); |
3452 | 0 |
|
3453 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
3454 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
3455 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
3456 | 0 | // otherwise we won't be able to properly recreate it later, since |
3457 | 0 | // we won't know what proto to use. Note that we don't check |
3458 | 0 | // aGivenProto here, since it's entirely possible (and even |
3459 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
3460 | 0 | // same as canonicalProto. |
3461 | 0 | if (proto != canonicalProto) { |
3462 | 0 | PreserveWrapper(aObject); |
3463 | 0 | } |
3464 | 0 |
|
3465 | 0 | return true; |
3466 | 0 | } |
3467 | | |
3468 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
3469 | | nullptr, |
3470 | | nullptr, |
3471 | | nullptr, |
3472 | | { nullptr, nullptr }, |
3473 | | prototypes::id::EXT_shader_texture_lod, |
3474 | | constructors::id::_ID_Count, |
3475 | | nullptr, |
3476 | | &DefaultXrayExpandoObjectClass |
3477 | | } }; |
3478 | | |
3479 | | void |
3480 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
3481 | 0 | { |
3482 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
3483 | 0 | if (!parentProto) { |
3484 | 0 | return; |
3485 | 0 | } |
3486 | 0 | |
3487 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::EXT_shader_texture_lod); |
3488 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
3489 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
3490 | 0 | &sPrototypeClass.mBase, protoCache, |
3491 | 0 | nullptr, |
3492 | 0 | nullptr, nullptr, 0, nullptr, |
3493 | 0 | interfaceCache, |
3494 | 0 | nullptr, |
3495 | 0 | nullptr, |
3496 | 0 | nullptr, aDefineOnGlobal, |
3497 | 0 | nullptr, |
3498 | 0 | false); |
3499 | 0 | } |
3500 | | |
3501 | | } // namespace EXT_shader_texture_lod_Binding |
3502 | | |
3503 | | |
3504 | | |
3505 | | namespace EXT_texture_filter_anisotropic_Binding { |
3506 | | |
3507 | | static bool |
3508 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
3509 | 0 | { |
3510 | 0 | mozilla::WebGLExtensionTextureFilterAnisotropic* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionTextureFilterAnisotropic>(obj); |
3511 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
3512 | 0 | // obviously can't preserve if we're not initialized. |
3513 | 0 | if (self && self->GetWrapperPreserveColor()) { |
3514 | 0 | PreserveWrapper(self); |
3515 | 0 | } |
3516 | 0 | return true; |
3517 | 0 | } |
3518 | | |
3519 | | static void |
3520 | | _finalize(js::FreeOp* fop, JSObject* obj) |
3521 | 0 | { |
3522 | 0 | mozilla::WebGLExtensionTextureFilterAnisotropic* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionTextureFilterAnisotropic>(obj); |
3523 | 0 | if (self) { |
3524 | 0 | ClearWrapper(self, self, obj); |
3525 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionTextureFilterAnisotropic>(self); |
3526 | 0 | } |
3527 | 0 | } |
3528 | | |
3529 | | static size_t |
3530 | | _objectMoved(JSObject* obj, JSObject* old) |
3531 | 0 | { |
3532 | 0 | mozilla::WebGLExtensionTextureFilterAnisotropic* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionTextureFilterAnisotropic>(obj); |
3533 | 0 | if (self) { |
3534 | 0 | UpdateWrapper(self, self, obj, old); |
3535 | 0 | } |
3536 | 0 |
|
3537 | 0 | return 0; |
3538 | 0 | } |
3539 | | |
3540 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
3541 | | #if defined(__clang__) |
3542 | | #pragma clang diagnostic push |
3543 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
3544 | | #endif |
3545 | | static const ConstantSpec sConstants_specs[] = { |
3546 | | { "TEXTURE_MAX_ANISOTROPY_EXT", JS::NumberValue(34046U) }, |
3547 | | { "MAX_TEXTURE_MAX_ANISOTROPY_EXT", JS::NumberValue(34047U) }, |
3548 | | { 0, JS::UndefinedValue() } |
3549 | | }; |
3550 | | #if defined(__clang__) |
3551 | | #pragma clang diagnostic pop |
3552 | | #endif |
3553 | | |
3554 | | |
3555 | | static const Prefable<const ConstantSpec> sConstants[] = { |
3556 | | { nullptr, &sConstants_specs[0] }, |
3557 | | { nullptr, nullptr } |
3558 | | }; |
3559 | | |
3560 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
3561 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
3562 | | static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
3563 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
3564 | | |
3565 | | |
3566 | | static uint16_t sNativeProperties_sortedPropertyIndices[2]; |
3567 | | static PropertyInfo sNativeProperties_propertyInfos[2]; |
3568 | | |
3569 | | static const NativePropertiesN<1> sNativeProperties = { |
3570 | | false, 0, |
3571 | | false, 0, |
3572 | | false, 0, |
3573 | | false, 0, |
3574 | | false, 0, |
3575 | | false, 0, |
3576 | | true, 0 /* sConstants */, |
3577 | | -1, |
3578 | | 2, |
3579 | | sNativeProperties_sortedPropertyIndices, |
3580 | | { |
3581 | | { sConstants, &sNativeProperties_propertyInfos[0] } |
3582 | | } |
3583 | | }; |
3584 | | static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
3585 | | "We have a property info count that is oversized"); |
3586 | | |
3587 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
3588 | | { |
3589 | | "EXT_texture_filter_anisotropicPrototype", |
3590 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
3591 | | JS_NULL_CLASS_OPS, |
3592 | | JS_NULL_CLASS_SPEC, |
3593 | | JS_NULL_CLASS_EXT, |
3594 | | JS_NULL_OBJECT_OPS |
3595 | | }, |
3596 | | eInterfacePrototype, |
3597 | | false, |
3598 | | prototypes::id::EXT_texture_filter_anisotropic, |
3599 | | PrototypeTraits<prototypes::id::EXT_texture_filter_anisotropic>::Depth, |
3600 | | sNativePropertyHooks, |
3601 | | "[object EXT_texture_filter_anisotropicPrototype]", |
3602 | | JS::GetRealmObjectPrototype |
3603 | | }; |
3604 | | |
3605 | | static const js::ClassOps sClassOps = { |
3606 | | _addProperty, /* addProperty */ |
3607 | | nullptr, /* delProperty */ |
3608 | | nullptr, /* enumerate */ |
3609 | | nullptr, /* newEnumerate */ |
3610 | | nullptr, /* resolve */ |
3611 | | nullptr, /* mayResolve */ |
3612 | | _finalize, /* finalize */ |
3613 | | nullptr, /* call */ |
3614 | | nullptr, /* hasInstance */ |
3615 | | nullptr, /* construct */ |
3616 | | nullptr, /* trace */ |
3617 | | }; |
3618 | | |
3619 | | static const js::ClassExtension sClassExtension = { |
3620 | | nullptr, /* weakmapKeyDelegateOp */ |
3621 | | _objectMoved /* objectMovedOp */ |
3622 | | }; |
3623 | | |
3624 | | static const DOMJSClass sClass = { |
3625 | | { "EXT_texture_filter_anisotropic", |
3626 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
3627 | | &sClassOps, |
3628 | | JS_NULL_CLASS_SPEC, |
3629 | | &sClassExtension, |
3630 | | JS_NULL_OBJECT_OPS |
3631 | | }, |
3632 | | { prototypes::id::EXT_texture_filter_anisotropic, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
3633 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionTextureFilterAnisotropic >::value, |
3634 | | sNativePropertyHooks, |
3635 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionTextureFilterAnisotropic>::Get, |
3636 | | GetProtoObjectHandle, |
3637 | | GetCCParticipant<mozilla::WebGLExtensionTextureFilterAnisotropic>::Get() |
3638 | | }; |
3639 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
3640 | | "Must have the right minimal number of reserved slots."); |
3641 | | static_assert(1 >= 1, |
3642 | | "Must have enough reserved slots."); |
3643 | | |
3644 | | const JSClass* |
3645 | | GetJSClass() |
3646 | 0 | { |
3647 | 0 | return sClass.ToJSClass(); |
3648 | 0 | } |
3649 | | |
3650 | | bool |
3651 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionTextureFilterAnisotropic* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
3652 | 0 | { |
3653 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionTextureFilterAnisotropic>::value, |
3654 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
3655 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionTextureFilterAnisotropic*>(aObject) == |
3656 | 0 | reinterpret_cast<mozilla::WebGLExtensionTextureFilterAnisotropic*>(aObject), |
3657 | 0 | "Multiple inheritance for mozilla::WebGLExtensionTextureFilterAnisotropic is broken."); |
3658 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
3659 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
3660 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
3661 | 0 | "You should probably not be using Wrap() directly; use " |
3662 | 0 | "GetOrCreateDOMReflector instead"); |
3663 | 0 |
|
3664 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
3665 | 0 | "nsISupports must be on our primary inheritance chain"); |
3666 | 0 |
|
3667 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
3668 | 0 | if (!global) { |
3669 | 0 | return false; |
3670 | 0 | } |
3671 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
3672 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
3673 | 0 |
|
3674 | 0 | // That might have ended up wrapping us already, due to the wonders |
3675 | 0 | // of XBL. Check for that, and bail out as needed. |
3676 | 0 | aReflector.set(aCache->GetWrapper()); |
3677 | 0 | if (aReflector) { |
3678 | | #ifdef DEBUG |
3679 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
3680 | | #endif // DEBUG |
3681 | | return true; |
3682 | 0 | } |
3683 | 0 |
|
3684 | 0 | JSAutoRealm ar(aCx, global); |
3685 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
3686 | 0 | if (!canonicalProto) { |
3687 | 0 | return false; |
3688 | 0 | } |
3689 | 0 | JS::Rooted<JSObject*> proto(aCx); |
3690 | 0 | if (aGivenProto) { |
3691 | 0 | proto = aGivenProto; |
3692 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
3693 | 0 | // coming in, we changed compartments to that of "parent" so may need |
3694 | 0 | // to wrap the proto here. |
3695 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
3696 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
3697 | 0 | return false; |
3698 | 0 | } |
3699 | 0 | } |
3700 | 0 | } else { |
3701 | 0 | proto = canonicalProto; |
3702 | 0 | } |
3703 | 0 |
|
3704 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionTextureFilterAnisotropic> creator(aCx); |
3705 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
3706 | 0 | if (!aReflector) { |
3707 | 0 | return false; |
3708 | 0 | } |
3709 | 0 | |
3710 | 0 | aCache->SetWrapper(aReflector); |
3711 | 0 | creator.InitializationSucceeded(); |
3712 | 0 |
|
3713 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
3714 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
3715 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
3716 | 0 | // otherwise we won't be able to properly recreate it later, since |
3717 | 0 | // we won't know what proto to use. Note that we don't check |
3718 | 0 | // aGivenProto here, since it's entirely possible (and even |
3719 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
3720 | 0 | // same as canonicalProto. |
3721 | 0 | if (proto != canonicalProto) { |
3722 | 0 | PreserveWrapper(aObject); |
3723 | 0 | } |
3724 | 0 |
|
3725 | 0 | return true; |
3726 | 0 | } |
3727 | | |
3728 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
3729 | | nullptr, |
3730 | | nullptr, |
3731 | | nullptr, |
3732 | | { sNativeProperties.Upcast(), nullptr }, |
3733 | | prototypes::id::EXT_texture_filter_anisotropic, |
3734 | | constructors::id::_ID_Count, |
3735 | | nullptr, |
3736 | | &DefaultXrayExpandoObjectClass |
3737 | | } }; |
3738 | | |
3739 | | void |
3740 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
3741 | 0 | { |
3742 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
3743 | 0 | if (!parentProto) { |
3744 | 0 | return; |
3745 | 0 | } |
3746 | 0 | |
3747 | 0 | static bool sIdsInited = false; |
3748 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
3749 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
3750 | 0 | return; |
3751 | 0 | } |
3752 | 0 | sIdsInited = true; |
3753 | 0 | } |
3754 | 0 |
|
3755 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::EXT_texture_filter_anisotropic); |
3756 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
3757 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
3758 | 0 | &sPrototypeClass.mBase, protoCache, |
3759 | 0 | nullptr, |
3760 | 0 | nullptr, nullptr, 0, nullptr, |
3761 | 0 | interfaceCache, |
3762 | 0 | sNativeProperties.Upcast(), |
3763 | 0 | nullptr, |
3764 | 0 | nullptr, aDefineOnGlobal, |
3765 | 0 | nullptr, |
3766 | 0 | false); |
3767 | 0 | } |
3768 | | |
3769 | | } // namespace EXT_texture_filter_anisotropic_Binding |
3770 | | |
3771 | | |
3772 | | |
3773 | | namespace MOZ_debug_Binding { |
3774 | | |
3775 | | MOZ_CAN_RUN_SCRIPT static bool |
3776 | | getParameter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionMOZDebug* self, const JSJitMethodCallArgs& args) |
3777 | 0 | { |
3778 | 0 | AUTO_PROFILER_LABEL_FAST("MOZ_debug.getParameter", DOM, cx); |
3779 | 0 |
|
3780 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
3781 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MOZ_debug.getParameter"); |
3782 | 0 | } |
3783 | 0 | uint32_t arg0; |
3784 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
3785 | 0 | return false; |
3786 | 0 | } |
3787 | 0 | FastErrorResult rv; |
3788 | 0 | JS::Rooted<JS::Value> result(cx); |
3789 | 0 | self->GetParameter(cx, arg0, &result, rv); |
3790 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
3791 | 0 | return false; |
3792 | 0 | } |
3793 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
3794 | 0 | JS::ExposeValueToActiveJS(result); |
3795 | 0 | args.rval().set(result); |
3796 | 0 | if (!MaybeWrapValue(cx, args.rval())) { |
3797 | 0 | return false; |
3798 | 0 | } |
3799 | 0 | return true; |
3800 | 0 | } |
3801 | | |
3802 | | static const JSJitInfo getParameter_methodinfo = { |
3803 | | { (JSJitGetterOp)getParameter }, |
3804 | | { prototypes::id::MOZ_debug }, |
3805 | | { PrototypeTraits<prototypes::id::MOZ_debug>::Depth }, |
3806 | | JSJitInfo::Method, |
3807 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
3808 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
3809 | | false, /* isInfallible. False in setters. */ |
3810 | | false, /* isMovable. Not relevant for setters. */ |
3811 | | false, /* isEliminatable. Not relevant for setters. */ |
3812 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
3813 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
3814 | | false, /* isTypedMethod. Only relevant for methods. */ |
3815 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
3816 | | }; |
3817 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
3818 | | static_assert(0 < 1, "There is no slot for us"); |
3819 | | |
3820 | | static bool |
3821 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
3822 | 0 | { |
3823 | 0 | mozilla::WebGLExtensionMOZDebug* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionMOZDebug>(obj); |
3824 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
3825 | 0 | // obviously can't preserve if we're not initialized. |
3826 | 0 | if (self && self->GetWrapperPreserveColor()) { |
3827 | 0 | PreserveWrapper(self); |
3828 | 0 | } |
3829 | 0 | return true; |
3830 | 0 | } |
3831 | | |
3832 | | static void |
3833 | | _finalize(js::FreeOp* fop, JSObject* obj) |
3834 | 0 | { |
3835 | 0 | mozilla::WebGLExtensionMOZDebug* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionMOZDebug>(obj); |
3836 | 0 | if (self) { |
3837 | 0 | ClearWrapper(self, self, obj); |
3838 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionMOZDebug>(self); |
3839 | 0 | } |
3840 | 0 | } |
3841 | | |
3842 | | static size_t |
3843 | | _objectMoved(JSObject* obj, JSObject* old) |
3844 | 0 | { |
3845 | 0 | mozilla::WebGLExtensionMOZDebug* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionMOZDebug>(obj); |
3846 | 0 | if (self) { |
3847 | 0 | UpdateWrapper(self, self, obj, old); |
3848 | 0 | } |
3849 | 0 |
|
3850 | 0 | return 0; |
3851 | 0 | } |
3852 | | |
3853 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
3854 | | #if defined(__clang__) |
3855 | | #pragma clang diagnostic push |
3856 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
3857 | | #endif |
3858 | | static const JSFunctionSpec sMethods_specs[] = { |
3859 | | JS_FNSPEC("getParameter", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getParameter_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
3860 | | JS_FS_END |
3861 | | }; |
3862 | | #if defined(__clang__) |
3863 | | #pragma clang diagnostic pop |
3864 | | #endif |
3865 | | |
3866 | | |
3867 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
3868 | | { nullptr, &sMethods_specs[0] }, |
3869 | | { nullptr, nullptr } |
3870 | | }; |
3871 | | |
3872 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
3873 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
3874 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
3875 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
3876 | | |
3877 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
3878 | | #if defined(__clang__) |
3879 | | #pragma clang diagnostic push |
3880 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
3881 | | #endif |
3882 | | static const ConstantSpec sConstants_specs[] = { |
3883 | | { "EXTENSIONS", JS::NumberValue(7939U) }, |
3884 | | { "WSI_INFO", JS::NumberValue(65536U) }, |
3885 | | { "UNPACK_REQUIRE_FASTPATH", JS::NumberValue(65537U) }, |
3886 | | { "DOES_INDEX_VALIDATION", JS::NumberValue(65538U) }, |
3887 | | { 0, JS::UndefinedValue() } |
3888 | | }; |
3889 | | #if defined(__clang__) |
3890 | | #pragma clang diagnostic pop |
3891 | | #endif |
3892 | | |
3893 | | |
3894 | | static const Prefable<const ConstantSpec> sConstants[] = { |
3895 | | { nullptr, &sConstants_specs[0] }, |
3896 | | { nullptr, nullptr } |
3897 | | }; |
3898 | | |
3899 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
3900 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
3901 | | static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
3902 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
3903 | | |
3904 | | |
3905 | | static uint16_t sNativeProperties_sortedPropertyIndices[5]; |
3906 | | static PropertyInfo sNativeProperties_propertyInfos[5]; |
3907 | | |
3908 | | static const NativePropertiesN<2> sNativeProperties = { |
3909 | | false, 0, |
3910 | | false, 0, |
3911 | | true, 0 /* sMethods */, |
3912 | | false, 0, |
3913 | | false, 0, |
3914 | | false, 0, |
3915 | | true, 1 /* sConstants */, |
3916 | | -1, |
3917 | | 5, |
3918 | | sNativeProperties_sortedPropertyIndices, |
3919 | | { |
3920 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
3921 | | { sConstants, &sNativeProperties_propertyInfos[1] } |
3922 | | } |
3923 | | }; |
3924 | | static_assert(5 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
3925 | | "We have a property info count that is oversized"); |
3926 | | |
3927 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
3928 | | { |
3929 | | "MOZ_debugPrototype", |
3930 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
3931 | | JS_NULL_CLASS_OPS, |
3932 | | JS_NULL_CLASS_SPEC, |
3933 | | JS_NULL_CLASS_EXT, |
3934 | | JS_NULL_OBJECT_OPS |
3935 | | }, |
3936 | | eInterfacePrototype, |
3937 | | false, |
3938 | | prototypes::id::MOZ_debug, |
3939 | | PrototypeTraits<prototypes::id::MOZ_debug>::Depth, |
3940 | | sNativePropertyHooks, |
3941 | | "[object MOZ_debugPrototype]", |
3942 | | JS::GetRealmObjectPrototype |
3943 | | }; |
3944 | | |
3945 | | static const js::ClassOps sClassOps = { |
3946 | | _addProperty, /* addProperty */ |
3947 | | nullptr, /* delProperty */ |
3948 | | nullptr, /* enumerate */ |
3949 | | nullptr, /* newEnumerate */ |
3950 | | nullptr, /* resolve */ |
3951 | | nullptr, /* mayResolve */ |
3952 | | _finalize, /* finalize */ |
3953 | | nullptr, /* call */ |
3954 | | nullptr, /* hasInstance */ |
3955 | | nullptr, /* construct */ |
3956 | | nullptr, /* trace */ |
3957 | | }; |
3958 | | |
3959 | | static const js::ClassExtension sClassExtension = { |
3960 | | nullptr, /* weakmapKeyDelegateOp */ |
3961 | | _objectMoved /* objectMovedOp */ |
3962 | | }; |
3963 | | |
3964 | | static const DOMJSClass sClass = { |
3965 | | { "MOZ_debug", |
3966 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
3967 | | &sClassOps, |
3968 | | JS_NULL_CLASS_SPEC, |
3969 | | &sClassExtension, |
3970 | | JS_NULL_OBJECT_OPS |
3971 | | }, |
3972 | | { prototypes::id::MOZ_debug, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
3973 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionMOZDebug >::value, |
3974 | | sNativePropertyHooks, |
3975 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionMOZDebug>::Get, |
3976 | | GetProtoObjectHandle, |
3977 | | GetCCParticipant<mozilla::WebGLExtensionMOZDebug>::Get() |
3978 | | }; |
3979 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
3980 | | "Must have the right minimal number of reserved slots."); |
3981 | | static_assert(1 >= 1, |
3982 | | "Must have enough reserved slots."); |
3983 | | |
3984 | | const JSClass* |
3985 | | GetJSClass() |
3986 | 0 | { |
3987 | 0 | return sClass.ToJSClass(); |
3988 | 0 | } |
3989 | | |
3990 | | bool |
3991 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionMOZDebug* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
3992 | 0 | { |
3993 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionMOZDebug>::value, |
3994 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
3995 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionMOZDebug*>(aObject) == |
3996 | 0 | reinterpret_cast<mozilla::WebGLExtensionMOZDebug*>(aObject), |
3997 | 0 | "Multiple inheritance for mozilla::WebGLExtensionMOZDebug is broken."); |
3998 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
3999 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
4000 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
4001 | 0 | "You should probably not be using Wrap() directly; use " |
4002 | 0 | "GetOrCreateDOMReflector instead"); |
4003 | 0 |
|
4004 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
4005 | 0 | "nsISupports must be on our primary inheritance chain"); |
4006 | 0 |
|
4007 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
4008 | 0 | if (!global) { |
4009 | 0 | return false; |
4010 | 0 | } |
4011 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
4012 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
4013 | 0 |
|
4014 | 0 | // That might have ended up wrapping us already, due to the wonders |
4015 | 0 | // of XBL. Check for that, and bail out as needed. |
4016 | 0 | aReflector.set(aCache->GetWrapper()); |
4017 | 0 | if (aReflector) { |
4018 | | #ifdef DEBUG |
4019 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
4020 | | #endif // DEBUG |
4021 | | return true; |
4022 | 0 | } |
4023 | 0 |
|
4024 | 0 | JSAutoRealm ar(aCx, global); |
4025 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
4026 | 0 | if (!canonicalProto) { |
4027 | 0 | return false; |
4028 | 0 | } |
4029 | 0 | JS::Rooted<JSObject*> proto(aCx); |
4030 | 0 | if (aGivenProto) { |
4031 | 0 | proto = aGivenProto; |
4032 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
4033 | 0 | // coming in, we changed compartments to that of "parent" so may need |
4034 | 0 | // to wrap the proto here. |
4035 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
4036 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
4037 | 0 | return false; |
4038 | 0 | } |
4039 | 0 | } |
4040 | 0 | } else { |
4041 | 0 | proto = canonicalProto; |
4042 | 0 | } |
4043 | 0 |
|
4044 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionMOZDebug> creator(aCx); |
4045 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
4046 | 0 | if (!aReflector) { |
4047 | 0 | return false; |
4048 | 0 | } |
4049 | 0 | |
4050 | 0 | aCache->SetWrapper(aReflector); |
4051 | 0 | creator.InitializationSucceeded(); |
4052 | 0 |
|
4053 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
4054 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
4055 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
4056 | 0 | // otherwise we won't be able to properly recreate it later, since |
4057 | 0 | // we won't know what proto to use. Note that we don't check |
4058 | 0 | // aGivenProto here, since it's entirely possible (and even |
4059 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
4060 | 0 | // same as canonicalProto. |
4061 | 0 | if (proto != canonicalProto) { |
4062 | 0 | PreserveWrapper(aObject); |
4063 | 0 | } |
4064 | 0 |
|
4065 | 0 | return true; |
4066 | 0 | } |
4067 | | |
4068 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
4069 | | nullptr, |
4070 | | nullptr, |
4071 | | nullptr, |
4072 | | { sNativeProperties.Upcast(), nullptr }, |
4073 | | prototypes::id::MOZ_debug, |
4074 | | constructors::id::_ID_Count, |
4075 | | nullptr, |
4076 | | &DefaultXrayExpandoObjectClass |
4077 | | } }; |
4078 | | |
4079 | | void |
4080 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
4081 | 0 | { |
4082 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
4083 | 0 | if (!parentProto) { |
4084 | 0 | return; |
4085 | 0 | } |
4086 | 0 | |
4087 | 0 | static bool sIdsInited = false; |
4088 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
4089 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
4090 | 0 | return; |
4091 | 0 | } |
4092 | 0 | sIdsInited = true; |
4093 | 0 | } |
4094 | 0 |
|
4095 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::MOZ_debug); |
4096 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
4097 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
4098 | 0 | &sPrototypeClass.mBase, protoCache, |
4099 | 0 | nullptr, |
4100 | 0 | nullptr, nullptr, 0, nullptr, |
4101 | 0 | interfaceCache, |
4102 | 0 | sNativeProperties.Upcast(), |
4103 | 0 | nullptr, |
4104 | 0 | nullptr, aDefineOnGlobal, |
4105 | 0 | nullptr, |
4106 | 0 | false); |
4107 | 0 | } |
4108 | | |
4109 | | } // namespace MOZ_debug_Binding |
4110 | | |
4111 | | |
4112 | | |
4113 | | namespace OES_element_index_uint_Binding { |
4114 | | |
4115 | | static bool |
4116 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
4117 | 0 | { |
4118 | 0 | mozilla::WebGLExtensionElementIndexUint* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionElementIndexUint>(obj); |
4119 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
4120 | 0 | // obviously can't preserve if we're not initialized. |
4121 | 0 | if (self && self->GetWrapperPreserveColor()) { |
4122 | 0 | PreserveWrapper(self); |
4123 | 0 | } |
4124 | 0 | return true; |
4125 | 0 | } |
4126 | | |
4127 | | static void |
4128 | | _finalize(js::FreeOp* fop, JSObject* obj) |
4129 | 0 | { |
4130 | 0 | mozilla::WebGLExtensionElementIndexUint* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionElementIndexUint>(obj); |
4131 | 0 | if (self) { |
4132 | 0 | ClearWrapper(self, self, obj); |
4133 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionElementIndexUint>(self); |
4134 | 0 | } |
4135 | 0 | } |
4136 | | |
4137 | | static size_t |
4138 | | _objectMoved(JSObject* obj, JSObject* old) |
4139 | 0 | { |
4140 | 0 | mozilla::WebGLExtensionElementIndexUint* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionElementIndexUint>(obj); |
4141 | 0 | if (self) { |
4142 | 0 | UpdateWrapper(self, self, obj, old); |
4143 | 0 | } |
4144 | 0 |
|
4145 | 0 | return 0; |
4146 | 0 | } |
4147 | | |
4148 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
4149 | | { |
4150 | | "OES_element_index_uintPrototype", |
4151 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
4152 | | JS_NULL_CLASS_OPS, |
4153 | | JS_NULL_CLASS_SPEC, |
4154 | | JS_NULL_CLASS_EXT, |
4155 | | JS_NULL_OBJECT_OPS |
4156 | | }, |
4157 | | eInterfacePrototype, |
4158 | | false, |
4159 | | prototypes::id::OES_element_index_uint, |
4160 | | PrototypeTraits<prototypes::id::OES_element_index_uint>::Depth, |
4161 | | sNativePropertyHooks, |
4162 | | "[object OES_element_index_uintPrototype]", |
4163 | | JS::GetRealmObjectPrototype |
4164 | | }; |
4165 | | |
4166 | | static const js::ClassOps sClassOps = { |
4167 | | _addProperty, /* addProperty */ |
4168 | | nullptr, /* delProperty */ |
4169 | | nullptr, /* enumerate */ |
4170 | | nullptr, /* newEnumerate */ |
4171 | | nullptr, /* resolve */ |
4172 | | nullptr, /* mayResolve */ |
4173 | | _finalize, /* finalize */ |
4174 | | nullptr, /* call */ |
4175 | | nullptr, /* hasInstance */ |
4176 | | nullptr, /* construct */ |
4177 | | nullptr, /* trace */ |
4178 | | }; |
4179 | | |
4180 | | static const js::ClassExtension sClassExtension = { |
4181 | | nullptr, /* weakmapKeyDelegateOp */ |
4182 | | _objectMoved /* objectMovedOp */ |
4183 | | }; |
4184 | | |
4185 | | static const DOMJSClass sClass = { |
4186 | | { "OES_element_index_uint", |
4187 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
4188 | | &sClassOps, |
4189 | | JS_NULL_CLASS_SPEC, |
4190 | | &sClassExtension, |
4191 | | JS_NULL_OBJECT_OPS |
4192 | | }, |
4193 | | { prototypes::id::OES_element_index_uint, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
4194 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionElementIndexUint >::value, |
4195 | | sNativePropertyHooks, |
4196 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionElementIndexUint>::Get, |
4197 | | GetProtoObjectHandle, |
4198 | | GetCCParticipant<mozilla::WebGLExtensionElementIndexUint>::Get() |
4199 | | }; |
4200 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
4201 | | "Must have the right minimal number of reserved slots."); |
4202 | | static_assert(1 >= 1, |
4203 | | "Must have enough reserved slots."); |
4204 | | |
4205 | | const JSClass* |
4206 | | GetJSClass() |
4207 | 0 | { |
4208 | 0 | return sClass.ToJSClass(); |
4209 | 0 | } |
4210 | | |
4211 | | bool |
4212 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionElementIndexUint* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
4213 | 0 | { |
4214 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionElementIndexUint>::value, |
4215 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
4216 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionElementIndexUint*>(aObject) == |
4217 | 0 | reinterpret_cast<mozilla::WebGLExtensionElementIndexUint*>(aObject), |
4218 | 0 | "Multiple inheritance for mozilla::WebGLExtensionElementIndexUint is broken."); |
4219 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
4220 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
4221 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
4222 | 0 | "You should probably not be using Wrap() directly; use " |
4223 | 0 | "GetOrCreateDOMReflector instead"); |
4224 | 0 |
|
4225 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
4226 | 0 | "nsISupports must be on our primary inheritance chain"); |
4227 | 0 |
|
4228 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
4229 | 0 | if (!global) { |
4230 | 0 | return false; |
4231 | 0 | } |
4232 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
4233 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
4234 | 0 |
|
4235 | 0 | // That might have ended up wrapping us already, due to the wonders |
4236 | 0 | // of XBL. Check for that, and bail out as needed. |
4237 | 0 | aReflector.set(aCache->GetWrapper()); |
4238 | 0 | if (aReflector) { |
4239 | | #ifdef DEBUG |
4240 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
4241 | | #endif // DEBUG |
4242 | | return true; |
4243 | 0 | } |
4244 | 0 |
|
4245 | 0 | JSAutoRealm ar(aCx, global); |
4246 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
4247 | 0 | if (!canonicalProto) { |
4248 | 0 | return false; |
4249 | 0 | } |
4250 | 0 | JS::Rooted<JSObject*> proto(aCx); |
4251 | 0 | if (aGivenProto) { |
4252 | 0 | proto = aGivenProto; |
4253 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
4254 | 0 | // coming in, we changed compartments to that of "parent" so may need |
4255 | 0 | // to wrap the proto here. |
4256 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
4257 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
4258 | 0 | return false; |
4259 | 0 | } |
4260 | 0 | } |
4261 | 0 | } else { |
4262 | 0 | proto = canonicalProto; |
4263 | 0 | } |
4264 | 0 |
|
4265 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionElementIndexUint> creator(aCx); |
4266 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
4267 | 0 | if (!aReflector) { |
4268 | 0 | return false; |
4269 | 0 | } |
4270 | 0 | |
4271 | 0 | aCache->SetWrapper(aReflector); |
4272 | 0 | creator.InitializationSucceeded(); |
4273 | 0 |
|
4274 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
4275 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
4276 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
4277 | 0 | // otherwise we won't be able to properly recreate it later, since |
4278 | 0 | // we won't know what proto to use. Note that we don't check |
4279 | 0 | // aGivenProto here, since it's entirely possible (and even |
4280 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
4281 | 0 | // same as canonicalProto. |
4282 | 0 | if (proto != canonicalProto) { |
4283 | 0 | PreserveWrapper(aObject); |
4284 | 0 | } |
4285 | 0 |
|
4286 | 0 | return true; |
4287 | 0 | } |
4288 | | |
4289 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
4290 | | nullptr, |
4291 | | nullptr, |
4292 | | nullptr, |
4293 | | { nullptr, nullptr }, |
4294 | | prototypes::id::OES_element_index_uint, |
4295 | | constructors::id::_ID_Count, |
4296 | | nullptr, |
4297 | | &DefaultXrayExpandoObjectClass |
4298 | | } }; |
4299 | | |
4300 | | void |
4301 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
4302 | 0 | { |
4303 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
4304 | 0 | if (!parentProto) { |
4305 | 0 | return; |
4306 | 0 | } |
4307 | 0 | |
4308 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::OES_element_index_uint); |
4309 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
4310 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
4311 | 0 | &sPrototypeClass.mBase, protoCache, |
4312 | 0 | nullptr, |
4313 | 0 | nullptr, nullptr, 0, nullptr, |
4314 | 0 | interfaceCache, |
4315 | 0 | nullptr, |
4316 | 0 | nullptr, |
4317 | 0 | nullptr, aDefineOnGlobal, |
4318 | 0 | nullptr, |
4319 | 0 | false); |
4320 | 0 | } |
4321 | | |
4322 | | } // namespace OES_element_index_uint_Binding |
4323 | | |
4324 | | |
4325 | | |
4326 | | namespace OES_standard_derivatives_Binding { |
4327 | | |
4328 | | static bool |
4329 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
4330 | 0 | { |
4331 | 0 | mozilla::WebGLExtensionStandardDerivatives* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionStandardDerivatives>(obj); |
4332 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
4333 | 0 | // obviously can't preserve if we're not initialized. |
4334 | 0 | if (self && self->GetWrapperPreserveColor()) { |
4335 | 0 | PreserveWrapper(self); |
4336 | 0 | } |
4337 | 0 | return true; |
4338 | 0 | } |
4339 | | |
4340 | | static void |
4341 | | _finalize(js::FreeOp* fop, JSObject* obj) |
4342 | 0 | { |
4343 | 0 | mozilla::WebGLExtensionStandardDerivatives* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionStandardDerivatives>(obj); |
4344 | 0 | if (self) { |
4345 | 0 | ClearWrapper(self, self, obj); |
4346 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionStandardDerivatives>(self); |
4347 | 0 | } |
4348 | 0 | } |
4349 | | |
4350 | | static size_t |
4351 | | _objectMoved(JSObject* obj, JSObject* old) |
4352 | 0 | { |
4353 | 0 | mozilla::WebGLExtensionStandardDerivatives* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionStandardDerivatives>(obj); |
4354 | 0 | if (self) { |
4355 | 0 | UpdateWrapper(self, self, obj, old); |
4356 | 0 | } |
4357 | 0 |
|
4358 | 0 | return 0; |
4359 | 0 | } |
4360 | | |
4361 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
4362 | | #if defined(__clang__) |
4363 | | #pragma clang diagnostic push |
4364 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
4365 | | #endif |
4366 | | static const ConstantSpec sConstants_specs[] = { |
4367 | | { "FRAGMENT_SHADER_DERIVATIVE_HINT_OES", JS::NumberValue(35723U) }, |
4368 | | { 0, JS::UndefinedValue() } |
4369 | | }; |
4370 | | #if defined(__clang__) |
4371 | | #pragma clang diagnostic pop |
4372 | | #endif |
4373 | | |
4374 | | |
4375 | | static const Prefable<const ConstantSpec> sConstants[] = { |
4376 | | { nullptr, &sConstants_specs[0] }, |
4377 | | { nullptr, nullptr } |
4378 | | }; |
4379 | | |
4380 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
4381 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
4382 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
4383 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
4384 | | |
4385 | | |
4386 | | static uint16_t sNativeProperties_sortedPropertyIndices[1]; |
4387 | | static PropertyInfo sNativeProperties_propertyInfos[1]; |
4388 | | |
4389 | | static const NativePropertiesN<1> sNativeProperties = { |
4390 | | false, 0, |
4391 | | false, 0, |
4392 | | false, 0, |
4393 | | false, 0, |
4394 | | false, 0, |
4395 | | false, 0, |
4396 | | true, 0 /* sConstants */, |
4397 | | -1, |
4398 | | 1, |
4399 | | sNativeProperties_sortedPropertyIndices, |
4400 | | { |
4401 | | { sConstants, &sNativeProperties_propertyInfos[0] } |
4402 | | } |
4403 | | }; |
4404 | | static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
4405 | | "We have a property info count that is oversized"); |
4406 | | |
4407 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
4408 | | { |
4409 | | "OES_standard_derivativesPrototype", |
4410 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
4411 | | JS_NULL_CLASS_OPS, |
4412 | | JS_NULL_CLASS_SPEC, |
4413 | | JS_NULL_CLASS_EXT, |
4414 | | JS_NULL_OBJECT_OPS |
4415 | | }, |
4416 | | eInterfacePrototype, |
4417 | | false, |
4418 | | prototypes::id::OES_standard_derivatives, |
4419 | | PrototypeTraits<prototypes::id::OES_standard_derivatives>::Depth, |
4420 | | sNativePropertyHooks, |
4421 | | "[object OES_standard_derivativesPrototype]", |
4422 | | JS::GetRealmObjectPrototype |
4423 | | }; |
4424 | | |
4425 | | static const js::ClassOps sClassOps = { |
4426 | | _addProperty, /* addProperty */ |
4427 | | nullptr, /* delProperty */ |
4428 | | nullptr, /* enumerate */ |
4429 | | nullptr, /* newEnumerate */ |
4430 | | nullptr, /* resolve */ |
4431 | | nullptr, /* mayResolve */ |
4432 | | _finalize, /* finalize */ |
4433 | | nullptr, /* call */ |
4434 | | nullptr, /* hasInstance */ |
4435 | | nullptr, /* construct */ |
4436 | | nullptr, /* trace */ |
4437 | | }; |
4438 | | |
4439 | | static const js::ClassExtension sClassExtension = { |
4440 | | nullptr, /* weakmapKeyDelegateOp */ |
4441 | | _objectMoved /* objectMovedOp */ |
4442 | | }; |
4443 | | |
4444 | | static const DOMJSClass sClass = { |
4445 | | { "OES_standard_derivatives", |
4446 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
4447 | | &sClassOps, |
4448 | | JS_NULL_CLASS_SPEC, |
4449 | | &sClassExtension, |
4450 | | JS_NULL_OBJECT_OPS |
4451 | | }, |
4452 | | { prototypes::id::OES_standard_derivatives, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
4453 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionStandardDerivatives >::value, |
4454 | | sNativePropertyHooks, |
4455 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionStandardDerivatives>::Get, |
4456 | | GetProtoObjectHandle, |
4457 | | GetCCParticipant<mozilla::WebGLExtensionStandardDerivatives>::Get() |
4458 | | }; |
4459 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
4460 | | "Must have the right minimal number of reserved slots."); |
4461 | | static_assert(1 >= 1, |
4462 | | "Must have enough reserved slots."); |
4463 | | |
4464 | | const JSClass* |
4465 | | GetJSClass() |
4466 | 0 | { |
4467 | 0 | return sClass.ToJSClass(); |
4468 | 0 | } |
4469 | | |
4470 | | bool |
4471 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionStandardDerivatives* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
4472 | 0 | { |
4473 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionStandardDerivatives>::value, |
4474 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
4475 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionStandardDerivatives*>(aObject) == |
4476 | 0 | reinterpret_cast<mozilla::WebGLExtensionStandardDerivatives*>(aObject), |
4477 | 0 | "Multiple inheritance for mozilla::WebGLExtensionStandardDerivatives is broken."); |
4478 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
4479 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
4480 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
4481 | 0 | "You should probably not be using Wrap() directly; use " |
4482 | 0 | "GetOrCreateDOMReflector instead"); |
4483 | 0 |
|
4484 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
4485 | 0 | "nsISupports must be on our primary inheritance chain"); |
4486 | 0 |
|
4487 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
4488 | 0 | if (!global) { |
4489 | 0 | return false; |
4490 | 0 | } |
4491 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
4492 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
4493 | 0 |
|
4494 | 0 | // That might have ended up wrapping us already, due to the wonders |
4495 | 0 | // of XBL. Check for that, and bail out as needed. |
4496 | 0 | aReflector.set(aCache->GetWrapper()); |
4497 | 0 | if (aReflector) { |
4498 | | #ifdef DEBUG |
4499 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
4500 | | #endif // DEBUG |
4501 | | return true; |
4502 | 0 | } |
4503 | 0 |
|
4504 | 0 | JSAutoRealm ar(aCx, global); |
4505 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
4506 | 0 | if (!canonicalProto) { |
4507 | 0 | return false; |
4508 | 0 | } |
4509 | 0 | JS::Rooted<JSObject*> proto(aCx); |
4510 | 0 | if (aGivenProto) { |
4511 | 0 | proto = aGivenProto; |
4512 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
4513 | 0 | // coming in, we changed compartments to that of "parent" so may need |
4514 | 0 | // to wrap the proto here. |
4515 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
4516 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
4517 | 0 | return false; |
4518 | 0 | } |
4519 | 0 | } |
4520 | 0 | } else { |
4521 | 0 | proto = canonicalProto; |
4522 | 0 | } |
4523 | 0 |
|
4524 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionStandardDerivatives> creator(aCx); |
4525 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
4526 | 0 | if (!aReflector) { |
4527 | 0 | return false; |
4528 | 0 | } |
4529 | 0 | |
4530 | 0 | aCache->SetWrapper(aReflector); |
4531 | 0 | creator.InitializationSucceeded(); |
4532 | 0 |
|
4533 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
4534 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
4535 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
4536 | 0 | // otherwise we won't be able to properly recreate it later, since |
4537 | 0 | // we won't know what proto to use. Note that we don't check |
4538 | 0 | // aGivenProto here, since it's entirely possible (and even |
4539 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
4540 | 0 | // same as canonicalProto. |
4541 | 0 | if (proto != canonicalProto) { |
4542 | 0 | PreserveWrapper(aObject); |
4543 | 0 | } |
4544 | 0 |
|
4545 | 0 | return true; |
4546 | 0 | } |
4547 | | |
4548 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
4549 | | nullptr, |
4550 | | nullptr, |
4551 | | nullptr, |
4552 | | { sNativeProperties.Upcast(), nullptr }, |
4553 | | prototypes::id::OES_standard_derivatives, |
4554 | | constructors::id::_ID_Count, |
4555 | | nullptr, |
4556 | | &DefaultXrayExpandoObjectClass |
4557 | | } }; |
4558 | | |
4559 | | void |
4560 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
4561 | 0 | { |
4562 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
4563 | 0 | if (!parentProto) { |
4564 | 0 | return; |
4565 | 0 | } |
4566 | 0 | |
4567 | 0 | static bool sIdsInited = false; |
4568 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
4569 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
4570 | 0 | return; |
4571 | 0 | } |
4572 | 0 | sIdsInited = true; |
4573 | 0 | } |
4574 | 0 |
|
4575 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::OES_standard_derivatives); |
4576 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
4577 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
4578 | 0 | &sPrototypeClass.mBase, protoCache, |
4579 | 0 | nullptr, |
4580 | 0 | nullptr, nullptr, 0, nullptr, |
4581 | 0 | interfaceCache, |
4582 | 0 | sNativeProperties.Upcast(), |
4583 | 0 | nullptr, |
4584 | 0 | nullptr, aDefineOnGlobal, |
4585 | 0 | nullptr, |
4586 | 0 | false); |
4587 | 0 | } |
4588 | | |
4589 | | } // namespace OES_standard_derivatives_Binding |
4590 | | |
4591 | | |
4592 | | |
4593 | | namespace OES_texture_float_Binding { |
4594 | | |
4595 | | static bool |
4596 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
4597 | 0 | { |
4598 | 0 | mozilla::WebGLExtensionTextureFloat* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionTextureFloat>(obj); |
4599 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
4600 | 0 | // obviously can't preserve if we're not initialized. |
4601 | 0 | if (self && self->GetWrapperPreserveColor()) { |
4602 | 0 | PreserveWrapper(self); |
4603 | 0 | } |
4604 | 0 | return true; |
4605 | 0 | } |
4606 | | |
4607 | | static void |
4608 | | _finalize(js::FreeOp* fop, JSObject* obj) |
4609 | 0 | { |
4610 | 0 | mozilla::WebGLExtensionTextureFloat* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionTextureFloat>(obj); |
4611 | 0 | if (self) { |
4612 | 0 | ClearWrapper(self, self, obj); |
4613 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionTextureFloat>(self); |
4614 | 0 | } |
4615 | 0 | } |
4616 | | |
4617 | | static size_t |
4618 | | _objectMoved(JSObject* obj, JSObject* old) |
4619 | 0 | { |
4620 | 0 | mozilla::WebGLExtensionTextureFloat* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionTextureFloat>(obj); |
4621 | 0 | if (self) { |
4622 | 0 | UpdateWrapper(self, self, obj, old); |
4623 | 0 | } |
4624 | 0 |
|
4625 | 0 | return 0; |
4626 | 0 | } |
4627 | | |
4628 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
4629 | | { |
4630 | | "OES_texture_floatPrototype", |
4631 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
4632 | | JS_NULL_CLASS_OPS, |
4633 | | JS_NULL_CLASS_SPEC, |
4634 | | JS_NULL_CLASS_EXT, |
4635 | | JS_NULL_OBJECT_OPS |
4636 | | }, |
4637 | | eInterfacePrototype, |
4638 | | false, |
4639 | | prototypes::id::OES_texture_float, |
4640 | | PrototypeTraits<prototypes::id::OES_texture_float>::Depth, |
4641 | | sNativePropertyHooks, |
4642 | | "[object OES_texture_floatPrototype]", |
4643 | | JS::GetRealmObjectPrototype |
4644 | | }; |
4645 | | |
4646 | | static const js::ClassOps sClassOps = { |
4647 | | _addProperty, /* addProperty */ |
4648 | | nullptr, /* delProperty */ |
4649 | | nullptr, /* enumerate */ |
4650 | | nullptr, /* newEnumerate */ |
4651 | | nullptr, /* resolve */ |
4652 | | nullptr, /* mayResolve */ |
4653 | | _finalize, /* finalize */ |
4654 | | nullptr, /* call */ |
4655 | | nullptr, /* hasInstance */ |
4656 | | nullptr, /* construct */ |
4657 | | nullptr, /* trace */ |
4658 | | }; |
4659 | | |
4660 | | static const js::ClassExtension sClassExtension = { |
4661 | | nullptr, /* weakmapKeyDelegateOp */ |
4662 | | _objectMoved /* objectMovedOp */ |
4663 | | }; |
4664 | | |
4665 | | static const DOMJSClass sClass = { |
4666 | | { "OES_texture_float", |
4667 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
4668 | | &sClassOps, |
4669 | | JS_NULL_CLASS_SPEC, |
4670 | | &sClassExtension, |
4671 | | JS_NULL_OBJECT_OPS |
4672 | | }, |
4673 | | { prototypes::id::OES_texture_float, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
4674 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionTextureFloat >::value, |
4675 | | sNativePropertyHooks, |
4676 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionTextureFloat>::Get, |
4677 | | GetProtoObjectHandle, |
4678 | | GetCCParticipant<mozilla::WebGLExtensionTextureFloat>::Get() |
4679 | | }; |
4680 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
4681 | | "Must have the right minimal number of reserved slots."); |
4682 | | static_assert(1 >= 1, |
4683 | | "Must have enough reserved slots."); |
4684 | | |
4685 | | const JSClass* |
4686 | | GetJSClass() |
4687 | 0 | { |
4688 | 0 | return sClass.ToJSClass(); |
4689 | 0 | } |
4690 | | |
4691 | | bool |
4692 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionTextureFloat* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
4693 | 0 | { |
4694 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionTextureFloat>::value, |
4695 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
4696 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionTextureFloat*>(aObject) == |
4697 | 0 | reinterpret_cast<mozilla::WebGLExtensionTextureFloat*>(aObject), |
4698 | 0 | "Multiple inheritance for mozilla::WebGLExtensionTextureFloat is broken."); |
4699 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
4700 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
4701 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
4702 | 0 | "You should probably not be using Wrap() directly; use " |
4703 | 0 | "GetOrCreateDOMReflector instead"); |
4704 | 0 |
|
4705 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
4706 | 0 | "nsISupports must be on our primary inheritance chain"); |
4707 | 0 |
|
4708 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
4709 | 0 | if (!global) { |
4710 | 0 | return false; |
4711 | 0 | } |
4712 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
4713 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
4714 | 0 |
|
4715 | 0 | // That might have ended up wrapping us already, due to the wonders |
4716 | 0 | // of XBL. Check for that, and bail out as needed. |
4717 | 0 | aReflector.set(aCache->GetWrapper()); |
4718 | 0 | if (aReflector) { |
4719 | | #ifdef DEBUG |
4720 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
4721 | | #endif // DEBUG |
4722 | | return true; |
4723 | 0 | } |
4724 | 0 |
|
4725 | 0 | JSAutoRealm ar(aCx, global); |
4726 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
4727 | 0 | if (!canonicalProto) { |
4728 | 0 | return false; |
4729 | 0 | } |
4730 | 0 | JS::Rooted<JSObject*> proto(aCx); |
4731 | 0 | if (aGivenProto) { |
4732 | 0 | proto = aGivenProto; |
4733 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
4734 | 0 | // coming in, we changed compartments to that of "parent" so may need |
4735 | 0 | // to wrap the proto here. |
4736 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
4737 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
4738 | 0 | return false; |
4739 | 0 | } |
4740 | 0 | } |
4741 | 0 | } else { |
4742 | 0 | proto = canonicalProto; |
4743 | 0 | } |
4744 | 0 |
|
4745 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionTextureFloat> creator(aCx); |
4746 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
4747 | 0 | if (!aReflector) { |
4748 | 0 | return false; |
4749 | 0 | } |
4750 | 0 | |
4751 | 0 | aCache->SetWrapper(aReflector); |
4752 | 0 | creator.InitializationSucceeded(); |
4753 | 0 |
|
4754 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
4755 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
4756 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
4757 | 0 | // otherwise we won't be able to properly recreate it later, since |
4758 | 0 | // we won't know what proto to use. Note that we don't check |
4759 | 0 | // aGivenProto here, since it's entirely possible (and even |
4760 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
4761 | 0 | // same as canonicalProto. |
4762 | 0 | if (proto != canonicalProto) { |
4763 | 0 | PreserveWrapper(aObject); |
4764 | 0 | } |
4765 | 0 |
|
4766 | 0 | return true; |
4767 | 0 | } |
4768 | | |
4769 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
4770 | | nullptr, |
4771 | | nullptr, |
4772 | | nullptr, |
4773 | | { nullptr, nullptr }, |
4774 | | prototypes::id::OES_texture_float, |
4775 | | constructors::id::_ID_Count, |
4776 | | nullptr, |
4777 | | &DefaultXrayExpandoObjectClass |
4778 | | } }; |
4779 | | |
4780 | | void |
4781 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
4782 | 0 | { |
4783 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
4784 | 0 | if (!parentProto) { |
4785 | 0 | return; |
4786 | 0 | } |
4787 | 0 | |
4788 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::OES_texture_float); |
4789 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
4790 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
4791 | 0 | &sPrototypeClass.mBase, protoCache, |
4792 | 0 | nullptr, |
4793 | 0 | nullptr, nullptr, 0, nullptr, |
4794 | 0 | interfaceCache, |
4795 | 0 | nullptr, |
4796 | 0 | nullptr, |
4797 | 0 | nullptr, aDefineOnGlobal, |
4798 | 0 | nullptr, |
4799 | 0 | false); |
4800 | 0 | } |
4801 | | |
4802 | | } // namespace OES_texture_float_Binding |
4803 | | |
4804 | | |
4805 | | |
4806 | | namespace OES_texture_float_linear_Binding { |
4807 | | |
4808 | | static bool |
4809 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
4810 | 0 | { |
4811 | 0 | mozilla::WebGLExtensionTextureFloatLinear* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionTextureFloatLinear>(obj); |
4812 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
4813 | 0 | // obviously can't preserve if we're not initialized. |
4814 | 0 | if (self && self->GetWrapperPreserveColor()) { |
4815 | 0 | PreserveWrapper(self); |
4816 | 0 | } |
4817 | 0 | return true; |
4818 | 0 | } |
4819 | | |
4820 | | static void |
4821 | | _finalize(js::FreeOp* fop, JSObject* obj) |
4822 | 0 | { |
4823 | 0 | mozilla::WebGLExtensionTextureFloatLinear* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionTextureFloatLinear>(obj); |
4824 | 0 | if (self) { |
4825 | 0 | ClearWrapper(self, self, obj); |
4826 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionTextureFloatLinear>(self); |
4827 | 0 | } |
4828 | 0 | } |
4829 | | |
4830 | | static size_t |
4831 | | _objectMoved(JSObject* obj, JSObject* old) |
4832 | 0 | { |
4833 | 0 | mozilla::WebGLExtensionTextureFloatLinear* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionTextureFloatLinear>(obj); |
4834 | 0 | if (self) { |
4835 | 0 | UpdateWrapper(self, self, obj, old); |
4836 | 0 | } |
4837 | 0 |
|
4838 | 0 | return 0; |
4839 | 0 | } |
4840 | | |
4841 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
4842 | | { |
4843 | | "OES_texture_float_linearPrototype", |
4844 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
4845 | | JS_NULL_CLASS_OPS, |
4846 | | JS_NULL_CLASS_SPEC, |
4847 | | JS_NULL_CLASS_EXT, |
4848 | | JS_NULL_OBJECT_OPS |
4849 | | }, |
4850 | | eInterfacePrototype, |
4851 | | false, |
4852 | | prototypes::id::OES_texture_float_linear, |
4853 | | PrototypeTraits<prototypes::id::OES_texture_float_linear>::Depth, |
4854 | | sNativePropertyHooks, |
4855 | | "[object OES_texture_float_linearPrototype]", |
4856 | | JS::GetRealmObjectPrototype |
4857 | | }; |
4858 | | |
4859 | | static const js::ClassOps sClassOps = { |
4860 | | _addProperty, /* addProperty */ |
4861 | | nullptr, /* delProperty */ |
4862 | | nullptr, /* enumerate */ |
4863 | | nullptr, /* newEnumerate */ |
4864 | | nullptr, /* resolve */ |
4865 | | nullptr, /* mayResolve */ |
4866 | | _finalize, /* finalize */ |
4867 | | nullptr, /* call */ |
4868 | | nullptr, /* hasInstance */ |
4869 | | nullptr, /* construct */ |
4870 | | nullptr, /* trace */ |
4871 | | }; |
4872 | | |
4873 | | static const js::ClassExtension sClassExtension = { |
4874 | | nullptr, /* weakmapKeyDelegateOp */ |
4875 | | _objectMoved /* objectMovedOp */ |
4876 | | }; |
4877 | | |
4878 | | static const DOMJSClass sClass = { |
4879 | | { "OES_texture_float_linear", |
4880 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
4881 | | &sClassOps, |
4882 | | JS_NULL_CLASS_SPEC, |
4883 | | &sClassExtension, |
4884 | | JS_NULL_OBJECT_OPS |
4885 | | }, |
4886 | | { prototypes::id::OES_texture_float_linear, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
4887 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionTextureFloatLinear >::value, |
4888 | | sNativePropertyHooks, |
4889 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionTextureFloatLinear>::Get, |
4890 | | GetProtoObjectHandle, |
4891 | | GetCCParticipant<mozilla::WebGLExtensionTextureFloatLinear>::Get() |
4892 | | }; |
4893 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
4894 | | "Must have the right minimal number of reserved slots."); |
4895 | | static_assert(1 >= 1, |
4896 | | "Must have enough reserved slots."); |
4897 | | |
4898 | | const JSClass* |
4899 | | GetJSClass() |
4900 | 0 | { |
4901 | 0 | return sClass.ToJSClass(); |
4902 | 0 | } |
4903 | | |
4904 | | bool |
4905 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionTextureFloatLinear* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
4906 | 0 | { |
4907 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionTextureFloatLinear>::value, |
4908 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
4909 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionTextureFloatLinear*>(aObject) == |
4910 | 0 | reinterpret_cast<mozilla::WebGLExtensionTextureFloatLinear*>(aObject), |
4911 | 0 | "Multiple inheritance for mozilla::WebGLExtensionTextureFloatLinear is broken."); |
4912 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
4913 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
4914 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
4915 | 0 | "You should probably not be using Wrap() directly; use " |
4916 | 0 | "GetOrCreateDOMReflector instead"); |
4917 | 0 |
|
4918 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
4919 | 0 | "nsISupports must be on our primary inheritance chain"); |
4920 | 0 |
|
4921 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
4922 | 0 | if (!global) { |
4923 | 0 | return false; |
4924 | 0 | } |
4925 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
4926 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
4927 | 0 |
|
4928 | 0 | // That might have ended up wrapping us already, due to the wonders |
4929 | 0 | // of XBL. Check for that, and bail out as needed. |
4930 | 0 | aReflector.set(aCache->GetWrapper()); |
4931 | 0 | if (aReflector) { |
4932 | | #ifdef DEBUG |
4933 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
4934 | | #endif // DEBUG |
4935 | | return true; |
4936 | 0 | } |
4937 | 0 |
|
4938 | 0 | JSAutoRealm ar(aCx, global); |
4939 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
4940 | 0 | if (!canonicalProto) { |
4941 | 0 | return false; |
4942 | 0 | } |
4943 | 0 | JS::Rooted<JSObject*> proto(aCx); |
4944 | 0 | if (aGivenProto) { |
4945 | 0 | proto = aGivenProto; |
4946 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
4947 | 0 | // coming in, we changed compartments to that of "parent" so may need |
4948 | 0 | // to wrap the proto here. |
4949 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
4950 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
4951 | 0 | return false; |
4952 | 0 | } |
4953 | 0 | } |
4954 | 0 | } else { |
4955 | 0 | proto = canonicalProto; |
4956 | 0 | } |
4957 | 0 |
|
4958 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionTextureFloatLinear> creator(aCx); |
4959 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
4960 | 0 | if (!aReflector) { |
4961 | 0 | return false; |
4962 | 0 | } |
4963 | 0 | |
4964 | 0 | aCache->SetWrapper(aReflector); |
4965 | 0 | creator.InitializationSucceeded(); |
4966 | 0 |
|
4967 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
4968 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
4969 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
4970 | 0 | // otherwise we won't be able to properly recreate it later, since |
4971 | 0 | // we won't know what proto to use. Note that we don't check |
4972 | 0 | // aGivenProto here, since it's entirely possible (and even |
4973 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
4974 | 0 | // same as canonicalProto. |
4975 | 0 | if (proto != canonicalProto) { |
4976 | 0 | PreserveWrapper(aObject); |
4977 | 0 | } |
4978 | 0 |
|
4979 | 0 | return true; |
4980 | 0 | } |
4981 | | |
4982 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
4983 | | nullptr, |
4984 | | nullptr, |
4985 | | nullptr, |
4986 | | { nullptr, nullptr }, |
4987 | | prototypes::id::OES_texture_float_linear, |
4988 | | constructors::id::_ID_Count, |
4989 | | nullptr, |
4990 | | &DefaultXrayExpandoObjectClass |
4991 | | } }; |
4992 | | |
4993 | | void |
4994 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
4995 | 0 | { |
4996 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
4997 | 0 | if (!parentProto) { |
4998 | 0 | return; |
4999 | 0 | } |
5000 | 0 | |
5001 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::OES_texture_float_linear); |
5002 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
5003 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
5004 | 0 | &sPrototypeClass.mBase, protoCache, |
5005 | 0 | nullptr, |
5006 | 0 | nullptr, nullptr, 0, nullptr, |
5007 | 0 | interfaceCache, |
5008 | 0 | nullptr, |
5009 | 0 | nullptr, |
5010 | 0 | nullptr, aDefineOnGlobal, |
5011 | 0 | nullptr, |
5012 | 0 | false); |
5013 | 0 | } |
5014 | | |
5015 | | } // namespace OES_texture_float_linear_Binding |
5016 | | |
5017 | | |
5018 | | |
5019 | | namespace OES_texture_half_float_Binding { |
5020 | | |
5021 | | static bool |
5022 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
5023 | 0 | { |
5024 | 0 | mozilla::WebGLExtensionTextureHalfFloat* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionTextureHalfFloat>(obj); |
5025 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
5026 | 0 | // obviously can't preserve if we're not initialized. |
5027 | 0 | if (self && self->GetWrapperPreserveColor()) { |
5028 | 0 | PreserveWrapper(self); |
5029 | 0 | } |
5030 | 0 | return true; |
5031 | 0 | } |
5032 | | |
5033 | | static void |
5034 | | _finalize(js::FreeOp* fop, JSObject* obj) |
5035 | 0 | { |
5036 | 0 | mozilla::WebGLExtensionTextureHalfFloat* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionTextureHalfFloat>(obj); |
5037 | 0 | if (self) { |
5038 | 0 | ClearWrapper(self, self, obj); |
5039 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionTextureHalfFloat>(self); |
5040 | 0 | } |
5041 | 0 | } |
5042 | | |
5043 | | static size_t |
5044 | | _objectMoved(JSObject* obj, JSObject* old) |
5045 | 0 | { |
5046 | 0 | mozilla::WebGLExtensionTextureHalfFloat* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionTextureHalfFloat>(obj); |
5047 | 0 | if (self) { |
5048 | 0 | UpdateWrapper(self, self, obj, old); |
5049 | 0 | } |
5050 | 0 |
|
5051 | 0 | return 0; |
5052 | 0 | } |
5053 | | |
5054 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
5055 | | #if defined(__clang__) |
5056 | | #pragma clang diagnostic push |
5057 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
5058 | | #endif |
5059 | | static const ConstantSpec sConstants_specs[] = { |
5060 | | { "HALF_FLOAT_OES", JS::NumberValue(36193U) }, |
5061 | | { 0, JS::UndefinedValue() } |
5062 | | }; |
5063 | | #if defined(__clang__) |
5064 | | #pragma clang diagnostic pop |
5065 | | #endif |
5066 | | |
5067 | | |
5068 | | static const Prefable<const ConstantSpec> sConstants[] = { |
5069 | | { nullptr, &sConstants_specs[0] }, |
5070 | | { nullptr, nullptr } |
5071 | | }; |
5072 | | |
5073 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
5074 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
5075 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
5076 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
5077 | | |
5078 | | |
5079 | | static uint16_t sNativeProperties_sortedPropertyIndices[1]; |
5080 | | static PropertyInfo sNativeProperties_propertyInfos[1]; |
5081 | | |
5082 | | static const NativePropertiesN<1> sNativeProperties = { |
5083 | | false, 0, |
5084 | | false, 0, |
5085 | | false, 0, |
5086 | | false, 0, |
5087 | | false, 0, |
5088 | | false, 0, |
5089 | | true, 0 /* sConstants */, |
5090 | | -1, |
5091 | | 1, |
5092 | | sNativeProperties_sortedPropertyIndices, |
5093 | | { |
5094 | | { sConstants, &sNativeProperties_propertyInfos[0] } |
5095 | | } |
5096 | | }; |
5097 | | static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
5098 | | "We have a property info count that is oversized"); |
5099 | | |
5100 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
5101 | | { |
5102 | | "OES_texture_half_floatPrototype", |
5103 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
5104 | | JS_NULL_CLASS_OPS, |
5105 | | JS_NULL_CLASS_SPEC, |
5106 | | JS_NULL_CLASS_EXT, |
5107 | | JS_NULL_OBJECT_OPS |
5108 | | }, |
5109 | | eInterfacePrototype, |
5110 | | false, |
5111 | | prototypes::id::OES_texture_half_float, |
5112 | | PrototypeTraits<prototypes::id::OES_texture_half_float>::Depth, |
5113 | | sNativePropertyHooks, |
5114 | | "[object OES_texture_half_floatPrototype]", |
5115 | | JS::GetRealmObjectPrototype |
5116 | | }; |
5117 | | |
5118 | | static const js::ClassOps sClassOps = { |
5119 | | _addProperty, /* addProperty */ |
5120 | | nullptr, /* delProperty */ |
5121 | | nullptr, /* enumerate */ |
5122 | | nullptr, /* newEnumerate */ |
5123 | | nullptr, /* resolve */ |
5124 | | nullptr, /* mayResolve */ |
5125 | | _finalize, /* finalize */ |
5126 | | nullptr, /* call */ |
5127 | | nullptr, /* hasInstance */ |
5128 | | nullptr, /* construct */ |
5129 | | nullptr, /* trace */ |
5130 | | }; |
5131 | | |
5132 | | static const js::ClassExtension sClassExtension = { |
5133 | | nullptr, /* weakmapKeyDelegateOp */ |
5134 | | _objectMoved /* objectMovedOp */ |
5135 | | }; |
5136 | | |
5137 | | static const DOMJSClass sClass = { |
5138 | | { "OES_texture_half_float", |
5139 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
5140 | | &sClassOps, |
5141 | | JS_NULL_CLASS_SPEC, |
5142 | | &sClassExtension, |
5143 | | JS_NULL_OBJECT_OPS |
5144 | | }, |
5145 | | { prototypes::id::OES_texture_half_float, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
5146 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionTextureHalfFloat >::value, |
5147 | | sNativePropertyHooks, |
5148 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionTextureHalfFloat>::Get, |
5149 | | GetProtoObjectHandle, |
5150 | | GetCCParticipant<mozilla::WebGLExtensionTextureHalfFloat>::Get() |
5151 | | }; |
5152 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
5153 | | "Must have the right minimal number of reserved slots."); |
5154 | | static_assert(1 >= 1, |
5155 | | "Must have enough reserved slots."); |
5156 | | |
5157 | | const JSClass* |
5158 | | GetJSClass() |
5159 | 0 | { |
5160 | 0 | return sClass.ToJSClass(); |
5161 | 0 | } |
5162 | | |
5163 | | bool |
5164 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionTextureHalfFloat* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
5165 | 0 | { |
5166 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionTextureHalfFloat>::value, |
5167 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
5168 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionTextureHalfFloat*>(aObject) == |
5169 | 0 | reinterpret_cast<mozilla::WebGLExtensionTextureHalfFloat*>(aObject), |
5170 | 0 | "Multiple inheritance for mozilla::WebGLExtensionTextureHalfFloat is broken."); |
5171 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
5172 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
5173 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
5174 | 0 | "You should probably not be using Wrap() directly; use " |
5175 | 0 | "GetOrCreateDOMReflector instead"); |
5176 | 0 |
|
5177 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
5178 | 0 | "nsISupports must be on our primary inheritance chain"); |
5179 | 0 |
|
5180 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
5181 | 0 | if (!global) { |
5182 | 0 | return false; |
5183 | 0 | } |
5184 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
5185 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
5186 | 0 |
|
5187 | 0 | // That might have ended up wrapping us already, due to the wonders |
5188 | 0 | // of XBL. Check for that, and bail out as needed. |
5189 | 0 | aReflector.set(aCache->GetWrapper()); |
5190 | 0 | if (aReflector) { |
5191 | | #ifdef DEBUG |
5192 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
5193 | | #endif // DEBUG |
5194 | | return true; |
5195 | 0 | } |
5196 | 0 |
|
5197 | 0 | JSAutoRealm ar(aCx, global); |
5198 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
5199 | 0 | if (!canonicalProto) { |
5200 | 0 | return false; |
5201 | 0 | } |
5202 | 0 | JS::Rooted<JSObject*> proto(aCx); |
5203 | 0 | if (aGivenProto) { |
5204 | 0 | proto = aGivenProto; |
5205 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
5206 | 0 | // coming in, we changed compartments to that of "parent" so may need |
5207 | 0 | // to wrap the proto here. |
5208 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
5209 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
5210 | 0 | return false; |
5211 | 0 | } |
5212 | 0 | } |
5213 | 0 | } else { |
5214 | 0 | proto = canonicalProto; |
5215 | 0 | } |
5216 | 0 |
|
5217 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionTextureHalfFloat> creator(aCx); |
5218 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
5219 | 0 | if (!aReflector) { |
5220 | 0 | return false; |
5221 | 0 | } |
5222 | 0 | |
5223 | 0 | aCache->SetWrapper(aReflector); |
5224 | 0 | creator.InitializationSucceeded(); |
5225 | 0 |
|
5226 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
5227 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
5228 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
5229 | 0 | // otherwise we won't be able to properly recreate it later, since |
5230 | 0 | // we won't know what proto to use. Note that we don't check |
5231 | 0 | // aGivenProto here, since it's entirely possible (and even |
5232 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
5233 | 0 | // same as canonicalProto. |
5234 | 0 | if (proto != canonicalProto) { |
5235 | 0 | PreserveWrapper(aObject); |
5236 | 0 | } |
5237 | 0 |
|
5238 | 0 | return true; |
5239 | 0 | } |
5240 | | |
5241 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
5242 | | nullptr, |
5243 | | nullptr, |
5244 | | nullptr, |
5245 | | { sNativeProperties.Upcast(), nullptr }, |
5246 | | prototypes::id::OES_texture_half_float, |
5247 | | constructors::id::_ID_Count, |
5248 | | nullptr, |
5249 | | &DefaultXrayExpandoObjectClass |
5250 | | } }; |
5251 | | |
5252 | | void |
5253 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
5254 | 0 | { |
5255 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
5256 | 0 | if (!parentProto) { |
5257 | 0 | return; |
5258 | 0 | } |
5259 | 0 | |
5260 | 0 | static bool sIdsInited = false; |
5261 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
5262 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
5263 | 0 | return; |
5264 | 0 | } |
5265 | 0 | sIdsInited = true; |
5266 | 0 | } |
5267 | 0 |
|
5268 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::OES_texture_half_float); |
5269 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
5270 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
5271 | 0 | &sPrototypeClass.mBase, protoCache, |
5272 | 0 | nullptr, |
5273 | 0 | nullptr, nullptr, 0, nullptr, |
5274 | 0 | interfaceCache, |
5275 | 0 | sNativeProperties.Upcast(), |
5276 | 0 | nullptr, |
5277 | 0 | nullptr, aDefineOnGlobal, |
5278 | 0 | nullptr, |
5279 | 0 | false); |
5280 | 0 | } |
5281 | | |
5282 | | } // namespace OES_texture_half_float_Binding |
5283 | | |
5284 | | |
5285 | | |
5286 | | namespace OES_texture_half_float_linear_Binding { |
5287 | | |
5288 | | static bool |
5289 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
5290 | 0 | { |
5291 | 0 | mozilla::WebGLExtensionTextureHalfFloatLinear* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionTextureHalfFloatLinear>(obj); |
5292 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
5293 | 0 | // obviously can't preserve if we're not initialized. |
5294 | 0 | if (self && self->GetWrapperPreserveColor()) { |
5295 | 0 | PreserveWrapper(self); |
5296 | 0 | } |
5297 | 0 | return true; |
5298 | 0 | } |
5299 | | |
5300 | | static void |
5301 | | _finalize(js::FreeOp* fop, JSObject* obj) |
5302 | 0 | { |
5303 | 0 | mozilla::WebGLExtensionTextureHalfFloatLinear* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionTextureHalfFloatLinear>(obj); |
5304 | 0 | if (self) { |
5305 | 0 | ClearWrapper(self, self, obj); |
5306 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionTextureHalfFloatLinear>(self); |
5307 | 0 | } |
5308 | 0 | } |
5309 | | |
5310 | | static size_t |
5311 | | _objectMoved(JSObject* obj, JSObject* old) |
5312 | 0 | { |
5313 | 0 | mozilla::WebGLExtensionTextureHalfFloatLinear* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionTextureHalfFloatLinear>(obj); |
5314 | 0 | if (self) { |
5315 | 0 | UpdateWrapper(self, self, obj, old); |
5316 | 0 | } |
5317 | 0 |
|
5318 | 0 | return 0; |
5319 | 0 | } |
5320 | | |
5321 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
5322 | | { |
5323 | | "OES_texture_half_float_linearPrototype", |
5324 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
5325 | | JS_NULL_CLASS_OPS, |
5326 | | JS_NULL_CLASS_SPEC, |
5327 | | JS_NULL_CLASS_EXT, |
5328 | | JS_NULL_OBJECT_OPS |
5329 | | }, |
5330 | | eInterfacePrototype, |
5331 | | false, |
5332 | | prototypes::id::OES_texture_half_float_linear, |
5333 | | PrototypeTraits<prototypes::id::OES_texture_half_float_linear>::Depth, |
5334 | | sNativePropertyHooks, |
5335 | | "[object OES_texture_half_float_linearPrototype]", |
5336 | | JS::GetRealmObjectPrototype |
5337 | | }; |
5338 | | |
5339 | | static const js::ClassOps sClassOps = { |
5340 | | _addProperty, /* addProperty */ |
5341 | | nullptr, /* delProperty */ |
5342 | | nullptr, /* enumerate */ |
5343 | | nullptr, /* newEnumerate */ |
5344 | | nullptr, /* resolve */ |
5345 | | nullptr, /* mayResolve */ |
5346 | | _finalize, /* finalize */ |
5347 | | nullptr, /* call */ |
5348 | | nullptr, /* hasInstance */ |
5349 | | nullptr, /* construct */ |
5350 | | nullptr, /* trace */ |
5351 | | }; |
5352 | | |
5353 | | static const js::ClassExtension sClassExtension = { |
5354 | | nullptr, /* weakmapKeyDelegateOp */ |
5355 | | _objectMoved /* objectMovedOp */ |
5356 | | }; |
5357 | | |
5358 | | static const DOMJSClass sClass = { |
5359 | | { "OES_texture_half_float_linear", |
5360 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
5361 | | &sClassOps, |
5362 | | JS_NULL_CLASS_SPEC, |
5363 | | &sClassExtension, |
5364 | | JS_NULL_OBJECT_OPS |
5365 | | }, |
5366 | | { prototypes::id::OES_texture_half_float_linear, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
5367 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionTextureHalfFloatLinear >::value, |
5368 | | sNativePropertyHooks, |
5369 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionTextureHalfFloatLinear>::Get, |
5370 | | GetProtoObjectHandle, |
5371 | | GetCCParticipant<mozilla::WebGLExtensionTextureHalfFloatLinear>::Get() |
5372 | | }; |
5373 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
5374 | | "Must have the right minimal number of reserved slots."); |
5375 | | static_assert(1 >= 1, |
5376 | | "Must have enough reserved slots."); |
5377 | | |
5378 | | const JSClass* |
5379 | | GetJSClass() |
5380 | 0 | { |
5381 | 0 | return sClass.ToJSClass(); |
5382 | 0 | } |
5383 | | |
5384 | | bool |
5385 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionTextureHalfFloatLinear* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
5386 | 0 | { |
5387 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionTextureHalfFloatLinear>::value, |
5388 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
5389 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionTextureHalfFloatLinear*>(aObject) == |
5390 | 0 | reinterpret_cast<mozilla::WebGLExtensionTextureHalfFloatLinear*>(aObject), |
5391 | 0 | "Multiple inheritance for mozilla::WebGLExtensionTextureHalfFloatLinear is broken."); |
5392 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
5393 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
5394 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
5395 | 0 | "You should probably not be using Wrap() directly; use " |
5396 | 0 | "GetOrCreateDOMReflector instead"); |
5397 | 0 |
|
5398 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
5399 | 0 | "nsISupports must be on our primary inheritance chain"); |
5400 | 0 |
|
5401 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
5402 | 0 | if (!global) { |
5403 | 0 | return false; |
5404 | 0 | } |
5405 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
5406 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
5407 | 0 |
|
5408 | 0 | // That might have ended up wrapping us already, due to the wonders |
5409 | 0 | // of XBL. Check for that, and bail out as needed. |
5410 | 0 | aReflector.set(aCache->GetWrapper()); |
5411 | 0 | if (aReflector) { |
5412 | | #ifdef DEBUG |
5413 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
5414 | | #endif // DEBUG |
5415 | | return true; |
5416 | 0 | } |
5417 | 0 |
|
5418 | 0 | JSAutoRealm ar(aCx, global); |
5419 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
5420 | 0 | if (!canonicalProto) { |
5421 | 0 | return false; |
5422 | 0 | } |
5423 | 0 | JS::Rooted<JSObject*> proto(aCx); |
5424 | 0 | if (aGivenProto) { |
5425 | 0 | proto = aGivenProto; |
5426 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
5427 | 0 | // coming in, we changed compartments to that of "parent" so may need |
5428 | 0 | // to wrap the proto here. |
5429 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
5430 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
5431 | 0 | return false; |
5432 | 0 | } |
5433 | 0 | } |
5434 | 0 | } else { |
5435 | 0 | proto = canonicalProto; |
5436 | 0 | } |
5437 | 0 |
|
5438 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionTextureHalfFloatLinear> creator(aCx); |
5439 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
5440 | 0 | if (!aReflector) { |
5441 | 0 | return false; |
5442 | 0 | } |
5443 | 0 | |
5444 | 0 | aCache->SetWrapper(aReflector); |
5445 | 0 | creator.InitializationSucceeded(); |
5446 | 0 |
|
5447 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
5448 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
5449 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
5450 | 0 | // otherwise we won't be able to properly recreate it later, since |
5451 | 0 | // we won't know what proto to use. Note that we don't check |
5452 | 0 | // aGivenProto here, since it's entirely possible (and even |
5453 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
5454 | 0 | // same as canonicalProto. |
5455 | 0 | if (proto != canonicalProto) { |
5456 | 0 | PreserveWrapper(aObject); |
5457 | 0 | } |
5458 | 0 |
|
5459 | 0 | return true; |
5460 | 0 | } |
5461 | | |
5462 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
5463 | | nullptr, |
5464 | | nullptr, |
5465 | | nullptr, |
5466 | | { nullptr, nullptr }, |
5467 | | prototypes::id::OES_texture_half_float_linear, |
5468 | | constructors::id::_ID_Count, |
5469 | | nullptr, |
5470 | | &DefaultXrayExpandoObjectClass |
5471 | | } }; |
5472 | | |
5473 | | void |
5474 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
5475 | 0 | { |
5476 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
5477 | 0 | if (!parentProto) { |
5478 | 0 | return; |
5479 | 0 | } |
5480 | 0 | |
5481 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::OES_texture_half_float_linear); |
5482 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
5483 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
5484 | 0 | &sPrototypeClass.mBase, protoCache, |
5485 | 0 | nullptr, |
5486 | 0 | nullptr, nullptr, 0, nullptr, |
5487 | 0 | interfaceCache, |
5488 | 0 | nullptr, |
5489 | 0 | nullptr, |
5490 | 0 | nullptr, aDefineOnGlobal, |
5491 | 0 | nullptr, |
5492 | 0 | false); |
5493 | 0 | } |
5494 | | |
5495 | | } // namespace OES_texture_half_float_linear_Binding |
5496 | | |
5497 | | |
5498 | | |
5499 | | namespace OES_vertex_array_object_Binding { |
5500 | | |
5501 | | MOZ_CAN_RUN_SCRIPT static bool |
5502 | | createVertexArrayOES(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionVertexArray* self, const JSJitMethodCallArgs& args) |
5503 | 0 | { |
5504 | 0 | AUTO_PROFILER_LABEL_FAST("OES_vertex_array_object.createVertexArrayOES", DOM, cx); |
5505 | 0 |
|
5506 | 0 | auto result(StrongOrRawPtr<mozilla::WebGLVertexArray>(self->CreateVertexArrayOES())); |
5507 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
5508 | 0 | if (!result) { |
5509 | 0 | args.rval().setNull(); |
5510 | 0 | return true; |
5511 | 0 | } |
5512 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
5513 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
5514 | 0 | return false; |
5515 | 0 | } |
5516 | 0 | return true; |
5517 | 0 | } |
5518 | | |
5519 | | static const JSJitInfo createVertexArrayOES_methodinfo = { |
5520 | | { (JSJitGetterOp)createVertexArrayOES }, |
5521 | | { prototypes::id::OES_vertex_array_object }, |
5522 | | { PrototypeTraits<prototypes::id::OES_vertex_array_object>::Depth }, |
5523 | | JSJitInfo::Method, |
5524 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
5525 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
5526 | | false, /* isInfallible. False in setters. */ |
5527 | | false, /* isMovable. Not relevant for setters. */ |
5528 | | false, /* isEliminatable. Not relevant for setters. */ |
5529 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
5530 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
5531 | | false, /* isTypedMethod. Only relevant for methods. */ |
5532 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
5533 | | }; |
5534 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
5535 | | static_assert(0 < 1, "There is no slot for us"); |
5536 | | |
5537 | | MOZ_CAN_RUN_SCRIPT static bool |
5538 | | deleteVertexArrayOES(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionVertexArray* self, const JSJitMethodCallArgs& args) |
5539 | 0 | { |
5540 | 0 | AUTO_PROFILER_LABEL_FAST("OES_vertex_array_object.deleteVertexArrayOES", DOM, cx); |
5541 | 0 |
|
5542 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
5543 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "OES_vertex_array_object.deleteVertexArrayOES"); |
5544 | 0 | } |
5545 | 0 | mozilla::WebGLVertexArray* arg0; |
5546 | 0 | if (args[0].isObject()) { |
5547 | 0 | { |
5548 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLVertexArrayObject, mozilla::WebGLVertexArray>(args[0], arg0); |
5549 | 0 | if (NS_FAILED(rv)) { |
5550 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of OES_vertex_array_object.deleteVertexArrayOES", "WebGLVertexArrayObject"); |
5551 | 0 | return false; |
5552 | 0 | } |
5553 | 0 | } |
5554 | 0 | } else if (args[0].isNullOrUndefined()) { |
5555 | 0 | arg0 = nullptr; |
5556 | 0 | } else { |
5557 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of OES_vertex_array_object.deleteVertexArrayOES"); |
5558 | 0 | return false; |
5559 | 0 | } |
5560 | 0 | self->DeleteVertexArrayOES(MOZ_KnownLive(Constify(arg0))); |
5561 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
5562 | 0 | args.rval().setUndefined(); |
5563 | 0 | return true; |
5564 | 0 | } |
5565 | | |
5566 | | static const JSJitInfo deleteVertexArrayOES_methodinfo = { |
5567 | | { (JSJitGetterOp)deleteVertexArrayOES }, |
5568 | | { prototypes::id::OES_vertex_array_object }, |
5569 | | { PrototypeTraits<prototypes::id::OES_vertex_array_object>::Depth }, |
5570 | | JSJitInfo::Method, |
5571 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
5572 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
5573 | | false, /* isInfallible. False in setters. */ |
5574 | | false, /* isMovable. Not relevant for setters. */ |
5575 | | false, /* isEliminatable. Not relevant for setters. */ |
5576 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
5577 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
5578 | | false, /* isTypedMethod. Only relevant for methods. */ |
5579 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
5580 | | }; |
5581 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
5582 | | static_assert(0 < 1, "There is no slot for us"); |
5583 | | |
5584 | | MOZ_CAN_RUN_SCRIPT static bool |
5585 | | isVertexArrayOES(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionVertexArray* self, const JSJitMethodCallArgs& args) |
5586 | 0 | { |
5587 | 0 | AUTO_PROFILER_LABEL_FAST("OES_vertex_array_object.isVertexArrayOES", DOM, cx); |
5588 | 0 |
|
5589 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
5590 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "OES_vertex_array_object.isVertexArrayOES"); |
5591 | 0 | } |
5592 | 0 | mozilla::WebGLVertexArray* arg0; |
5593 | 0 | if (args[0].isObject()) { |
5594 | 0 | { |
5595 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLVertexArrayObject, mozilla::WebGLVertexArray>(args[0], arg0); |
5596 | 0 | if (NS_FAILED(rv)) { |
5597 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of OES_vertex_array_object.isVertexArrayOES", "WebGLVertexArrayObject"); |
5598 | 0 | return false; |
5599 | 0 | } |
5600 | 0 | } |
5601 | 0 | } else if (args[0].isNullOrUndefined()) { |
5602 | 0 | arg0 = nullptr; |
5603 | 0 | } else { |
5604 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of OES_vertex_array_object.isVertexArrayOES"); |
5605 | 0 | return false; |
5606 | 0 | } |
5607 | 0 | bool result(self->IsVertexArrayOES(MOZ_KnownLive(Constify(arg0)))); |
5608 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
5609 | 0 | args.rval().setBoolean(result); |
5610 | 0 | return true; |
5611 | 0 | } |
5612 | | |
5613 | | static const JSJitInfo isVertexArrayOES_methodinfo = { |
5614 | | { (JSJitGetterOp)isVertexArrayOES }, |
5615 | | { prototypes::id::OES_vertex_array_object }, |
5616 | | { PrototypeTraits<prototypes::id::OES_vertex_array_object>::Depth }, |
5617 | | JSJitInfo::Method, |
5618 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
5619 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
5620 | | false, /* isInfallible. False in setters. */ |
5621 | | false, /* isMovable. Not relevant for setters. */ |
5622 | | false, /* isEliminatable. Not relevant for setters. */ |
5623 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
5624 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
5625 | | false, /* isTypedMethod. Only relevant for methods. */ |
5626 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
5627 | | }; |
5628 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
5629 | | static_assert(0 < 1, "There is no slot for us"); |
5630 | | |
5631 | | MOZ_CAN_RUN_SCRIPT static bool |
5632 | | bindVertexArrayOES(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionVertexArray* self, const JSJitMethodCallArgs& args) |
5633 | 0 | { |
5634 | 0 | AUTO_PROFILER_LABEL_FAST("OES_vertex_array_object.bindVertexArrayOES", DOM, cx); |
5635 | 0 |
|
5636 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
5637 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "OES_vertex_array_object.bindVertexArrayOES"); |
5638 | 0 | } |
5639 | 0 | mozilla::WebGLVertexArray* arg0; |
5640 | 0 | if (args[0].isObject()) { |
5641 | 0 | { |
5642 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLVertexArrayObject, mozilla::WebGLVertexArray>(args[0], arg0); |
5643 | 0 | if (NS_FAILED(rv)) { |
5644 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of OES_vertex_array_object.bindVertexArrayOES", "WebGLVertexArrayObject"); |
5645 | 0 | return false; |
5646 | 0 | } |
5647 | 0 | } |
5648 | 0 | } else if (args[0].isNullOrUndefined()) { |
5649 | 0 | arg0 = nullptr; |
5650 | 0 | } else { |
5651 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of OES_vertex_array_object.bindVertexArrayOES"); |
5652 | 0 | return false; |
5653 | 0 | } |
5654 | 0 | self->BindVertexArrayOES(MOZ_KnownLive(Constify(arg0))); |
5655 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
5656 | 0 | args.rval().setUndefined(); |
5657 | 0 | return true; |
5658 | 0 | } |
5659 | | |
5660 | | static const JSJitInfo bindVertexArrayOES_methodinfo = { |
5661 | | { (JSJitGetterOp)bindVertexArrayOES }, |
5662 | | { prototypes::id::OES_vertex_array_object }, |
5663 | | { PrototypeTraits<prototypes::id::OES_vertex_array_object>::Depth }, |
5664 | | JSJitInfo::Method, |
5665 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
5666 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
5667 | | false, /* isInfallible. False in setters. */ |
5668 | | false, /* isMovable. Not relevant for setters. */ |
5669 | | false, /* isEliminatable. Not relevant for setters. */ |
5670 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
5671 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
5672 | | false, /* isTypedMethod. Only relevant for methods. */ |
5673 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
5674 | | }; |
5675 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
5676 | | static_assert(0 < 1, "There is no slot for us"); |
5677 | | |
5678 | | static bool |
5679 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
5680 | 0 | { |
5681 | 0 | mozilla::WebGLExtensionVertexArray* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionVertexArray>(obj); |
5682 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
5683 | 0 | // obviously can't preserve if we're not initialized. |
5684 | 0 | if (self && self->GetWrapperPreserveColor()) { |
5685 | 0 | PreserveWrapper(self); |
5686 | 0 | } |
5687 | 0 | return true; |
5688 | 0 | } |
5689 | | |
5690 | | static void |
5691 | | _finalize(js::FreeOp* fop, JSObject* obj) |
5692 | 0 | { |
5693 | 0 | mozilla::WebGLExtensionVertexArray* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionVertexArray>(obj); |
5694 | 0 | if (self) { |
5695 | 0 | ClearWrapper(self, self, obj); |
5696 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionVertexArray>(self); |
5697 | 0 | } |
5698 | 0 | } |
5699 | | |
5700 | | static size_t |
5701 | | _objectMoved(JSObject* obj, JSObject* old) |
5702 | 0 | { |
5703 | 0 | mozilla::WebGLExtensionVertexArray* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionVertexArray>(obj); |
5704 | 0 | if (self) { |
5705 | 0 | UpdateWrapper(self, self, obj, old); |
5706 | 0 | } |
5707 | 0 |
|
5708 | 0 | return 0; |
5709 | 0 | } |
5710 | | |
5711 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
5712 | | #if defined(__clang__) |
5713 | | #pragma clang diagnostic push |
5714 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
5715 | | #endif |
5716 | | static const JSFunctionSpec sMethods_specs[] = { |
5717 | | JS_FNSPEC("createVertexArrayOES", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createVertexArrayOES_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
5718 | | JS_FNSPEC("deleteVertexArrayOES", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&deleteVertexArrayOES_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5719 | | JS_FNSPEC("isVertexArrayOES", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&isVertexArrayOES_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5720 | | JS_FNSPEC("bindVertexArrayOES", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&bindVertexArrayOES_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
5721 | | JS_FS_END |
5722 | | }; |
5723 | | #if defined(__clang__) |
5724 | | #pragma clang diagnostic pop |
5725 | | #endif |
5726 | | |
5727 | | |
5728 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
5729 | | { nullptr, &sMethods_specs[0] }, |
5730 | | { nullptr, nullptr } |
5731 | | }; |
5732 | | |
5733 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
5734 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
5735 | | static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
5736 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
5737 | | |
5738 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
5739 | | #if defined(__clang__) |
5740 | | #pragma clang diagnostic push |
5741 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
5742 | | #endif |
5743 | | static const ConstantSpec sConstants_specs[] = { |
5744 | | { "VERTEX_ARRAY_BINDING_OES", JS::NumberValue(34229U) }, |
5745 | | { 0, JS::UndefinedValue() } |
5746 | | }; |
5747 | | #if defined(__clang__) |
5748 | | #pragma clang diagnostic pop |
5749 | | #endif |
5750 | | |
5751 | | |
5752 | | static const Prefable<const ConstantSpec> sConstants[] = { |
5753 | | { nullptr, &sConstants_specs[0] }, |
5754 | | { nullptr, nullptr } |
5755 | | }; |
5756 | | |
5757 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
5758 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
5759 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
5760 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
5761 | | |
5762 | | |
5763 | | static uint16_t sNativeProperties_sortedPropertyIndices[5]; |
5764 | | static PropertyInfo sNativeProperties_propertyInfos[5]; |
5765 | | |
5766 | | static const NativePropertiesN<2> sNativeProperties = { |
5767 | | false, 0, |
5768 | | false, 0, |
5769 | | true, 0 /* sMethods */, |
5770 | | false, 0, |
5771 | | false, 0, |
5772 | | false, 0, |
5773 | | true, 1 /* sConstants */, |
5774 | | -1, |
5775 | | 5, |
5776 | | sNativeProperties_sortedPropertyIndices, |
5777 | | { |
5778 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
5779 | | { sConstants, &sNativeProperties_propertyInfos[4] } |
5780 | | } |
5781 | | }; |
5782 | | static_assert(5 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
5783 | | "We have a property info count that is oversized"); |
5784 | | |
5785 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
5786 | | { |
5787 | | "OES_vertex_array_objectPrototype", |
5788 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
5789 | | JS_NULL_CLASS_OPS, |
5790 | | JS_NULL_CLASS_SPEC, |
5791 | | JS_NULL_CLASS_EXT, |
5792 | | JS_NULL_OBJECT_OPS |
5793 | | }, |
5794 | | eInterfacePrototype, |
5795 | | false, |
5796 | | prototypes::id::OES_vertex_array_object, |
5797 | | PrototypeTraits<prototypes::id::OES_vertex_array_object>::Depth, |
5798 | | sNativePropertyHooks, |
5799 | | "[object OES_vertex_array_objectPrototype]", |
5800 | | JS::GetRealmObjectPrototype |
5801 | | }; |
5802 | | |
5803 | | static const js::ClassOps sClassOps = { |
5804 | | _addProperty, /* addProperty */ |
5805 | | nullptr, /* delProperty */ |
5806 | | nullptr, /* enumerate */ |
5807 | | nullptr, /* newEnumerate */ |
5808 | | nullptr, /* resolve */ |
5809 | | nullptr, /* mayResolve */ |
5810 | | _finalize, /* finalize */ |
5811 | | nullptr, /* call */ |
5812 | | nullptr, /* hasInstance */ |
5813 | | nullptr, /* construct */ |
5814 | | nullptr, /* trace */ |
5815 | | }; |
5816 | | |
5817 | | static const js::ClassExtension sClassExtension = { |
5818 | | nullptr, /* weakmapKeyDelegateOp */ |
5819 | | _objectMoved /* objectMovedOp */ |
5820 | | }; |
5821 | | |
5822 | | static const DOMJSClass sClass = { |
5823 | | { "OES_vertex_array_object", |
5824 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
5825 | | &sClassOps, |
5826 | | JS_NULL_CLASS_SPEC, |
5827 | | &sClassExtension, |
5828 | | JS_NULL_OBJECT_OPS |
5829 | | }, |
5830 | | { prototypes::id::OES_vertex_array_object, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
5831 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionVertexArray >::value, |
5832 | | sNativePropertyHooks, |
5833 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionVertexArray>::Get, |
5834 | | GetProtoObjectHandle, |
5835 | | GetCCParticipant<mozilla::WebGLExtensionVertexArray>::Get() |
5836 | | }; |
5837 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
5838 | | "Must have the right minimal number of reserved slots."); |
5839 | | static_assert(1 >= 1, |
5840 | | "Must have enough reserved slots."); |
5841 | | |
5842 | | const JSClass* |
5843 | | GetJSClass() |
5844 | 0 | { |
5845 | 0 | return sClass.ToJSClass(); |
5846 | 0 | } |
5847 | | |
5848 | | bool |
5849 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionVertexArray* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
5850 | 0 | { |
5851 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionVertexArray>::value, |
5852 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
5853 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionVertexArray*>(aObject) == |
5854 | 0 | reinterpret_cast<mozilla::WebGLExtensionVertexArray*>(aObject), |
5855 | 0 | "Multiple inheritance for mozilla::WebGLExtensionVertexArray is broken."); |
5856 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
5857 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
5858 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
5859 | 0 | "You should probably not be using Wrap() directly; use " |
5860 | 0 | "GetOrCreateDOMReflector instead"); |
5861 | 0 |
|
5862 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
5863 | 0 | "nsISupports must be on our primary inheritance chain"); |
5864 | 0 |
|
5865 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
5866 | 0 | if (!global) { |
5867 | 0 | return false; |
5868 | 0 | } |
5869 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
5870 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
5871 | 0 |
|
5872 | 0 | // That might have ended up wrapping us already, due to the wonders |
5873 | 0 | // of XBL. Check for that, and bail out as needed. |
5874 | 0 | aReflector.set(aCache->GetWrapper()); |
5875 | 0 | if (aReflector) { |
5876 | | #ifdef DEBUG |
5877 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
5878 | | #endif // DEBUG |
5879 | | return true; |
5880 | 0 | } |
5881 | 0 |
|
5882 | 0 | JSAutoRealm ar(aCx, global); |
5883 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
5884 | 0 | if (!canonicalProto) { |
5885 | 0 | return false; |
5886 | 0 | } |
5887 | 0 | JS::Rooted<JSObject*> proto(aCx); |
5888 | 0 | if (aGivenProto) { |
5889 | 0 | proto = aGivenProto; |
5890 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
5891 | 0 | // coming in, we changed compartments to that of "parent" so may need |
5892 | 0 | // to wrap the proto here. |
5893 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
5894 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
5895 | 0 | return false; |
5896 | 0 | } |
5897 | 0 | } |
5898 | 0 | } else { |
5899 | 0 | proto = canonicalProto; |
5900 | 0 | } |
5901 | 0 |
|
5902 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionVertexArray> creator(aCx); |
5903 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
5904 | 0 | if (!aReflector) { |
5905 | 0 | return false; |
5906 | 0 | } |
5907 | 0 | |
5908 | 0 | aCache->SetWrapper(aReflector); |
5909 | 0 | creator.InitializationSucceeded(); |
5910 | 0 |
|
5911 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
5912 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
5913 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
5914 | 0 | // otherwise we won't be able to properly recreate it later, since |
5915 | 0 | // we won't know what proto to use. Note that we don't check |
5916 | 0 | // aGivenProto here, since it's entirely possible (and even |
5917 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
5918 | 0 | // same as canonicalProto. |
5919 | 0 | if (proto != canonicalProto) { |
5920 | 0 | PreserveWrapper(aObject); |
5921 | 0 | } |
5922 | 0 |
|
5923 | 0 | return true; |
5924 | 0 | } |
5925 | | |
5926 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
5927 | | nullptr, |
5928 | | nullptr, |
5929 | | nullptr, |
5930 | | { sNativeProperties.Upcast(), nullptr }, |
5931 | | prototypes::id::OES_vertex_array_object, |
5932 | | constructors::id::_ID_Count, |
5933 | | nullptr, |
5934 | | &DefaultXrayExpandoObjectClass |
5935 | | } }; |
5936 | | |
5937 | | void |
5938 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
5939 | 0 | { |
5940 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
5941 | 0 | if (!parentProto) { |
5942 | 0 | return; |
5943 | 0 | } |
5944 | 0 | |
5945 | 0 | static bool sIdsInited = false; |
5946 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
5947 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
5948 | 0 | return; |
5949 | 0 | } |
5950 | 0 | sIdsInited = true; |
5951 | 0 | } |
5952 | 0 |
|
5953 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::OES_vertex_array_object); |
5954 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
5955 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
5956 | 0 | &sPrototypeClass.mBase, protoCache, |
5957 | 0 | nullptr, |
5958 | 0 | nullptr, nullptr, 0, nullptr, |
5959 | 0 | interfaceCache, |
5960 | 0 | sNativeProperties.Upcast(), |
5961 | 0 | nullptr, |
5962 | 0 | nullptr, aDefineOnGlobal, |
5963 | 0 | nullptr, |
5964 | 0 | false); |
5965 | 0 | } |
5966 | | |
5967 | | } // namespace OES_vertex_array_object_Binding |
5968 | | |
5969 | | |
5970 | | |
5971 | | namespace WEBGL_color_buffer_float_Binding { |
5972 | | |
5973 | | static bool |
5974 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
5975 | 0 | { |
5976 | 0 | mozilla::WebGLExtensionColorBufferFloat* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionColorBufferFloat>(obj); |
5977 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
5978 | 0 | // obviously can't preserve if we're not initialized. |
5979 | 0 | if (self && self->GetWrapperPreserveColor()) { |
5980 | 0 | PreserveWrapper(self); |
5981 | 0 | } |
5982 | 0 | return true; |
5983 | 0 | } |
5984 | | |
5985 | | static void |
5986 | | _finalize(js::FreeOp* fop, JSObject* obj) |
5987 | 0 | { |
5988 | 0 | mozilla::WebGLExtensionColorBufferFloat* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionColorBufferFloat>(obj); |
5989 | 0 | if (self) { |
5990 | 0 | ClearWrapper(self, self, obj); |
5991 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionColorBufferFloat>(self); |
5992 | 0 | } |
5993 | 0 | } |
5994 | | |
5995 | | static size_t |
5996 | | _objectMoved(JSObject* obj, JSObject* old) |
5997 | 0 | { |
5998 | 0 | mozilla::WebGLExtensionColorBufferFloat* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionColorBufferFloat>(obj); |
5999 | 0 | if (self) { |
6000 | 0 | UpdateWrapper(self, self, obj, old); |
6001 | 0 | } |
6002 | 0 |
|
6003 | 0 | return 0; |
6004 | 0 | } |
6005 | | |
6006 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
6007 | | #if defined(__clang__) |
6008 | | #pragma clang diagnostic push |
6009 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
6010 | | #endif |
6011 | | static const ConstantSpec sConstants_specs[] = { |
6012 | | { "RGBA32F_EXT", JS::NumberValue(34836U) }, |
6013 | | { "RGB32F_EXT", JS::NumberValue(34837U) }, |
6014 | | { "FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT", JS::NumberValue(33297U) }, |
6015 | | { "UNSIGNED_NORMALIZED_EXT", JS::NumberValue(35863U) }, |
6016 | | { 0, JS::UndefinedValue() } |
6017 | | }; |
6018 | | #if defined(__clang__) |
6019 | | #pragma clang diagnostic pop |
6020 | | #endif |
6021 | | |
6022 | | |
6023 | | static const Prefable<const ConstantSpec> sConstants[] = { |
6024 | | { nullptr, &sConstants_specs[0] }, |
6025 | | { nullptr, nullptr } |
6026 | | }; |
6027 | | |
6028 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
6029 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
6030 | | static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
6031 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
6032 | | |
6033 | | |
6034 | | static uint16_t sNativeProperties_sortedPropertyIndices[4]; |
6035 | | static PropertyInfo sNativeProperties_propertyInfos[4]; |
6036 | | |
6037 | | static const NativePropertiesN<1> sNativeProperties = { |
6038 | | false, 0, |
6039 | | false, 0, |
6040 | | false, 0, |
6041 | | false, 0, |
6042 | | false, 0, |
6043 | | false, 0, |
6044 | | true, 0 /* sConstants */, |
6045 | | -1, |
6046 | | 4, |
6047 | | sNativeProperties_sortedPropertyIndices, |
6048 | | { |
6049 | | { sConstants, &sNativeProperties_propertyInfos[0] } |
6050 | | } |
6051 | | }; |
6052 | | static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
6053 | | "We have a property info count that is oversized"); |
6054 | | |
6055 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
6056 | | { |
6057 | | "WEBGL_color_buffer_floatPrototype", |
6058 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
6059 | | JS_NULL_CLASS_OPS, |
6060 | | JS_NULL_CLASS_SPEC, |
6061 | | JS_NULL_CLASS_EXT, |
6062 | | JS_NULL_OBJECT_OPS |
6063 | | }, |
6064 | | eInterfacePrototype, |
6065 | | false, |
6066 | | prototypes::id::WEBGL_color_buffer_float, |
6067 | | PrototypeTraits<prototypes::id::WEBGL_color_buffer_float>::Depth, |
6068 | | sNativePropertyHooks, |
6069 | | "[object WEBGL_color_buffer_floatPrototype]", |
6070 | | JS::GetRealmObjectPrototype |
6071 | | }; |
6072 | | |
6073 | | static const js::ClassOps sClassOps = { |
6074 | | _addProperty, /* addProperty */ |
6075 | | nullptr, /* delProperty */ |
6076 | | nullptr, /* enumerate */ |
6077 | | nullptr, /* newEnumerate */ |
6078 | | nullptr, /* resolve */ |
6079 | | nullptr, /* mayResolve */ |
6080 | | _finalize, /* finalize */ |
6081 | | nullptr, /* call */ |
6082 | | nullptr, /* hasInstance */ |
6083 | | nullptr, /* construct */ |
6084 | | nullptr, /* trace */ |
6085 | | }; |
6086 | | |
6087 | | static const js::ClassExtension sClassExtension = { |
6088 | | nullptr, /* weakmapKeyDelegateOp */ |
6089 | | _objectMoved /* objectMovedOp */ |
6090 | | }; |
6091 | | |
6092 | | static const DOMJSClass sClass = { |
6093 | | { "WEBGL_color_buffer_float", |
6094 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
6095 | | &sClassOps, |
6096 | | JS_NULL_CLASS_SPEC, |
6097 | | &sClassExtension, |
6098 | | JS_NULL_OBJECT_OPS |
6099 | | }, |
6100 | | { prototypes::id::WEBGL_color_buffer_float, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
6101 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionColorBufferFloat >::value, |
6102 | | sNativePropertyHooks, |
6103 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionColorBufferFloat>::Get, |
6104 | | GetProtoObjectHandle, |
6105 | | GetCCParticipant<mozilla::WebGLExtensionColorBufferFloat>::Get() |
6106 | | }; |
6107 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
6108 | | "Must have the right minimal number of reserved slots."); |
6109 | | static_assert(1 >= 1, |
6110 | | "Must have enough reserved slots."); |
6111 | | |
6112 | | const JSClass* |
6113 | | GetJSClass() |
6114 | 0 | { |
6115 | 0 | return sClass.ToJSClass(); |
6116 | 0 | } |
6117 | | |
6118 | | bool |
6119 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionColorBufferFloat* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
6120 | 0 | { |
6121 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionColorBufferFloat>::value, |
6122 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
6123 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionColorBufferFloat*>(aObject) == |
6124 | 0 | reinterpret_cast<mozilla::WebGLExtensionColorBufferFloat*>(aObject), |
6125 | 0 | "Multiple inheritance for mozilla::WebGLExtensionColorBufferFloat is broken."); |
6126 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
6127 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
6128 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
6129 | 0 | "You should probably not be using Wrap() directly; use " |
6130 | 0 | "GetOrCreateDOMReflector instead"); |
6131 | 0 |
|
6132 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
6133 | 0 | "nsISupports must be on our primary inheritance chain"); |
6134 | 0 |
|
6135 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
6136 | 0 | if (!global) { |
6137 | 0 | return false; |
6138 | 0 | } |
6139 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
6140 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
6141 | 0 |
|
6142 | 0 | // That might have ended up wrapping us already, due to the wonders |
6143 | 0 | // of XBL. Check for that, and bail out as needed. |
6144 | 0 | aReflector.set(aCache->GetWrapper()); |
6145 | 0 | if (aReflector) { |
6146 | | #ifdef DEBUG |
6147 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
6148 | | #endif // DEBUG |
6149 | | return true; |
6150 | 0 | } |
6151 | 0 |
|
6152 | 0 | JSAutoRealm ar(aCx, global); |
6153 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
6154 | 0 | if (!canonicalProto) { |
6155 | 0 | return false; |
6156 | 0 | } |
6157 | 0 | JS::Rooted<JSObject*> proto(aCx); |
6158 | 0 | if (aGivenProto) { |
6159 | 0 | proto = aGivenProto; |
6160 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
6161 | 0 | // coming in, we changed compartments to that of "parent" so may need |
6162 | 0 | // to wrap the proto here. |
6163 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
6164 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
6165 | 0 | return false; |
6166 | 0 | } |
6167 | 0 | } |
6168 | 0 | } else { |
6169 | 0 | proto = canonicalProto; |
6170 | 0 | } |
6171 | 0 |
|
6172 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionColorBufferFloat> creator(aCx); |
6173 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
6174 | 0 | if (!aReflector) { |
6175 | 0 | return false; |
6176 | 0 | } |
6177 | 0 | |
6178 | 0 | aCache->SetWrapper(aReflector); |
6179 | 0 | creator.InitializationSucceeded(); |
6180 | 0 |
|
6181 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
6182 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
6183 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
6184 | 0 | // otherwise we won't be able to properly recreate it later, since |
6185 | 0 | // we won't know what proto to use. Note that we don't check |
6186 | 0 | // aGivenProto here, since it's entirely possible (and even |
6187 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
6188 | 0 | // same as canonicalProto. |
6189 | 0 | if (proto != canonicalProto) { |
6190 | 0 | PreserveWrapper(aObject); |
6191 | 0 | } |
6192 | 0 |
|
6193 | 0 | return true; |
6194 | 0 | } |
6195 | | |
6196 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
6197 | | nullptr, |
6198 | | nullptr, |
6199 | | nullptr, |
6200 | | { sNativeProperties.Upcast(), nullptr }, |
6201 | | prototypes::id::WEBGL_color_buffer_float, |
6202 | | constructors::id::_ID_Count, |
6203 | | nullptr, |
6204 | | &DefaultXrayExpandoObjectClass |
6205 | | } }; |
6206 | | |
6207 | | void |
6208 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
6209 | 0 | { |
6210 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
6211 | 0 | if (!parentProto) { |
6212 | 0 | return; |
6213 | 0 | } |
6214 | 0 | |
6215 | 0 | static bool sIdsInited = false; |
6216 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
6217 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
6218 | 0 | return; |
6219 | 0 | } |
6220 | 0 | sIdsInited = true; |
6221 | 0 | } |
6222 | 0 |
|
6223 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WEBGL_color_buffer_float); |
6224 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
6225 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
6226 | 0 | &sPrototypeClass.mBase, protoCache, |
6227 | 0 | nullptr, |
6228 | 0 | nullptr, nullptr, 0, nullptr, |
6229 | 0 | interfaceCache, |
6230 | 0 | sNativeProperties.Upcast(), |
6231 | 0 | nullptr, |
6232 | 0 | nullptr, aDefineOnGlobal, |
6233 | 0 | nullptr, |
6234 | 0 | false); |
6235 | 0 | } |
6236 | | |
6237 | | } // namespace WEBGL_color_buffer_float_Binding |
6238 | | |
6239 | | |
6240 | | |
6241 | | namespace WEBGL_compressed_texture_astc_Binding { |
6242 | | |
6243 | | MOZ_CAN_RUN_SCRIPT static bool |
6244 | | getSupportedProfiles(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionCompressedTextureASTC* self, const JSJitMethodCallArgs& args) |
6245 | 0 | { |
6246 | 0 | AUTO_PROFILER_LABEL_FAST("WEBGL_compressed_texture_astc.getSupportedProfiles", DOM, cx); |
6247 | 0 |
|
6248 | 0 | Nullable<nsTArray<nsString>> result; |
6249 | 0 | self->GetSupportedProfiles(result); |
6250 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
6251 | 0 |
|
6252 | 0 | if (result.IsNull()) { |
6253 | 0 | args.rval().setNull(); |
6254 | 0 | return true; |
6255 | 0 | } |
6256 | 0 | |
6257 | 0 | uint32_t length = result.Value().Length(); |
6258 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
6259 | 0 | if (!returnArray) { |
6260 | 0 | return false; |
6261 | 0 | } |
6262 | 0 | // Scope for 'tmp' |
6263 | 0 | { |
6264 | 0 | JS::Rooted<JS::Value> tmp(cx); |
6265 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
6266 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
6267 | 0 | // are different ways to succeed at wrapping the object. |
6268 | 0 | do { |
6269 | 0 | if (!xpc::NonVoidStringToJsval(cx, result.Value()[sequenceIdx0], &tmp)) { |
6270 | 0 | return false; |
6271 | 0 | } |
6272 | 0 | break; |
6273 | 0 | } while (false); |
6274 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
6275 | 0 | JSPROP_ENUMERATE)) { |
6276 | 0 | return false; |
6277 | 0 | } |
6278 | 0 | } |
6279 | 0 | } |
6280 | 0 | args.rval().setObject(*returnArray); |
6281 | 0 | return true; |
6282 | 0 | } |
6283 | | |
6284 | | static const JSJitInfo getSupportedProfiles_methodinfo = { |
6285 | | { (JSJitGetterOp)getSupportedProfiles }, |
6286 | | { prototypes::id::WEBGL_compressed_texture_astc }, |
6287 | | { PrototypeTraits<prototypes::id::WEBGL_compressed_texture_astc>::Depth }, |
6288 | | JSJitInfo::Method, |
6289 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
6290 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
6291 | | false, /* isInfallible. False in setters. */ |
6292 | | false, /* isMovable. Not relevant for setters. */ |
6293 | | false, /* isEliminatable. Not relevant for setters. */ |
6294 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
6295 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
6296 | | false, /* isTypedMethod. Only relevant for methods. */ |
6297 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
6298 | | }; |
6299 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
6300 | | static_assert(0 < 1, "There is no slot for us"); |
6301 | | |
6302 | | static bool |
6303 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
6304 | 0 | { |
6305 | 0 | mozilla::WebGLExtensionCompressedTextureASTC* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTextureASTC>(obj); |
6306 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
6307 | 0 | // obviously can't preserve if we're not initialized. |
6308 | 0 | if (self && self->GetWrapperPreserveColor()) { |
6309 | 0 | PreserveWrapper(self); |
6310 | 0 | } |
6311 | 0 | return true; |
6312 | 0 | } |
6313 | | |
6314 | | static void |
6315 | | _finalize(js::FreeOp* fop, JSObject* obj) |
6316 | 0 | { |
6317 | 0 | mozilla::WebGLExtensionCompressedTextureASTC* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTextureASTC>(obj); |
6318 | 0 | if (self) { |
6319 | 0 | ClearWrapper(self, self, obj); |
6320 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionCompressedTextureASTC>(self); |
6321 | 0 | } |
6322 | 0 | } |
6323 | | |
6324 | | static size_t |
6325 | | _objectMoved(JSObject* obj, JSObject* old) |
6326 | 0 | { |
6327 | 0 | mozilla::WebGLExtensionCompressedTextureASTC* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTextureASTC>(obj); |
6328 | 0 | if (self) { |
6329 | 0 | UpdateWrapper(self, self, obj, old); |
6330 | 0 | } |
6331 | 0 |
|
6332 | 0 | return 0; |
6333 | 0 | } |
6334 | | |
6335 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
6336 | | #if defined(__clang__) |
6337 | | #pragma clang diagnostic push |
6338 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
6339 | | #endif |
6340 | | static const JSFunctionSpec sMethods_specs[] = { |
6341 | | JS_FNSPEC("getSupportedProfiles", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getSupportedProfiles_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
6342 | | JS_FS_END |
6343 | | }; |
6344 | | #if defined(__clang__) |
6345 | | #pragma clang diagnostic pop |
6346 | | #endif |
6347 | | |
6348 | | |
6349 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
6350 | | { nullptr, &sMethods_specs[0] }, |
6351 | | { nullptr, nullptr } |
6352 | | }; |
6353 | | |
6354 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
6355 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
6356 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
6357 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
6358 | | |
6359 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
6360 | | #if defined(__clang__) |
6361 | | #pragma clang diagnostic push |
6362 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
6363 | | #endif |
6364 | | static const ConstantSpec sConstants_specs[] = { |
6365 | | { "COMPRESSED_RGBA_ASTC_4x4_KHR", JS::NumberValue(37808U) }, |
6366 | | { "COMPRESSED_RGBA_ASTC_5x4_KHR", JS::NumberValue(37809U) }, |
6367 | | { "COMPRESSED_RGBA_ASTC_5x5_KHR", JS::NumberValue(37810U) }, |
6368 | | { "COMPRESSED_RGBA_ASTC_6x5_KHR", JS::NumberValue(37811U) }, |
6369 | | { "COMPRESSED_RGBA_ASTC_6x6_KHR", JS::NumberValue(37812U) }, |
6370 | | { "COMPRESSED_RGBA_ASTC_8x5_KHR", JS::NumberValue(37813U) }, |
6371 | | { "COMPRESSED_RGBA_ASTC_8x6_KHR", JS::NumberValue(37814U) }, |
6372 | | { "COMPRESSED_RGBA_ASTC_8x8_KHR", JS::NumberValue(37815U) }, |
6373 | | { "COMPRESSED_RGBA_ASTC_10x5_KHR", JS::NumberValue(37816U) }, |
6374 | | { "COMPRESSED_RGBA_ASTC_10x6_KHR", JS::NumberValue(37817U) }, |
6375 | | { "COMPRESSED_RGBA_ASTC_10x8_KHR", JS::NumberValue(37818U) }, |
6376 | | { "COMPRESSED_RGBA_ASTC_10x10_KHR", JS::NumberValue(37819U) }, |
6377 | | { "COMPRESSED_RGBA_ASTC_12x10_KHR", JS::NumberValue(37820U) }, |
6378 | | { "COMPRESSED_RGBA_ASTC_12x12_KHR", JS::NumberValue(37821U) }, |
6379 | | { "COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR", JS::NumberValue(37840U) }, |
6380 | | { "COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR", JS::NumberValue(37841U) }, |
6381 | | { "COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR", JS::NumberValue(37842U) }, |
6382 | | { "COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR", JS::NumberValue(37843U) }, |
6383 | | { "COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR", JS::NumberValue(37844U) }, |
6384 | | { "COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR", JS::NumberValue(37845U) }, |
6385 | | { "COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR", JS::NumberValue(37846U) }, |
6386 | | { "COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR", JS::NumberValue(37847U) }, |
6387 | | { "COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR", JS::NumberValue(37848U) }, |
6388 | | { "COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR", JS::NumberValue(37849U) }, |
6389 | | { "COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR", JS::NumberValue(37850U) }, |
6390 | | { "COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR", JS::NumberValue(37851U) }, |
6391 | | { "COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR", JS::NumberValue(37852U) }, |
6392 | | { "COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR", JS::NumberValue(37853U) }, |
6393 | | { 0, JS::UndefinedValue() } |
6394 | | }; |
6395 | | #if defined(__clang__) |
6396 | | #pragma clang diagnostic pop |
6397 | | #endif |
6398 | | |
6399 | | |
6400 | | static const Prefable<const ConstantSpec> sConstants[] = { |
6401 | | { nullptr, &sConstants_specs[0] }, |
6402 | | { nullptr, nullptr } |
6403 | | }; |
6404 | | |
6405 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
6406 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
6407 | | static_assert(28 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
6408 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
6409 | | |
6410 | | |
6411 | | static uint16_t sNativeProperties_sortedPropertyIndices[29]; |
6412 | | static PropertyInfo sNativeProperties_propertyInfos[29]; |
6413 | | |
6414 | | static const NativePropertiesN<2> sNativeProperties = { |
6415 | | false, 0, |
6416 | | false, 0, |
6417 | | true, 0 /* sMethods */, |
6418 | | false, 0, |
6419 | | false, 0, |
6420 | | false, 0, |
6421 | | true, 1 /* sConstants */, |
6422 | | -1, |
6423 | | 29, |
6424 | | sNativeProperties_sortedPropertyIndices, |
6425 | | { |
6426 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
6427 | | { sConstants, &sNativeProperties_propertyInfos[1] } |
6428 | | } |
6429 | | }; |
6430 | | static_assert(29 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
6431 | | "We have a property info count that is oversized"); |
6432 | | |
6433 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
6434 | | { |
6435 | | "WEBGL_compressed_texture_astcPrototype", |
6436 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
6437 | | JS_NULL_CLASS_OPS, |
6438 | | JS_NULL_CLASS_SPEC, |
6439 | | JS_NULL_CLASS_EXT, |
6440 | | JS_NULL_OBJECT_OPS |
6441 | | }, |
6442 | | eInterfacePrototype, |
6443 | | false, |
6444 | | prototypes::id::WEBGL_compressed_texture_astc, |
6445 | | PrototypeTraits<prototypes::id::WEBGL_compressed_texture_astc>::Depth, |
6446 | | sNativePropertyHooks, |
6447 | | "[object WEBGL_compressed_texture_astcPrototype]", |
6448 | | JS::GetRealmObjectPrototype |
6449 | | }; |
6450 | | |
6451 | | static const js::ClassOps sClassOps = { |
6452 | | _addProperty, /* addProperty */ |
6453 | | nullptr, /* delProperty */ |
6454 | | nullptr, /* enumerate */ |
6455 | | nullptr, /* newEnumerate */ |
6456 | | nullptr, /* resolve */ |
6457 | | nullptr, /* mayResolve */ |
6458 | | _finalize, /* finalize */ |
6459 | | nullptr, /* call */ |
6460 | | nullptr, /* hasInstance */ |
6461 | | nullptr, /* construct */ |
6462 | | nullptr, /* trace */ |
6463 | | }; |
6464 | | |
6465 | | static const js::ClassExtension sClassExtension = { |
6466 | | nullptr, /* weakmapKeyDelegateOp */ |
6467 | | _objectMoved /* objectMovedOp */ |
6468 | | }; |
6469 | | |
6470 | | static const DOMJSClass sClass = { |
6471 | | { "WEBGL_compressed_texture_astc", |
6472 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
6473 | | &sClassOps, |
6474 | | JS_NULL_CLASS_SPEC, |
6475 | | &sClassExtension, |
6476 | | JS_NULL_OBJECT_OPS |
6477 | | }, |
6478 | | { prototypes::id::WEBGL_compressed_texture_astc, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
6479 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionCompressedTextureASTC >::value, |
6480 | | sNativePropertyHooks, |
6481 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionCompressedTextureASTC>::Get, |
6482 | | GetProtoObjectHandle, |
6483 | | GetCCParticipant<mozilla::WebGLExtensionCompressedTextureASTC>::Get() |
6484 | | }; |
6485 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
6486 | | "Must have the right minimal number of reserved slots."); |
6487 | | static_assert(1 >= 1, |
6488 | | "Must have enough reserved slots."); |
6489 | | |
6490 | | const JSClass* |
6491 | | GetJSClass() |
6492 | 0 | { |
6493 | 0 | return sClass.ToJSClass(); |
6494 | 0 | } |
6495 | | |
6496 | | bool |
6497 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionCompressedTextureASTC* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
6498 | 0 | { |
6499 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionCompressedTextureASTC>::value, |
6500 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
6501 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionCompressedTextureASTC*>(aObject) == |
6502 | 0 | reinterpret_cast<mozilla::WebGLExtensionCompressedTextureASTC*>(aObject), |
6503 | 0 | "Multiple inheritance for mozilla::WebGLExtensionCompressedTextureASTC is broken."); |
6504 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
6505 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
6506 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
6507 | 0 | "You should probably not be using Wrap() directly; use " |
6508 | 0 | "GetOrCreateDOMReflector instead"); |
6509 | 0 |
|
6510 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
6511 | 0 | "nsISupports must be on our primary inheritance chain"); |
6512 | 0 |
|
6513 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
6514 | 0 | if (!global) { |
6515 | 0 | return false; |
6516 | 0 | } |
6517 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
6518 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
6519 | 0 |
|
6520 | 0 | // That might have ended up wrapping us already, due to the wonders |
6521 | 0 | // of XBL. Check for that, and bail out as needed. |
6522 | 0 | aReflector.set(aCache->GetWrapper()); |
6523 | 0 | if (aReflector) { |
6524 | | #ifdef DEBUG |
6525 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
6526 | | #endif // DEBUG |
6527 | | return true; |
6528 | 0 | } |
6529 | 0 |
|
6530 | 0 | JSAutoRealm ar(aCx, global); |
6531 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
6532 | 0 | if (!canonicalProto) { |
6533 | 0 | return false; |
6534 | 0 | } |
6535 | 0 | JS::Rooted<JSObject*> proto(aCx); |
6536 | 0 | if (aGivenProto) { |
6537 | 0 | proto = aGivenProto; |
6538 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
6539 | 0 | // coming in, we changed compartments to that of "parent" so may need |
6540 | 0 | // to wrap the proto here. |
6541 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
6542 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
6543 | 0 | return false; |
6544 | 0 | } |
6545 | 0 | } |
6546 | 0 | } else { |
6547 | 0 | proto = canonicalProto; |
6548 | 0 | } |
6549 | 0 |
|
6550 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionCompressedTextureASTC> creator(aCx); |
6551 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
6552 | 0 | if (!aReflector) { |
6553 | 0 | return false; |
6554 | 0 | } |
6555 | 0 | |
6556 | 0 | aCache->SetWrapper(aReflector); |
6557 | 0 | creator.InitializationSucceeded(); |
6558 | 0 |
|
6559 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
6560 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
6561 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
6562 | 0 | // otherwise we won't be able to properly recreate it later, since |
6563 | 0 | // we won't know what proto to use. Note that we don't check |
6564 | 0 | // aGivenProto here, since it's entirely possible (and even |
6565 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
6566 | 0 | // same as canonicalProto. |
6567 | 0 | if (proto != canonicalProto) { |
6568 | 0 | PreserveWrapper(aObject); |
6569 | 0 | } |
6570 | 0 |
|
6571 | 0 | return true; |
6572 | 0 | } |
6573 | | |
6574 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
6575 | | nullptr, |
6576 | | nullptr, |
6577 | | nullptr, |
6578 | | { sNativeProperties.Upcast(), nullptr }, |
6579 | | prototypes::id::WEBGL_compressed_texture_astc, |
6580 | | constructors::id::_ID_Count, |
6581 | | nullptr, |
6582 | | &DefaultXrayExpandoObjectClass |
6583 | | } }; |
6584 | | |
6585 | | void |
6586 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
6587 | 0 | { |
6588 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
6589 | 0 | if (!parentProto) { |
6590 | 0 | return; |
6591 | 0 | } |
6592 | 0 | |
6593 | 0 | static bool sIdsInited = false; |
6594 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
6595 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
6596 | 0 | return; |
6597 | 0 | } |
6598 | 0 | sIdsInited = true; |
6599 | 0 | } |
6600 | 0 |
|
6601 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WEBGL_compressed_texture_astc); |
6602 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
6603 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
6604 | 0 | &sPrototypeClass.mBase, protoCache, |
6605 | 0 | nullptr, |
6606 | 0 | nullptr, nullptr, 0, nullptr, |
6607 | 0 | interfaceCache, |
6608 | 0 | sNativeProperties.Upcast(), |
6609 | 0 | nullptr, |
6610 | 0 | nullptr, aDefineOnGlobal, |
6611 | 0 | nullptr, |
6612 | 0 | false); |
6613 | 0 | } |
6614 | | |
6615 | | } // namespace WEBGL_compressed_texture_astc_Binding |
6616 | | |
6617 | | |
6618 | | |
6619 | | namespace WEBGL_compressed_texture_atc_Binding { |
6620 | | |
6621 | | static bool |
6622 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
6623 | 0 | { |
6624 | 0 | mozilla::WebGLExtensionCompressedTextureATC* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTextureATC>(obj); |
6625 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
6626 | 0 | // obviously can't preserve if we're not initialized. |
6627 | 0 | if (self && self->GetWrapperPreserveColor()) { |
6628 | 0 | PreserveWrapper(self); |
6629 | 0 | } |
6630 | 0 | return true; |
6631 | 0 | } |
6632 | | |
6633 | | static void |
6634 | | _finalize(js::FreeOp* fop, JSObject* obj) |
6635 | 0 | { |
6636 | 0 | mozilla::WebGLExtensionCompressedTextureATC* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTextureATC>(obj); |
6637 | 0 | if (self) { |
6638 | 0 | ClearWrapper(self, self, obj); |
6639 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionCompressedTextureATC>(self); |
6640 | 0 | } |
6641 | 0 | } |
6642 | | |
6643 | | static size_t |
6644 | | _objectMoved(JSObject* obj, JSObject* old) |
6645 | 0 | { |
6646 | 0 | mozilla::WebGLExtensionCompressedTextureATC* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTextureATC>(obj); |
6647 | 0 | if (self) { |
6648 | 0 | UpdateWrapper(self, self, obj, old); |
6649 | 0 | } |
6650 | 0 |
|
6651 | 0 | return 0; |
6652 | 0 | } |
6653 | | |
6654 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
6655 | | #if defined(__clang__) |
6656 | | #pragma clang diagnostic push |
6657 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
6658 | | #endif |
6659 | | static const ConstantSpec sConstants_specs[] = { |
6660 | | { "COMPRESSED_RGB_ATC_WEBGL", JS::NumberValue(35986U) }, |
6661 | | { "COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL", JS::NumberValue(35987U) }, |
6662 | | { "COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL", JS::NumberValue(34798U) }, |
6663 | | { 0, JS::UndefinedValue() } |
6664 | | }; |
6665 | | #if defined(__clang__) |
6666 | | #pragma clang diagnostic pop |
6667 | | #endif |
6668 | | |
6669 | | |
6670 | | static const Prefable<const ConstantSpec> sConstants[] = { |
6671 | | { nullptr, &sConstants_specs[0] }, |
6672 | | { nullptr, nullptr } |
6673 | | }; |
6674 | | |
6675 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
6676 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
6677 | | static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
6678 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
6679 | | |
6680 | | |
6681 | | static uint16_t sNativeProperties_sortedPropertyIndices[3]; |
6682 | | static PropertyInfo sNativeProperties_propertyInfos[3]; |
6683 | | |
6684 | | static const NativePropertiesN<1> sNativeProperties = { |
6685 | | false, 0, |
6686 | | false, 0, |
6687 | | false, 0, |
6688 | | false, 0, |
6689 | | false, 0, |
6690 | | false, 0, |
6691 | | true, 0 /* sConstants */, |
6692 | | -1, |
6693 | | 3, |
6694 | | sNativeProperties_sortedPropertyIndices, |
6695 | | { |
6696 | | { sConstants, &sNativeProperties_propertyInfos[0] } |
6697 | | } |
6698 | | }; |
6699 | | static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
6700 | | "We have a property info count that is oversized"); |
6701 | | |
6702 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
6703 | | { |
6704 | | "WEBGL_compressed_texture_atcPrototype", |
6705 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
6706 | | JS_NULL_CLASS_OPS, |
6707 | | JS_NULL_CLASS_SPEC, |
6708 | | JS_NULL_CLASS_EXT, |
6709 | | JS_NULL_OBJECT_OPS |
6710 | | }, |
6711 | | eInterfacePrototype, |
6712 | | false, |
6713 | | prototypes::id::WEBGL_compressed_texture_atc, |
6714 | | PrototypeTraits<prototypes::id::WEBGL_compressed_texture_atc>::Depth, |
6715 | | sNativePropertyHooks, |
6716 | | "[object WEBGL_compressed_texture_atcPrototype]", |
6717 | | JS::GetRealmObjectPrototype |
6718 | | }; |
6719 | | |
6720 | | static const js::ClassOps sClassOps = { |
6721 | | _addProperty, /* addProperty */ |
6722 | | nullptr, /* delProperty */ |
6723 | | nullptr, /* enumerate */ |
6724 | | nullptr, /* newEnumerate */ |
6725 | | nullptr, /* resolve */ |
6726 | | nullptr, /* mayResolve */ |
6727 | | _finalize, /* finalize */ |
6728 | | nullptr, /* call */ |
6729 | | nullptr, /* hasInstance */ |
6730 | | nullptr, /* construct */ |
6731 | | nullptr, /* trace */ |
6732 | | }; |
6733 | | |
6734 | | static const js::ClassExtension sClassExtension = { |
6735 | | nullptr, /* weakmapKeyDelegateOp */ |
6736 | | _objectMoved /* objectMovedOp */ |
6737 | | }; |
6738 | | |
6739 | | static const DOMJSClass sClass = { |
6740 | | { "WEBGL_compressed_texture_atc", |
6741 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
6742 | | &sClassOps, |
6743 | | JS_NULL_CLASS_SPEC, |
6744 | | &sClassExtension, |
6745 | | JS_NULL_OBJECT_OPS |
6746 | | }, |
6747 | | { prototypes::id::WEBGL_compressed_texture_atc, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
6748 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionCompressedTextureATC >::value, |
6749 | | sNativePropertyHooks, |
6750 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionCompressedTextureATC>::Get, |
6751 | | GetProtoObjectHandle, |
6752 | | GetCCParticipant<mozilla::WebGLExtensionCompressedTextureATC>::Get() |
6753 | | }; |
6754 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
6755 | | "Must have the right minimal number of reserved slots."); |
6756 | | static_assert(1 >= 1, |
6757 | | "Must have enough reserved slots."); |
6758 | | |
6759 | | const JSClass* |
6760 | | GetJSClass() |
6761 | 0 | { |
6762 | 0 | return sClass.ToJSClass(); |
6763 | 0 | } |
6764 | | |
6765 | | bool |
6766 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionCompressedTextureATC* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
6767 | 0 | { |
6768 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionCompressedTextureATC>::value, |
6769 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
6770 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionCompressedTextureATC*>(aObject) == |
6771 | 0 | reinterpret_cast<mozilla::WebGLExtensionCompressedTextureATC*>(aObject), |
6772 | 0 | "Multiple inheritance for mozilla::WebGLExtensionCompressedTextureATC is broken."); |
6773 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
6774 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
6775 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
6776 | 0 | "You should probably not be using Wrap() directly; use " |
6777 | 0 | "GetOrCreateDOMReflector instead"); |
6778 | 0 |
|
6779 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
6780 | 0 | "nsISupports must be on our primary inheritance chain"); |
6781 | 0 |
|
6782 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
6783 | 0 | if (!global) { |
6784 | 0 | return false; |
6785 | 0 | } |
6786 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
6787 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
6788 | 0 |
|
6789 | 0 | // That might have ended up wrapping us already, due to the wonders |
6790 | 0 | // of XBL. Check for that, and bail out as needed. |
6791 | 0 | aReflector.set(aCache->GetWrapper()); |
6792 | 0 | if (aReflector) { |
6793 | | #ifdef DEBUG |
6794 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
6795 | | #endif // DEBUG |
6796 | | return true; |
6797 | 0 | } |
6798 | 0 |
|
6799 | 0 | JSAutoRealm ar(aCx, global); |
6800 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
6801 | 0 | if (!canonicalProto) { |
6802 | 0 | return false; |
6803 | 0 | } |
6804 | 0 | JS::Rooted<JSObject*> proto(aCx); |
6805 | 0 | if (aGivenProto) { |
6806 | 0 | proto = aGivenProto; |
6807 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
6808 | 0 | // coming in, we changed compartments to that of "parent" so may need |
6809 | 0 | // to wrap the proto here. |
6810 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
6811 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
6812 | 0 | return false; |
6813 | 0 | } |
6814 | 0 | } |
6815 | 0 | } else { |
6816 | 0 | proto = canonicalProto; |
6817 | 0 | } |
6818 | 0 |
|
6819 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionCompressedTextureATC> creator(aCx); |
6820 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
6821 | 0 | if (!aReflector) { |
6822 | 0 | return false; |
6823 | 0 | } |
6824 | 0 | |
6825 | 0 | aCache->SetWrapper(aReflector); |
6826 | 0 | creator.InitializationSucceeded(); |
6827 | 0 |
|
6828 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
6829 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
6830 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
6831 | 0 | // otherwise we won't be able to properly recreate it later, since |
6832 | 0 | // we won't know what proto to use. Note that we don't check |
6833 | 0 | // aGivenProto here, since it's entirely possible (and even |
6834 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
6835 | 0 | // same as canonicalProto. |
6836 | 0 | if (proto != canonicalProto) { |
6837 | 0 | PreserveWrapper(aObject); |
6838 | 0 | } |
6839 | 0 |
|
6840 | 0 | return true; |
6841 | 0 | } |
6842 | | |
6843 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
6844 | | nullptr, |
6845 | | nullptr, |
6846 | | nullptr, |
6847 | | { sNativeProperties.Upcast(), nullptr }, |
6848 | | prototypes::id::WEBGL_compressed_texture_atc, |
6849 | | constructors::id::_ID_Count, |
6850 | | nullptr, |
6851 | | &DefaultXrayExpandoObjectClass |
6852 | | } }; |
6853 | | |
6854 | | void |
6855 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
6856 | 0 | { |
6857 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
6858 | 0 | if (!parentProto) { |
6859 | 0 | return; |
6860 | 0 | } |
6861 | 0 | |
6862 | 0 | static bool sIdsInited = false; |
6863 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
6864 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
6865 | 0 | return; |
6866 | 0 | } |
6867 | 0 | sIdsInited = true; |
6868 | 0 | } |
6869 | 0 |
|
6870 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WEBGL_compressed_texture_atc); |
6871 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
6872 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
6873 | 0 | &sPrototypeClass.mBase, protoCache, |
6874 | 0 | nullptr, |
6875 | 0 | nullptr, nullptr, 0, nullptr, |
6876 | 0 | interfaceCache, |
6877 | 0 | sNativeProperties.Upcast(), |
6878 | 0 | nullptr, |
6879 | 0 | nullptr, aDefineOnGlobal, |
6880 | 0 | nullptr, |
6881 | 0 | false); |
6882 | 0 | } |
6883 | | |
6884 | | } // namespace WEBGL_compressed_texture_atc_Binding |
6885 | | |
6886 | | |
6887 | | |
6888 | | namespace WEBGL_compressed_texture_etc_Binding { |
6889 | | |
6890 | | static bool |
6891 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
6892 | 0 | { |
6893 | 0 | mozilla::WebGLExtensionCompressedTextureES3* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTextureES3>(obj); |
6894 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
6895 | 0 | // obviously can't preserve if we're not initialized. |
6896 | 0 | if (self && self->GetWrapperPreserveColor()) { |
6897 | 0 | PreserveWrapper(self); |
6898 | 0 | } |
6899 | 0 | return true; |
6900 | 0 | } |
6901 | | |
6902 | | static void |
6903 | | _finalize(js::FreeOp* fop, JSObject* obj) |
6904 | 0 | { |
6905 | 0 | mozilla::WebGLExtensionCompressedTextureES3* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTextureES3>(obj); |
6906 | 0 | if (self) { |
6907 | 0 | ClearWrapper(self, self, obj); |
6908 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionCompressedTextureES3>(self); |
6909 | 0 | } |
6910 | 0 | } |
6911 | | |
6912 | | static size_t |
6913 | | _objectMoved(JSObject* obj, JSObject* old) |
6914 | 0 | { |
6915 | 0 | mozilla::WebGLExtensionCompressedTextureES3* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTextureES3>(obj); |
6916 | 0 | if (self) { |
6917 | 0 | UpdateWrapper(self, self, obj, old); |
6918 | 0 | } |
6919 | 0 |
|
6920 | 0 | return 0; |
6921 | 0 | } |
6922 | | |
6923 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
6924 | | #if defined(__clang__) |
6925 | | #pragma clang diagnostic push |
6926 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
6927 | | #endif |
6928 | | static const ConstantSpec sConstants_specs[] = { |
6929 | | { "COMPRESSED_R11_EAC", JS::NumberValue(37488U) }, |
6930 | | { "COMPRESSED_SIGNED_R11_EAC", JS::NumberValue(37489U) }, |
6931 | | { "COMPRESSED_RG11_EAC", JS::NumberValue(37490U) }, |
6932 | | { "COMPRESSED_SIGNED_RG11_EAC", JS::NumberValue(37491U) }, |
6933 | | { "COMPRESSED_RGB8_ETC2", JS::NumberValue(37492U) }, |
6934 | | { "COMPRESSED_SRGB8_ETC2", JS::NumberValue(37493U) }, |
6935 | | { "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", JS::NumberValue(37494U) }, |
6936 | | { "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", JS::NumberValue(37495U) }, |
6937 | | { "COMPRESSED_RGBA8_ETC2_EAC", JS::NumberValue(37496U) }, |
6938 | | { "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", JS::NumberValue(37497U) }, |
6939 | | { 0, JS::UndefinedValue() } |
6940 | | }; |
6941 | | #if defined(__clang__) |
6942 | | #pragma clang diagnostic pop |
6943 | | #endif |
6944 | | |
6945 | | |
6946 | | static const Prefable<const ConstantSpec> sConstants[] = { |
6947 | | { nullptr, &sConstants_specs[0] }, |
6948 | | { nullptr, nullptr } |
6949 | | }; |
6950 | | |
6951 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
6952 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
6953 | | static_assert(10 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
6954 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
6955 | | |
6956 | | |
6957 | | static uint16_t sNativeProperties_sortedPropertyIndices[10]; |
6958 | | static PropertyInfo sNativeProperties_propertyInfos[10]; |
6959 | | |
6960 | | static const NativePropertiesN<1> sNativeProperties = { |
6961 | | false, 0, |
6962 | | false, 0, |
6963 | | false, 0, |
6964 | | false, 0, |
6965 | | false, 0, |
6966 | | false, 0, |
6967 | | true, 0 /* sConstants */, |
6968 | | -1, |
6969 | | 10, |
6970 | | sNativeProperties_sortedPropertyIndices, |
6971 | | { |
6972 | | { sConstants, &sNativeProperties_propertyInfos[0] } |
6973 | | } |
6974 | | }; |
6975 | | static_assert(10 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
6976 | | "We have a property info count that is oversized"); |
6977 | | |
6978 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
6979 | | { |
6980 | | "WEBGL_compressed_texture_etcPrototype", |
6981 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
6982 | | JS_NULL_CLASS_OPS, |
6983 | | JS_NULL_CLASS_SPEC, |
6984 | | JS_NULL_CLASS_EXT, |
6985 | | JS_NULL_OBJECT_OPS |
6986 | | }, |
6987 | | eInterfacePrototype, |
6988 | | false, |
6989 | | prototypes::id::WEBGL_compressed_texture_etc, |
6990 | | PrototypeTraits<prototypes::id::WEBGL_compressed_texture_etc>::Depth, |
6991 | | sNativePropertyHooks, |
6992 | | "[object WEBGL_compressed_texture_etcPrototype]", |
6993 | | JS::GetRealmObjectPrototype |
6994 | | }; |
6995 | | |
6996 | | static const js::ClassOps sClassOps = { |
6997 | | _addProperty, /* addProperty */ |
6998 | | nullptr, /* delProperty */ |
6999 | | nullptr, /* enumerate */ |
7000 | | nullptr, /* newEnumerate */ |
7001 | | nullptr, /* resolve */ |
7002 | | nullptr, /* mayResolve */ |
7003 | | _finalize, /* finalize */ |
7004 | | nullptr, /* call */ |
7005 | | nullptr, /* hasInstance */ |
7006 | | nullptr, /* construct */ |
7007 | | nullptr, /* trace */ |
7008 | | }; |
7009 | | |
7010 | | static const js::ClassExtension sClassExtension = { |
7011 | | nullptr, /* weakmapKeyDelegateOp */ |
7012 | | _objectMoved /* objectMovedOp */ |
7013 | | }; |
7014 | | |
7015 | | static const DOMJSClass sClass = { |
7016 | | { "WEBGL_compressed_texture_etc", |
7017 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
7018 | | &sClassOps, |
7019 | | JS_NULL_CLASS_SPEC, |
7020 | | &sClassExtension, |
7021 | | JS_NULL_OBJECT_OPS |
7022 | | }, |
7023 | | { prototypes::id::WEBGL_compressed_texture_etc, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
7024 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionCompressedTextureES3 >::value, |
7025 | | sNativePropertyHooks, |
7026 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionCompressedTextureES3>::Get, |
7027 | | GetProtoObjectHandle, |
7028 | | GetCCParticipant<mozilla::WebGLExtensionCompressedTextureES3>::Get() |
7029 | | }; |
7030 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
7031 | | "Must have the right minimal number of reserved slots."); |
7032 | | static_assert(1 >= 1, |
7033 | | "Must have enough reserved slots."); |
7034 | | |
7035 | | const JSClass* |
7036 | | GetJSClass() |
7037 | 0 | { |
7038 | 0 | return sClass.ToJSClass(); |
7039 | 0 | } |
7040 | | |
7041 | | bool |
7042 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionCompressedTextureES3* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
7043 | 0 | { |
7044 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionCompressedTextureES3>::value, |
7045 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
7046 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionCompressedTextureES3*>(aObject) == |
7047 | 0 | reinterpret_cast<mozilla::WebGLExtensionCompressedTextureES3*>(aObject), |
7048 | 0 | "Multiple inheritance for mozilla::WebGLExtensionCompressedTextureES3 is broken."); |
7049 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
7050 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
7051 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
7052 | 0 | "You should probably not be using Wrap() directly; use " |
7053 | 0 | "GetOrCreateDOMReflector instead"); |
7054 | 0 |
|
7055 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
7056 | 0 | "nsISupports must be on our primary inheritance chain"); |
7057 | 0 |
|
7058 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
7059 | 0 | if (!global) { |
7060 | 0 | return false; |
7061 | 0 | } |
7062 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
7063 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
7064 | 0 |
|
7065 | 0 | // That might have ended up wrapping us already, due to the wonders |
7066 | 0 | // of XBL. Check for that, and bail out as needed. |
7067 | 0 | aReflector.set(aCache->GetWrapper()); |
7068 | 0 | if (aReflector) { |
7069 | | #ifdef DEBUG |
7070 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
7071 | | #endif // DEBUG |
7072 | | return true; |
7073 | 0 | } |
7074 | 0 |
|
7075 | 0 | JSAutoRealm ar(aCx, global); |
7076 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
7077 | 0 | if (!canonicalProto) { |
7078 | 0 | return false; |
7079 | 0 | } |
7080 | 0 | JS::Rooted<JSObject*> proto(aCx); |
7081 | 0 | if (aGivenProto) { |
7082 | 0 | proto = aGivenProto; |
7083 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
7084 | 0 | // coming in, we changed compartments to that of "parent" so may need |
7085 | 0 | // to wrap the proto here. |
7086 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
7087 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
7088 | 0 | return false; |
7089 | 0 | } |
7090 | 0 | } |
7091 | 0 | } else { |
7092 | 0 | proto = canonicalProto; |
7093 | 0 | } |
7094 | 0 |
|
7095 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionCompressedTextureES3> creator(aCx); |
7096 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
7097 | 0 | if (!aReflector) { |
7098 | 0 | return false; |
7099 | 0 | } |
7100 | 0 | |
7101 | 0 | aCache->SetWrapper(aReflector); |
7102 | 0 | creator.InitializationSucceeded(); |
7103 | 0 |
|
7104 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
7105 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
7106 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
7107 | 0 | // otherwise we won't be able to properly recreate it later, since |
7108 | 0 | // we won't know what proto to use. Note that we don't check |
7109 | 0 | // aGivenProto here, since it's entirely possible (and even |
7110 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
7111 | 0 | // same as canonicalProto. |
7112 | 0 | if (proto != canonicalProto) { |
7113 | 0 | PreserveWrapper(aObject); |
7114 | 0 | } |
7115 | 0 |
|
7116 | 0 | return true; |
7117 | 0 | } |
7118 | | |
7119 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
7120 | | nullptr, |
7121 | | nullptr, |
7122 | | nullptr, |
7123 | | { sNativeProperties.Upcast(), nullptr }, |
7124 | | prototypes::id::WEBGL_compressed_texture_etc, |
7125 | | constructors::id::_ID_Count, |
7126 | | nullptr, |
7127 | | &DefaultXrayExpandoObjectClass |
7128 | | } }; |
7129 | | |
7130 | | void |
7131 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
7132 | 0 | { |
7133 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
7134 | 0 | if (!parentProto) { |
7135 | 0 | return; |
7136 | 0 | } |
7137 | 0 | |
7138 | 0 | static bool sIdsInited = false; |
7139 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
7140 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
7141 | 0 | return; |
7142 | 0 | } |
7143 | 0 | sIdsInited = true; |
7144 | 0 | } |
7145 | 0 |
|
7146 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WEBGL_compressed_texture_etc); |
7147 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
7148 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
7149 | 0 | &sPrototypeClass.mBase, protoCache, |
7150 | 0 | nullptr, |
7151 | 0 | nullptr, nullptr, 0, nullptr, |
7152 | 0 | interfaceCache, |
7153 | 0 | sNativeProperties.Upcast(), |
7154 | 0 | nullptr, |
7155 | 0 | nullptr, aDefineOnGlobal, |
7156 | 0 | nullptr, |
7157 | 0 | false); |
7158 | 0 | } |
7159 | | |
7160 | | } // namespace WEBGL_compressed_texture_etc_Binding |
7161 | | |
7162 | | |
7163 | | |
7164 | | namespace WEBGL_compressed_texture_etc1_Binding { |
7165 | | |
7166 | | static bool |
7167 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
7168 | 0 | { |
7169 | 0 | mozilla::WebGLExtensionCompressedTextureETC1* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTextureETC1>(obj); |
7170 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
7171 | 0 | // obviously can't preserve if we're not initialized. |
7172 | 0 | if (self && self->GetWrapperPreserveColor()) { |
7173 | 0 | PreserveWrapper(self); |
7174 | 0 | } |
7175 | 0 | return true; |
7176 | 0 | } |
7177 | | |
7178 | | static void |
7179 | | _finalize(js::FreeOp* fop, JSObject* obj) |
7180 | 0 | { |
7181 | 0 | mozilla::WebGLExtensionCompressedTextureETC1* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTextureETC1>(obj); |
7182 | 0 | if (self) { |
7183 | 0 | ClearWrapper(self, self, obj); |
7184 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionCompressedTextureETC1>(self); |
7185 | 0 | } |
7186 | 0 | } |
7187 | | |
7188 | | static size_t |
7189 | | _objectMoved(JSObject* obj, JSObject* old) |
7190 | 0 | { |
7191 | 0 | mozilla::WebGLExtensionCompressedTextureETC1* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTextureETC1>(obj); |
7192 | 0 | if (self) { |
7193 | 0 | UpdateWrapper(self, self, obj, old); |
7194 | 0 | } |
7195 | 0 |
|
7196 | 0 | return 0; |
7197 | 0 | } |
7198 | | |
7199 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
7200 | | #if defined(__clang__) |
7201 | | #pragma clang diagnostic push |
7202 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
7203 | | #endif |
7204 | | static const ConstantSpec sConstants_specs[] = { |
7205 | | { "COMPRESSED_RGB_ETC1_WEBGL", JS::NumberValue(36196U) }, |
7206 | | { 0, JS::UndefinedValue() } |
7207 | | }; |
7208 | | #if defined(__clang__) |
7209 | | #pragma clang diagnostic pop |
7210 | | #endif |
7211 | | |
7212 | | |
7213 | | static const Prefable<const ConstantSpec> sConstants[] = { |
7214 | | { nullptr, &sConstants_specs[0] }, |
7215 | | { nullptr, nullptr } |
7216 | | }; |
7217 | | |
7218 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
7219 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
7220 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
7221 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
7222 | | |
7223 | | |
7224 | | static uint16_t sNativeProperties_sortedPropertyIndices[1]; |
7225 | | static PropertyInfo sNativeProperties_propertyInfos[1]; |
7226 | | |
7227 | | static const NativePropertiesN<1> sNativeProperties = { |
7228 | | false, 0, |
7229 | | false, 0, |
7230 | | false, 0, |
7231 | | false, 0, |
7232 | | false, 0, |
7233 | | false, 0, |
7234 | | true, 0 /* sConstants */, |
7235 | | -1, |
7236 | | 1, |
7237 | | sNativeProperties_sortedPropertyIndices, |
7238 | | { |
7239 | | { sConstants, &sNativeProperties_propertyInfos[0] } |
7240 | | } |
7241 | | }; |
7242 | | static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
7243 | | "We have a property info count that is oversized"); |
7244 | | |
7245 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
7246 | | { |
7247 | | "WEBGL_compressed_texture_etc1Prototype", |
7248 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
7249 | | JS_NULL_CLASS_OPS, |
7250 | | JS_NULL_CLASS_SPEC, |
7251 | | JS_NULL_CLASS_EXT, |
7252 | | JS_NULL_OBJECT_OPS |
7253 | | }, |
7254 | | eInterfacePrototype, |
7255 | | false, |
7256 | | prototypes::id::WEBGL_compressed_texture_etc1, |
7257 | | PrototypeTraits<prototypes::id::WEBGL_compressed_texture_etc1>::Depth, |
7258 | | sNativePropertyHooks, |
7259 | | "[object WEBGL_compressed_texture_etc1Prototype]", |
7260 | | JS::GetRealmObjectPrototype |
7261 | | }; |
7262 | | |
7263 | | static const js::ClassOps sClassOps = { |
7264 | | _addProperty, /* addProperty */ |
7265 | | nullptr, /* delProperty */ |
7266 | | nullptr, /* enumerate */ |
7267 | | nullptr, /* newEnumerate */ |
7268 | | nullptr, /* resolve */ |
7269 | | nullptr, /* mayResolve */ |
7270 | | _finalize, /* finalize */ |
7271 | | nullptr, /* call */ |
7272 | | nullptr, /* hasInstance */ |
7273 | | nullptr, /* construct */ |
7274 | | nullptr, /* trace */ |
7275 | | }; |
7276 | | |
7277 | | static const js::ClassExtension sClassExtension = { |
7278 | | nullptr, /* weakmapKeyDelegateOp */ |
7279 | | _objectMoved /* objectMovedOp */ |
7280 | | }; |
7281 | | |
7282 | | static const DOMJSClass sClass = { |
7283 | | { "WEBGL_compressed_texture_etc1", |
7284 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
7285 | | &sClassOps, |
7286 | | JS_NULL_CLASS_SPEC, |
7287 | | &sClassExtension, |
7288 | | JS_NULL_OBJECT_OPS |
7289 | | }, |
7290 | | { prototypes::id::WEBGL_compressed_texture_etc1, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
7291 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionCompressedTextureETC1 >::value, |
7292 | | sNativePropertyHooks, |
7293 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionCompressedTextureETC1>::Get, |
7294 | | GetProtoObjectHandle, |
7295 | | GetCCParticipant<mozilla::WebGLExtensionCompressedTextureETC1>::Get() |
7296 | | }; |
7297 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
7298 | | "Must have the right minimal number of reserved slots."); |
7299 | | static_assert(1 >= 1, |
7300 | | "Must have enough reserved slots."); |
7301 | | |
7302 | | const JSClass* |
7303 | | GetJSClass() |
7304 | 0 | { |
7305 | 0 | return sClass.ToJSClass(); |
7306 | 0 | } |
7307 | | |
7308 | | bool |
7309 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionCompressedTextureETC1* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
7310 | 0 | { |
7311 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionCompressedTextureETC1>::value, |
7312 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
7313 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionCompressedTextureETC1*>(aObject) == |
7314 | 0 | reinterpret_cast<mozilla::WebGLExtensionCompressedTextureETC1*>(aObject), |
7315 | 0 | "Multiple inheritance for mozilla::WebGLExtensionCompressedTextureETC1 is broken."); |
7316 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
7317 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
7318 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
7319 | 0 | "You should probably not be using Wrap() directly; use " |
7320 | 0 | "GetOrCreateDOMReflector instead"); |
7321 | 0 |
|
7322 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
7323 | 0 | "nsISupports must be on our primary inheritance chain"); |
7324 | 0 |
|
7325 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
7326 | 0 | if (!global) { |
7327 | 0 | return false; |
7328 | 0 | } |
7329 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
7330 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
7331 | 0 |
|
7332 | 0 | // That might have ended up wrapping us already, due to the wonders |
7333 | 0 | // of XBL. Check for that, and bail out as needed. |
7334 | 0 | aReflector.set(aCache->GetWrapper()); |
7335 | 0 | if (aReflector) { |
7336 | | #ifdef DEBUG |
7337 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
7338 | | #endif // DEBUG |
7339 | | return true; |
7340 | 0 | } |
7341 | 0 |
|
7342 | 0 | JSAutoRealm ar(aCx, global); |
7343 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
7344 | 0 | if (!canonicalProto) { |
7345 | 0 | return false; |
7346 | 0 | } |
7347 | 0 | JS::Rooted<JSObject*> proto(aCx); |
7348 | 0 | if (aGivenProto) { |
7349 | 0 | proto = aGivenProto; |
7350 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
7351 | 0 | // coming in, we changed compartments to that of "parent" so may need |
7352 | 0 | // to wrap the proto here. |
7353 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
7354 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
7355 | 0 | return false; |
7356 | 0 | } |
7357 | 0 | } |
7358 | 0 | } else { |
7359 | 0 | proto = canonicalProto; |
7360 | 0 | } |
7361 | 0 |
|
7362 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionCompressedTextureETC1> creator(aCx); |
7363 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
7364 | 0 | if (!aReflector) { |
7365 | 0 | return false; |
7366 | 0 | } |
7367 | 0 | |
7368 | 0 | aCache->SetWrapper(aReflector); |
7369 | 0 | creator.InitializationSucceeded(); |
7370 | 0 |
|
7371 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
7372 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
7373 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
7374 | 0 | // otherwise we won't be able to properly recreate it later, since |
7375 | 0 | // we won't know what proto to use. Note that we don't check |
7376 | 0 | // aGivenProto here, since it's entirely possible (and even |
7377 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
7378 | 0 | // same as canonicalProto. |
7379 | 0 | if (proto != canonicalProto) { |
7380 | 0 | PreserveWrapper(aObject); |
7381 | 0 | } |
7382 | 0 |
|
7383 | 0 | return true; |
7384 | 0 | } |
7385 | | |
7386 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
7387 | | nullptr, |
7388 | | nullptr, |
7389 | | nullptr, |
7390 | | { sNativeProperties.Upcast(), nullptr }, |
7391 | | prototypes::id::WEBGL_compressed_texture_etc1, |
7392 | | constructors::id::_ID_Count, |
7393 | | nullptr, |
7394 | | &DefaultXrayExpandoObjectClass |
7395 | | } }; |
7396 | | |
7397 | | void |
7398 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
7399 | 0 | { |
7400 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
7401 | 0 | if (!parentProto) { |
7402 | 0 | return; |
7403 | 0 | } |
7404 | 0 | |
7405 | 0 | static bool sIdsInited = false; |
7406 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
7407 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
7408 | 0 | return; |
7409 | 0 | } |
7410 | 0 | sIdsInited = true; |
7411 | 0 | } |
7412 | 0 |
|
7413 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WEBGL_compressed_texture_etc1); |
7414 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
7415 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
7416 | 0 | &sPrototypeClass.mBase, protoCache, |
7417 | 0 | nullptr, |
7418 | 0 | nullptr, nullptr, 0, nullptr, |
7419 | 0 | interfaceCache, |
7420 | 0 | sNativeProperties.Upcast(), |
7421 | 0 | nullptr, |
7422 | 0 | nullptr, aDefineOnGlobal, |
7423 | 0 | nullptr, |
7424 | 0 | false); |
7425 | 0 | } |
7426 | | |
7427 | | } // namespace WEBGL_compressed_texture_etc1_Binding |
7428 | | |
7429 | | |
7430 | | |
7431 | | namespace WEBGL_compressed_texture_pvrtc_Binding { |
7432 | | |
7433 | | static bool |
7434 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
7435 | 0 | { |
7436 | 0 | mozilla::WebGLExtensionCompressedTexturePVRTC* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTexturePVRTC>(obj); |
7437 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
7438 | 0 | // obviously can't preserve if we're not initialized. |
7439 | 0 | if (self && self->GetWrapperPreserveColor()) { |
7440 | 0 | PreserveWrapper(self); |
7441 | 0 | } |
7442 | 0 | return true; |
7443 | 0 | } |
7444 | | |
7445 | | static void |
7446 | | _finalize(js::FreeOp* fop, JSObject* obj) |
7447 | 0 | { |
7448 | 0 | mozilla::WebGLExtensionCompressedTexturePVRTC* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTexturePVRTC>(obj); |
7449 | 0 | if (self) { |
7450 | 0 | ClearWrapper(self, self, obj); |
7451 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionCompressedTexturePVRTC>(self); |
7452 | 0 | } |
7453 | 0 | } |
7454 | | |
7455 | | static size_t |
7456 | | _objectMoved(JSObject* obj, JSObject* old) |
7457 | 0 | { |
7458 | 0 | mozilla::WebGLExtensionCompressedTexturePVRTC* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTexturePVRTC>(obj); |
7459 | 0 | if (self) { |
7460 | 0 | UpdateWrapper(self, self, obj, old); |
7461 | 0 | } |
7462 | 0 |
|
7463 | 0 | return 0; |
7464 | 0 | } |
7465 | | |
7466 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
7467 | | #if defined(__clang__) |
7468 | | #pragma clang diagnostic push |
7469 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
7470 | | #endif |
7471 | | static const ConstantSpec sConstants_specs[] = { |
7472 | | { "COMPRESSED_RGB_PVRTC_4BPPV1_IMG", JS::NumberValue(35840U) }, |
7473 | | { "COMPRESSED_RGB_PVRTC_2BPPV1_IMG", JS::NumberValue(35841U) }, |
7474 | | { "COMPRESSED_RGBA_PVRTC_4BPPV1_IMG", JS::NumberValue(35842U) }, |
7475 | | { "COMPRESSED_RGBA_PVRTC_2BPPV1_IMG", JS::NumberValue(35843U) }, |
7476 | | { 0, JS::UndefinedValue() } |
7477 | | }; |
7478 | | #if defined(__clang__) |
7479 | | #pragma clang diagnostic pop |
7480 | | #endif |
7481 | | |
7482 | | |
7483 | | static const Prefable<const ConstantSpec> sConstants[] = { |
7484 | | { nullptr, &sConstants_specs[0] }, |
7485 | | { nullptr, nullptr } |
7486 | | }; |
7487 | | |
7488 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
7489 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
7490 | | static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
7491 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
7492 | | |
7493 | | |
7494 | | static uint16_t sNativeProperties_sortedPropertyIndices[4]; |
7495 | | static PropertyInfo sNativeProperties_propertyInfos[4]; |
7496 | | |
7497 | | static const NativePropertiesN<1> sNativeProperties = { |
7498 | | false, 0, |
7499 | | false, 0, |
7500 | | false, 0, |
7501 | | false, 0, |
7502 | | false, 0, |
7503 | | false, 0, |
7504 | | true, 0 /* sConstants */, |
7505 | | -1, |
7506 | | 4, |
7507 | | sNativeProperties_sortedPropertyIndices, |
7508 | | { |
7509 | | { sConstants, &sNativeProperties_propertyInfos[0] } |
7510 | | } |
7511 | | }; |
7512 | | static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
7513 | | "We have a property info count that is oversized"); |
7514 | | |
7515 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
7516 | | { |
7517 | | "WEBGL_compressed_texture_pvrtcPrototype", |
7518 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
7519 | | JS_NULL_CLASS_OPS, |
7520 | | JS_NULL_CLASS_SPEC, |
7521 | | JS_NULL_CLASS_EXT, |
7522 | | JS_NULL_OBJECT_OPS |
7523 | | }, |
7524 | | eInterfacePrototype, |
7525 | | false, |
7526 | | prototypes::id::WEBGL_compressed_texture_pvrtc, |
7527 | | PrototypeTraits<prototypes::id::WEBGL_compressed_texture_pvrtc>::Depth, |
7528 | | sNativePropertyHooks, |
7529 | | "[object WEBGL_compressed_texture_pvrtcPrototype]", |
7530 | | JS::GetRealmObjectPrototype |
7531 | | }; |
7532 | | |
7533 | | static const js::ClassOps sClassOps = { |
7534 | | _addProperty, /* addProperty */ |
7535 | | nullptr, /* delProperty */ |
7536 | | nullptr, /* enumerate */ |
7537 | | nullptr, /* newEnumerate */ |
7538 | | nullptr, /* resolve */ |
7539 | | nullptr, /* mayResolve */ |
7540 | | _finalize, /* finalize */ |
7541 | | nullptr, /* call */ |
7542 | | nullptr, /* hasInstance */ |
7543 | | nullptr, /* construct */ |
7544 | | nullptr, /* trace */ |
7545 | | }; |
7546 | | |
7547 | | static const js::ClassExtension sClassExtension = { |
7548 | | nullptr, /* weakmapKeyDelegateOp */ |
7549 | | _objectMoved /* objectMovedOp */ |
7550 | | }; |
7551 | | |
7552 | | static const DOMJSClass sClass = { |
7553 | | { "WEBGL_compressed_texture_pvrtc", |
7554 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
7555 | | &sClassOps, |
7556 | | JS_NULL_CLASS_SPEC, |
7557 | | &sClassExtension, |
7558 | | JS_NULL_OBJECT_OPS |
7559 | | }, |
7560 | | { prototypes::id::WEBGL_compressed_texture_pvrtc, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
7561 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionCompressedTexturePVRTC >::value, |
7562 | | sNativePropertyHooks, |
7563 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionCompressedTexturePVRTC>::Get, |
7564 | | GetProtoObjectHandle, |
7565 | | GetCCParticipant<mozilla::WebGLExtensionCompressedTexturePVRTC>::Get() |
7566 | | }; |
7567 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
7568 | | "Must have the right minimal number of reserved slots."); |
7569 | | static_assert(1 >= 1, |
7570 | | "Must have enough reserved slots."); |
7571 | | |
7572 | | const JSClass* |
7573 | | GetJSClass() |
7574 | 0 | { |
7575 | 0 | return sClass.ToJSClass(); |
7576 | 0 | } |
7577 | | |
7578 | | bool |
7579 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionCompressedTexturePVRTC* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
7580 | 0 | { |
7581 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionCompressedTexturePVRTC>::value, |
7582 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
7583 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionCompressedTexturePVRTC*>(aObject) == |
7584 | 0 | reinterpret_cast<mozilla::WebGLExtensionCompressedTexturePVRTC*>(aObject), |
7585 | 0 | "Multiple inheritance for mozilla::WebGLExtensionCompressedTexturePVRTC is broken."); |
7586 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
7587 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
7588 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
7589 | 0 | "You should probably not be using Wrap() directly; use " |
7590 | 0 | "GetOrCreateDOMReflector instead"); |
7591 | 0 |
|
7592 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
7593 | 0 | "nsISupports must be on our primary inheritance chain"); |
7594 | 0 |
|
7595 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
7596 | 0 | if (!global) { |
7597 | 0 | return false; |
7598 | 0 | } |
7599 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
7600 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
7601 | 0 |
|
7602 | 0 | // That might have ended up wrapping us already, due to the wonders |
7603 | 0 | // of XBL. Check for that, and bail out as needed. |
7604 | 0 | aReflector.set(aCache->GetWrapper()); |
7605 | 0 | if (aReflector) { |
7606 | | #ifdef DEBUG |
7607 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
7608 | | #endif // DEBUG |
7609 | | return true; |
7610 | 0 | } |
7611 | 0 |
|
7612 | 0 | JSAutoRealm ar(aCx, global); |
7613 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
7614 | 0 | if (!canonicalProto) { |
7615 | 0 | return false; |
7616 | 0 | } |
7617 | 0 | JS::Rooted<JSObject*> proto(aCx); |
7618 | 0 | if (aGivenProto) { |
7619 | 0 | proto = aGivenProto; |
7620 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
7621 | 0 | // coming in, we changed compartments to that of "parent" so may need |
7622 | 0 | // to wrap the proto here. |
7623 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
7624 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
7625 | 0 | return false; |
7626 | 0 | } |
7627 | 0 | } |
7628 | 0 | } else { |
7629 | 0 | proto = canonicalProto; |
7630 | 0 | } |
7631 | 0 |
|
7632 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionCompressedTexturePVRTC> creator(aCx); |
7633 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
7634 | 0 | if (!aReflector) { |
7635 | 0 | return false; |
7636 | 0 | } |
7637 | 0 | |
7638 | 0 | aCache->SetWrapper(aReflector); |
7639 | 0 | creator.InitializationSucceeded(); |
7640 | 0 |
|
7641 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
7642 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
7643 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
7644 | 0 | // otherwise we won't be able to properly recreate it later, since |
7645 | 0 | // we won't know what proto to use. Note that we don't check |
7646 | 0 | // aGivenProto here, since it's entirely possible (and even |
7647 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
7648 | 0 | // same as canonicalProto. |
7649 | 0 | if (proto != canonicalProto) { |
7650 | 0 | PreserveWrapper(aObject); |
7651 | 0 | } |
7652 | 0 |
|
7653 | 0 | return true; |
7654 | 0 | } |
7655 | | |
7656 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
7657 | | nullptr, |
7658 | | nullptr, |
7659 | | nullptr, |
7660 | | { sNativeProperties.Upcast(), nullptr }, |
7661 | | prototypes::id::WEBGL_compressed_texture_pvrtc, |
7662 | | constructors::id::_ID_Count, |
7663 | | nullptr, |
7664 | | &DefaultXrayExpandoObjectClass |
7665 | | } }; |
7666 | | |
7667 | | void |
7668 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
7669 | 0 | { |
7670 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
7671 | 0 | if (!parentProto) { |
7672 | 0 | return; |
7673 | 0 | } |
7674 | 0 | |
7675 | 0 | static bool sIdsInited = false; |
7676 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
7677 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
7678 | 0 | return; |
7679 | 0 | } |
7680 | 0 | sIdsInited = true; |
7681 | 0 | } |
7682 | 0 |
|
7683 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WEBGL_compressed_texture_pvrtc); |
7684 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
7685 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
7686 | 0 | &sPrototypeClass.mBase, protoCache, |
7687 | 0 | nullptr, |
7688 | 0 | nullptr, nullptr, 0, nullptr, |
7689 | 0 | interfaceCache, |
7690 | 0 | sNativeProperties.Upcast(), |
7691 | 0 | nullptr, |
7692 | 0 | nullptr, aDefineOnGlobal, |
7693 | 0 | nullptr, |
7694 | 0 | false); |
7695 | 0 | } |
7696 | | |
7697 | | } // namespace WEBGL_compressed_texture_pvrtc_Binding |
7698 | | |
7699 | | |
7700 | | |
7701 | | namespace WEBGL_compressed_texture_s3tc_Binding { |
7702 | | |
7703 | | static bool |
7704 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
7705 | 0 | { |
7706 | 0 | mozilla::WebGLExtensionCompressedTextureS3TC* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTextureS3TC>(obj); |
7707 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
7708 | 0 | // obviously can't preserve if we're not initialized. |
7709 | 0 | if (self && self->GetWrapperPreserveColor()) { |
7710 | 0 | PreserveWrapper(self); |
7711 | 0 | } |
7712 | 0 | return true; |
7713 | 0 | } |
7714 | | |
7715 | | static void |
7716 | | _finalize(js::FreeOp* fop, JSObject* obj) |
7717 | 0 | { |
7718 | 0 | mozilla::WebGLExtensionCompressedTextureS3TC* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTextureS3TC>(obj); |
7719 | 0 | if (self) { |
7720 | 0 | ClearWrapper(self, self, obj); |
7721 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionCompressedTextureS3TC>(self); |
7722 | 0 | } |
7723 | 0 | } |
7724 | | |
7725 | | static size_t |
7726 | | _objectMoved(JSObject* obj, JSObject* old) |
7727 | 0 | { |
7728 | 0 | mozilla::WebGLExtensionCompressedTextureS3TC* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTextureS3TC>(obj); |
7729 | 0 | if (self) { |
7730 | 0 | UpdateWrapper(self, self, obj, old); |
7731 | 0 | } |
7732 | 0 |
|
7733 | 0 | return 0; |
7734 | 0 | } |
7735 | | |
7736 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
7737 | | #if defined(__clang__) |
7738 | | #pragma clang diagnostic push |
7739 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
7740 | | #endif |
7741 | | static const ConstantSpec sConstants_specs[] = { |
7742 | | { "COMPRESSED_RGB_S3TC_DXT1_EXT", JS::NumberValue(33776U) }, |
7743 | | { "COMPRESSED_RGBA_S3TC_DXT1_EXT", JS::NumberValue(33777U) }, |
7744 | | { "COMPRESSED_RGBA_S3TC_DXT3_EXT", JS::NumberValue(33778U) }, |
7745 | | { "COMPRESSED_RGBA_S3TC_DXT5_EXT", JS::NumberValue(33779U) }, |
7746 | | { 0, JS::UndefinedValue() } |
7747 | | }; |
7748 | | #if defined(__clang__) |
7749 | | #pragma clang diagnostic pop |
7750 | | #endif |
7751 | | |
7752 | | |
7753 | | static const Prefable<const ConstantSpec> sConstants[] = { |
7754 | | { nullptr, &sConstants_specs[0] }, |
7755 | | { nullptr, nullptr } |
7756 | | }; |
7757 | | |
7758 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
7759 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
7760 | | static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
7761 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
7762 | | |
7763 | | |
7764 | | static uint16_t sNativeProperties_sortedPropertyIndices[4]; |
7765 | | static PropertyInfo sNativeProperties_propertyInfos[4]; |
7766 | | |
7767 | | static const NativePropertiesN<1> sNativeProperties = { |
7768 | | false, 0, |
7769 | | false, 0, |
7770 | | false, 0, |
7771 | | false, 0, |
7772 | | false, 0, |
7773 | | false, 0, |
7774 | | true, 0 /* sConstants */, |
7775 | | -1, |
7776 | | 4, |
7777 | | sNativeProperties_sortedPropertyIndices, |
7778 | | { |
7779 | | { sConstants, &sNativeProperties_propertyInfos[0] } |
7780 | | } |
7781 | | }; |
7782 | | static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
7783 | | "We have a property info count that is oversized"); |
7784 | | |
7785 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
7786 | | { |
7787 | | "WEBGL_compressed_texture_s3tcPrototype", |
7788 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
7789 | | JS_NULL_CLASS_OPS, |
7790 | | JS_NULL_CLASS_SPEC, |
7791 | | JS_NULL_CLASS_EXT, |
7792 | | JS_NULL_OBJECT_OPS |
7793 | | }, |
7794 | | eInterfacePrototype, |
7795 | | false, |
7796 | | prototypes::id::WEBGL_compressed_texture_s3tc, |
7797 | | PrototypeTraits<prototypes::id::WEBGL_compressed_texture_s3tc>::Depth, |
7798 | | sNativePropertyHooks, |
7799 | | "[object WEBGL_compressed_texture_s3tcPrototype]", |
7800 | | JS::GetRealmObjectPrototype |
7801 | | }; |
7802 | | |
7803 | | static const js::ClassOps sClassOps = { |
7804 | | _addProperty, /* addProperty */ |
7805 | | nullptr, /* delProperty */ |
7806 | | nullptr, /* enumerate */ |
7807 | | nullptr, /* newEnumerate */ |
7808 | | nullptr, /* resolve */ |
7809 | | nullptr, /* mayResolve */ |
7810 | | _finalize, /* finalize */ |
7811 | | nullptr, /* call */ |
7812 | | nullptr, /* hasInstance */ |
7813 | | nullptr, /* construct */ |
7814 | | nullptr, /* trace */ |
7815 | | }; |
7816 | | |
7817 | | static const js::ClassExtension sClassExtension = { |
7818 | | nullptr, /* weakmapKeyDelegateOp */ |
7819 | | _objectMoved /* objectMovedOp */ |
7820 | | }; |
7821 | | |
7822 | | static const DOMJSClass sClass = { |
7823 | | { "WEBGL_compressed_texture_s3tc", |
7824 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
7825 | | &sClassOps, |
7826 | | JS_NULL_CLASS_SPEC, |
7827 | | &sClassExtension, |
7828 | | JS_NULL_OBJECT_OPS |
7829 | | }, |
7830 | | { prototypes::id::WEBGL_compressed_texture_s3tc, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
7831 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionCompressedTextureS3TC >::value, |
7832 | | sNativePropertyHooks, |
7833 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionCompressedTextureS3TC>::Get, |
7834 | | GetProtoObjectHandle, |
7835 | | GetCCParticipant<mozilla::WebGLExtensionCompressedTextureS3TC>::Get() |
7836 | | }; |
7837 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
7838 | | "Must have the right minimal number of reserved slots."); |
7839 | | static_assert(1 >= 1, |
7840 | | "Must have enough reserved slots."); |
7841 | | |
7842 | | const JSClass* |
7843 | | GetJSClass() |
7844 | 0 | { |
7845 | 0 | return sClass.ToJSClass(); |
7846 | 0 | } |
7847 | | |
7848 | | bool |
7849 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionCompressedTextureS3TC* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
7850 | 0 | { |
7851 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionCompressedTextureS3TC>::value, |
7852 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
7853 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionCompressedTextureS3TC*>(aObject) == |
7854 | 0 | reinterpret_cast<mozilla::WebGLExtensionCompressedTextureS3TC*>(aObject), |
7855 | 0 | "Multiple inheritance for mozilla::WebGLExtensionCompressedTextureS3TC is broken."); |
7856 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
7857 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
7858 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
7859 | 0 | "You should probably not be using Wrap() directly; use " |
7860 | 0 | "GetOrCreateDOMReflector instead"); |
7861 | 0 |
|
7862 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
7863 | 0 | "nsISupports must be on our primary inheritance chain"); |
7864 | 0 |
|
7865 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
7866 | 0 | if (!global) { |
7867 | 0 | return false; |
7868 | 0 | } |
7869 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
7870 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
7871 | 0 |
|
7872 | 0 | // That might have ended up wrapping us already, due to the wonders |
7873 | 0 | // of XBL. Check for that, and bail out as needed. |
7874 | 0 | aReflector.set(aCache->GetWrapper()); |
7875 | 0 | if (aReflector) { |
7876 | | #ifdef DEBUG |
7877 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
7878 | | #endif // DEBUG |
7879 | | return true; |
7880 | 0 | } |
7881 | 0 |
|
7882 | 0 | JSAutoRealm ar(aCx, global); |
7883 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
7884 | 0 | if (!canonicalProto) { |
7885 | 0 | return false; |
7886 | 0 | } |
7887 | 0 | JS::Rooted<JSObject*> proto(aCx); |
7888 | 0 | if (aGivenProto) { |
7889 | 0 | proto = aGivenProto; |
7890 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
7891 | 0 | // coming in, we changed compartments to that of "parent" so may need |
7892 | 0 | // to wrap the proto here. |
7893 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
7894 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
7895 | 0 | return false; |
7896 | 0 | } |
7897 | 0 | } |
7898 | 0 | } else { |
7899 | 0 | proto = canonicalProto; |
7900 | 0 | } |
7901 | 0 |
|
7902 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionCompressedTextureS3TC> creator(aCx); |
7903 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
7904 | 0 | if (!aReflector) { |
7905 | 0 | return false; |
7906 | 0 | } |
7907 | 0 | |
7908 | 0 | aCache->SetWrapper(aReflector); |
7909 | 0 | creator.InitializationSucceeded(); |
7910 | 0 |
|
7911 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
7912 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
7913 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
7914 | 0 | // otherwise we won't be able to properly recreate it later, since |
7915 | 0 | // we won't know what proto to use. Note that we don't check |
7916 | 0 | // aGivenProto here, since it's entirely possible (and even |
7917 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
7918 | 0 | // same as canonicalProto. |
7919 | 0 | if (proto != canonicalProto) { |
7920 | 0 | PreserveWrapper(aObject); |
7921 | 0 | } |
7922 | 0 |
|
7923 | 0 | return true; |
7924 | 0 | } |
7925 | | |
7926 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
7927 | | nullptr, |
7928 | | nullptr, |
7929 | | nullptr, |
7930 | | { sNativeProperties.Upcast(), nullptr }, |
7931 | | prototypes::id::WEBGL_compressed_texture_s3tc, |
7932 | | constructors::id::_ID_Count, |
7933 | | nullptr, |
7934 | | &DefaultXrayExpandoObjectClass |
7935 | | } }; |
7936 | | |
7937 | | void |
7938 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
7939 | 0 | { |
7940 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
7941 | 0 | if (!parentProto) { |
7942 | 0 | return; |
7943 | 0 | } |
7944 | 0 | |
7945 | 0 | static bool sIdsInited = false; |
7946 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
7947 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
7948 | 0 | return; |
7949 | 0 | } |
7950 | 0 | sIdsInited = true; |
7951 | 0 | } |
7952 | 0 |
|
7953 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WEBGL_compressed_texture_s3tc); |
7954 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
7955 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
7956 | 0 | &sPrototypeClass.mBase, protoCache, |
7957 | 0 | nullptr, |
7958 | 0 | nullptr, nullptr, 0, nullptr, |
7959 | 0 | interfaceCache, |
7960 | 0 | sNativeProperties.Upcast(), |
7961 | 0 | nullptr, |
7962 | 0 | nullptr, aDefineOnGlobal, |
7963 | 0 | nullptr, |
7964 | 0 | false); |
7965 | 0 | } |
7966 | | |
7967 | | } // namespace WEBGL_compressed_texture_s3tc_Binding |
7968 | | |
7969 | | |
7970 | | |
7971 | | namespace WEBGL_compressed_texture_s3tc_srgb_Binding { |
7972 | | |
7973 | | static bool |
7974 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
7975 | 0 | { |
7976 | 0 | mozilla::WebGLExtensionCompressedTextureS3TC_SRGB* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTextureS3TC_SRGB>(obj); |
7977 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
7978 | 0 | // obviously can't preserve if we're not initialized. |
7979 | 0 | if (self && self->GetWrapperPreserveColor()) { |
7980 | 0 | PreserveWrapper(self); |
7981 | 0 | } |
7982 | 0 | return true; |
7983 | 0 | } |
7984 | | |
7985 | | static void |
7986 | | _finalize(js::FreeOp* fop, JSObject* obj) |
7987 | 0 | { |
7988 | 0 | mozilla::WebGLExtensionCompressedTextureS3TC_SRGB* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTextureS3TC_SRGB>(obj); |
7989 | 0 | if (self) { |
7990 | 0 | ClearWrapper(self, self, obj); |
7991 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionCompressedTextureS3TC_SRGB>(self); |
7992 | 0 | } |
7993 | 0 | } |
7994 | | |
7995 | | static size_t |
7996 | | _objectMoved(JSObject* obj, JSObject* old) |
7997 | 0 | { |
7998 | 0 | mozilla::WebGLExtensionCompressedTextureS3TC_SRGB* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionCompressedTextureS3TC_SRGB>(obj); |
7999 | 0 | if (self) { |
8000 | 0 | UpdateWrapper(self, self, obj, old); |
8001 | 0 | } |
8002 | 0 |
|
8003 | 0 | return 0; |
8004 | 0 | } |
8005 | | |
8006 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
8007 | | #if defined(__clang__) |
8008 | | #pragma clang diagnostic push |
8009 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
8010 | | #endif |
8011 | | static const ConstantSpec sConstants_specs[] = { |
8012 | | { "COMPRESSED_SRGB_S3TC_DXT1_EXT", JS::NumberValue(35916U) }, |
8013 | | { "COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT", JS::NumberValue(35917U) }, |
8014 | | { "COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT", JS::NumberValue(35918U) }, |
8015 | | { "COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT", JS::NumberValue(35919U) }, |
8016 | | { 0, JS::UndefinedValue() } |
8017 | | }; |
8018 | | #if defined(__clang__) |
8019 | | #pragma clang diagnostic pop |
8020 | | #endif |
8021 | | |
8022 | | |
8023 | | static const Prefable<const ConstantSpec> sConstants[] = { |
8024 | | { nullptr, &sConstants_specs[0] }, |
8025 | | { nullptr, nullptr } |
8026 | | }; |
8027 | | |
8028 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
8029 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
8030 | | static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
8031 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
8032 | | |
8033 | | |
8034 | | static uint16_t sNativeProperties_sortedPropertyIndices[4]; |
8035 | | static PropertyInfo sNativeProperties_propertyInfos[4]; |
8036 | | |
8037 | | static const NativePropertiesN<1> sNativeProperties = { |
8038 | | false, 0, |
8039 | | false, 0, |
8040 | | false, 0, |
8041 | | false, 0, |
8042 | | false, 0, |
8043 | | false, 0, |
8044 | | true, 0 /* sConstants */, |
8045 | | -1, |
8046 | | 4, |
8047 | | sNativeProperties_sortedPropertyIndices, |
8048 | | { |
8049 | | { sConstants, &sNativeProperties_propertyInfos[0] } |
8050 | | } |
8051 | | }; |
8052 | | static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
8053 | | "We have a property info count that is oversized"); |
8054 | | |
8055 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
8056 | | { |
8057 | | "WEBGL_compressed_texture_s3tc_srgbPrototype", |
8058 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
8059 | | JS_NULL_CLASS_OPS, |
8060 | | JS_NULL_CLASS_SPEC, |
8061 | | JS_NULL_CLASS_EXT, |
8062 | | JS_NULL_OBJECT_OPS |
8063 | | }, |
8064 | | eInterfacePrototype, |
8065 | | false, |
8066 | | prototypes::id::WEBGL_compressed_texture_s3tc_srgb, |
8067 | | PrototypeTraits<prototypes::id::WEBGL_compressed_texture_s3tc_srgb>::Depth, |
8068 | | sNativePropertyHooks, |
8069 | | "[object WEBGL_compressed_texture_s3tc_srgbPrototype]", |
8070 | | JS::GetRealmObjectPrototype |
8071 | | }; |
8072 | | |
8073 | | static const js::ClassOps sClassOps = { |
8074 | | _addProperty, /* addProperty */ |
8075 | | nullptr, /* delProperty */ |
8076 | | nullptr, /* enumerate */ |
8077 | | nullptr, /* newEnumerate */ |
8078 | | nullptr, /* resolve */ |
8079 | | nullptr, /* mayResolve */ |
8080 | | _finalize, /* finalize */ |
8081 | | nullptr, /* call */ |
8082 | | nullptr, /* hasInstance */ |
8083 | | nullptr, /* construct */ |
8084 | | nullptr, /* trace */ |
8085 | | }; |
8086 | | |
8087 | | static const js::ClassExtension sClassExtension = { |
8088 | | nullptr, /* weakmapKeyDelegateOp */ |
8089 | | _objectMoved /* objectMovedOp */ |
8090 | | }; |
8091 | | |
8092 | | static const DOMJSClass sClass = { |
8093 | | { "WEBGL_compressed_texture_s3tc_srgb", |
8094 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
8095 | | &sClassOps, |
8096 | | JS_NULL_CLASS_SPEC, |
8097 | | &sClassExtension, |
8098 | | JS_NULL_OBJECT_OPS |
8099 | | }, |
8100 | | { prototypes::id::WEBGL_compressed_texture_s3tc_srgb, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
8101 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionCompressedTextureS3TC_SRGB >::value, |
8102 | | sNativePropertyHooks, |
8103 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionCompressedTextureS3TC_SRGB>::Get, |
8104 | | GetProtoObjectHandle, |
8105 | | GetCCParticipant<mozilla::WebGLExtensionCompressedTextureS3TC_SRGB>::Get() |
8106 | | }; |
8107 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
8108 | | "Must have the right minimal number of reserved slots."); |
8109 | | static_assert(1 >= 1, |
8110 | | "Must have enough reserved slots."); |
8111 | | |
8112 | | const JSClass* |
8113 | | GetJSClass() |
8114 | 0 | { |
8115 | 0 | return sClass.ToJSClass(); |
8116 | 0 | } |
8117 | | |
8118 | | bool |
8119 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionCompressedTextureS3TC_SRGB* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
8120 | 0 | { |
8121 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionCompressedTextureS3TC_SRGB>::value, |
8122 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
8123 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionCompressedTextureS3TC_SRGB*>(aObject) == |
8124 | 0 | reinterpret_cast<mozilla::WebGLExtensionCompressedTextureS3TC_SRGB*>(aObject), |
8125 | 0 | "Multiple inheritance for mozilla::WebGLExtensionCompressedTextureS3TC_SRGB is broken."); |
8126 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
8127 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
8128 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
8129 | 0 | "You should probably not be using Wrap() directly; use " |
8130 | 0 | "GetOrCreateDOMReflector instead"); |
8131 | 0 |
|
8132 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
8133 | 0 | "nsISupports must be on our primary inheritance chain"); |
8134 | 0 |
|
8135 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
8136 | 0 | if (!global) { |
8137 | 0 | return false; |
8138 | 0 | } |
8139 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
8140 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
8141 | 0 |
|
8142 | 0 | // That might have ended up wrapping us already, due to the wonders |
8143 | 0 | // of XBL. Check for that, and bail out as needed. |
8144 | 0 | aReflector.set(aCache->GetWrapper()); |
8145 | 0 | if (aReflector) { |
8146 | | #ifdef DEBUG |
8147 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
8148 | | #endif // DEBUG |
8149 | | return true; |
8150 | 0 | } |
8151 | 0 |
|
8152 | 0 | JSAutoRealm ar(aCx, global); |
8153 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
8154 | 0 | if (!canonicalProto) { |
8155 | 0 | return false; |
8156 | 0 | } |
8157 | 0 | JS::Rooted<JSObject*> proto(aCx); |
8158 | 0 | if (aGivenProto) { |
8159 | 0 | proto = aGivenProto; |
8160 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
8161 | 0 | // coming in, we changed compartments to that of "parent" so may need |
8162 | 0 | // to wrap the proto here. |
8163 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
8164 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
8165 | 0 | return false; |
8166 | 0 | } |
8167 | 0 | } |
8168 | 0 | } else { |
8169 | 0 | proto = canonicalProto; |
8170 | 0 | } |
8171 | 0 |
|
8172 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionCompressedTextureS3TC_SRGB> creator(aCx); |
8173 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
8174 | 0 | if (!aReflector) { |
8175 | 0 | return false; |
8176 | 0 | } |
8177 | 0 | |
8178 | 0 | aCache->SetWrapper(aReflector); |
8179 | 0 | creator.InitializationSucceeded(); |
8180 | 0 |
|
8181 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
8182 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
8183 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
8184 | 0 | // otherwise we won't be able to properly recreate it later, since |
8185 | 0 | // we won't know what proto to use. Note that we don't check |
8186 | 0 | // aGivenProto here, since it's entirely possible (and even |
8187 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
8188 | 0 | // same as canonicalProto. |
8189 | 0 | if (proto != canonicalProto) { |
8190 | 0 | PreserveWrapper(aObject); |
8191 | 0 | } |
8192 | 0 |
|
8193 | 0 | return true; |
8194 | 0 | } |
8195 | | |
8196 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
8197 | | nullptr, |
8198 | | nullptr, |
8199 | | nullptr, |
8200 | | { sNativeProperties.Upcast(), nullptr }, |
8201 | | prototypes::id::WEBGL_compressed_texture_s3tc_srgb, |
8202 | | constructors::id::_ID_Count, |
8203 | | nullptr, |
8204 | | &DefaultXrayExpandoObjectClass |
8205 | | } }; |
8206 | | |
8207 | | void |
8208 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
8209 | 0 | { |
8210 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
8211 | 0 | if (!parentProto) { |
8212 | 0 | return; |
8213 | 0 | } |
8214 | 0 | |
8215 | 0 | static bool sIdsInited = false; |
8216 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
8217 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
8218 | 0 | return; |
8219 | 0 | } |
8220 | 0 | sIdsInited = true; |
8221 | 0 | } |
8222 | 0 |
|
8223 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WEBGL_compressed_texture_s3tc_srgb); |
8224 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
8225 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
8226 | 0 | &sPrototypeClass.mBase, protoCache, |
8227 | 0 | nullptr, |
8228 | 0 | nullptr, nullptr, 0, nullptr, |
8229 | 0 | interfaceCache, |
8230 | 0 | sNativeProperties.Upcast(), |
8231 | 0 | nullptr, |
8232 | 0 | nullptr, aDefineOnGlobal, |
8233 | 0 | nullptr, |
8234 | 0 | false); |
8235 | 0 | } |
8236 | | |
8237 | | } // namespace WEBGL_compressed_texture_s3tc_srgb_Binding |
8238 | | |
8239 | | |
8240 | | |
8241 | | namespace WEBGL_debug_renderer_info_Binding { |
8242 | | |
8243 | | static bool |
8244 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
8245 | 0 | { |
8246 | 0 | mozilla::WebGLExtensionDebugRendererInfo* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionDebugRendererInfo>(obj); |
8247 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
8248 | 0 | // obviously can't preserve if we're not initialized. |
8249 | 0 | if (self && self->GetWrapperPreserveColor()) { |
8250 | 0 | PreserveWrapper(self); |
8251 | 0 | } |
8252 | 0 | return true; |
8253 | 0 | } |
8254 | | |
8255 | | static void |
8256 | | _finalize(js::FreeOp* fop, JSObject* obj) |
8257 | 0 | { |
8258 | 0 | mozilla::WebGLExtensionDebugRendererInfo* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionDebugRendererInfo>(obj); |
8259 | 0 | if (self) { |
8260 | 0 | ClearWrapper(self, self, obj); |
8261 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionDebugRendererInfo>(self); |
8262 | 0 | } |
8263 | 0 | } |
8264 | | |
8265 | | static size_t |
8266 | | _objectMoved(JSObject* obj, JSObject* old) |
8267 | 0 | { |
8268 | 0 | mozilla::WebGLExtensionDebugRendererInfo* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionDebugRendererInfo>(obj); |
8269 | 0 | if (self) { |
8270 | 0 | UpdateWrapper(self, self, obj, old); |
8271 | 0 | } |
8272 | 0 |
|
8273 | 0 | return 0; |
8274 | 0 | } |
8275 | | |
8276 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
8277 | | #if defined(__clang__) |
8278 | | #pragma clang diagnostic push |
8279 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
8280 | | #endif |
8281 | | static const ConstantSpec sConstants_specs[] = { |
8282 | | { "UNMASKED_VENDOR_WEBGL", JS::NumberValue(37445U) }, |
8283 | | { "UNMASKED_RENDERER_WEBGL", JS::NumberValue(37446U) }, |
8284 | | { 0, JS::UndefinedValue() } |
8285 | | }; |
8286 | | #if defined(__clang__) |
8287 | | #pragma clang diagnostic pop |
8288 | | #endif |
8289 | | |
8290 | | |
8291 | | static const Prefable<const ConstantSpec> sConstants[] = { |
8292 | | { nullptr, &sConstants_specs[0] }, |
8293 | | { nullptr, nullptr } |
8294 | | }; |
8295 | | |
8296 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
8297 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
8298 | | static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
8299 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
8300 | | |
8301 | | |
8302 | | static uint16_t sNativeProperties_sortedPropertyIndices[2]; |
8303 | | static PropertyInfo sNativeProperties_propertyInfos[2]; |
8304 | | |
8305 | | static const NativePropertiesN<1> sNativeProperties = { |
8306 | | false, 0, |
8307 | | false, 0, |
8308 | | false, 0, |
8309 | | false, 0, |
8310 | | false, 0, |
8311 | | false, 0, |
8312 | | true, 0 /* sConstants */, |
8313 | | -1, |
8314 | | 2, |
8315 | | sNativeProperties_sortedPropertyIndices, |
8316 | | { |
8317 | | { sConstants, &sNativeProperties_propertyInfos[0] } |
8318 | | } |
8319 | | }; |
8320 | | static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
8321 | | "We have a property info count that is oversized"); |
8322 | | |
8323 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
8324 | | { |
8325 | | "WEBGL_debug_renderer_infoPrototype", |
8326 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
8327 | | JS_NULL_CLASS_OPS, |
8328 | | JS_NULL_CLASS_SPEC, |
8329 | | JS_NULL_CLASS_EXT, |
8330 | | JS_NULL_OBJECT_OPS |
8331 | | }, |
8332 | | eInterfacePrototype, |
8333 | | false, |
8334 | | prototypes::id::WEBGL_debug_renderer_info, |
8335 | | PrototypeTraits<prototypes::id::WEBGL_debug_renderer_info>::Depth, |
8336 | | sNativePropertyHooks, |
8337 | | "[object WEBGL_debug_renderer_infoPrototype]", |
8338 | | JS::GetRealmObjectPrototype |
8339 | | }; |
8340 | | |
8341 | | static const js::ClassOps sClassOps = { |
8342 | | _addProperty, /* addProperty */ |
8343 | | nullptr, /* delProperty */ |
8344 | | nullptr, /* enumerate */ |
8345 | | nullptr, /* newEnumerate */ |
8346 | | nullptr, /* resolve */ |
8347 | | nullptr, /* mayResolve */ |
8348 | | _finalize, /* finalize */ |
8349 | | nullptr, /* call */ |
8350 | | nullptr, /* hasInstance */ |
8351 | | nullptr, /* construct */ |
8352 | | nullptr, /* trace */ |
8353 | | }; |
8354 | | |
8355 | | static const js::ClassExtension sClassExtension = { |
8356 | | nullptr, /* weakmapKeyDelegateOp */ |
8357 | | _objectMoved /* objectMovedOp */ |
8358 | | }; |
8359 | | |
8360 | | static const DOMJSClass sClass = { |
8361 | | { "WEBGL_debug_renderer_info", |
8362 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
8363 | | &sClassOps, |
8364 | | JS_NULL_CLASS_SPEC, |
8365 | | &sClassExtension, |
8366 | | JS_NULL_OBJECT_OPS |
8367 | | }, |
8368 | | { prototypes::id::WEBGL_debug_renderer_info, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
8369 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionDebugRendererInfo >::value, |
8370 | | sNativePropertyHooks, |
8371 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionDebugRendererInfo>::Get, |
8372 | | GetProtoObjectHandle, |
8373 | | GetCCParticipant<mozilla::WebGLExtensionDebugRendererInfo>::Get() |
8374 | | }; |
8375 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
8376 | | "Must have the right minimal number of reserved slots."); |
8377 | | static_assert(1 >= 1, |
8378 | | "Must have enough reserved slots."); |
8379 | | |
8380 | | const JSClass* |
8381 | | GetJSClass() |
8382 | 0 | { |
8383 | 0 | return sClass.ToJSClass(); |
8384 | 0 | } |
8385 | | |
8386 | | bool |
8387 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionDebugRendererInfo* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
8388 | 0 | { |
8389 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionDebugRendererInfo>::value, |
8390 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
8391 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionDebugRendererInfo*>(aObject) == |
8392 | 0 | reinterpret_cast<mozilla::WebGLExtensionDebugRendererInfo*>(aObject), |
8393 | 0 | "Multiple inheritance for mozilla::WebGLExtensionDebugRendererInfo is broken."); |
8394 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
8395 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
8396 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
8397 | 0 | "You should probably not be using Wrap() directly; use " |
8398 | 0 | "GetOrCreateDOMReflector instead"); |
8399 | 0 |
|
8400 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
8401 | 0 | "nsISupports must be on our primary inheritance chain"); |
8402 | 0 |
|
8403 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
8404 | 0 | if (!global) { |
8405 | 0 | return false; |
8406 | 0 | } |
8407 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
8408 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
8409 | 0 |
|
8410 | 0 | // That might have ended up wrapping us already, due to the wonders |
8411 | 0 | // of XBL. Check for that, and bail out as needed. |
8412 | 0 | aReflector.set(aCache->GetWrapper()); |
8413 | 0 | if (aReflector) { |
8414 | | #ifdef DEBUG |
8415 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
8416 | | #endif // DEBUG |
8417 | | return true; |
8418 | 0 | } |
8419 | 0 |
|
8420 | 0 | JSAutoRealm ar(aCx, global); |
8421 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
8422 | 0 | if (!canonicalProto) { |
8423 | 0 | return false; |
8424 | 0 | } |
8425 | 0 | JS::Rooted<JSObject*> proto(aCx); |
8426 | 0 | if (aGivenProto) { |
8427 | 0 | proto = aGivenProto; |
8428 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
8429 | 0 | // coming in, we changed compartments to that of "parent" so may need |
8430 | 0 | // to wrap the proto here. |
8431 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
8432 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
8433 | 0 | return false; |
8434 | 0 | } |
8435 | 0 | } |
8436 | 0 | } else { |
8437 | 0 | proto = canonicalProto; |
8438 | 0 | } |
8439 | 0 |
|
8440 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionDebugRendererInfo> creator(aCx); |
8441 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
8442 | 0 | if (!aReflector) { |
8443 | 0 | return false; |
8444 | 0 | } |
8445 | 0 | |
8446 | 0 | aCache->SetWrapper(aReflector); |
8447 | 0 | creator.InitializationSucceeded(); |
8448 | 0 |
|
8449 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
8450 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
8451 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
8452 | 0 | // otherwise we won't be able to properly recreate it later, since |
8453 | 0 | // we won't know what proto to use. Note that we don't check |
8454 | 0 | // aGivenProto here, since it's entirely possible (and even |
8455 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
8456 | 0 | // same as canonicalProto. |
8457 | 0 | if (proto != canonicalProto) { |
8458 | 0 | PreserveWrapper(aObject); |
8459 | 0 | } |
8460 | 0 |
|
8461 | 0 | return true; |
8462 | 0 | } |
8463 | | |
8464 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
8465 | | nullptr, |
8466 | | nullptr, |
8467 | | nullptr, |
8468 | | { sNativeProperties.Upcast(), nullptr }, |
8469 | | prototypes::id::WEBGL_debug_renderer_info, |
8470 | | constructors::id::_ID_Count, |
8471 | | nullptr, |
8472 | | &DefaultXrayExpandoObjectClass |
8473 | | } }; |
8474 | | |
8475 | | void |
8476 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
8477 | 0 | { |
8478 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
8479 | 0 | if (!parentProto) { |
8480 | 0 | return; |
8481 | 0 | } |
8482 | 0 | |
8483 | 0 | static bool sIdsInited = false; |
8484 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
8485 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
8486 | 0 | return; |
8487 | 0 | } |
8488 | 0 | sIdsInited = true; |
8489 | 0 | } |
8490 | 0 |
|
8491 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WEBGL_debug_renderer_info); |
8492 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
8493 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
8494 | 0 | &sPrototypeClass.mBase, protoCache, |
8495 | 0 | nullptr, |
8496 | 0 | nullptr, nullptr, 0, nullptr, |
8497 | 0 | interfaceCache, |
8498 | 0 | sNativeProperties.Upcast(), |
8499 | 0 | nullptr, |
8500 | 0 | nullptr, aDefineOnGlobal, |
8501 | 0 | nullptr, |
8502 | 0 | false); |
8503 | 0 | } |
8504 | | |
8505 | | } // namespace WEBGL_debug_renderer_info_Binding |
8506 | | |
8507 | | |
8508 | | |
8509 | | namespace WEBGL_debug_shaders_Binding { |
8510 | | |
8511 | | MOZ_CAN_RUN_SCRIPT static bool |
8512 | | getTranslatedShaderSource(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionDebugShaders* self, const JSJitMethodCallArgs& args) |
8513 | 0 | { |
8514 | 0 | AUTO_PROFILER_LABEL_FAST("WEBGL_debug_shaders.getTranslatedShaderSource", DOM, cx); |
8515 | 0 |
|
8516 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
8517 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WEBGL_debug_shaders.getTranslatedShaderSource"); |
8518 | 0 | } |
8519 | 0 | NonNull<mozilla::WebGLShader> arg0; |
8520 | 0 | if (args[0].isObject()) { |
8521 | 0 | { |
8522 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLShader, mozilla::WebGLShader>(args[0], arg0); |
8523 | 0 | if (NS_FAILED(rv)) { |
8524 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WEBGL_debug_shaders.getTranslatedShaderSource", "WebGLShader"); |
8525 | 0 | return false; |
8526 | 0 | } |
8527 | 0 | } |
8528 | 0 | } else { |
8529 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WEBGL_debug_shaders.getTranslatedShaderSource"); |
8530 | 0 | return false; |
8531 | 0 | } |
8532 | 0 | DOMString result; |
8533 | 0 | self->GetTranslatedShaderSource(MOZ_KnownLive(NonNullHelper(arg0)), result); |
8534 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
8535 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
8536 | 0 | return false; |
8537 | 0 | } |
8538 | 0 | return true; |
8539 | 0 | } |
8540 | | |
8541 | | static const JSJitInfo getTranslatedShaderSource_methodinfo = { |
8542 | | { (JSJitGetterOp)getTranslatedShaderSource }, |
8543 | | { prototypes::id::WEBGL_debug_shaders }, |
8544 | | { PrototypeTraits<prototypes::id::WEBGL_debug_shaders>::Depth }, |
8545 | | JSJitInfo::Method, |
8546 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
8547 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
8548 | | false, /* isInfallible. False in setters. */ |
8549 | | false, /* isMovable. Not relevant for setters. */ |
8550 | | false, /* isEliminatable. Not relevant for setters. */ |
8551 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
8552 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
8553 | | false, /* isTypedMethod. Only relevant for methods. */ |
8554 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
8555 | | }; |
8556 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
8557 | | static_assert(0 < 1, "There is no slot for us"); |
8558 | | |
8559 | | static bool |
8560 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
8561 | 0 | { |
8562 | 0 | mozilla::WebGLExtensionDebugShaders* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionDebugShaders>(obj); |
8563 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
8564 | 0 | // obviously can't preserve if we're not initialized. |
8565 | 0 | if (self && self->GetWrapperPreserveColor()) { |
8566 | 0 | PreserveWrapper(self); |
8567 | 0 | } |
8568 | 0 | return true; |
8569 | 0 | } |
8570 | | |
8571 | | static void |
8572 | | _finalize(js::FreeOp* fop, JSObject* obj) |
8573 | 0 | { |
8574 | 0 | mozilla::WebGLExtensionDebugShaders* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionDebugShaders>(obj); |
8575 | 0 | if (self) { |
8576 | 0 | ClearWrapper(self, self, obj); |
8577 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionDebugShaders>(self); |
8578 | 0 | } |
8579 | 0 | } |
8580 | | |
8581 | | static size_t |
8582 | | _objectMoved(JSObject* obj, JSObject* old) |
8583 | 0 | { |
8584 | 0 | mozilla::WebGLExtensionDebugShaders* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionDebugShaders>(obj); |
8585 | 0 | if (self) { |
8586 | 0 | UpdateWrapper(self, self, obj, old); |
8587 | 0 | } |
8588 | 0 |
|
8589 | 0 | return 0; |
8590 | 0 | } |
8591 | | |
8592 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
8593 | | #if defined(__clang__) |
8594 | | #pragma clang diagnostic push |
8595 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
8596 | | #endif |
8597 | | static const JSFunctionSpec sMethods_specs[] = { |
8598 | | JS_FNSPEC("getTranslatedShaderSource", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getTranslatedShaderSource_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
8599 | | JS_FS_END |
8600 | | }; |
8601 | | #if defined(__clang__) |
8602 | | #pragma clang diagnostic pop |
8603 | | #endif |
8604 | | |
8605 | | |
8606 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
8607 | | { nullptr, &sMethods_specs[0] }, |
8608 | | { nullptr, nullptr } |
8609 | | }; |
8610 | | |
8611 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
8612 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
8613 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
8614 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
8615 | | |
8616 | | |
8617 | | static uint16_t sNativeProperties_sortedPropertyIndices[1]; |
8618 | | static PropertyInfo sNativeProperties_propertyInfos[1]; |
8619 | | |
8620 | | static const NativePropertiesN<1> sNativeProperties = { |
8621 | | false, 0, |
8622 | | false, 0, |
8623 | | true, 0 /* sMethods */, |
8624 | | false, 0, |
8625 | | false, 0, |
8626 | | false, 0, |
8627 | | false, 0, |
8628 | | -1, |
8629 | | 1, |
8630 | | sNativeProperties_sortedPropertyIndices, |
8631 | | { |
8632 | | { sMethods, &sNativeProperties_propertyInfos[0] } |
8633 | | } |
8634 | | }; |
8635 | | static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
8636 | | "We have a property info count that is oversized"); |
8637 | | |
8638 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
8639 | | { |
8640 | | "WEBGL_debug_shadersPrototype", |
8641 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
8642 | | JS_NULL_CLASS_OPS, |
8643 | | JS_NULL_CLASS_SPEC, |
8644 | | JS_NULL_CLASS_EXT, |
8645 | | JS_NULL_OBJECT_OPS |
8646 | | }, |
8647 | | eInterfacePrototype, |
8648 | | false, |
8649 | | prototypes::id::WEBGL_debug_shaders, |
8650 | | PrototypeTraits<prototypes::id::WEBGL_debug_shaders>::Depth, |
8651 | | sNativePropertyHooks, |
8652 | | "[object WEBGL_debug_shadersPrototype]", |
8653 | | JS::GetRealmObjectPrototype |
8654 | | }; |
8655 | | |
8656 | | static const js::ClassOps sClassOps = { |
8657 | | _addProperty, /* addProperty */ |
8658 | | nullptr, /* delProperty */ |
8659 | | nullptr, /* enumerate */ |
8660 | | nullptr, /* newEnumerate */ |
8661 | | nullptr, /* resolve */ |
8662 | | nullptr, /* mayResolve */ |
8663 | | _finalize, /* finalize */ |
8664 | | nullptr, /* call */ |
8665 | | nullptr, /* hasInstance */ |
8666 | | nullptr, /* construct */ |
8667 | | nullptr, /* trace */ |
8668 | | }; |
8669 | | |
8670 | | static const js::ClassExtension sClassExtension = { |
8671 | | nullptr, /* weakmapKeyDelegateOp */ |
8672 | | _objectMoved /* objectMovedOp */ |
8673 | | }; |
8674 | | |
8675 | | static const DOMJSClass sClass = { |
8676 | | { "WEBGL_debug_shaders", |
8677 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
8678 | | &sClassOps, |
8679 | | JS_NULL_CLASS_SPEC, |
8680 | | &sClassExtension, |
8681 | | JS_NULL_OBJECT_OPS |
8682 | | }, |
8683 | | { prototypes::id::WEBGL_debug_shaders, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
8684 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionDebugShaders >::value, |
8685 | | sNativePropertyHooks, |
8686 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionDebugShaders>::Get, |
8687 | | GetProtoObjectHandle, |
8688 | | GetCCParticipant<mozilla::WebGLExtensionDebugShaders>::Get() |
8689 | | }; |
8690 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
8691 | | "Must have the right minimal number of reserved slots."); |
8692 | | static_assert(1 >= 1, |
8693 | | "Must have enough reserved slots."); |
8694 | | |
8695 | | const JSClass* |
8696 | | GetJSClass() |
8697 | 0 | { |
8698 | 0 | return sClass.ToJSClass(); |
8699 | 0 | } |
8700 | | |
8701 | | bool |
8702 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionDebugShaders* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
8703 | 0 | { |
8704 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionDebugShaders>::value, |
8705 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
8706 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionDebugShaders*>(aObject) == |
8707 | 0 | reinterpret_cast<mozilla::WebGLExtensionDebugShaders*>(aObject), |
8708 | 0 | "Multiple inheritance for mozilla::WebGLExtensionDebugShaders is broken."); |
8709 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
8710 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
8711 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
8712 | 0 | "You should probably not be using Wrap() directly; use " |
8713 | 0 | "GetOrCreateDOMReflector instead"); |
8714 | 0 |
|
8715 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
8716 | 0 | "nsISupports must be on our primary inheritance chain"); |
8717 | 0 |
|
8718 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
8719 | 0 | if (!global) { |
8720 | 0 | return false; |
8721 | 0 | } |
8722 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
8723 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
8724 | 0 |
|
8725 | 0 | // That might have ended up wrapping us already, due to the wonders |
8726 | 0 | // of XBL. Check for that, and bail out as needed. |
8727 | 0 | aReflector.set(aCache->GetWrapper()); |
8728 | 0 | if (aReflector) { |
8729 | | #ifdef DEBUG |
8730 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
8731 | | #endif // DEBUG |
8732 | | return true; |
8733 | 0 | } |
8734 | 0 |
|
8735 | 0 | JSAutoRealm ar(aCx, global); |
8736 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
8737 | 0 | if (!canonicalProto) { |
8738 | 0 | return false; |
8739 | 0 | } |
8740 | 0 | JS::Rooted<JSObject*> proto(aCx); |
8741 | 0 | if (aGivenProto) { |
8742 | 0 | proto = aGivenProto; |
8743 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
8744 | 0 | // coming in, we changed compartments to that of "parent" so may need |
8745 | 0 | // to wrap the proto here. |
8746 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
8747 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
8748 | 0 | return false; |
8749 | 0 | } |
8750 | 0 | } |
8751 | 0 | } else { |
8752 | 0 | proto = canonicalProto; |
8753 | 0 | } |
8754 | 0 |
|
8755 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionDebugShaders> creator(aCx); |
8756 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
8757 | 0 | if (!aReflector) { |
8758 | 0 | return false; |
8759 | 0 | } |
8760 | 0 | |
8761 | 0 | aCache->SetWrapper(aReflector); |
8762 | 0 | creator.InitializationSucceeded(); |
8763 | 0 |
|
8764 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
8765 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
8766 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
8767 | 0 | // otherwise we won't be able to properly recreate it later, since |
8768 | 0 | // we won't know what proto to use. Note that we don't check |
8769 | 0 | // aGivenProto here, since it's entirely possible (and even |
8770 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
8771 | 0 | // same as canonicalProto. |
8772 | 0 | if (proto != canonicalProto) { |
8773 | 0 | PreserveWrapper(aObject); |
8774 | 0 | } |
8775 | 0 |
|
8776 | 0 | return true; |
8777 | 0 | } |
8778 | | |
8779 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
8780 | | nullptr, |
8781 | | nullptr, |
8782 | | nullptr, |
8783 | | { sNativeProperties.Upcast(), nullptr }, |
8784 | | prototypes::id::WEBGL_debug_shaders, |
8785 | | constructors::id::_ID_Count, |
8786 | | nullptr, |
8787 | | &DefaultXrayExpandoObjectClass |
8788 | | } }; |
8789 | | |
8790 | | void |
8791 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
8792 | 0 | { |
8793 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
8794 | 0 | if (!parentProto) { |
8795 | 0 | return; |
8796 | 0 | } |
8797 | 0 | |
8798 | 0 | static bool sIdsInited = false; |
8799 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
8800 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
8801 | 0 | return; |
8802 | 0 | } |
8803 | 0 | sIdsInited = true; |
8804 | 0 | } |
8805 | 0 |
|
8806 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WEBGL_debug_shaders); |
8807 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
8808 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
8809 | 0 | &sPrototypeClass.mBase, protoCache, |
8810 | 0 | nullptr, |
8811 | 0 | nullptr, nullptr, 0, nullptr, |
8812 | 0 | interfaceCache, |
8813 | 0 | sNativeProperties.Upcast(), |
8814 | 0 | nullptr, |
8815 | 0 | nullptr, aDefineOnGlobal, |
8816 | 0 | nullptr, |
8817 | 0 | false); |
8818 | 0 | } |
8819 | | |
8820 | | } // namespace WEBGL_debug_shaders_Binding |
8821 | | |
8822 | | |
8823 | | |
8824 | | namespace WEBGL_depth_texture_Binding { |
8825 | | |
8826 | | static bool |
8827 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
8828 | 0 | { |
8829 | 0 | mozilla::WebGLExtensionDepthTexture* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionDepthTexture>(obj); |
8830 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
8831 | 0 | // obviously can't preserve if we're not initialized. |
8832 | 0 | if (self && self->GetWrapperPreserveColor()) { |
8833 | 0 | PreserveWrapper(self); |
8834 | 0 | } |
8835 | 0 | return true; |
8836 | 0 | } |
8837 | | |
8838 | | static void |
8839 | | _finalize(js::FreeOp* fop, JSObject* obj) |
8840 | 0 | { |
8841 | 0 | mozilla::WebGLExtensionDepthTexture* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionDepthTexture>(obj); |
8842 | 0 | if (self) { |
8843 | 0 | ClearWrapper(self, self, obj); |
8844 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionDepthTexture>(self); |
8845 | 0 | } |
8846 | 0 | } |
8847 | | |
8848 | | static size_t |
8849 | | _objectMoved(JSObject* obj, JSObject* old) |
8850 | 0 | { |
8851 | 0 | mozilla::WebGLExtensionDepthTexture* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionDepthTexture>(obj); |
8852 | 0 | if (self) { |
8853 | 0 | UpdateWrapper(self, self, obj, old); |
8854 | 0 | } |
8855 | 0 |
|
8856 | 0 | return 0; |
8857 | 0 | } |
8858 | | |
8859 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
8860 | | #if defined(__clang__) |
8861 | | #pragma clang diagnostic push |
8862 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
8863 | | #endif |
8864 | | static const ConstantSpec sConstants_specs[] = { |
8865 | | { "UNSIGNED_INT_24_8_WEBGL", JS::NumberValue(34042U) }, |
8866 | | { 0, JS::UndefinedValue() } |
8867 | | }; |
8868 | | #if defined(__clang__) |
8869 | | #pragma clang diagnostic pop |
8870 | | #endif |
8871 | | |
8872 | | |
8873 | | static const Prefable<const ConstantSpec> sConstants[] = { |
8874 | | { nullptr, &sConstants_specs[0] }, |
8875 | | { nullptr, nullptr } |
8876 | | }; |
8877 | | |
8878 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
8879 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
8880 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
8881 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
8882 | | |
8883 | | |
8884 | | static uint16_t sNativeProperties_sortedPropertyIndices[1]; |
8885 | | static PropertyInfo sNativeProperties_propertyInfos[1]; |
8886 | | |
8887 | | static const NativePropertiesN<1> sNativeProperties = { |
8888 | | false, 0, |
8889 | | false, 0, |
8890 | | false, 0, |
8891 | | false, 0, |
8892 | | false, 0, |
8893 | | false, 0, |
8894 | | true, 0 /* sConstants */, |
8895 | | -1, |
8896 | | 1, |
8897 | | sNativeProperties_sortedPropertyIndices, |
8898 | | { |
8899 | | { sConstants, &sNativeProperties_propertyInfos[0] } |
8900 | | } |
8901 | | }; |
8902 | | static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
8903 | | "We have a property info count that is oversized"); |
8904 | | |
8905 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
8906 | | { |
8907 | | "WEBGL_depth_texturePrototype", |
8908 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
8909 | | JS_NULL_CLASS_OPS, |
8910 | | JS_NULL_CLASS_SPEC, |
8911 | | JS_NULL_CLASS_EXT, |
8912 | | JS_NULL_OBJECT_OPS |
8913 | | }, |
8914 | | eInterfacePrototype, |
8915 | | false, |
8916 | | prototypes::id::WEBGL_depth_texture, |
8917 | | PrototypeTraits<prototypes::id::WEBGL_depth_texture>::Depth, |
8918 | | sNativePropertyHooks, |
8919 | | "[object WEBGL_depth_texturePrototype]", |
8920 | | JS::GetRealmObjectPrototype |
8921 | | }; |
8922 | | |
8923 | | static const js::ClassOps sClassOps = { |
8924 | | _addProperty, /* addProperty */ |
8925 | | nullptr, /* delProperty */ |
8926 | | nullptr, /* enumerate */ |
8927 | | nullptr, /* newEnumerate */ |
8928 | | nullptr, /* resolve */ |
8929 | | nullptr, /* mayResolve */ |
8930 | | _finalize, /* finalize */ |
8931 | | nullptr, /* call */ |
8932 | | nullptr, /* hasInstance */ |
8933 | | nullptr, /* construct */ |
8934 | | nullptr, /* trace */ |
8935 | | }; |
8936 | | |
8937 | | static const js::ClassExtension sClassExtension = { |
8938 | | nullptr, /* weakmapKeyDelegateOp */ |
8939 | | _objectMoved /* objectMovedOp */ |
8940 | | }; |
8941 | | |
8942 | | static const DOMJSClass sClass = { |
8943 | | { "WEBGL_depth_texture", |
8944 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
8945 | | &sClassOps, |
8946 | | JS_NULL_CLASS_SPEC, |
8947 | | &sClassExtension, |
8948 | | JS_NULL_OBJECT_OPS |
8949 | | }, |
8950 | | { prototypes::id::WEBGL_depth_texture, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
8951 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionDepthTexture >::value, |
8952 | | sNativePropertyHooks, |
8953 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionDepthTexture>::Get, |
8954 | | GetProtoObjectHandle, |
8955 | | GetCCParticipant<mozilla::WebGLExtensionDepthTexture>::Get() |
8956 | | }; |
8957 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
8958 | | "Must have the right minimal number of reserved slots."); |
8959 | | static_assert(1 >= 1, |
8960 | | "Must have enough reserved slots."); |
8961 | | |
8962 | | const JSClass* |
8963 | | GetJSClass() |
8964 | 0 | { |
8965 | 0 | return sClass.ToJSClass(); |
8966 | 0 | } |
8967 | | |
8968 | | bool |
8969 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionDepthTexture* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
8970 | 0 | { |
8971 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionDepthTexture>::value, |
8972 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
8973 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionDepthTexture*>(aObject) == |
8974 | 0 | reinterpret_cast<mozilla::WebGLExtensionDepthTexture*>(aObject), |
8975 | 0 | "Multiple inheritance for mozilla::WebGLExtensionDepthTexture is broken."); |
8976 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
8977 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
8978 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
8979 | 0 | "You should probably not be using Wrap() directly; use " |
8980 | 0 | "GetOrCreateDOMReflector instead"); |
8981 | 0 |
|
8982 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
8983 | 0 | "nsISupports must be on our primary inheritance chain"); |
8984 | 0 |
|
8985 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
8986 | 0 | if (!global) { |
8987 | 0 | return false; |
8988 | 0 | } |
8989 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
8990 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
8991 | 0 |
|
8992 | 0 | // That might have ended up wrapping us already, due to the wonders |
8993 | 0 | // of XBL. Check for that, and bail out as needed. |
8994 | 0 | aReflector.set(aCache->GetWrapper()); |
8995 | 0 | if (aReflector) { |
8996 | | #ifdef DEBUG |
8997 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
8998 | | #endif // DEBUG |
8999 | | return true; |
9000 | 0 | } |
9001 | 0 |
|
9002 | 0 | JSAutoRealm ar(aCx, global); |
9003 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
9004 | 0 | if (!canonicalProto) { |
9005 | 0 | return false; |
9006 | 0 | } |
9007 | 0 | JS::Rooted<JSObject*> proto(aCx); |
9008 | 0 | if (aGivenProto) { |
9009 | 0 | proto = aGivenProto; |
9010 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
9011 | 0 | // coming in, we changed compartments to that of "parent" so may need |
9012 | 0 | // to wrap the proto here. |
9013 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
9014 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
9015 | 0 | return false; |
9016 | 0 | } |
9017 | 0 | } |
9018 | 0 | } else { |
9019 | 0 | proto = canonicalProto; |
9020 | 0 | } |
9021 | 0 |
|
9022 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionDepthTexture> creator(aCx); |
9023 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
9024 | 0 | if (!aReflector) { |
9025 | 0 | return false; |
9026 | 0 | } |
9027 | 0 | |
9028 | 0 | aCache->SetWrapper(aReflector); |
9029 | 0 | creator.InitializationSucceeded(); |
9030 | 0 |
|
9031 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
9032 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
9033 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
9034 | 0 | // otherwise we won't be able to properly recreate it later, since |
9035 | 0 | // we won't know what proto to use. Note that we don't check |
9036 | 0 | // aGivenProto here, since it's entirely possible (and even |
9037 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
9038 | 0 | // same as canonicalProto. |
9039 | 0 | if (proto != canonicalProto) { |
9040 | 0 | PreserveWrapper(aObject); |
9041 | 0 | } |
9042 | 0 |
|
9043 | 0 | return true; |
9044 | 0 | } |
9045 | | |
9046 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
9047 | | nullptr, |
9048 | | nullptr, |
9049 | | nullptr, |
9050 | | { sNativeProperties.Upcast(), nullptr }, |
9051 | | prototypes::id::WEBGL_depth_texture, |
9052 | | constructors::id::_ID_Count, |
9053 | | nullptr, |
9054 | | &DefaultXrayExpandoObjectClass |
9055 | | } }; |
9056 | | |
9057 | | void |
9058 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
9059 | 0 | { |
9060 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
9061 | 0 | if (!parentProto) { |
9062 | 0 | return; |
9063 | 0 | } |
9064 | 0 | |
9065 | 0 | static bool sIdsInited = false; |
9066 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
9067 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
9068 | 0 | return; |
9069 | 0 | } |
9070 | 0 | sIdsInited = true; |
9071 | 0 | } |
9072 | 0 |
|
9073 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WEBGL_depth_texture); |
9074 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
9075 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
9076 | 0 | &sPrototypeClass.mBase, protoCache, |
9077 | 0 | nullptr, |
9078 | 0 | nullptr, nullptr, 0, nullptr, |
9079 | 0 | interfaceCache, |
9080 | 0 | sNativeProperties.Upcast(), |
9081 | 0 | nullptr, |
9082 | 0 | nullptr, aDefineOnGlobal, |
9083 | 0 | nullptr, |
9084 | 0 | false); |
9085 | 0 | } |
9086 | | |
9087 | | } // namespace WEBGL_depth_texture_Binding |
9088 | | |
9089 | | |
9090 | | |
9091 | | namespace WEBGL_draw_buffers_Binding { |
9092 | | |
9093 | | MOZ_CAN_RUN_SCRIPT static bool |
9094 | | drawBuffersWEBGL(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionDrawBuffers* self, const JSJitMethodCallArgs& args) |
9095 | 0 | { |
9096 | 0 | AUTO_PROFILER_LABEL_FAST("WEBGL_draw_buffers.drawBuffersWEBGL", DOM, cx); |
9097 | 0 |
|
9098 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
9099 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WEBGL_draw_buffers.drawBuffersWEBGL"); |
9100 | 0 | } |
9101 | 0 | binding_detail::AutoSequence<uint32_t> arg0; |
9102 | 0 | if (args[0].isObject()) { |
9103 | 0 | JS::ForOfIterator iter(cx); |
9104 | 0 | if (!iter.init(args[0], JS::ForOfIterator::AllowNonIterable)) { |
9105 | 0 | return false; |
9106 | 0 | } |
9107 | 0 | if (!iter.valueIsIterable()) { |
9108 | 0 | ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 1 of WEBGL_draw_buffers.drawBuffersWEBGL"); |
9109 | 0 | return false; |
9110 | 0 | } |
9111 | 0 | binding_detail::AutoSequence<uint32_t> &arr = arg0; |
9112 | 0 | JS::Rooted<JS::Value> temp(cx); |
9113 | 0 | while (true) { |
9114 | 0 | bool done; |
9115 | 0 | if (!iter.next(&temp, &done)) { |
9116 | 0 | return false; |
9117 | 0 | } |
9118 | 0 | if (done) { |
9119 | 0 | break; |
9120 | 0 | } |
9121 | 0 | uint32_t* slotPtr = arr.AppendElement(mozilla::fallible); |
9122 | 0 | if (!slotPtr) { |
9123 | 0 | JS_ReportOutOfMemory(cx); |
9124 | 0 | return false; |
9125 | 0 | } |
9126 | 0 | uint32_t& slot = *slotPtr; |
9127 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp, &slot)) { |
9128 | 0 | return false; |
9129 | 0 | } |
9130 | 0 | } |
9131 | 0 | } else { |
9132 | 0 | ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 1 of WEBGL_draw_buffers.drawBuffersWEBGL"); |
9133 | 0 | return false; |
9134 | 0 | } |
9135 | 0 | self->DrawBuffersWEBGL(Constify(arg0)); |
9136 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
9137 | 0 | args.rval().setUndefined(); |
9138 | 0 | return true; |
9139 | 0 | } |
9140 | | |
9141 | | static const JSJitInfo drawBuffersWEBGL_methodinfo = { |
9142 | | { (JSJitGetterOp)drawBuffersWEBGL }, |
9143 | | { prototypes::id::WEBGL_draw_buffers }, |
9144 | | { PrototypeTraits<prototypes::id::WEBGL_draw_buffers>::Depth }, |
9145 | | JSJitInfo::Method, |
9146 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
9147 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
9148 | | false, /* isInfallible. False in setters. */ |
9149 | | false, /* isMovable. Not relevant for setters. */ |
9150 | | false, /* isEliminatable. Not relevant for setters. */ |
9151 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
9152 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
9153 | | false, /* isTypedMethod. Only relevant for methods. */ |
9154 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
9155 | | }; |
9156 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
9157 | | static_assert(0 < 1, "There is no slot for us"); |
9158 | | |
9159 | | static bool |
9160 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
9161 | 0 | { |
9162 | 0 | mozilla::WebGLExtensionDrawBuffers* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionDrawBuffers>(obj); |
9163 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
9164 | 0 | // obviously can't preserve if we're not initialized. |
9165 | 0 | if (self && self->GetWrapperPreserveColor()) { |
9166 | 0 | PreserveWrapper(self); |
9167 | 0 | } |
9168 | 0 | return true; |
9169 | 0 | } |
9170 | | |
9171 | | static void |
9172 | | _finalize(js::FreeOp* fop, JSObject* obj) |
9173 | 0 | { |
9174 | 0 | mozilla::WebGLExtensionDrawBuffers* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionDrawBuffers>(obj); |
9175 | 0 | if (self) { |
9176 | 0 | ClearWrapper(self, self, obj); |
9177 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionDrawBuffers>(self); |
9178 | 0 | } |
9179 | 0 | } |
9180 | | |
9181 | | static size_t |
9182 | | _objectMoved(JSObject* obj, JSObject* old) |
9183 | 0 | { |
9184 | 0 | mozilla::WebGLExtensionDrawBuffers* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionDrawBuffers>(obj); |
9185 | 0 | if (self) { |
9186 | 0 | UpdateWrapper(self, self, obj, old); |
9187 | 0 | } |
9188 | 0 |
|
9189 | 0 | return 0; |
9190 | 0 | } |
9191 | | |
9192 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
9193 | | #if defined(__clang__) |
9194 | | #pragma clang diagnostic push |
9195 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
9196 | | #endif |
9197 | | static const JSFunctionSpec sMethods_specs[] = { |
9198 | | JS_FNSPEC("drawBuffersWEBGL", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&drawBuffersWEBGL_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
9199 | | JS_FS_END |
9200 | | }; |
9201 | | #if defined(__clang__) |
9202 | | #pragma clang diagnostic pop |
9203 | | #endif |
9204 | | |
9205 | | |
9206 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
9207 | | { nullptr, &sMethods_specs[0] }, |
9208 | | { nullptr, nullptr } |
9209 | | }; |
9210 | | |
9211 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
9212 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
9213 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
9214 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
9215 | | |
9216 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
9217 | | #if defined(__clang__) |
9218 | | #pragma clang diagnostic push |
9219 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
9220 | | #endif |
9221 | | static const ConstantSpec sConstants_specs[] = { |
9222 | | { "COLOR_ATTACHMENT0_WEBGL", JS::NumberValue(36064U) }, |
9223 | | { "COLOR_ATTACHMENT1_WEBGL", JS::NumberValue(36065U) }, |
9224 | | { "COLOR_ATTACHMENT2_WEBGL", JS::NumberValue(36066U) }, |
9225 | | { "COLOR_ATTACHMENT3_WEBGL", JS::NumberValue(36067U) }, |
9226 | | { "COLOR_ATTACHMENT4_WEBGL", JS::NumberValue(36068U) }, |
9227 | | { "COLOR_ATTACHMENT5_WEBGL", JS::NumberValue(36069U) }, |
9228 | | { "COLOR_ATTACHMENT6_WEBGL", JS::NumberValue(36070U) }, |
9229 | | { "COLOR_ATTACHMENT7_WEBGL", JS::NumberValue(36071U) }, |
9230 | | { "COLOR_ATTACHMENT8_WEBGL", JS::NumberValue(36072U) }, |
9231 | | { "COLOR_ATTACHMENT9_WEBGL", JS::NumberValue(36073U) }, |
9232 | | { "COLOR_ATTACHMENT10_WEBGL", JS::NumberValue(36074U) }, |
9233 | | { "COLOR_ATTACHMENT11_WEBGL", JS::NumberValue(36075U) }, |
9234 | | { "COLOR_ATTACHMENT12_WEBGL", JS::NumberValue(36076U) }, |
9235 | | { "COLOR_ATTACHMENT13_WEBGL", JS::NumberValue(36077U) }, |
9236 | | { "COLOR_ATTACHMENT14_WEBGL", JS::NumberValue(36078U) }, |
9237 | | { "COLOR_ATTACHMENT15_WEBGL", JS::NumberValue(36079U) }, |
9238 | | { "DRAW_BUFFER0_WEBGL", JS::NumberValue(34853U) }, |
9239 | | { "DRAW_BUFFER1_WEBGL", JS::NumberValue(34854U) }, |
9240 | | { "DRAW_BUFFER2_WEBGL", JS::NumberValue(34855U) }, |
9241 | | { "DRAW_BUFFER3_WEBGL", JS::NumberValue(34856U) }, |
9242 | | { "DRAW_BUFFER4_WEBGL", JS::NumberValue(34857U) }, |
9243 | | { "DRAW_BUFFER5_WEBGL", JS::NumberValue(34858U) }, |
9244 | | { "DRAW_BUFFER6_WEBGL", JS::NumberValue(34859U) }, |
9245 | | { "DRAW_BUFFER7_WEBGL", JS::NumberValue(34860U) }, |
9246 | | { "DRAW_BUFFER8_WEBGL", JS::NumberValue(34861U) }, |
9247 | | { "DRAW_BUFFER9_WEBGL", JS::NumberValue(34862U) }, |
9248 | | { "DRAW_BUFFER10_WEBGL", JS::NumberValue(34863U) }, |
9249 | | { "DRAW_BUFFER11_WEBGL", JS::NumberValue(34864U) }, |
9250 | | { "DRAW_BUFFER12_WEBGL", JS::NumberValue(34865U) }, |
9251 | | { "DRAW_BUFFER13_WEBGL", JS::NumberValue(34866U) }, |
9252 | | { "DRAW_BUFFER14_WEBGL", JS::NumberValue(34867U) }, |
9253 | | { "DRAW_BUFFER15_WEBGL", JS::NumberValue(34868U) }, |
9254 | | { "MAX_COLOR_ATTACHMENTS_WEBGL", JS::NumberValue(36063U) }, |
9255 | | { "MAX_DRAW_BUFFERS_WEBGL", JS::NumberValue(34852U) }, |
9256 | | { 0, JS::UndefinedValue() } |
9257 | | }; |
9258 | | #if defined(__clang__) |
9259 | | #pragma clang diagnostic pop |
9260 | | #endif |
9261 | | |
9262 | | |
9263 | | static const Prefable<const ConstantSpec> sConstants[] = { |
9264 | | { nullptr, &sConstants_specs[0] }, |
9265 | | { nullptr, nullptr } |
9266 | | }; |
9267 | | |
9268 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
9269 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
9270 | | static_assert(34 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
9271 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
9272 | | |
9273 | | |
9274 | | static uint16_t sNativeProperties_sortedPropertyIndices[35]; |
9275 | | static PropertyInfo sNativeProperties_propertyInfos[35]; |
9276 | | |
9277 | | static const NativePropertiesN<2> sNativeProperties = { |
9278 | | false, 0, |
9279 | | false, 0, |
9280 | | true, 0 /* sMethods */, |
9281 | | false, 0, |
9282 | | false, 0, |
9283 | | false, 0, |
9284 | | true, 1 /* sConstants */, |
9285 | | -1, |
9286 | | 35, |
9287 | | sNativeProperties_sortedPropertyIndices, |
9288 | | { |
9289 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
9290 | | { sConstants, &sNativeProperties_propertyInfos[1] } |
9291 | | } |
9292 | | }; |
9293 | | static_assert(35 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
9294 | | "We have a property info count that is oversized"); |
9295 | | |
9296 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
9297 | | { |
9298 | | "WEBGL_draw_buffersPrototype", |
9299 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
9300 | | JS_NULL_CLASS_OPS, |
9301 | | JS_NULL_CLASS_SPEC, |
9302 | | JS_NULL_CLASS_EXT, |
9303 | | JS_NULL_OBJECT_OPS |
9304 | | }, |
9305 | | eInterfacePrototype, |
9306 | | false, |
9307 | | prototypes::id::WEBGL_draw_buffers, |
9308 | | PrototypeTraits<prototypes::id::WEBGL_draw_buffers>::Depth, |
9309 | | sNativePropertyHooks, |
9310 | | "[object WEBGL_draw_buffersPrototype]", |
9311 | | JS::GetRealmObjectPrototype |
9312 | | }; |
9313 | | |
9314 | | static const js::ClassOps sClassOps = { |
9315 | | _addProperty, /* addProperty */ |
9316 | | nullptr, /* delProperty */ |
9317 | | nullptr, /* enumerate */ |
9318 | | nullptr, /* newEnumerate */ |
9319 | | nullptr, /* resolve */ |
9320 | | nullptr, /* mayResolve */ |
9321 | | _finalize, /* finalize */ |
9322 | | nullptr, /* call */ |
9323 | | nullptr, /* hasInstance */ |
9324 | | nullptr, /* construct */ |
9325 | | nullptr, /* trace */ |
9326 | | }; |
9327 | | |
9328 | | static const js::ClassExtension sClassExtension = { |
9329 | | nullptr, /* weakmapKeyDelegateOp */ |
9330 | | _objectMoved /* objectMovedOp */ |
9331 | | }; |
9332 | | |
9333 | | static const DOMJSClass sClass = { |
9334 | | { "WEBGL_draw_buffers", |
9335 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
9336 | | &sClassOps, |
9337 | | JS_NULL_CLASS_SPEC, |
9338 | | &sClassExtension, |
9339 | | JS_NULL_OBJECT_OPS |
9340 | | }, |
9341 | | { prototypes::id::WEBGL_draw_buffers, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
9342 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionDrawBuffers >::value, |
9343 | | sNativePropertyHooks, |
9344 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionDrawBuffers>::Get, |
9345 | | GetProtoObjectHandle, |
9346 | | GetCCParticipant<mozilla::WebGLExtensionDrawBuffers>::Get() |
9347 | | }; |
9348 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
9349 | | "Must have the right minimal number of reserved slots."); |
9350 | | static_assert(1 >= 1, |
9351 | | "Must have enough reserved slots."); |
9352 | | |
9353 | | const JSClass* |
9354 | | GetJSClass() |
9355 | 0 | { |
9356 | 0 | return sClass.ToJSClass(); |
9357 | 0 | } |
9358 | | |
9359 | | bool |
9360 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionDrawBuffers* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
9361 | 0 | { |
9362 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionDrawBuffers>::value, |
9363 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
9364 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionDrawBuffers*>(aObject) == |
9365 | 0 | reinterpret_cast<mozilla::WebGLExtensionDrawBuffers*>(aObject), |
9366 | 0 | "Multiple inheritance for mozilla::WebGLExtensionDrawBuffers is broken."); |
9367 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
9368 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
9369 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
9370 | 0 | "You should probably not be using Wrap() directly; use " |
9371 | 0 | "GetOrCreateDOMReflector instead"); |
9372 | 0 |
|
9373 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
9374 | 0 | "nsISupports must be on our primary inheritance chain"); |
9375 | 0 |
|
9376 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
9377 | 0 | if (!global) { |
9378 | 0 | return false; |
9379 | 0 | } |
9380 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
9381 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
9382 | 0 |
|
9383 | 0 | // That might have ended up wrapping us already, due to the wonders |
9384 | 0 | // of XBL. Check for that, and bail out as needed. |
9385 | 0 | aReflector.set(aCache->GetWrapper()); |
9386 | 0 | if (aReflector) { |
9387 | | #ifdef DEBUG |
9388 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
9389 | | #endif // DEBUG |
9390 | | return true; |
9391 | 0 | } |
9392 | 0 |
|
9393 | 0 | JSAutoRealm ar(aCx, global); |
9394 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
9395 | 0 | if (!canonicalProto) { |
9396 | 0 | return false; |
9397 | 0 | } |
9398 | 0 | JS::Rooted<JSObject*> proto(aCx); |
9399 | 0 | if (aGivenProto) { |
9400 | 0 | proto = aGivenProto; |
9401 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
9402 | 0 | // coming in, we changed compartments to that of "parent" so may need |
9403 | 0 | // to wrap the proto here. |
9404 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
9405 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
9406 | 0 | return false; |
9407 | 0 | } |
9408 | 0 | } |
9409 | 0 | } else { |
9410 | 0 | proto = canonicalProto; |
9411 | 0 | } |
9412 | 0 |
|
9413 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionDrawBuffers> creator(aCx); |
9414 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
9415 | 0 | if (!aReflector) { |
9416 | 0 | return false; |
9417 | 0 | } |
9418 | 0 | |
9419 | 0 | aCache->SetWrapper(aReflector); |
9420 | 0 | creator.InitializationSucceeded(); |
9421 | 0 |
|
9422 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
9423 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
9424 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
9425 | 0 | // otherwise we won't be able to properly recreate it later, since |
9426 | 0 | // we won't know what proto to use. Note that we don't check |
9427 | 0 | // aGivenProto here, since it's entirely possible (and even |
9428 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
9429 | 0 | // same as canonicalProto. |
9430 | 0 | if (proto != canonicalProto) { |
9431 | 0 | PreserveWrapper(aObject); |
9432 | 0 | } |
9433 | 0 |
|
9434 | 0 | return true; |
9435 | 0 | } |
9436 | | |
9437 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
9438 | | nullptr, |
9439 | | nullptr, |
9440 | | nullptr, |
9441 | | { sNativeProperties.Upcast(), nullptr }, |
9442 | | prototypes::id::WEBGL_draw_buffers, |
9443 | | constructors::id::_ID_Count, |
9444 | | nullptr, |
9445 | | &DefaultXrayExpandoObjectClass |
9446 | | } }; |
9447 | | |
9448 | | void |
9449 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
9450 | 0 | { |
9451 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
9452 | 0 | if (!parentProto) { |
9453 | 0 | return; |
9454 | 0 | } |
9455 | 0 | |
9456 | 0 | static bool sIdsInited = false; |
9457 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
9458 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
9459 | 0 | return; |
9460 | 0 | } |
9461 | 0 | sIdsInited = true; |
9462 | 0 | } |
9463 | 0 |
|
9464 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WEBGL_draw_buffers); |
9465 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
9466 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
9467 | 0 | &sPrototypeClass.mBase, protoCache, |
9468 | 0 | nullptr, |
9469 | 0 | nullptr, nullptr, 0, nullptr, |
9470 | 0 | interfaceCache, |
9471 | 0 | sNativeProperties.Upcast(), |
9472 | 0 | nullptr, |
9473 | 0 | nullptr, aDefineOnGlobal, |
9474 | 0 | nullptr, |
9475 | 0 | false); |
9476 | 0 | } |
9477 | | |
9478 | | } // namespace WEBGL_draw_buffers_Binding |
9479 | | |
9480 | | |
9481 | | |
9482 | | namespace WEBGL_lose_context_Binding { |
9483 | | |
9484 | | MOZ_CAN_RUN_SCRIPT static bool |
9485 | | loseContext(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionLoseContext* self, const JSJitMethodCallArgs& args) |
9486 | 0 | { |
9487 | 0 | AUTO_PROFILER_LABEL_FAST("WEBGL_lose_context.loseContext", DOM, cx); |
9488 | 0 |
|
9489 | 0 | self->LoseContext(); |
9490 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
9491 | 0 | args.rval().setUndefined(); |
9492 | 0 | return true; |
9493 | 0 | } |
9494 | | |
9495 | | static const JSJitInfo loseContext_methodinfo = { |
9496 | | { (JSJitGetterOp)loseContext }, |
9497 | | { prototypes::id::WEBGL_lose_context }, |
9498 | | { PrototypeTraits<prototypes::id::WEBGL_lose_context>::Depth }, |
9499 | | JSJitInfo::Method, |
9500 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
9501 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
9502 | | true, /* isInfallible. False in setters. */ |
9503 | | false, /* isMovable. Not relevant for setters. */ |
9504 | | false, /* isEliminatable. Not relevant for setters. */ |
9505 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
9506 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
9507 | | false, /* isTypedMethod. Only relevant for methods. */ |
9508 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
9509 | | }; |
9510 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
9511 | | static_assert(0 < 1, "There is no slot for us"); |
9512 | | |
9513 | | MOZ_CAN_RUN_SCRIPT static bool |
9514 | | restoreContext(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLExtensionLoseContext* self, const JSJitMethodCallArgs& args) |
9515 | 0 | { |
9516 | 0 | AUTO_PROFILER_LABEL_FAST("WEBGL_lose_context.restoreContext", DOM, cx); |
9517 | 0 |
|
9518 | 0 | self->RestoreContext(); |
9519 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
9520 | 0 | args.rval().setUndefined(); |
9521 | 0 | return true; |
9522 | 0 | } |
9523 | | |
9524 | | static const JSJitInfo restoreContext_methodinfo = { |
9525 | | { (JSJitGetterOp)restoreContext }, |
9526 | | { prototypes::id::WEBGL_lose_context }, |
9527 | | { PrototypeTraits<prototypes::id::WEBGL_lose_context>::Depth }, |
9528 | | JSJitInfo::Method, |
9529 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
9530 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
9531 | | true, /* isInfallible. False in setters. */ |
9532 | | false, /* isMovable. Not relevant for setters. */ |
9533 | | false, /* isEliminatable. Not relevant for setters. */ |
9534 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
9535 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
9536 | | false, /* isTypedMethod. Only relevant for methods. */ |
9537 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
9538 | | }; |
9539 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
9540 | | static_assert(0 < 1, "There is no slot for us"); |
9541 | | |
9542 | | static bool |
9543 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
9544 | 0 | { |
9545 | 0 | mozilla::WebGLExtensionLoseContext* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionLoseContext>(obj); |
9546 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
9547 | 0 | // obviously can't preserve if we're not initialized. |
9548 | 0 | if (self && self->GetWrapperPreserveColor()) { |
9549 | 0 | PreserveWrapper(self); |
9550 | 0 | } |
9551 | 0 | return true; |
9552 | 0 | } |
9553 | | |
9554 | | static void |
9555 | | _finalize(js::FreeOp* fop, JSObject* obj) |
9556 | 0 | { |
9557 | 0 | mozilla::WebGLExtensionLoseContext* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionLoseContext>(obj); |
9558 | 0 | if (self) { |
9559 | 0 | ClearWrapper(self, self, obj); |
9560 | 0 | AddForDeferredFinalization<mozilla::WebGLExtensionLoseContext>(self); |
9561 | 0 | } |
9562 | 0 | } |
9563 | | |
9564 | | static size_t |
9565 | | _objectMoved(JSObject* obj, JSObject* old) |
9566 | 0 | { |
9567 | 0 | mozilla::WebGLExtensionLoseContext* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLExtensionLoseContext>(obj); |
9568 | 0 | if (self) { |
9569 | 0 | UpdateWrapper(self, self, obj, old); |
9570 | 0 | } |
9571 | 0 |
|
9572 | 0 | return 0; |
9573 | 0 | } |
9574 | | |
9575 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
9576 | | #if defined(__clang__) |
9577 | | #pragma clang diagnostic push |
9578 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
9579 | | #endif |
9580 | | static const JSFunctionSpec sMethods_specs[] = { |
9581 | | JS_FNSPEC("loseContext", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&loseContext_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
9582 | | JS_FNSPEC("restoreContext", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&restoreContext_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
9583 | | JS_FS_END |
9584 | | }; |
9585 | | #if defined(__clang__) |
9586 | | #pragma clang diagnostic pop |
9587 | | #endif |
9588 | | |
9589 | | |
9590 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
9591 | | { nullptr, &sMethods_specs[0] }, |
9592 | | { nullptr, nullptr } |
9593 | | }; |
9594 | | |
9595 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
9596 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
9597 | | static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
9598 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
9599 | | |
9600 | | |
9601 | | static uint16_t sNativeProperties_sortedPropertyIndices[2]; |
9602 | | static PropertyInfo sNativeProperties_propertyInfos[2]; |
9603 | | |
9604 | | static const NativePropertiesN<1> sNativeProperties = { |
9605 | | false, 0, |
9606 | | false, 0, |
9607 | | true, 0 /* sMethods */, |
9608 | | false, 0, |
9609 | | false, 0, |
9610 | | false, 0, |
9611 | | false, 0, |
9612 | | -1, |
9613 | | 2, |
9614 | | sNativeProperties_sortedPropertyIndices, |
9615 | | { |
9616 | | { sMethods, &sNativeProperties_propertyInfos[0] } |
9617 | | } |
9618 | | }; |
9619 | | static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
9620 | | "We have a property info count that is oversized"); |
9621 | | |
9622 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
9623 | | { |
9624 | | "WEBGL_lose_contextPrototype", |
9625 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
9626 | | JS_NULL_CLASS_OPS, |
9627 | | JS_NULL_CLASS_SPEC, |
9628 | | JS_NULL_CLASS_EXT, |
9629 | | JS_NULL_OBJECT_OPS |
9630 | | }, |
9631 | | eInterfacePrototype, |
9632 | | false, |
9633 | | prototypes::id::WEBGL_lose_context, |
9634 | | PrototypeTraits<prototypes::id::WEBGL_lose_context>::Depth, |
9635 | | sNativePropertyHooks, |
9636 | | "[object WEBGL_lose_contextPrototype]", |
9637 | | JS::GetRealmObjectPrototype |
9638 | | }; |
9639 | | |
9640 | | static const js::ClassOps sClassOps = { |
9641 | | _addProperty, /* addProperty */ |
9642 | | nullptr, /* delProperty */ |
9643 | | nullptr, /* enumerate */ |
9644 | | nullptr, /* newEnumerate */ |
9645 | | nullptr, /* resolve */ |
9646 | | nullptr, /* mayResolve */ |
9647 | | _finalize, /* finalize */ |
9648 | | nullptr, /* call */ |
9649 | | nullptr, /* hasInstance */ |
9650 | | nullptr, /* construct */ |
9651 | | nullptr, /* trace */ |
9652 | | }; |
9653 | | |
9654 | | static const js::ClassExtension sClassExtension = { |
9655 | | nullptr, /* weakmapKeyDelegateOp */ |
9656 | | _objectMoved /* objectMovedOp */ |
9657 | | }; |
9658 | | |
9659 | | static const DOMJSClass sClass = { |
9660 | | { "WEBGL_lose_context", |
9661 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
9662 | | &sClassOps, |
9663 | | JS_NULL_CLASS_SPEC, |
9664 | | &sClassExtension, |
9665 | | JS_NULL_OBJECT_OPS |
9666 | | }, |
9667 | | { prototypes::id::WEBGL_lose_context, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
9668 | | IsBaseOf<nsISupports, mozilla::WebGLExtensionLoseContext >::value, |
9669 | | sNativePropertyHooks, |
9670 | | FindAssociatedGlobalForNative<mozilla::WebGLExtensionLoseContext>::Get, |
9671 | | GetProtoObjectHandle, |
9672 | | GetCCParticipant<mozilla::WebGLExtensionLoseContext>::Get() |
9673 | | }; |
9674 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
9675 | | "Must have the right minimal number of reserved slots."); |
9676 | | static_assert(1 >= 1, |
9677 | | "Must have enough reserved slots."); |
9678 | | |
9679 | | const JSClass* |
9680 | | GetJSClass() |
9681 | 0 | { |
9682 | 0 | return sClass.ToJSClass(); |
9683 | 0 | } |
9684 | | |
9685 | | bool |
9686 | | Wrap(JSContext* aCx, mozilla::WebGLExtensionLoseContext* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
9687 | 0 | { |
9688 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLExtensionLoseContext>::value, |
9689 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
9690 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLExtensionLoseContext*>(aObject) == |
9691 | 0 | reinterpret_cast<mozilla::WebGLExtensionLoseContext*>(aObject), |
9692 | 0 | "Multiple inheritance for mozilla::WebGLExtensionLoseContext is broken."); |
9693 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
9694 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
9695 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
9696 | 0 | "You should probably not be using Wrap() directly; use " |
9697 | 0 | "GetOrCreateDOMReflector instead"); |
9698 | 0 |
|
9699 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
9700 | 0 | "nsISupports must be on our primary inheritance chain"); |
9701 | 0 |
|
9702 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
9703 | 0 | if (!global) { |
9704 | 0 | return false; |
9705 | 0 | } |
9706 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
9707 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
9708 | 0 |
|
9709 | 0 | // That might have ended up wrapping us already, due to the wonders |
9710 | 0 | // of XBL. Check for that, and bail out as needed. |
9711 | 0 | aReflector.set(aCache->GetWrapper()); |
9712 | 0 | if (aReflector) { |
9713 | | #ifdef DEBUG |
9714 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
9715 | | #endif // DEBUG |
9716 | | return true; |
9717 | 0 | } |
9718 | 0 |
|
9719 | 0 | JSAutoRealm ar(aCx, global); |
9720 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
9721 | 0 | if (!canonicalProto) { |
9722 | 0 | return false; |
9723 | 0 | } |
9724 | 0 | JS::Rooted<JSObject*> proto(aCx); |
9725 | 0 | if (aGivenProto) { |
9726 | 0 | proto = aGivenProto; |
9727 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
9728 | 0 | // coming in, we changed compartments to that of "parent" so may need |
9729 | 0 | // to wrap the proto here. |
9730 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
9731 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
9732 | 0 | return false; |
9733 | 0 | } |
9734 | 0 | } |
9735 | 0 | } else { |
9736 | 0 | proto = canonicalProto; |
9737 | 0 | } |
9738 | 0 |
|
9739 | 0 | BindingJSObjectCreator<mozilla::WebGLExtensionLoseContext> creator(aCx); |
9740 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
9741 | 0 | if (!aReflector) { |
9742 | 0 | return false; |
9743 | 0 | } |
9744 | 0 | |
9745 | 0 | aCache->SetWrapper(aReflector); |
9746 | 0 | creator.InitializationSucceeded(); |
9747 | 0 |
|
9748 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
9749 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
9750 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
9751 | 0 | // otherwise we won't be able to properly recreate it later, since |
9752 | 0 | // we won't know what proto to use. Note that we don't check |
9753 | 0 | // aGivenProto here, since it's entirely possible (and even |
9754 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
9755 | 0 | // same as canonicalProto. |
9756 | 0 | if (proto != canonicalProto) { |
9757 | 0 | PreserveWrapper(aObject); |
9758 | 0 | } |
9759 | 0 |
|
9760 | 0 | return true; |
9761 | 0 | } |
9762 | | |
9763 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
9764 | | nullptr, |
9765 | | nullptr, |
9766 | | nullptr, |
9767 | | { sNativeProperties.Upcast(), nullptr }, |
9768 | | prototypes::id::WEBGL_lose_context, |
9769 | | constructors::id::_ID_Count, |
9770 | | nullptr, |
9771 | | &DefaultXrayExpandoObjectClass |
9772 | | } }; |
9773 | | |
9774 | | void |
9775 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
9776 | 0 | { |
9777 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
9778 | 0 | if (!parentProto) { |
9779 | 0 | return; |
9780 | 0 | } |
9781 | 0 | |
9782 | 0 | static bool sIdsInited = false; |
9783 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
9784 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
9785 | 0 | return; |
9786 | 0 | } |
9787 | 0 | sIdsInited = true; |
9788 | 0 | } |
9789 | 0 |
|
9790 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WEBGL_lose_context); |
9791 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
9792 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
9793 | 0 | &sPrototypeClass.mBase, protoCache, |
9794 | 0 | nullptr, |
9795 | 0 | nullptr, nullptr, 0, nullptr, |
9796 | 0 | interfaceCache, |
9797 | 0 | sNativeProperties.Upcast(), |
9798 | 0 | nullptr, |
9799 | 0 | nullptr, aDefineOnGlobal, |
9800 | 0 | nullptr, |
9801 | 0 | false); |
9802 | 0 | } |
9803 | | |
9804 | | } // namespace WEBGL_lose_context_Binding |
9805 | | |
9806 | | |
9807 | | |
9808 | | namespace WebGLActiveInfo_Binding { |
9809 | | |
9810 | | MOZ_CAN_RUN_SCRIPT static bool |
9811 | | get_size(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLActiveInfo* self, JSJitGetterCallArgs args) |
9812 | 0 | { |
9813 | 0 | AUTO_PROFILER_LABEL_FAST("get WebGLActiveInfo.size", DOM, cx); |
9814 | 0 |
|
9815 | 0 | int32_t result(self->Size()); |
9816 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
9817 | 0 | args.rval().setInt32(int32_t(result)); |
9818 | 0 | return true; |
9819 | 0 | } |
9820 | | |
9821 | | static const JSJitInfo size_getterinfo = { |
9822 | | { (JSJitGetterOp)get_size }, |
9823 | | { prototypes::id::WebGLActiveInfo }, |
9824 | | { PrototypeTraits<prototypes::id::WebGLActiveInfo>::Depth }, |
9825 | | JSJitInfo::Getter, |
9826 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
9827 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
9828 | | true, /* isInfallible. False in setters. */ |
9829 | | false, /* isMovable. Not relevant for setters. */ |
9830 | | false, /* isEliminatable. Not relevant for setters. */ |
9831 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
9832 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
9833 | | false, /* isTypedMethod. Only relevant for methods. */ |
9834 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
9835 | | }; |
9836 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
9837 | | static_assert(0 < 1, "There is no slot for us"); |
9838 | | |
9839 | | MOZ_CAN_RUN_SCRIPT static bool |
9840 | | get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLActiveInfo* self, JSJitGetterCallArgs args) |
9841 | 0 | { |
9842 | 0 | AUTO_PROFILER_LABEL_FAST("get WebGLActiveInfo.type", DOM, cx); |
9843 | 0 |
|
9844 | 0 | uint32_t result(self->Type()); |
9845 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
9846 | 0 | args.rval().setNumber(result); |
9847 | 0 | return true; |
9848 | 0 | } |
9849 | | |
9850 | | static const JSJitInfo type_getterinfo = { |
9851 | | { (JSJitGetterOp)get_type }, |
9852 | | { prototypes::id::WebGLActiveInfo }, |
9853 | | { PrototypeTraits<prototypes::id::WebGLActiveInfo>::Depth }, |
9854 | | JSJitInfo::Getter, |
9855 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
9856 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
9857 | | true, /* isInfallible. False in setters. */ |
9858 | | false, /* isMovable. Not relevant for setters. */ |
9859 | | false, /* isEliminatable. Not relevant for setters. */ |
9860 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
9861 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
9862 | | false, /* isTypedMethod. Only relevant for methods. */ |
9863 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
9864 | | }; |
9865 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
9866 | | static_assert(0 < 1, "There is no slot for us"); |
9867 | | |
9868 | | MOZ_CAN_RUN_SCRIPT static bool |
9869 | | get_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLActiveInfo* self, JSJitGetterCallArgs args) |
9870 | 0 | { |
9871 | 0 | AUTO_PROFILER_LABEL_FAST("get WebGLActiveInfo.name", DOM, cx); |
9872 | 0 |
|
9873 | 0 | DOMString result; |
9874 | 0 | self->GetName(result); |
9875 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
9876 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
9877 | 0 | return false; |
9878 | 0 | } |
9879 | 0 | return true; |
9880 | 0 | } |
9881 | | |
9882 | | static const JSJitInfo name_getterinfo = { |
9883 | | { (JSJitGetterOp)get_name }, |
9884 | | { prototypes::id::WebGLActiveInfo }, |
9885 | | { PrototypeTraits<prototypes::id::WebGLActiveInfo>::Depth }, |
9886 | | JSJitInfo::Getter, |
9887 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
9888 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
9889 | | false, /* isInfallible. False in setters. */ |
9890 | | false, /* isMovable. Not relevant for setters. */ |
9891 | | false, /* isEliminatable. Not relevant for setters. */ |
9892 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
9893 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
9894 | | false, /* isTypedMethod. Only relevant for methods. */ |
9895 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
9896 | | }; |
9897 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
9898 | | static_assert(0 < 1, "There is no slot for us"); |
9899 | | |
9900 | | static bool |
9901 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
9902 | 0 | { |
9903 | 0 | mozilla::WebGLActiveInfo* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLActiveInfo>(obj); |
9904 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
9905 | 0 | // obviously can't preserve if we're not initialized. |
9906 | 0 | if (self && self->GetWrapperPreserveColor()) { |
9907 | 0 | PreserveWrapper(self); |
9908 | 0 | } |
9909 | 0 | return true; |
9910 | 0 | } |
9911 | | |
9912 | | static void |
9913 | | _finalize(js::FreeOp* fop, JSObject* obj) |
9914 | 0 | { |
9915 | 0 | mozilla::WebGLActiveInfo* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLActiveInfo>(obj); |
9916 | 0 | if (self) { |
9917 | 0 | ClearWrapper(self, self, obj); |
9918 | 0 | AddForDeferredFinalization<mozilla::WebGLActiveInfo>(self); |
9919 | 0 | } |
9920 | 0 | } |
9921 | | |
9922 | | static size_t |
9923 | | _objectMoved(JSObject* obj, JSObject* old) |
9924 | 0 | { |
9925 | 0 | mozilla::WebGLActiveInfo* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLActiveInfo>(obj); |
9926 | 0 | if (self) { |
9927 | 0 | UpdateWrapper(self, self, obj, old); |
9928 | 0 | } |
9929 | 0 |
|
9930 | 0 | return 0; |
9931 | 0 | } |
9932 | | |
9933 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
9934 | | #if defined(__clang__) |
9935 | | #pragma clang diagnostic push |
9936 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
9937 | | #endif |
9938 | | static const JSPropertySpec sAttributes_specs[] = { |
9939 | | { "size", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &size_getterinfo, nullptr, nullptr }, |
9940 | | { "type", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &type_getterinfo, nullptr, nullptr }, |
9941 | | { "name", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &name_getterinfo, nullptr, nullptr }, |
9942 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
9943 | | }; |
9944 | | #if defined(__clang__) |
9945 | | #pragma clang diagnostic pop |
9946 | | #endif |
9947 | | |
9948 | | |
9949 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
9950 | | { nullptr, &sAttributes_specs[0] }, |
9951 | | { nullptr, nullptr } |
9952 | | }; |
9953 | | |
9954 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
9955 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
9956 | | static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
9957 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
9958 | | |
9959 | | |
9960 | | static uint16_t sNativeProperties_sortedPropertyIndices[3]; |
9961 | | static PropertyInfo sNativeProperties_propertyInfos[3]; |
9962 | | |
9963 | | static const NativePropertiesN<1> sNativeProperties = { |
9964 | | false, 0, |
9965 | | false, 0, |
9966 | | false, 0, |
9967 | | true, 0 /* sAttributes */, |
9968 | | false, 0, |
9969 | | false, 0, |
9970 | | false, 0, |
9971 | | -1, |
9972 | | 3, |
9973 | | sNativeProperties_sortedPropertyIndices, |
9974 | | { |
9975 | | { sAttributes, &sNativeProperties_propertyInfos[0] } |
9976 | | } |
9977 | | }; |
9978 | | static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
9979 | | "We have a property info count that is oversized"); |
9980 | | |
9981 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
9982 | | { |
9983 | | "Function", |
9984 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
9985 | | &sBoringInterfaceObjectClassClassOps, |
9986 | | JS_NULL_CLASS_SPEC, |
9987 | | JS_NULL_CLASS_EXT, |
9988 | | &sInterfaceObjectClassObjectOps |
9989 | | }, |
9990 | | eInterface, |
9991 | | true, |
9992 | | prototypes::id::WebGLActiveInfo, |
9993 | | PrototypeTraits<prototypes::id::WebGLActiveInfo>::Depth, |
9994 | | sNativePropertyHooks, |
9995 | | "function WebGLActiveInfo() {\n [native code]\n}", |
9996 | | JS::GetRealmFunctionPrototype |
9997 | | }; |
9998 | | |
9999 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
10000 | | { |
10001 | | "WebGLActiveInfoPrototype", |
10002 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
10003 | | JS_NULL_CLASS_OPS, |
10004 | | JS_NULL_CLASS_SPEC, |
10005 | | JS_NULL_CLASS_EXT, |
10006 | | JS_NULL_OBJECT_OPS |
10007 | | }, |
10008 | | eInterfacePrototype, |
10009 | | false, |
10010 | | prototypes::id::WebGLActiveInfo, |
10011 | | PrototypeTraits<prototypes::id::WebGLActiveInfo>::Depth, |
10012 | | sNativePropertyHooks, |
10013 | | "[object WebGLActiveInfoPrototype]", |
10014 | | JS::GetRealmObjectPrototype |
10015 | | }; |
10016 | | |
10017 | | bool |
10018 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
10019 | 0 | { |
10020 | 0 | return mozilla::dom::OffscreenCanvas::PrefEnabledOnWorkerThread(aCx, aObj); |
10021 | 0 | } |
10022 | | |
10023 | | static const js::ClassOps sClassOps = { |
10024 | | _addProperty, /* addProperty */ |
10025 | | nullptr, /* delProperty */ |
10026 | | nullptr, /* enumerate */ |
10027 | | nullptr, /* newEnumerate */ |
10028 | | nullptr, /* resolve */ |
10029 | | nullptr, /* mayResolve */ |
10030 | | _finalize, /* finalize */ |
10031 | | nullptr, /* call */ |
10032 | | nullptr, /* hasInstance */ |
10033 | | nullptr, /* construct */ |
10034 | | nullptr, /* trace */ |
10035 | | }; |
10036 | | |
10037 | | static const js::ClassExtension sClassExtension = { |
10038 | | nullptr, /* weakmapKeyDelegateOp */ |
10039 | | _objectMoved /* objectMovedOp */ |
10040 | | }; |
10041 | | |
10042 | | static const DOMJSClass sClass = { |
10043 | | { "WebGLActiveInfo", |
10044 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
10045 | | &sClassOps, |
10046 | | JS_NULL_CLASS_SPEC, |
10047 | | &sClassExtension, |
10048 | | JS_NULL_OBJECT_OPS |
10049 | | }, |
10050 | | { prototypes::id::WebGLActiveInfo, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
10051 | | IsBaseOf<nsISupports, mozilla::WebGLActiveInfo >::value, |
10052 | | sNativePropertyHooks, |
10053 | | FindAssociatedGlobalForNative<mozilla::WebGLActiveInfo>::Get, |
10054 | | GetProtoObjectHandle, |
10055 | | GetCCParticipant<mozilla::WebGLActiveInfo>::Get() |
10056 | | }; |
10057 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
10058 | | "Must have the right minimal number of reserved slots."); |
10059 | | static_assert(1 >= 1, |
10060 | | "Must have enough reserved slots."); |
10061 | | |
10062 | | const JSClass* |
10063 | | GetJSClass() |
10064 | 0 | { |
10065 | 0 | return sClass.ToJSClass(); |
10066 | 0 | } |
10067 | | |
10068 | | bool |
10069 | | Wrap(JSContext* aCx, mozilla::WebGLActiveInfo* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
10070 | 0 | { |
10071 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLActiveInfo>::value, |
10072 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
10073 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLActiveInfo*>(aObject) == |
10074 | 0 | reinterpret_cast<mozilla::WebGLActiveInfo*>(aObject), |
10075 | 0 | "Multiple inheritance for mozilla::WebGLActiveInfo is broken."); |
10076 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
10077 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
10078 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
10079 | 0 | "You should probably not be using Wrap() directly; use " |
10080 | 0 | "GetOrCreateDOMReflector instead"); |
10081 | 0 |
|
10082 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
10083 | 0 | "nsISupports must be on our primary inheritance chain"); |
10084 | 0 |
|
10085 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
10086 | 0 | if (!global) { |
10087 | 0 | return false; |
10088 | 0 | } |
10089 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
10090 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
10091 | 0 |
|
10092 | 0 | // That might have ended up wrapping us already, due to the wonders |
10093 | 0 | // of XBL. Check for that, and bail out as needed. |
10094 | 0 | aReflector.set(aCache->GetWrapper()); |
10095 | 0 | if (aReflector) { |
10096 | | #ifdef DEBUG |
10097 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
10098 | | #endif // DEBUG |
10099 | | return true; |
10100 | 0 | } |
10101 | 0 |
|
10102 | 0 | JSAutoRealm ar(aCx, global); |
10103 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
10104 | 0 | if (!canonicalProto) { |
10105 | 0 | return false; |
10106 | 0 | } |
10107 | 0 | JS::Rooted<JSObject*> proto(aCx); |
10108 | 0 | if (aGivenProto) { |
10109 | 0 | proto = aGivenProto; |
10110 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
10111 | 0 | // coming in, we changed compartments to that of "parent" so may need |
10112 | 0 | // to wrap the proto here. |
10113 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
10114 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
10115 | 0 | return false; |
10116 | 0 | } |
10117 | 0 | } |
10118 | 0 | } else { |
10119 | 0 | proto = canonicalProto; |
10120 | 0 | } |
10121 | 0 |
|
10122 | 0 | BindingJSObjectCreator<mozilla::WebGLActiveInfo> creator(aCx); |
10123 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
10124 | 0 | if (!aReflector) { |
10125 | 0 | return false; |
10126 | 0 | } |
10127 | 0 | |
10128 | 0 | aCache->SetWrapper(aReflector); |
10129 | 0 | creator.InitializationSucceeded(); |
10130 | 0 |
|
10131 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
10132 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
10133 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
10134 | 0 | // otherwise we won't be able to properly recreate it later, since |
10135 | 0 | // we won't know what proto to use. Note that we don't check |
10136 | 0 | // aGivenProto here, since it's entirely possible (and even |
10137 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
10138 | 0 | // same as canonicalProto. |
10139 | 0 | if (proto != canonicalProto) { |
10140 | 0 | PreserveWrapper(aObject); |
10141 | 0 | } |
10142 | 0 |
|
10143 | 0 | return true; |
10144 | 0 | } |
10145 | | |
10146 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
10147 | | nullptr, |
10148 | | nullptr, |
10149 | | nullptr, |
10150 | | { sNativeProperties.Upcast(), nullptr }, |
10151 | | prototypes::id::WebGLActiveInfo, |
10152 | | constructors::id::WebGLActiveInfo, |
10153 | | nullptr, |
10154 | | &DefaultXrayExpandoObjectClass |
10155 | | } }; |
10156 | | |
10157 | | void |
10158 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
10159 | 0 | { |
10160 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
10161 | 0 | if (!parentProto) { |
10162 | 0 | return; |
10163 | 0 | } |
10164 | 0 | |
10165 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
10166 | 0 | if (!constructorProto) { |
10167 | 0 | return; |
10168 | 0 | } |
10169 | 0 | |
10170 | 0 | static bool sIdsInited = false; |
10171 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
10172 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
10173 | 0 | return; |
10174 | 0 | } |
10175 | 0 | sIdsInited = true; |
10176 | 0 | } |
10177 | 0 |
|
10178 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WebGLActiveInfo); |
10179 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WebGLActiveInfo); |
10180 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
10181 | 0 | &sPrototypeClass.mBase, protoCache, |
10182 | 0 | nullptr, |
10183 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
10184 | 0 | interfaceCache, |
10185 | 0 | sNativeProperties.Upcast(), |
10186 | 0 | nullptr, |
10187 | 0 | "WebGLActiveInfo", aDefineOnGlobal, |
10188 | 0 | nullptr, |
10189 | 0 | false); |
10190 | 0 | } |
10191 | | |
10192 | | JSObject* |
10193 | | GetConstructorObject(JSContext* aCx) |
10194 | 0 | { |
10195 | 0 | return GetConstructorObjectHandle(aCx); |
10196 | 0 | } |
10197 | | |
10198 | | } // namespace WebGLActiveInfo_Binding |
10199 | | |
10200 | | |
10201 | | |
10202 | | namespace WebGLBuffer_Binding { |
10203 | | |
10204 | | static bool |
10205 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
10206 | 0 | { |
10207 | 0 | mozilla::WebGLBuffer* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLBuffer>(obj); |
10208 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
10209 | 0 | // obviously can't preserve if we're not initialized. |
10210 | 0 | if (self && self->GetWrapperPreserveColor()) { |
10211 | 0 | PreserveWrapper(self); |
10212 | 0 | } |
10213 | 0 | return true; |
10214 | 0 | } |
10215 | | |
10216 | | static void |
10217 | | _finalize(js::FreeOp* fop, JSObject* obj) |
10218 | 0 | { |
10219 | 0 | mozilla::WebGLBuffer* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLBuffer>(obj); |
10220 | 0 | if (self) { |
10221 | 0 | ClearWrapper(self, self, obj); |
10222 | 0 | AddForDeferredFinalization<mozilla::WebGLBuffer>(self); |
10223 | 0 | } |
10224 | 0 | } |
10225 | | |
10226 | | static size_t |
10227 | | _objectMoved(JSObject* obj, JSObject* old) |
10228 | 0 | { |
10229 | 0 | mozilla::WebGLBuffer* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLBuffer>(obj); |
10230 | 0 | if (self) { |
10231 | 0 | UpdateWrapper(self, self, obj, old); |
10232 | 0 | } |
10233 | 0 |
|
10234 | 0 | return 0; |
10235 | 0 | } |
10236 | | |
10237 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
10238 | | { |
10239 | | "Function", |
10240 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
10241 | | &sBoringInterfaceObjectClassClassOps, |
10242 | | JS_NULL_CLASS_SPEC, |
10243 | | JS_NULL_CLASS_EXT, |
10244 | | &sInterfaceObjectClassObjectOps |
10245 | | }, |
10246 | | eInterface, |
10247 | | true, |
10248 | | prototypes::id::WebGLBuffer, |
10249 | | PrototypeTraits<prototypes::id::WebGLBuffer>::Depth, |
10250 | | sNativePropertyHooks, |
10251 | | "function WebGLBuffer() {\n [native code]\n}", |
10252 | | JS::GetRealmFunctionPrototype |
10253 | | }; |
10254 | | |
10255 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
10256 | | { |
10257 | | "WebGLBufferPrototype", |
10258 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
10259 | | JS_NULL_CLASS_OPS, |
10260 | | JS_NULL_CLASS_SPEC, |
10261 | | JS_NULL_CLASS_EXT, |
10262 | | JS_NULL_OBJECT_OPS |
10263 | | }, |
10264 | | eInterfacePrototype, |
10265 | | false, |
10266 | | prototypes::id::WebGLBuffer, |
10267 | | PrototypeTraits<prototypes::id::WebGLBuffer>::Depth, |
10268 | | sNativePropertyHooks, |
10269 | | "[object WebGLBufferPrototype]", |
10270 | | JS::GetRealmObjectPrototype |
10271 | | }; |
10272 | | |
10273 | | bool |
10274 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
10275 | 0 | { |
10276 | 0 | return mozilla::dom::OffscreenCanvas::PrefEnabledOnWorkerThread(aCx, aObj); |
10277 | 0 | } |
10278 | | |
10279 | | static const js::ClassOps sClassOps = { |
10280 | | _addProperty, /* addProperty */ |
10281 | | nullptr, /* delProperty */ |
10282 | | nullptr, /* enumerate */ |
10283 | | nullptr, /* newEnumerate */ |
10284 | | nullptr, /* resolve */ |
10285 | | nullptr, /* mayResolve */ |
10286 | | _finalize, /* finalize */ |
10287 | | nullptr, /* call */ |
10288 | | nullptr, /* hasInstance */ |
10289 | | nullptr, /* construct */ |
10290 | | nullptr, /* trace */ |
10291 | | }; |
10292 | | |
10293 | | static const js::ClassExtension sClassExtension = { |
10294 | | nullptr, /* weakmapKeyDelegateOp */ |
10295 | | _objectMoved /* objectMovedOp */ |
10296 | | }; |
10297 | | |
10298 | | static const DOMJSClass sClass = { |
10299 | | { "WebGLBuffer", |
10300 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
10301 | | &sClassOps, |
10302 | | JS_NULL_CLASS_SPEC, |
10303 | | &sClassExtension, |
10304 | | JS_NULL_OBJECT_OPS |
10305 | | }, |
10306 | | { prototypes::id::WebGLBuffer, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
10307 | | IsBaseOf<nsISupports, mozilla::WebGLBuffer >::value, |
10308 | | sNativePropertyHooks, |
10309 | | FindAssociatedGlobalForNative<mozilla::WebGLBuffer>::Get, |
10310 | | GetProtoObjectHandle, |
10311 | | GetCCParticipant<mozilla::WebGLBuffer>::Get() |
10312 | | }; |
10313 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
10314 | | "Must have the right minimal number of reserved slots."); |
10315 | | static_assert(1 >= 1, |
10316 | | "Must have enough reserved slots."); |
10317 | | |
10318 | | const JSClass* |
10319 | | GetJSClass() |
10320 | 0 | { |
10321 | 0 | return sClass.ToJSClass(); |
10322 | 0 | } |
10323 | | |
10324 | | bool |
10325 | | Wrap(JSContext* aCx, mozilla::WebGLBuffer* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
10326 | 0 | { |
10327 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLBuffer>::value, |
10328 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
10329 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLBuffer*>(aObject) == |
10330 | 0 | reinterpret_cast<mozilla::WebGLBuffer*>(aObject), |
10331 | 0 | "Multiple inheritance for mozilla::WebGLBuffer is broken."); |
10332 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
10333 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
10334 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
10335 | 0 | "You should probably not be using Wrap() directly; use " |
10336 | 0 | "GetOrCreateDOMReflector instead"); |
10337 | 0 |
|
10338 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
10339 | 0 | "nsISupports must be on our primary inheritance chain"); |
10340 | 0 |
|
10341 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
10342 | 0 | if (!global) { |
10343 | 0 | return false; |
10344 | 0 | } |
10345 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
10346 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
10347 | 0 |
|
10348 | 0 | // That might have ended up wrapping us already, due to the wonders |
10349 | 0 | // of XBL. Check for that, and bail out as needed. |
10350 | 0 | aReflector.set(aCache->GetWrapper()); |
10351 | 0 | if (aReflector) { |
10352 | | #ifdef DEBUG |
10353 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
10354 | | #endif // DEBUG |
10355 | | return true; |
10356 | 0 | } |
10357 | 0 |
|
10358 | 0 | JSAutoRealm ar(aCx, global); |
10359 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
10360 | 0 | if (!canonicalProto) { |
10361 | 0 | return false; |
10362 | 0 | } |
10363 | 0 | JS::Rooted<JSObject*> proto(aCx); |
10364 | 0 | if (aGivenProto) { |
10365 | 0 | proto = aGivenProto; |
10366 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
10367 | 0 | // coming in, we changed compartments to that of "parent" so may need |
10368 | 0 | // to wrap the proto here. |
10369 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
10370 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
10371 | 0 | return false; |
10372 | 0 | } |
10373 | 0 | } |
10374 | 0 | } else { |
10375 | 0 | proto = canonicalProto; |
10376 | 0 | } |
10377 | 0 |
|
10378 | 0 | BindingJSObjectCreator<mozilla::WebGLBuffer> creator(aCx); |
10379 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
10380 | 0 | if (!aReflector) { |
10381 | 0 | return false; |
10382 | 0 | } |
10383 | 0 | |
10384 | 0 | aCache->SetWrapper(aReflector); |
10385 | 0 | creator.InitializationSucceeded(); |
10386 | 0 |
|
10387 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
10388 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
10389 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
10390 | 0 | // otherwise we won't be able to properly recreate it later, since |
10391 | 0 | // we won't know what proto to use. Note that we don't check |
10392 | 0 | // aGivenProto here, since it's entirely possible (and even |
10393 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
10394 | 0 | // same as canonicalProto. |
10395 | 0 | if (proto != canonicalProto) { |
10396 | 0 | PreserveWrapper(aObject); |
10397 | 0 | } |
10398 | 0 |
|
10399 | 0 | return true; |
10400 | 0 | } |
10401 | | |
10402 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
10403 | | nullptr, |
10404 | | nullptr, |
10405 | | nullptr, |
10406 | | { nullptr, nullptr }, |
10407 | | prototypes::id::WebGLBuffer, |
10408 | | constructors::id::WebGLBuffer, |
10409 | | nullptr, |
10410 | | &DefaultXrayExpandoObjectClass |
10411 | | } }; |
10412 | | |
10413 | | void |
10414 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
10415 | 0 | { |
10416 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
10417 | 0 | if (!parentProto) { |
10418 | 0 | return; |
10419 | 0 | } |
10420 | 0 | |
10421 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
10422 | 0 | if (!constructorProto) { |
10423 | 0 | return; |
10424 | 0 | } |
10425 | 0 | |
10426 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WebGLBuffer); |
10427 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WebGLBuffer); |
10428 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
10429 | 0 | &sPrototypeClass.mBase, protoCache, |
10430 | 0 | nullptr, |
10431 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
10432 | 0 | interfaceCache, |
10433 | 0 | nullptr, |
10434 | 0 | nullptr, |
10435 | 0 | "WebGLBuffer", aDefineOnGlobal, |
10436 | 0 | nullptr, |
10437 | 0 | false); |
10438 | 0 | } |
10439 | | |
10440 | | JSObject* |
10441 | | GetConstructorObject(JSContext* aCx) |
10442 | 0 | { |
10443 | 0 | return GetConstructorObjectHandle(aCx); |
10444 | 0 | } |
10445 | | |
10446 | | } // namespace WebGLBuffer_Binding |
10447 | | |
10448 | | |
10449 | | |
10450 | | namespace WebGLFramebuffer_Binding { |
10451 | | |
10452 | | static bool |
10453 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
10454 | 0 | { |
10455 | 0 | mozilla::WebGLFramebuffer* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLFramebuffer>(obj); |
10456 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
10457 | 0 | // obviously can't preserve if we're not initialized. |
10458 | 0 | if (self && self->GetWrapperPreserveColor()) { |
10459 | 0 | PreserveWrapper(self); |
10460 | 0 | } |
10461 | 0 | return true; |
10462 | 0 | } |
10463 | | |
10464 | | static void |
10465 | | _finalize(js::FreeOp* fop, JSObject* obj) |
10466 | 0 | { |
10467 | 0 | mozilla::WebGLFramebuffer* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLFramebuffer>(obj); |
10468 | 0 | if (self) { |
10469 | 0 | ClearWrapper(self, self, obj); |
10470 | 0 | AddForDeferredFinalization<mozilla::WebGLFramebuffer>(self); |
10471 | 0 | } |
10472 | 0 | } |
10473 | | |
10474 | | static size_t |
10475 | | _objectMoved(JSObject* obj, JSObject* old) |
10476 | 0 | { |
10477 | 0 | mozilla::WebGLFramebuffer* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLFramebuffer>(obj); |
10478 | 0 | if (self) { |
10479 | 0 | UpdateWrapper(self, self, obj, old); |
10480 | 0 | } |
10481 | 0 |
|
10482 | 0 | return 0; |
10483 | 0 | } |
10484 | | |
10485 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
10486 | | { |
10487 | | "Function", |
10488 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
10489 | | &sBoringInterfaceObjectClassClassOps, |
10490 | | JS_NULL_CLASS_SPEC, |
10491 | | JS_NULL_CLASS_EXT, |
10492 | | &sInterfaceObjectClassObjectOps |
10493 | | }, |
10494 | | eInterface, |
10495 | | true, |
10496 | | prototypes::id::WebGLFramebuffer, |
10497 | | PrototypeTraits<prototypes::id::WebGLFramebuffer>::Depth, |
10498 | | sNativePropertyHooks, |
10499 | | "function WebGLFramebuffer() {\n [native code]\n}", |
10500 | | JS::GetRealmFunctionPrototype |
10501 | | }; |
10502 | | |
10503 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
10504 | | { |
10505 | | "WebGLFramebufferPrototype", |
10506 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
10507 | | JS_NULL_CLASS_OPS, |
10508 | | JS_NULL_CLASS_SPEC, |
10509 | | JS_NULL_CLASS_EXT, |
10510 | | JS_NULL_OBJECT_OPS |
10511 | | }, |
10512 | | eInterfacePrototype, |
10513 | | false, |
10514 | | prototypes::id::WebGLFramebuffer, |
10515 | | PrototypeTraits<prototypes::id::WebGLFramebuffer>::Depth, |
10516 | | sNativePropertyHooks, |
10517 | | "[object WebGLFramebufferPrototype]", |
10518 | | JS::GetRealmObjectPrototype |
10519 | | }; |
10520 | | |
10521 | | bool |
10522 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
10523 | 0 | { |
10524 | 0 | return mozilla::dom::OffscreenCanvas::PrefEnabledOnWorkerThread(aCx, aObj); |
10525 | 0 | } |
10526 | | |
10527 | | static const js::ClassOps sClassOps = { |
10528 | | _addProperty, /* addProperty */ |
10529 | | nullptr, /* delProperty */ |
10530 | | nullptr, /* enumerate */ |
10531 | | nullptr, /* newEnumerate */ |
10532 | | nullptr, /* resolve */ |
10533 | | nullptr, /* mayResolve */ |
10534 | | _finalize, /* finalize */ |
10535 | | nullptr, /* call */ |
10536 | | nullptr, /* hasInstance */ |
10537 | | nullptr, /* construct */ |
10538 | | nullptr, /* trace */ |
10539 | | }; |
10540 | | |
10541 | | static const js::ClassExtension sClassExtension = { |
10542 | | nullptr, /* weakmapKeyDelegateOp */ |
10543 | | _objectMoved /* objectMovedOp */ |
10544 | | }; |
10545 | | |
10546 | | static const DOMJSClass sClass = { |
10547 | | { "WebGLFramebuffer", |
10548 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
10549 | | &sClassOps, |
10550 | | JS_NULL_CLASS_SPEC, |
10551 | | &sClassExtension, |
10552 | | JS_NULL_OBJECT_OPS |
10553 | | }, |
10554 | | { prototypes::id::WebGLFramebuffer, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
10555 | | IsBaseOf<nsISupports, mozilla::WebGLFramebuffer >::value, |
10556 | | sNativePropertyHooks, |
10557 | | FindAssociatedGlobalForNative<mozilla::WebGLFramebuffer>::Get, |
10558 | | GetProtoObjectHandle, |
10559 | | GetCCParticipant<mozilla::WebGLFramebuffer>::Get() |
10560 | | }; |
10561 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
10562 | | "Must have the right minimal number of reserved slots."); |
10563 | | static_assert(1 >= 1, |
10564 | | "Must have enough reserved slots."); |
10565 | | |
10566 | | const JSClass* |
10567 | | GetJSClass() |
10568 | 0 | { |
10569 | 0 | return sClass.ToJSClass(); |
10570 | 0 | } |
10571 | | |
10572 | | bool |
10573 | | Wrap(JSContext* aCx, mozilla::WebGLFramebuffer* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
10574 | 0 | { |
10575 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLFramebuffer>::value, |
10576 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
10577 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLFramebuffer*>(aObject) == |
10578 | 0 | reinterpret_cast<mozilla::WebGLFramebuffer*>(aObject), |
10579 | 0 | "Multiple inheritance for mozilla::WebGLFramebuffer is broken."); |
10580 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
10581 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
10582 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
10583 | 0 | "You should probably not be using Wrap() directly; use " |
10584 | 0 | "GetOrCreateDOMReflector instead"); |
10585 | 0 |
|
10586 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
10587 | 0 | "nsISupports must be on our primary inheritance chain"); |
10588 | 0 |
|
10589 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
10590 | 0 | if (!global) { |
10591 | 0 | return false; |
10592 | 0 | } |
10593 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
10594 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
10595 | 0 |
|
10596 | 0 | // That might have ended up wrapping us already, due to the wonders |
10597 | 0 | // of XBL. Check for that, and bail out as needed. |
10598 | 0 | aReflector.set(aCache->GetWrapper()); |
10599 | 0 | if (aReflector) { |
10600 | | #ifdef DEBUG |
10601 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
10602 | | #endif // DEBUG |
10603 | | return true; |
10604 | 0 | } |
10605 | 0 |
|
10606 | 0 | JSAutoRealm ar(aCx, global); |
10607 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
10608 | 0 | if (!canonicalProto) { |
10609 | 0 | return false; |
10610 | 0 | } |
10611 | 0 | JS::Rooted<JSObject*> proto(aCx); |
10612 | 0 | if (aGivenProto) { |
10613 | 0 | proto = aGivenProto; |
10614 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
10615 | 0 | // coming in, we changed compartments to that of "parent" so may need |
10616 | 0 | // to wrap the proto here. |
10617 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
10618 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
10619 | 0 | return false; |
10620 | 0 | } |
10621 | 0 | } |
10622 | 0 | } else { |
10623 | 0 | proto = canonicalProto; |
10624 | 0 | } |
10625 | 0 |
|
10626 | 0 | BindingJSObjectCreator<mozilla::WebGLFramebuffer> creator(aCx); |
10627 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
10628 | 0 | if (!aReflector) { |
10629 | 0 | return false; |
10630 | 0 | } |
10631 | 0 | |
10632 | 0 | aCache->SetWrapper(aReflector); |
10633 | 0 | creator.InitializationSucceeded(); |
10634 | 0 |
|
10635 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
10636 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
10637 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
10638 | 0 | // otherwise we won't be able to properly recreate it later, since |
10639 | 0 | // we won't know what proto to use. Note that we don't check |
10640 | 0 | // aGivenProto here, since it's entirely possible (and even |
10641 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
10642 | 0 | // same as canonicalProto. |
10643 | 0 | if (proto != canonicalProto) { |
10644 | 0 | PreserveWrapper(aObject); |
10645 | 0 | } |
10646 | 0 |
|
10647 | 0 | return true; |
10648 | 0 | } |
10649 | | |
10650 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
10651 | | nullptr, |
10652 | | nullptr, |
10653 | | nullptr, |
10654 | | { nullptr, nullptr }, |
10655 | | prototypes::id::WebGLFramebuffer, |
10656 | | constructors::id::WebGLFramebuffer, |
10657 | | nullptr, |
10658 | | &DefaultXrayExpandoObjectClass |
10659 | | } }; |
10660 | | |
10661 | | void |
10662 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
10663 | 0 | { |
10664 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
10665 | 0 | if (!parentProto) { |
10666 | 0 | return; |
10667 | 0 | } |
10668 | 0 | |
10669 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
10670 | 0 | if (!constructorProto) { |
10671 | 0 | return; |
10672 | 0 | } |
10673 | 0 | |
10674 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WebGLFramebuffer); |
10675 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WebGLFramebuffer); |
10676 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
10677 | 0 | &sPrototypeClass.mBase, protoCache, |
10678 | 0 | nullptr, |
10679 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
10680 | 0 | interfaceCache, |
10681 | 0 | nullptr, |
10682 | 0 | nullptr, |
10683 | 0 | "WebGLFramebuffer", aDefineOnGlobal, |
10684 | 0 | nullptr, |
10685 | 0 | false); |
10686 | 0 | } |
10687 | | |
10688 | | JSObject* |
10689 | | GetConstructorObject(JSContext* aCx) |
10690 | 0 | { |
10691 | 0 | return GetConstructorObjectHandle(aCx); |
10692 | 0 | } |
10693 | | |
10694 | | } // namespace WebGLFramebuffer_Binding |
10695 | | |
10696 | | |
10697 | | |
10698 | | namespace WebGLProgram_Binding { |
10699 | | |
10700 | | static bool |
10701 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
10702 | 0 | { |
10703 | 0 | mozilla::WebGLProgram* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLProgram>(obj); |
10704 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
10705 | 0 | // obviously can't preserve if we're not initialized. |
10706 | 0 | if (self && self->GetWrapperPreserveColor()) { |
10707 | 0 | PreserveWrapper(self); |
10708 | 0 | } |
10709 | 0 | return true; |
10710 | 0 | } |
10711 | | |
10712 | | static void |
10713 | | _finalize(js::FreeOp* fop, JSObject* obj) |
10714 | 0 | { |
10715 | 0 | mozilla::WebGLProgram* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLProgram>(obj); |
10716 | 0 | if (self) { |
10717 | 0 | ClearWrapper(self, self, obj); |
10718 | 0 | AddForDeferredFinalization<mozilla::WebGLProgram>(self); |
10719 | 0 | } |
10720 | 0 | } |
10721 | | |
10722 | | static size_t |
10723 | | _objectMoved(JSObject* obj, JSObject* old) |
10724 | 0 | { |
10725 | 0 | mozilla::WebGLProgram* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLProgram>(obj); |
10726 | 0 | if (self) { |
10727 | 0 | UpdateWrapper(self, self, obj, old); |
10728 | 0 | } |
10729 | 0 |
|
10730 | 0 | return 0; |
10731 | 0 | } |
10732 | | |
10733 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
10734 | | { |
10735 | | "Function", |
10736 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
10737 | | &sBoringInterfaceObjectClassClassOps, |
10738 | | JS_NULL_CLASS_SPEC, |
10739 | | JS_NULL_CLASS_EXT, |
10740 | | &sInterfaceObjectClassObjectOps |
10741 | | }, |
10742 | | eInterface, |
10743 | | true, |
10744 | | prototypes::id::WebGLProgram, |
10745 | | PrototypeTraits<prototypes::id::WebGLProgram>::Depth, |
10746 | | sNativePropertyHooks, |
10747 | | "function WebGLProgram() {\n [native code]\n}", |
10748 | | JS::GetRealmFunctionPrototype |
10749 | | }; |
10750 | | |
10751 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
10752 | | { |
10753 | | "WebGLProgramPrototype", |
10754 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
10755 | | JS_NULL_CLASS_OPS, |
10756 | | JS_NULL_CLASS_SPEC, |
10757 | | JS_NULL_CLASS_EXT, |
10758 | | JS_NULL_OBJECT_OPS |
10759 | | }, |
10760 | | eInterfacePrototype, |
10761 | | false, |
10762 | | prototypes::id::WebGLProgram, |
10763 | | PrototypeTraits<prototypes::id::WebGLProgram>::Depth, |
10764 | | sNativePropertyHooks, |
10765 | | "[object WebGLProgramPrototype]", |
10766 | | JS::GetRealmObjectPrototype |
10767 | | }; |
10768 | | |
10769 | | bool |
10770 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
10771 | 0 | { |
10772 | 0 | return mozilla::dom::OffscreenCanvas::PrefEnabledOnWorkerThread(aCx, aObj); |
10773 | 0 | } |
10774 | | |
10775 | | static const js::ClassOps sClassOps = { |
10776 | | _addProperty, /* addProperty */ |
10777 | | nullptr, /* delProperty */ |
10778 | | nullptr, /* enumerate */ |
10779 | | nullptr, /* newEnumerate */ |
10780 | | nullptr, /* resolve */ |
10781 | | nullptr, /* mayResolve */ |
10782 | | _finalize, /* finalize */ |
10783 | | nullptr, /* call */ |
10784 | | nullptr, /* hasInstance */ |
10785 | | nullptr, /* construct */ |
10786 | | nullptr, /* trace */ |
10787 | | }; |
10788 | | |
10789 | | static const js::ClassExtension sClassExtension = { |
10790 | | nullptr, /* weakmapKeyDelegateOp */ |
10791 | | _objectMoved /* objectMovedOp */ |
10792 | | }; |
10793 | | |
10794 | | static const DOMJSClass sClass = { |
10795 | | { "WebGLProgram", |
10796 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
10797 | | &sClassOps, |
10798 | | JS_NULL_CLASS_SPEC, |
10799 | | &sClassExtension, |
10800 | | JS_NULL_OBJECT_OPS |
10801 | | }, |
10802 | | { prototypes::id::WebGLProgram, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
10803 | | IsBaseOf<nsISupports, mozilla::WebGLProgram >::value, |
10804 | | sNativePropertyHooks, |
10805 | | FindAssociatedGlobalForNative<mozilla::WebGLProgram>::Get, |
10806 | | GetProtoObjectHandle, |
10807 | | GetCCParticipant<mozilla::WebGLProgram>::Get() |
10808 | | }; |
10809 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
10810 | | "Must have the right minimal number of reserved slots."); |
10811 | | static_assert(1 >= 1, |
10812 | | "Must have enough reserved slots."); |
10813 | | |
10814 | | const JSClass* |
10815 | | GetJSClass() |
10816 | 0 | { |
10817 | 0 | return sClass.ToJSClass(); |
10818 | 0 | } |
10819 | | |
10820 | | bool |
10821 | | Wrap(JSContext* aCx, mozilla::WebGLProgram* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
10822 | 0 | { |
10823 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLProgram>::value, |
10824 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
10825 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLProgram*>(aObject) == |
10826 | 0 | reinterpret_cast<mozilla::WebGLProgram*>(aObject), |
10827 | 0 | "Multiple inheritance for mozilla::WebGLProgram is broken."); |
10828 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
10829 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
10830 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
10831 | 0 | "You should probably not be using Wrap() directly; use " |
10832 | 0 | "GetOrCreateDOMReflector instead"); |
10833 | 0 |
|
10834 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
10835 | 0 | "nsISupports must be on our primary inheritance chain"); |
10836 | 0 |
|
10837 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
10838 | 0 | if (!global) { |
10839 | 0 | return false; |
10840 | 0 | } |
10841 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
10842 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
10843 | 0 |
|
10844 | 0 | // That might have ended up wrapping us already, due to the wonders |
10845 | 0 | // of XBL. Check for that, and bail out as needed. |
10846 | 0 | aReflector.set(aCache->GetWrapper()); |
10847 | 0 | if (aReflector) { |
10848 | | #ifdef DEBUG |
10849 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
10850 | | #endif // DEBUG |
10851 | | return true; |
10852 | 0 | } |
10853 | 0 |
|
10854 | 0 | JSAutoRealm ar(aCx, global); |
10855 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
10856 | 0 | if (!canonicalProto) { |
10857 | 0 | return false; |
10858 | 0 | } |
10859 | 0 | JS::Rooted<JSObject*> proto(aCx); |
10860 | 0 | if (aGivenProto) { |
10861 | 0 | proto = aGivenProto; |
10862 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
10863 | 0 | // coming in, we changed compartments to that of "parent" so may need |
10864 | 0 | // to wrap the proto here. |
10865 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
10866 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
10867 | 0 | return false; |
10868 | 0 | } |
10869 | 0 | } |
10870 | 0 | } else { |
10871 | 0 | proto = canonicalProto; |
10872 | 0 | } |
10873 | 0 |
|
10874 | 0 | BindingJSObjectCreator<mozilla::WebGLProgram> creator(aCx); |
10875 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
10876 | 0 | if (!aReflector) { |
10877 | 0 | return false; |
10878 | 0 | } |
10879 | 0 | |
10880 | 0 | aCache->SetWrapper(aReflector); |
10881 | 0 | creator.InitializationSucceeded(); |
10882 | 0 |
|
10883 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
10884 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
10885 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
10886 | 0 | // otherwise we won't be able to properly recreate it later, since |
10887 | 0 | // we won't know what proto to use. Note that we don't check |
10888 | 0 | // aGivenProto here, since it's entirely possible (and even |
10889 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
10890 | 0 | // same as canonicalProto. |
10891 | 0 | if (proto != canonicalProto) { |
10892 | 0 | PreserveWrapper(aObject); |
10893 | 0 | } |
10894 | 0 |
|
10895 | 0 | return true; |
10896 | 0 | } |
10897 | | |
10898 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
10899 | | nullptr, |
10900 | | nullptr, |
10901 | | nullptr, |
10902 | | { nullptr, nullptr }, |
10903 | | prototypes::id::WebGLProgram, |
10904 | | constructors::id::WebGLProgram, |
10905 | | nullptr, |
10906 | | &DefaultXrayExpandoObjectClass |
10907 | | } }; |
10908 | | |
10909 | | void |
10910 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
10911 | 0 | { |
10912 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
10913 | 0 | if (!parentProto) { |
10914 | 0 | return; |
10915 | 0 | } |
10916 | 0 | |
10917 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
10918 | 0 | if (!constructorProto) { |
10919 | 0 | return; |
10920 | 0 | } |
10921 | 0 | |
10922 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WebGLProgram); |
10923 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WebGLProgram); |
10924 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
10925 | 0 | &sPrototypeClass.mBase, protoCache, |
10926 | 0 | nullptr, |
10927 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
10928 | 0 | interfaceCache, |
10929 | 0 | nullptr, |
10930 | 0 | nullptr, |
10931 | 0 | "WebGLProgram", aDefineOnGlobal, |
10932 | 0 | nullptr, |
10933 | 0 | false); |
10934 | 0 | } |
10935 | | |
10936 | | JSObject* |
10937 | | GetConstructorObject(JSContext* aCx) |
10938 | 0 | { |
10939 | 0 | return GetConstructorObjectHandle(aCx); |
10940 | 0 | } |
10941 | | |
10942 | | } // namespace WebGLProgram_Binding |
10943 | | |
10944 | | |
10945 | | |
10946 | | namespace WebGLQuery_Binding { |
10947 | | |
10948 | | static bool |
10949 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
10950 | 0 | { |
10951 | 0 | mozilla::WebGLQuery* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLQuery>(obj); |
10952 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
10953 | 0 | // obviously can't preserve if we're not initialized. |
10954 | 0 | if (self && self->GetWrapperPreserveColor()) { |
10955 | 0 | PreserveWrapper(self); |
10956 | 0 | } |
10957 | 0 | return true; |
10958 | 0 | } |
10959 | | |
10960 | | static void |
10961 | | _finalize(js::FreeOp* fop, JSObject* obj) |
10962 | 0 | { |
10963 | 0 | mozilla::WebGLQuery* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLQuery>(obj); |
10964 | 0 | if (self) { |
10965 | 0 | ClearWrapper(self, self, obj); |
10966 | 0 | AddForDeferredFinalization<mozilla::WebGLQuery>(self); |
10967 | 0 | } |
10968 | 0 | } |
10969 | | |
10970 | | static size_t |
10971 | | _objectMoved(JSObject* obj, JSObject* old) |
10972 | 0 | { |
10973 | 0 | mozilla::WebGLQuery* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLQuery>(obj); |
10974 | 0 | if (self) { |
10975 | 0 | UpdateWrapper(self, self, obj, old); |
10976 | 0 | } |
10977 | 0 |
|
10978 | 0 | return 0; |
10979 | 0 | } |
10980 | | |
10981 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
10982 | | { |
10983 | | "Function", |
10984 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
10985 | | &sBoringInterfaceObjectClassClassOps, |
10986 | | JS_NULL_CLASS_SPEC, |
10987 | | JS_NULL_CLASS_EXT, |
10988 | | &sInterfaceObjectClassObjectOps |
10989 | | }, |
10990 | | eInterface, |
10991 | | true, |
10992 | | prototypes::id::WebGLQuery, |
10993 | | PrototypeTraits<prototypes::id::WebGLQuery>::Depth, |
10994 | | sNativePropertyHooks, |
10995 | | "function WebGLQuery() {\n [native code]\n}", |
10996 | | JS::GetRealmFunctionPrototype |
10997 | | }; |
10998 | | |
10999 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
11000 | | { |
11001 | | "WebGLQueryPrototype", |
11002 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
11003 | | JS_NULL_CLASS_OPS, |
11004 | | JS_NULL_CLASS_SPEC, |
11005 | | JS_NULL_CLASS_EXT, |
11006 | | JS_NULL_OBJECT_OPS |
11007 | | }, |
11008 | | eInterfacePrototype, |
11009 | | false, |
11010 | | prototypes::id::WebGLQuery, |
11011 | | PrototypeTraits<prototypes::id::WebGLQuery>::Depth, |
11012 | | sNativePropertyHooks, |
11013 | | "[object WebGLQueryPrototype]", |
11014 | | JS::GetRealmObjectPrototype |
11015 | | }; |
11016 | | |
11017 | | static const js::ClassOps sClassOps = { |
11018 | | _addProperty, /* addProperty */ |
11019 | | nullptr, /* delProperty */ |
11020 | | nullptr, /* enumerate */ |
11021 | | nullptr, /* newEnumerate */ |
11022 | | nullptr, /* resolve */ |
11023 | | nullptr, /* mayResolve */ |
11024 | | _finalize, /* finalize */ |
11025 | | nullptr, /* call */ |
11026 | | nullptr, /* hasInstance */ |
11027 | | nullptr, /* construct */ |
11028 | | nullptr, /* trace */ |
11029 | | }; |
11030 | | |
11031 | | static const js::ClassExtension sClassExtension = { |
11032 | | nullptr, /* weakmapKeyDelegateOp */ |
11033 | | _objectMoved /* objectMovedOp */ |
11034 | | }; |
11035 | | |
11036 | | static const DOMJSClass sClass = { |
11037 | | { "WebGLQuery", |
11038 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
11039 | | &sClassOps, |
11040 | | JS_NULL_CLASS_SPEC, |
11041 | | &sClassExtension, |
11042 | | JS_NULL_OBJECT_OPS |
11043 | | }, |
11044 | | { prototypes::id::WebGLQuery, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
11045 | | IsBaseOf<nsISupports, mozilla::WebGLQuery >::value, |
11046 | | sNativePropertyHooks, |
11047 | | FindAssociatedGlobalForNative<mozilla::WebGLQuery>::Get, |
11048 | | GetProtoObjectHandle, |
11049 | | GetCCParticipant<mozilla::WebGLQuery>::Get() |
11050 | | }; |
11051 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
11052 | | "Must have the right minimal number of reserved slots."); |
11053 | | static_assert(1 >= 1, |
11054 | | "Must have enough reserved slots."); |
11055 | | |
11056 | | const JSClass* |
11057 | | GetJSClass() |
11058 | 0 | { |
11059 | 0 | return sClass.ToJSClass(); |
11060 | 0 | } |
11061 | | |
11062 | | bool |
11063 | | Wrap(JSContext* aCx, mozilla::WebGLQuery* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
11064 | 0 | { |
11065 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLQuery>::value, |
11066 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
11067 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLQuery*>(aObject) == |
11068 | 0 | reinterpret_cast<mozilla::WebGLQuery*>(aObject), |
11069 | 0 | "Multiple inheritance for mozilla::WebGLQuery is broken."); |
11070 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
11071 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
11072 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
11073 | 0 | "You should probably not be using Wrap() directly; use " |
11074 | 0 | "GetOrCreateDOMReflector instead"); |
11075 | 0 |
|
11076 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
11077 | 0 | "nsISupports must be on our primary inheritance chain"); |
11078 | 0 |
|
11079 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
11080 | 0 | if (!global) { |
11081 | 0 | return false; |
11082 | 0 | } |
11083 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
11084 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
11085 | 0 |
|
11086 | 0 | // That might have ended up wrapping us already, due to the wonders |
11087 | 0 | // of XBL. Check for that, and bail out as needed. |
11088 | 0 | aReflector.set(aCache->GetWrapper()); |
11089 | 0 | if (aReflector) { |
11090 | | #ifdef DEBUG |
11091 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
11092 | | #endif // DEBUG |
11093 | | return true; |
11094 | 0 | } |
11095 | 0 |
|
11096 | 0 | JSAutoRealm ar(aCx, global); |
11097 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
11098 | 0 | if (!canonicalProto) { |
11099 | 0 | return false; |
11100 | 0 | } |
11101 | 0 | JS::Rooted<JSObject*> proto(aCx); |
11102 | 0 | if (aGivenProto) { |
11103 | 0 | proto = aGivenProto; |
11104 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
11105 | 0 | // coming in, we changed compartments to that of "parent" so may need |
11106 | 0 | // to wrap the proto here. |
11107 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
11108 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
11109 | 0 | return false; |
11110 | 0 | } |
11111 | 0 | } |
11112 | 0 | } else { |
11113 | 0 | proto = canonicalProto; |
11114 | 0 | } |
11115 | 0 |
|
11116 | 0 | BindingJSObjectCreator<mozilla::WebGLQuery> creator(aCx); |
11117 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
11118 | 0 | if (!aReflector) { |
11119 | 0 | return false; |
11120 | 0 | } |
11121 | 0 | |
11122 | 0 | aCache->SetWrapper(aReflector); |
11123 | 0 | creator.InitializationSucceeded(); |
11124 | 0 |
|
11125 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
11126 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
11127 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
11128 | 0 | // otherwise we won't be able to properly recreate it later, since |
11129 | 0 | // we won't know what proto to use. Note that we don't check |
11130 | 0 | // aGivenProto here, since it's entirely possible (and even |
11131 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
11132 | 0 | // same as canonicalProto. |
11133 | 0 | if (proto != canonicalProto) { |
11134 | 0 | PreserveWrapper(aObject); |
11135 | 0 | } |
11136 | 0 |
|
11137 | 0 | return true; |
11138 | 0 | } |
11139 | | |
11140 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
11141 | | nullptr, |
11142 | | nullptr, |
11143 | | nullptr, |
11144 | | { nullptr, nullptr }, |
11145 | | prototypes::id::WebGLQuery, |
11146 | | constructors::id::WebGLQuery, |
11147 | | nullptr, |
11148 | | &DefaultXrayExpandoObjectClass |
11149 | | } }; |
11150 | | |
11151 | | void |
11152 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
11153 | 0 | { |
11154 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
11155 | 0 | if (!parentProto) { |
11156 | 0 | return; |
11157 | 0 | } |
11158 | 0 | |
11159 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
11160 | 0 | if (!constructorProto) { |
11161 | 0 | return; |
11162 | 0 | } |
11163 | 0 | |
11164 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WebGLQuery); |
11165 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WebGLQuery); |
11166 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
11167 | 0 | &sPrototypeClass.mBase, protoCache, |
11168 | 0 | nullptr, |
11169 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
11170 | 0 | interfaceCache, |
11171 | 0 | nullptr, |
11172 | 0 | nullptr, |
11173 | 0 | "WebGLQuery", aDefineOnGlobal, |
11174 | 0 | nullptr, |
11175 | 0 | false); |
11176 | 0 | } |
11177 | | |
11178 | | JSObject* |
11179 | | GetConstructorObject(JSContext* aCx) |
11180 | 0 | { |
11181 | 0 | return GetConstructorObjectHandle(aCx); |
11182 | 0 | } |
11183 | | |
11184 | | } // namespace WebGLQuery_Binding |
11185 | | |
11186 | | |
11187 | | |
11188 | | namespace WebGLRenderbuffer_Binding { |
11189 | | |
11190 | | static bool |
11191 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
11192 | 0 | { |
11193 | 0 | mozilla::WebGLRenderbuffer* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLRenderbuffer>(obj); |
11194 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
11195 | 0 | // obviously can't preserve if we're not initialized. |
11196 | 0 | if (self && self->GetWrapperPreserveColor()) { |
11197 | 0 | PreserveWrapper(self); |
11198 | 0 | } |
11199 | 0 | return true; |
11200 | 0 | } |
11201 | | |
11202 | | static void |
11203 | | _finalize(js::FreeOp* fop, JSObject* obj) |
11204 | 0 | { |
11205 | 0 | mozilla::WebGLRenderbuffer* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLRenderbuffer>(obj); |
11206 | 0 | if (self) { |
11207 | 0 | ClearWrapper(self, self, obj); |
11208 | 0 | AddForDeferredFinalization<mozilla::WebGLRenderbuffer>(self); |
11209 | 0 | } |
11210 | 0 | } |
11211 | | |
11212 | | static size_t |
11213 | | _objectMoved(JSObject* obj, JSObject* old) |
11214 | 0 | { |
11215 | 0 | mozilla::WebGLRenderbuffer* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLRenderbuffer>(obj); |
11216 | 0 | if (self) { |
11217 | 0 | UpdateWrapper(self, self, obj, old); |
11218 | 0 | } |
11219 | 0 |
|
11220 | 0 | return 0; |
11221 | 0 | } |
11222 | | |
11223 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
11224 | | { |
11225 | | "Function", |
11226 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
11227 | | &sBoringInterfaceObjectClassClassOps, |
11228 | | JS_NULL_CLASS_SPEC, |
11229 | | JS_NULL_CLASS_EXT, |
11230 | | &sInterfaceObjectClassObjectOps |
11231 | | }, |
11232 | | eInterface, |
11233 | | true, |
11234 | | prototypes::id::WebGLRenderbuffer, |
11235 | | PrototypeTraits<prototypes::id::WebGLRenderbuffer>::Depth, |
11236 | | sNativePropertyHooks, |
11237 | | "function WebGLRenderbuffer() {\n [native code]\n}", |
11238 | | JS::GetRealmFunctionPrototype |
11239 | | }; |
11240 | | |
11241 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
11242 | | { |
11243 | | "WebGLRenderbufferPrototype", |
11244 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
11245 | | JS_NULL_CLASS_OPS, |
11246 | | JS_NULL_CLASS_SPEC, |
11247 | | JS_NULL_CLASS_EXT, |
11248 | | JS_NULL_OBJECT_OPS |
11249 | | }, |
11250 | | eInterfacePrototype, |
11251 | | false, |
11252 | | prototypes::id::WebGLRenderbuffer, |
11253 | | PrototypeTraits<prototypes::id::WebGLRenderbuffer>::Depth, |
11254 | | sNativePropertyHooks, |
11255 | | "[object WebGLRenderbufferPrototype]", |
11256 | | JS::GetRealmObjectPrototype |
11257 | | }; |
11258 | | |
11259 | | bool |
11260 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
11261 | 0 | { |
11262 | 0 | return mozilla::dom::OffscreenCanvas::PrefEnabledOnWorkerThread(aCx, aObj); |
11263 | 0 | } |
11264 | | |
11265 | | static const js::ClassOps sClassOps = { |
11266 | | _addProperty, /* addProperty */ |
11267 | | nullptr, /* delProperty */ |
11268 | | nullptr, /* enumerate */ |
11269 | | nullptr, /* newEnumerate */ |
11270 | | nullptr, /* resolve */ |
11271 | | nullptr, /* mayResolve */ |
11272 | | _finalize, /* finalize */ |
11273 | | nullptr, /* call */ |
11274 | | nullptr, /* hasInstance */ |
11275 | | nullptr, /* construct */ |
11276 | | nullptr, /* trace */ |
11277 | | }; |
11278 | | |
11279 | | static const js::ClassExtension sClassExtension = { |
11280 | | nullptr, /* weakmapKeyDelegateOp */ |
11281 | | _objectMoved /* objectMovedOp */ |
11282 | | }; |
11283 | | |
11284 | | static const DOMJSClass sClass = { |
11285 | | { "WebGLRenderbuffer", |
11286 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
11287 | | &sClassOps, |
11288 | | JS_NULL_CLASS_SPEC, |
11289 | | &sClassExtension, |
11290 | | JS_NULL_OBJECT_OPS |
11291 | | }, |
11292 | | { prototypes::id::WebGLRenderbuffer, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
11293 | | IsBaseOf<nsISupports, mozilla::WebGLRenderbuffer >::value, |
11294 | | sNativePropertyHooks, |
11295 | | FindAssociatedGlobalForNative<mozilla::WebGLRenderbuffer>::Get, |
11296 | | GetProtoObjectHandle, |
11297 | | GetCCParticipant<mozilla::WebGLRenderbuffer>::Get() |
11298 | | }; |
11299 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
11300 | | "Must have the right minimal number of reserved slots."); |
11301 | | static_assert(1 >= 1, |
11302 | | "Must have enough reserved slots."); |
11303 | | |
11304 | | const JSClass* |
11305 | | GetJSClass() |
11306 | 0 | { |
11307 | 0 | return sClass.ToJSClass(); |
11308 | 0 | } |
11309 | | |
11310 | | bool |
11311 | | Wrap(JSContext* aCx, mozilla::WebGLRenderbuffer* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
11312 | 0 | { |
11313 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLRenderbuffer>::value, |
11314 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
11315 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLRenderbuffer*>(aObject) == |
11316 | 0 | reinterpret_cast<mozilla::WebGLRenderbuffer*>(aObject), |
11317 | 0 | "Multiple inheritance for mozilla::WebGLRenderbuffer is broken."); |
11318 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
11319 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
11320 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
11321 | 0 | "You should probably not be using Wrap() directly; use " |
11322 | 0 | "GetOrCreateDOMReflector instead"); |
11323 | 0 |
|
11324 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
11325 | 0 | "nsISupports must be on our primary inheritance chain"); |
11326 | 0 |
|
11327 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
11328 | 0 | if (!global) { |
11329 | 0 | return false; |
11330 | 0 | } |
11331 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
11332 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
11333 | 0 |
|
11334 | 0 | // That might have ended up wrapping us already, due to the wonders |
11335 | 0 | // of XBL. Check for that, and bail out as needed. |
11336 | 0 | aReflector.set(aCache->GetWrapper()); |
11337 | 0 | if (aReflector) { |
11338 | | #ifdef DEBUG |
11339 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
11340 | | #endif // DEBUG |
11341 | | return true; |
11342 | 0 | } |
11343 | 0 |
|
11344 | 0 | JSAutoRealm ar(aCx, global); |
11345 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
11346 | 0 | if (!canonicalProto) { |
11347 | 0 | return false; |
11348 | 0 | } |
11349 | 0 | JS::Rooted<JSObject*> proto(aCx); |
11350 | 0 | if (aGivenProto) { |
11351 | 0 | proto = aGivenProto; |
11352 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
11353 | 0 | // coming in, we changed compartments to that of "parent" so may need |
11354 | 0 | // to wrap the proto here. |
11355 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
11356 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
11357 | 0 | return false; |
11358 | 0 | } |
11359 | 0 | } |
11360 | 0 | } else { |
11361 | 0 | proto = canonicalProto; |
11362 | 0 | } |
11363 | 0 |
|
11364 | 0 | BindingJSObjectCreator<mozilla::WebGLRenderbuffer> creator(aCx); |
11365 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
11366 | 0 | if (!aReflector) { |
11367 | 0 | return false; |
11368 | 0 | } |
11369 | 0 | |
11370 | 0 | aCache->SetWrapper(aReflector); |
11371 | 0 | creator.InitializationSucceeded(); |
11372 | 0 |
|
11373 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
11374 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
11375 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
11376 | 0 | // otherwise we won't be able to properly recreate it later, since |
11377 | 0 | // we won't know what proto to use. Note that we don't check |
11378 | 0 | // aGivenProto here, since it's entirely possible (and even |
11379 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
11380 | 0 | // same as canonicalProto. |
11381 | 0 | if (proto != canonicalProto) { |
11382 | 0 | PreserveWrapper(aObject); |
11383 | 0 | } |
11384 | 0 |
|
11385 | 0 | return true; |
11386 | 0 | } |
11387 | | |
11388 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
11389 | | nullptr, |
11390 | | nullptr, |
11391 | | nullptr, |
11392 | | { nullptr, nullptr }, |
11393 | | prototypes::id::WebGLRenderbuffer, |
11394 | | constructors::id::WebGLRenderbuffer, |
11395 | | nullptr, |
11396 | | &DefaultXrayExpandoObjectClass |
11397 | | } }; |
11398 | | |
11399 | | void |
11400 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
11401 | 0 | { |
11402 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
11403 | 0 | if (!parentProto) { |
11404 | 0 | return; |
11405 | 0 | } |
11406 | 0 | |
11407 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
11408 | 0 | if (!constructorProto) { |
11409 | 0 | return; |
11410 | 0 | } |
11411 | 0 | |
11412 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WebGLRenderbuffer); |
11413 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WebGLRenderbuffer); |
11414 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
11415 | 0 | &sPrototypeClass.mBase, protoCache, |
11416 | 0 | nullptr, |
11417 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
11418 | 0 | interfaceCache, |
11419 | 0 | nullptr, |
11420 | 0 | nullptr, |
11421 | 0 | "WebGLRenderbuffer", aDefineOnGlobal, |
11422 | 0 | nullptr, |
11423 | 0 | false); |
11424 | 0 | } |
11425 | | |
11426 | | JSObject* |
11427 | | GetConstructorObject(JSContext* aCx) |
11428 | 0 | { |
11429 | 0 | return GetConstructorObjectHandle(aCx); |
11430 | 0 | } |
11431 | | |
11432 | | } // namespace WebGLRenderbuffer_Binding |
11433 | | |
11434 | | |
11435 | | |
11436 | | namespace WebGLRenderingContext_Binding { |
11437 | | |
11438 | | MOZ_CAN_RUN_SCRIPT static bool |
11439 | | bufferData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
11440 | 0 | { |
11441 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.bufferData", DOM, cx); |
11442 | 0 |
|
11443 | 0 | unsigned argcount = std::min(args.length(), 3u); |
11444 | 0 | switch (argcount) { |
11445 | 0 | case 3: { |
11446 | 0 | uint32_t arg0; |
11447 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
11448 | 0 | return false; |
11449 | 0 | } |
11450 | 0 | if (args[1].isNullOrUndefined()) { |
11451 | 0 | RootedSpiderMonkeyInterface<Nullable<ArrayBuffer>> arg1(cx); |
11452 | 0 | arg1.SetNull(); |
11453 | 0 | uint32_t arg2; |
11454 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) { |
11455 | 0 | return false; |
11456 | 0 | } |
11457 | 0 | self->BufferData(arg0, Constify(arg1), arg2); |
11458 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
11459 | 0 | args.rval().setUndefined(); |
11460 | 0 | return true; |
11461 | 0 | } |
11462 | 0 | if (args[1].isObject()) { |
11463 | 0 | do { |
11464 | 0 | RootedSpiderMonkeyInterface<Nullable<ArrayBuffer>> arg1(cx); |
11465 | 0 | if (!arg1.SetValue().Init(&args[1].toObject())) { |
11466 | 0 | break; |
11467 | 0 | } |
11468 | 0 | uint32_t arg2; |
11469 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) { |
11470 | 0 | return false; |
11471 | 0 | } |
11472 | 0 | self->BufferData(arg0, Constify(arg1), arg2); |
11473 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
11474 | 0 | args.rval().setUndefined(); |
11475 | 0 | return true; |
11476 | 0 | } while (false); |
11477 | 0 | do { |
11478 | 0 | RootedSpiderMonkeyInterface<ArrayBufferView> arg1(cx); |
11479 | 0 | if (!arg1.Init(&args[1].toObject())) { |
11480 | 0 | break; |
11481 | 0 | } |
11482 | 0 | uint32_t arg2; |
11483 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) { |
11484 | 0 | return false; |
11485 | 0 | } |
11486 | 0 | self->BufferData(arg0, Constify(arg1), arg2); |
11487 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
11488 | 0 | args.rval().setUndefined(); |
11489 | 0 | return true; |
11490 | 0 | } while (false); |
11491 | 0 | } |
11492 | 0 | int64_t arg1; |
11493 | 0 | if (!ValueToPrimitive<int64_t, eDefault>(cx, args[1], &arg1)) { |
11494 | 0 | return false; |
11495 | 0 | } |
11496 | 0 | uint32_t arg2; |
11497 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) { |
11498 | 0 | return false; |
11499 | 0 | } |
11500 | 0 | self->BufferData(arg0, arg1, arg2); |
11501 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
11502 | 0 | args.rval().setUndefined(); |
11503 | 0 | return true; |
11504 | 0 | break; |
11505 | 0 | } |
11506 | 0 | default: { |
11507 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.bufferData"); |
11508 | 0 | break; |
11509 | 0 | } |
11510 | 0 | } |
11511 | 0 | MOZ_CRASH("We have an always-returning default case"); |
11512 | 0 | return false; |
11513 | 0 | } |
11514 | | |
11515 | | static const JSJitInfo bufferData_methodinfo = { |
11516 | | { (JSJitGetterOp)bufferData }, |
11517 | | { prototypes::id::WebGLRenderingContext }, |
11518 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
11519 | | JSJitInfo::Method, |
11520 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
11521 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
11522 | | false, /* isInfallible. False in setters. */ |
11523 | | false, /* isMovable. Not relevant for setters. */ |
11524 | | false, /* isEliminatable. Not relevant for setters. */ |
11525 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
11526 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
11527 | | false, /* isTypedMethod. Only relevant for methods. */ |
11528 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
11529 | | }; |
11530 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
11531 | | static_assert(0 < 1, "There is no slot for us"); |
11532 | | |
11533 | | MOZ_CAN_RUN_SCRIPT static bool |
11534 | | bufferSubData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
11535 | 0 | { |
11536 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.bufferSubData", DOM, cx); |
11537 | 0 |
|
11538 | 0 | unsigned argcount = std::min(args.length(), 3u); |
11539 | 0 | switch (argcount) { |
11540 | 0 | case 3: { |
11541 | 0 | uint32_t arg0; |
11542 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
11543 | 0 | return false; |
11544 | 0 | } |
11545 | 0 | int64_t arg1; |
11546 | 0 | if (!ValueToPrimitive<int64_t, eDefault>(cx, args[1], &arg1)) { |
11547 | 0 | return false; |
11548 | 0 | } |
11549 | 0 | if (args[2].isObject()) { |
11550 | 0 | do { |
11551 | 0 | RootedSpiderMonkeyInterface<ArrayBuffer> arg2(cx); |
11552 | 0 | if (!arg2.Init(&args[2].toObject())) { |
11553 | 0 | break; |
11554 | 0 | } |
11555 | 0 | self->BufferSubData(arg0, arg1, Constify(arg2)); |
11556 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
11557 | 0 | args.rval().setUndefined(); |
11558 | 0 | return true; |
11559 | 0 | } while (false); |
11560 | 0 | do { |
11561 | 0 | RootedSpiderMonkeyInterface<ArrayBufferView> arg2(cx); |
11562 | 0 | if (!arg2.Init(&args[2].toObject())) { |
11563 | 0 | break; |
11564 | 0 | } |
11565 | 0 | self->BufferSubData(arg0, arg1, Constify(arg2)); |
11566 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
11567 | 0 | args.rval().setUndefined(); |
11568 | 0 | return true; |
11569 | 0 | } while (false); |
11570 | 0 | } |
11571 | 0 | return ThrowErrorMessage(cx, MSG_OVERLOAD_RESOLUTION_FAILED, "3", "3", "WebGLRenderingContext.bufferSubData"); |
11572 | 0 | break; |
11573 | 0 | } |
11574 | 0 | default: { |
11575 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.bufferSubData"); |
11576 | 0 | break; |
11577 | 0 | } |
11578 | 0 | } |
11579 | 0 | MOZ_CRASH("We have an always-returning default case"); |
11580 | 0 | return false; |
11581 | 0 | } |
11582 | | |
11583 | | static const JSJitInfo bufferSubData_methodinfo = { |
11584 | | { (JSJitGetterOp)bufferSubData }, |
11585 | | { prototypes::id::WebGLRenderingContext }, |
11586 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
11587 | | JSJitInfo::Method, |
11588 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
11589 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
11590 | | false, /* isInfallible. False in setters. */ |
11591 | | false, /* isMovable. Not relevant for setters. */ |
11592 | | false, /* isEliminatable. Not relevant for setters. */ |
11593 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
11594 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
11595 | | false, /* isTypedMethod. Only relevant for methods. */ |
11596 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
11597 | | }; |
11598 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
11599 | | static_assert(0 < 1, "There is no slot for us"); |
11600 | | |
11601 | | MOZ_CAN_RUN_SCRIPT static bool |
11602 | | compressedTexImage2D(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
11603 | 0 | { |
11604 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.compressedTexImage2D", DOM, cx); |
11605 | 0 |
|
11606 | 0 | if (MOZ_UNLIKELY(args.length() < 7)) { |
11607 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.compressedTexImage2D"); |
11608 | 0 | } |
11609 | 0 | uint32_t arg0; |
11610 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
11611 | 0 | return false; |
11612 | 0 | } |
11613 | 0 | int32_t arg1; |
11614 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
11615 | 0 | return false; |
11616 | 0 | } |
11617 | 0 | uint32_t arg2; |
11618 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) { |
11619 | 0 | return false; |
11620 | 0 | } |
11621 | 0 | int32_t arg3; |
11622 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[3], &arg3)) { |
11623 | 0 | return false; |
11624 | 0 | } |
11625 | 0 | int32_t arg4; |
11626 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) { |
11627 | 0 | return false; |
11628 | 0 | } |
11629 | 0 | int32_t arg5; |
11630 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[5], &arg5)) { |
11631 | 0 | return false; |
11632 | 0 | } |
11633 | 0 | RootedSpiderMonkeyInterface<ArrayBufferView> arg6(cx); |
11634 | 0 | if (args[6].isObject()) { |
11635 | 0 | if (!arg6.Init(&args[6].toObject())) { |
11636 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 7 of WebGLRenderingContext.compressedTexImage2D", "ArrayBufferView"); |
11637 | 0 | return false; |
11638 | 0 | } |
11639 | 0 | } else { |
11640 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 7 of WebGLRenderingContext.compressedTexImage2D"); |
11641 | 0 | return false; |
11642 | 0 | } |
11643 | 0 | self->CompressedTexImage2D(arg0, arg1, arg2, arg3, arg4, arg5, Constify(arg6)); |
11644 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
11645 | 0 | args.rval().setUndefined(); |
11646 | 0 | return true; |
11647 | 0 | } |
11648 | | |
11649 | | static const JSJitInfo compressedTexImage2D_methodinfo = { |
11650 | | { (JSJitGetterOp)compressedTexImage2D }, |
11651 | | { prototypes::id::WebGLRenderingContext }, |
11652 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
11653 | | JSJitInfo::Method, |
11654 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
11655 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
11656 | | false, /* isInfallible. False in setters. */ |
11657 | | false, /* isMovable. Not relevant for setters. */ |
11658 | | false, /* isEliminatable. Not relevant for setters. */ |
11659 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
11660 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
11661 | | false, /* isTypedMethod. Only relevant for methods. */ |
11662 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
11663 | | }; |
11664 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
11665 | | static_assert(0 < 1, "There is no slot for us"); |
11666 | | |
11667 | | MOZ_CAN_RUN_SCRIPT static bool |
11668 | | compressedTexSubImage2D(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
11669 | 0 | { |
11670 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.compressedTexSubImage2D", DOM, cx); |
11671 | 0 |
|
11672 | 0 | if (MOZ_UNLIKELY(args.length() < 8)) { |
11673 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.compressedTexSubImage2D"); |
11674 | 0 | } |
11675 | 0 | uint32_t arg0; |
11676 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
11677 | 0 | return false; |
11678 | 0 | } |
11679 | 0 | int32_t arg1; |
11680 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
11681 | 0 | return false; |
11682 | 0 | } |
11683 | 0 | int32_t arg2; |
11684 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
11685 | 0 | return false; |
11686 | 0 | } |
11687 | 0 | int32_t arg3; |
11688 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[3], &arg3)) { |
11689 | 0 | return false; |
11690 | 0 | } |
11691 | 0 | int32_t arg4; |
11692 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) { |
11693 | 0 | return false; |
11694 | 0 | } |
11695 | 0 | int32_t arg5; |
11696 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[5], &arg5)) { |
11697 | 0 | return false; |
11698 | 0 | } |
11699 | 0 | uint32_t arg6; |
11700 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[6], &arg6)) { |
11701 | 0 | return false; |
11702 | 0 | } |
11703 | 0 | RootedSpiderMonkeyInterface<ArrayBufferView> arg7(cx); |
11704 | 0 | if (args[7].isObject()) { |
11705 | 0 | if (!arg7.Init(&args[7].toObject())) { |
11706 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 8 of WebGLRenderingContext.compressedTexSubImage2D", "ArrayBufferView"); |
11707 | 0 | return false; |
11708 | 0 | } |
11709 | 0 | } else { |
11710 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 8 of WebGLRenderingContext.compressedTexSubImage2D"); |
11711 | 0 | return false; |
11712 | 0 | } |
11713 | 0 | self->CompressedTexSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, Constify(arg7)); |
11714 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
11715 | 0 | args.rval().setUndefined(); |
11716 | 0 | return true; |
11717 | 0 | } |
11718 | | |
11719 | | static const JSJitInfo compressedTexSubImage2D_methodinfo = { |
11720 | | { (JSJitGetterOp)compressedTexSubImage2D }, |
11721 | | { prototypes::id::WebGLRenderingContext }, |
11722 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
11723 | | JSJitInfo::Method, |
11724 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
11725 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
11726 | | false, /* isInfallible. False in setters. */ |
11727 | | false, /* isMovable. Not relevant for setters. */ |
11728 | | false, /* isEliminatable. Not relevant for setters. */ |
11729 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
11730 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
11731 | | false, /* isTypedMethod. Only relevant for methods. */ |
11732 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
11733 | | }; |
11734 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
11735 | | static_assert(0 < 1, "There is no slot for us"); |
11736 | | |
11737 | | MOZ_CAN_RUN_SCRIPT static bool |
11738 | | readPixels(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
11739 | 0 | { |
11740 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.readPixels", DOM, cx); |
11741 | 0 |
|
11742 | 0 | if (MOZ_UNLIKELY(args.length() < 7)) { |
11743 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.readPixels"); |
11744 | 0 | } |
11745 | 0 | int32_t arg0; |
11746 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) { |
11747 | 0 | return false; |
11748 | 0 | } |
11749 | 0 | int32_t arg1; |
11750 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
11751 | 0 | return false; |
11752 | 0 | } |
11753 | 0 | int32_t arg2; |
11754 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
11755 | 0 | return false; |
11756 | 0 | } |
11757 | 0 | int32_t arg3; |
11758 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[3], &arg3)) { |
11759 | 0 | return false; |
11760 | 0 | } |
11761 | 0 | uint32_t arg4; |
11762 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[4], &arg4)) { |
11763 | 0 | return false; |
11764 | 0 | } |
11765 | 0 | uint32_t arg5; |
11766 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[5], &arg5)) { |
11767 | 0 | return false; |
11768 | 0 | } |
11769 | 0 | RootedSpiderMonkeyInterface<Nullable<ArrayBufferView>> arg6(cx); |
11770 | 0 | if (args[6].isObject()) { |
11771 | 0 | if (!arg6.SetValue().Init(&args[6].toObject())) { |
11772 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 7 of WebGLRenderingContext.readPixels", "ArrayBufferViewOrNull"); |
11773 | 0 | return false; |
11774 | 0 | } |
11775 | 0 | } else if (args[6].isNullOrUndefined()) { |
11776 | 0 | arg6.SetNull(); |
11777 | 0 | } else { |
11778 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 7 of WebGLRenderingContext.readPixels"); |
11779 | 0 | return false; |
11780 | 0 | } |
11781 | 0 | FastErrorResult rv; |
11782 | 0 | self->ReadPixels(arg0, arg1, arg2, arg3, arg4, arg5, Constify(arg6), nsContentUtils::ThreadsafeIsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv); |
11783 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
11784 | 0 | return false; |
11785 | 0 | } |
11786 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
11787 | 0 | args.rval().setUndefined(); |
11788 | 0 | return true; |
11789 | 0 | } |
11790 | | |
11791 | | static const JSJitInfo readPixels_methodinfo = { |
11792 | | { (JSJitGetterOp)readPixels }, |
11793 | | { prototypes::id::WebGLRenderingContext }, |
11794 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
11795 | | JSJitInfo::Method, |
11796 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
11797 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
11798 | | false, /* isInfallible. False in setters. */ |
11799 | | false, /* isMovable. Not relevant for setters. */ |
11800 | | false, /* isEliminatable. Not relevant for setters. */ |
11801 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
11802 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
11803 | | false, /* isTypedMethod. Only relevant for methods. */ |
11804 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
11805 | | }; |
11806 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
11807 | | static_assert(0 < 1, "There is no slot for us"); |
11808 | | |
11809 | | MOZ_CAN_RUN_SCRIPT static bool |
11810 | | texImage2D(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
11811 | 0 | { |
11812 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.texImage2D", DOM, cx); |
11813 | 0 |
|
11814 | 0 | unsigned argcount = std::min(args.length(), 9u); |
11815 | 0 | switch (argcount) { |
11816 | 0 | case 6: { |
11817 | 0 | uint32_t arg0; |
11818 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
11819 | 0 | return false; |
11820 | 0 | } |
11821 | 0 | int32_t arg1; |
11822 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
11823 | 0 | return false; |
11824 | 0 | } |
11825 | 0 | int32_t arg2; |
11826 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
11827 | 0 | return false; |
11828 | 0 | } |
11829 | 0 | uint32_t arg3; |
11830 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[3], &arg3)) { |
11831 | 0 | return false; |
11832 | 0 | } |
11833 | 0 | uint32_t arg4; |
11834 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[4], &arg4)) { |
11835 | 0 | return false; |
11836 | 0 | } |
11837 | 0 | if (args[5].isObject()) { |
11838 | 0 | do { |
11839 | 0 | NonNull<mozilla::dom::ImageBitmap> arg5; |
11840 | 0 | { |
11841 | 0 | nsresult rv = UnwrapObject<prototypes::id::ImageBitmap, mozilla::dom::ImageBitmap>(args[5], arg5); |
11842 | 0 | if (NS_FAILED(rv)) { |
11843 | 0 | break; |
11844 | 0 | } |
11845 | 0 | } |
11846 | 0 | FastErrorResult rv; |
11847 | 0 | self->TexImage2D(arg0, arg1, arg2, arg3, arg4, MOZ_KnownLive(NonNullHelper(arg5)), rv); |
11848 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
11849 | 0 | return false; |
11850 | 0 | } |
11851 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
11852 | 0 | args.rval().setUndefined(); |
11853 | 0 | return true; |
11854 | 0 | } while (false); |
11855 | 0 | do { |
11856 | 0 | NonNull<mozilla::dom::ImageData> arg5; |
11857 | 0 | { |
11858 | 0 | nsresult rv = UnwrapObject<prototypes::id::ImageData, mozilla::dom::ImageData>(args[5], arg5); |
11859 | 0 | if (NS_FAILED(rv)) { |
11860 | 0 | break; |
11861 | 0 | } |
11862 | 0 | } |
11863 | 0 | FastErrorResult rv; |
11864 | 0 | self->TexImage2D(arg0, arg1, arg2, arg3, arg4, MOZ_KnownLive(NonNullHelper(arg5)), rv); |
11865 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
11866 | 0 | return false; |
11867 | 0 | } |
11868 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
11869 | 0 | args.rval().setUndefined(); |
11870 | 0 | return true; |
11871 | 0 | } while (false); |
11872 | 0 | do { |
11873 | 0 | NonNull<mozilla::dom::HTMLImageElement> arg5; |
11874 | 0 | { |
11875 | 0 | nsresult rv = UnwrapObject<prototypes::id::HTMLImageElement, mozilla::dom::HTMLImageElement>(args[5], arg5); |
11876 | 0 | if (NS_FAILED(rv)) { |
11877 | 0 | break; |
11878 | 0 | } |
11879 | 0 | } |
11880 | 0 | FastErrorResult rv; |
11881 | 0 | self->TexImage2D(arg0, arg1, arg2, arg3, arg4, MOZ_KnownLive(NonNullHelper(arg5)), rv); |
11882 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
11883 | 0 | return false; |
11884 | 0 | } |
11885 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
11886 | 0 | args.rval().setUndefined(); |
11887 | 0 | return true; |
11888 | 0 | } while (false); |
11889 | 0 | do { |
11890 | 0 | NonNull<mozilla::dom::HTMLCanvasElement> arg5; |
11891 | 0 | { |
11892 | 0 | nsresult rv = UnwrapObject<prototypes::id::HTMLCanvasElement, mozilla::dom::HTMLCanvasElement>(args[5], arg5); |
11893 | 0 | if (NS_FAILED(rv)) { |
11894 | 0 | break; |
11895 | 0 | } |
11896 | 0 | } |
11897 | 0 | FastErrorResult rv; |
11898 | 0 | self->TexImage2D(arg0, arg1, arg2, arg3, arg4, MOZ_KnownLive(NonNullHelper(arg5)), rv); |
11899 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
11900 | 0 | return false; |
11901 | 0 | } |
11902 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
11903 | 0 | args.rval().setUndefined(); |
11904 | 0 | return true; |
11905 | 0 | } while (false); |
11906 | 0 | do { |
11907 | 0 | NonNull<mozilla::dom::HTMLVideoElement> arg5; |
11908 | 0 | { |
11909 | 0 | nsresult rv = UnwrapObject<prototypes::id::HTMLVideoElement, mozilla::dom::HTMLVideoElement>(args[5], arg5); |
11910 | 0 | if (NS_FAILED(rv)) { |
11911 | 0 | break; |
11912 | 0 | } |
11913 | 0 | } |
11914 | 0 | FastErrorResult rv; |
11915 | 0 | self->TexImage2D(arg0, arg1, arg2, arg3, arg4, MOZ_KnownLive(NonNullHelper(arg5)), rv); |
11916 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
11917 | 0 | return false; |
11918 | 0 | } |
11919 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
11920 | 0 | args.rval().setUndefined(); |
11921 | 0 | return true; |
11922 | 0 | } while (false); |
11923 | 0 | } |
11924 | 0 | return ThrowErrorMessage(cx, MSG_OVERLOAD_RESOLUTION_FAILED, "6", "6", "WebGLRenderingContext.texImage2D"); |
11925 | 0 | break; |
11926 | 0 | } |
11927 | 0 | case 9: { |
11928 | 0 | uint32_t arg0; |
11929 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
11930 | 0 | return false; |
11931 | 0 | } |
11932 | 0 | int32_t arg1; |
11933 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
11934 | 0 | return false; |
11935 | 0 | } |
11936 | 0 | int32_t arg2; |
11937 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
11938 | 0 | return false; |
11939 | 0 | } |
11940 | 0 | int32_t arg3; |
11941 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[3], &arg3)) { |
11942 | 0 | return false; |
11943 | 0 | } |
11944 | 0 | int32_t arg4; |
11945 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) { |
11946 | 0 | return false; |
11947 | 0 | } |
11948 | 0 | int32_t arg5; |
11949 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[5], &arg5)) { |
11950 | 0 | return false; |
11951 | 0 | } |
11952 | 0 | uint32_t arg6; |
11953 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[6], &arg6)) { |
11954 | 0 | return false; |
11955 | 0 | } |
11956 | 0 | uint32_t arg7; |
11957 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[7], &arg7)) { |
11958 | 0 | return false; |
11959 | 0 | } |
11960 | 0 | RootedSpiderMonkeyInterface<Nullable<ArrayBufferView>> arg8(cx); |
11961 | 0 | if (args[8].isObject()) { |
11962 | 0 | if (!arg8.SetValue().Init(&args[8].toObject())) { |
11963 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 9 of WebGLRenderingContext.texImage2D", "ArrayBufferViewOrNull"); |
11964 | 0 | return false; |
11965 | 0 | } |
11966 | 0 | } else if (args[8].isNullOrUndefined()) { |
11967 | 0 | arg8.SetNull(); |
11968 | 0 | } else { |
11969 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 9 of WebGLRenderingContext.texImage2D"); |
11970 | 0 | return false; |
11971 | 0 | } |
11972 | 0 | FastErrorResult rv; |
11973 | 0 | self->TexImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, Constify(arg8), rv); |
11974 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
11975 | 0 | return false; |
11976 | 0 | } |
11977 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
11978 | 0 | args.rval().setUndefined(); |
11979 | 0 | return true; |
11980 | 0 | break; |
11981 | 0 | } |
11982 | 0 | default: { |
11983 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.texImage2D"); |
11984 | 0 | break; |
11985 | 0 | } |
11986 | 0 | } |
11987 | 0 | MOZ_CRASH("We have an always-returning default case"); |
11988 | 0 | return false; |
11989 | 0 | } |
11990 | | |
11991 | | static const JSJitInfo texImage2D_methodinfo = { |
11992 | | { (JSJitGetterOp)texImage2D }, |
11993 | | { prototypes::id::WebGLRenderingContext }, |
11994 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
11995 | | JSJitInfo::Method, |
11996 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
11997 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
11998 | | false, /* isInfallible. False in setters. */ |
11999 | | false, /* isMovable. Not relevant for setters. */ |
12000 | | false, /* isEliminatable. Not relevant for setters. */ |
12001 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
12002 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
12003 | | false, /* isTypedMethod. Only relevant for methods. */ |
12004 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
12005 | | }; |
12006 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
12007 | | static_assert(0 < 1, "There is no slot for us"); |
12008 | | |
12009 | | MOZ_CAN_RUN_SCRIPT static bool |
12010 | | texSubImage2D(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
12011 | 0 | { |
12012 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.texSubImage2D", DOM, cx); |
12013 | 0 |
|
12014 | 0 | unsigned argcount = std::min(args.length(), 9u); |
12015 | 0 | switch (argcount) { |
12016 | 0 | case 7: { |
12017 | 0 | uint32_t arg0; |
12018 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
12019 | 0 | return false; |
12020 | 0 | } |
12021 | 0 | int32_t arg1; |
12022 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
12023 | 0 | return false; |
12024 | 0 | } |
12025 | 0 | int32_t arg2; |
12026 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
12027 | 0 | return false; |
12028 | 0 | } |
12029 | 0 | int32_t arg3; |
12030 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[3], &arg3)) { |
12031 | 0 | return false; |
12032 | 0 | } |
12033 | 0 | uint32_t arg4; |
12034 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[4], &arg4)) { |
12035 | 0 | return false; |
12036 | 0 | } |
12037 | 0 | uint32_t arg5; |
12038 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[5], &arg5)) { |
12039 | 0 | return false; |
12040 | 0 | } |
12041 | 0 | if (args[6].isObject()) { |
12042 | 0 | do { |
12043 | 0 | NonNull<mozilla::dom::ImageBitmap> arg6; |
12044 | 0 | { |
12045 | 0 | nsresult rv = UnwrapObject<prototypes::id::ImageBitmap, mozilla::dom::ImageBitmap>(args[6], arg6); |
12046 | 0 | if (NS_FAILED(rv)) { |
12047 | 0 | break; |
12048 | 0 | } |
12049 | 0 | } |
12050 | 0 | FastErrorResult rv; |
12051 | 0 | self->TexSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, MOZ_KnownLive(NonNullHelper(arg6)), rv); |
12052 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
12053 | 0 | return false; |
12054 | 0 | } |
12055 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12056 | 0 | args.rval().setUndefined(); |
12057 | 0 | return true; |
12058 | 0 | } while (false); |
12059 | 0 | do { |
12060 | 0 | NonNull<mozilla::dom::ImageData> arg6; |
12061 | 0 | { |
12062 | 0 | nsresult rv = UnwrapObject<prototypes::id::ImageData, mozilla::dom::ImageData>(args[6], arg6); |
12063 | 0 | if (NS_FAILED(rv)) { |
12064 | 0 | break; |
12065 | 0 | } |
12066 | 0 | } |
12067 | 0 | FastErrorResult rv; |
12068 | 0 | self->TexSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, MOZ_KnownLive(NonNullHelper(arg6)), rv); |
12069 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
12070 | 0 | return false; |
12071 | 0 | } |
12072 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12073 | 0 | args.rval().setUndefined(); |
12074 | 0 | return true; |
12075 | 0 | } while (false); |
12076 | 0 | do { |
12077 | 0 | NonNull<mozilla::dom::HTMLImageElement> arg6; |
12078 | 0 | { |
12079 | 0 | nsresult rv = UnwrapObject<prototypes::id::HTMLImageElement, mozilla::dom::HTMLImageElement>(args[6], arg6); |
12080 | 0 | if (NS_FAILED(rv)) { |
12081 | 0 | break; |
12082 | 0 | } |
12083 | 0 | } |
12084 | 0 | FastErrorResult rv; |
12085 | 0 | self->TexSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, MOZ_KnownLive(NonNullHelper(arg6)), rv); |
12086 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
12087 | 0 | return false; |
12088 | 0 | } |
12089 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12090 | 0 | args.rval().setUndefined(); |
12091 | 0 | return true; |
12092 | 0 | } while (false); |
12093 | 0 | do { |
12094 | 0 | NonNull<mozilla::dom::HTMLCanvasElement> arg6; |
12095 | 0 | { |
12096 | 0 | nsresult rv = UnwrapObject<prototypes::id::HTMLCanvasElement, mozilla::dom::HTMLCanvasElement>(args[6], arg6); |
12097 | 0 | if (NS_FAILED(rv)) { |
12098 | 0 | break; |
12099 | 0 | } |
12100 | 0 | } |
12101 | 0 | FastErrorResult rv; |
12102 | 0 | self->TexSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, MOZ_KnownLive(NonNullHelper(arg6)), rv); |
12103 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
12104 | 0 | return false; |
12105 | 0 | } |
12106 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12107 | 0 | args.rval().setUndefined(); |
12108 | 0 | return true; |
12109 | 0 | } while (false); |
12110 | 0 | do { |
12111 | 0 | NonNull<mozilla::dom::HTMLVideoElement> arg6; |
12112 | 0 | { |
12113 | 0 | nsresult rv = UnwrapObject<prototypes::id::HTMLVideoElement, mozilla::dom::HTMLVideoElement>(args[6], arg6); |
12114 | 0 | if (NS_FAILED(rv)) { |
12115 | 0 | break; |
12116 | 0 | } |
12117 | 0 | } |
12118 | 0 | FastErrorResult rv; |
12119 | 0 | self->TexSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, MOZ_KnownLive(NonNullHelper(arg6)), rv); |
12120 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
12121 | 0 | return false; |
12122 | 0 | } |
12123 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12124 | 0 | args.rval().setUndefined(); |
12125 | 0 | return true; |
12126 | 0 | } while (false); |
12127 | 0 | } |
12128 | 0 | return ThrowErrorMessage(cx, MSG_OVERLOAD_RESOLUTION_FAILED, "7", "7", "WebGLRenderingContext.texSubImage2D"); |
12129 | 0 | break; |
12130 | 0 | } |
12131 | 0 | case 9: { |
12132 | 0 | uint32_t arg0; |
12133 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
12134 | 0 | return false; |
12135 | 0 | } |
12136 | 0 | int32_t arg1; |
12137 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
12138 | 0 | return false; |
12139 | 0 | } |
12140 | 0 | int32_t arg2; |
12141 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
12142 | 0 | return false; |
12143 | 0 | } |
12144 | 0 | int32_t arg3; |
12145 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[3], &arg3)) { |
12146 | 0 | return false; |
12147 | 0 | } |
12148 | 0 | int32_t arg4; |
12149 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) { |
12150 | 0 | return false; |
12151 | 0 | } |
12152 | 0 | int32_t arg5; |
12153 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[5], &arg5)) { |
12154 | 0 | return false; |
12155 | 0 | } |
12156 | 0 | uint32_t arg6; |
12157 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[6], &arg6)) { |
12158 | 0 | return false; |
12159 | 0 | } |
12160 | 0 | uint32_t arg7; |
12161 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[7], &arg7)) { |
12162 | 0 | return false; |
12163 | 0 | } |
12164 | 0 | RootedSpiderMonkeyInterface<Nullable<ArrayBufferView>> arg8(cx); |
12165 | 0 | if (args[8].isObject()) { |
12166 | 0 | if (!arg8.SetValue().Init(&args[8].toObject())) { |
12167 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 9 of WebGLRenderingContext.texSubImage2D", "ArrayBufferViewOrNull"); |
12168 | 0 | return false; |
12169 | 0 | } |
12170 | 0 | } else if (args[8].isNullOrUndefined()) { |
12171 | 0 | arg8.SetNull(); |
12172 | 0 | } else { |
12173 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 9 of WebGLRenderingContext.texSubImage2D"); |
12174 | 0 | return false; |
12175 | 0 | } |
12176 | 0 | FastErrorResult rv; |
12177 | 0 | self->TexSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, Constify(arg8), rv); |
12178 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
12179 | 0 | return false; |
12180 | 0 | } |
12181 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12182 | 0 | args.rval().setUndefined(); |
12183 | 0 | return true; |
12184 | 0 | break; |
12185 | 0 | } |
12186 | 0 | default: { |
12187 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.texSubImage2D"); |
12188 | 0 | break; |
12189 | 0 | } |
12190 | 0 | } |
12191 | 0 | MOZ_CRASH("We have an always-returning default case"); |
12192 | 0 | return false; |
12193 | 0 | } |
12194 | | |
12195 | | static const JSJitInfo texSubImage2D_methodinfo = { |
12196 | | { (JSJitGetterOp)texSubImage2D }, |
12197 | | { prototypes::id::WebGLRenderingContext }, |
12198 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
12199 | | JSJitInfo::Method, |
12200 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
12201 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
12202 | | false, /* isInfallible. False in setters. */ |
12203 | | false, /* isMovable. Not relevant for setters. */ |
12204 | | false, /* isEliminatable. Not relevant for setters. */ |
12205 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
12206 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
12207 | | false, /* isTypedMethod. Only relevant for methods. */ |
12208 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
12209 | | }; |
12210 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
12211 | | static_assert(0 < 1, "There is no slot for us"); |
12212 | | |
12213 | | MOZ_CAN_RUN_SCRIPT static bool |
12214 | | uniform1fv(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
12215 | 0 | { |
12216 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniform1fv", DOM, cx); |
12217 | 0 |
|
12218 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
12219 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniform1fv"); |
12220 | 0 | } |
12221 | 0 | mozilla::WebGLUniformLocation* arg0; |
12222 | 0 | if (args[0].isObject()) { |
12223 | 0 | { |
12224 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
12225 | 0 | if (NS_FAILED(rv)) { |
12226 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniform1fv", "WebGLUniformLocation"); |
12227 | 0 | return false; |
12228 | 0 | } |
12229 | 0 | } |
12230 | 0 | } else if (args[0].isNullOrUndefined()) { |
12231 | 0 | arg0 = nullptr; |
12232 | 0 | } else { |
12233 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniform1fv"); |
12234 | 0 | return false; |
12235 | 0 | } |
12236 | 0 | Float32ArrayOrUnrestrictedFloatSequence arg1; |
12237 | 0 | Float32ArrayOrUnrestrictedFloatSequenceArgument arg1_holder(arg1); |
12238 | 0 | { |
12239 | 0 | bool done = false, failed = false, tryNext; |
12240 | 0 | if (args[1].isObject()) { |
12241 | 0 | done = (failed = !arg1_holder.TrySetToFloat32Array(cx, args[1], tryNext, false)) || !tryNext; |
12242 | 0 |
|
12243 | 0 | if (!done) { |
12244 | 0 | done = (failed = !arg1_holder.TrySetToUnrestrictedFloatSequence(cx, args[1], tryNext, false)) || !tryNext; |
12245 | 0 | } |
12246 | 0 | } |
12247 | 0 | if (failed) { |
12248 | 0 | return false; |
12249 | 0 | } |
12250 | 0 | if (!done) { |
12251 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of WebGLRenderingContext.uniform1fv", "Float32Array, UnrestrictedFloatSequence"); |
12252 | 0 | return false; |
12253 | 0 | } |
12254 | 0 | } |
12255 | 0 | self->Uniform1fv(MOZ_KnownLive(Constify(arg0)), Constify(arg1)); |
12256 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12257 | 0 | args.rval().setUndefined(); |
12258 | 0 | return true; |
12259 | 0 | } |
12260 | | |
12261 | | static const JSJitInfo uniform1fv_methodinfo = { |
12262 | | { (JSJitGetterOp)uniform1fv }, |
12263 | | { prototypes::id::WebGLRenderingContext }, |
12264 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
12265 | | JSJitInfo::Method, |
12266 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
12267 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
12268 | | false, /* isInfallible. False in setters. */ |
12269 | | false, /* isMovable. Not relevant for setters. */ |
12270 | | false, /* isEliminatable. Not relevant for setters. */ |
12271 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
12272 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
12273 | | false, /* isTypedMethod. Only relevant for methods. */ |
12274 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
12275 | | }; |
12276 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
12277 | | static_assert(0 < 1, "There is no slot for us"); |
12278 | | |
12279 | | MOZ_CAN_RUN_SCRIPT static bool |
12280 | | uniform2fv(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
12281 | 0 | { |
12282 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniform2fv", DOM, cx); |
12283 | 0 |
|
12284 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
12285 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniform2fv"); |
12286 | 0 | } |
12287 | 0 | mozilla::WebGLUniformLocation* arg0; |
12288 | 0 | if (args[0].isObject()) { |
12289 | 0 | { |
12290 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
12291 | 0 | if (NS_FAILED(rv)) { |
12292 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniform2fv", "WebGLUniformLocation"); |
12293 | 0 | return false; |
12294 | 0 | } |
12295 | 0 | } |
12296 | 0 | } else if (args[0].isNullOrUndefined()) { |
12297 | 0 | arg0 = nullptr; |
12298 | 0 | } else { |
12299 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniform2fv"); |
12300 | 0 | return false; |
12301 | 0 | } |
12302 | 0 | Float32ArrayOrUnrestrictedFloatSequence arg1; |
12303 | 0 | Float32ArrayOrUnrestrictedFloatSequenceArgument arg1_holder(arg1); |
12304 | 0 | { |
12305 | 0 | bool done = false, failed = false, tryNext; |
12306 | 0 | if (args[1].isObject()) { |
12307 | 0 | done = (failed = !arg1_holder.TrySetToFloat32Array(cx, args[1], tryNext, false)) || !tryNext; |
12308 | 0 |
|
12309 | 0 | if (!done) { |
12310 | 0 | done = (failed = !arg1_holder.TrySetToUnrestrictedFloatSequence(cx, args[1], tryNext, false)) || !tryNext; |
12311 | 0 | } |
12312 | 0 | } |
12313 | 0 | if (failed) { |
12314 | 0 | return false; |
12315 | 0 | } |
12316 | 0 | if (!done) { |
12317 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of WebGLRenderingContext.uniform2fv", "Float32Array, UnrestrictedFloatSequence"); |
12318 | 0 | return false; |
12319 | 0 | } |
12320 | 0 | } |
12321 | 0 | self->Uniform2fv(MOZ_KnownLive(Constify(arg0)), Constify(arg1)); |
12322 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12323 | 0 | args.rval().setUndefined(); |
12324 | 0 | return true; |
12325 | 0 | } |
12326 | | |
12327 | | static const JSJitInfo uniform2fv_methodinfo = { |
12328 | | { (JSJitGetterOp)uniform2fv }, |
12329 | | { prototypes::id::WebGLRenderingContext }, |
12330 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
12331 | | JSJitInfo::Method, |
12332 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
12333 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
12334 | | false, /* isInfallible. False in setters. */ |
12335 | | false, /* isMovable. Not relevant for setters. */ |
12336 | | false, /* isEliminatable. Not relevant for setters. */ |
12337 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
12338 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
12339 | | false, /* isTypedMethod. Only relevant for methods. */ |
12340 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
12341 | | }; |
12342 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
12343 | | static_assert(0 < 1, "There is no slot for us"); |
12344 | | |
12345 | | MOZ_CAN_RUN_SCRIPT static bool |
12346 | | uniform3fv(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
12347 | 0 | { |
12348 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniform3fv", DOM, cx); |
12349 | 0 |
|
12350 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
12351 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniform3fv"); |
12352 | 0 | } |
12353 | 0 | mozilla::WebGLUniformLocation* arg0; |
12354 | 0 | if (args[0].isObject()) { |
12355 | 0 | { |
12356 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
12357 | 0 | if (NS_FAILED(rv)) { |
12358 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniform3fv", "WebGLUniformLocation"); |
12359 | 0 | return false; |
12360 | 0 | } |
12361 | 0 | } |
12362 | 0 | } else if (args[0].isNullOrUndefined()) { |
12363 | 0 | arg0 = nullptr; |
12364 | 0 | } else { |
12365 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniform3fv"); |
12366 | 0 | return false; |
12367 | 0 | } |
12368 | 0 | Float32ArrayOrUnrestrictedFloatSequence arg1; |
12369 | 0 | Float32ArrayOrUnrestrictedFloatSequenceArgument arg1_holder(arg1); |
12370 | 0 | { |
12371 | 0 | bool done = false, failed = false, tryNext; |
12372 | 0 | if (args[1].isObject()) { |
12373 | 0 | done = (failed = !arg1_holder.TrySetToFloat32Array(cx, args[1], tryNext, false)) || !tryNext; |
12374 | 0 |
|
12375 | 0 | if (!done) { |
12376 | 0 | done = (failed = !arg1_holder.TrySetToUnrestrictedFloatSequence(cx, args[1], tryNext, false)) || !tryNext; |
12377 | 0 | } |
12378 | 0 | } |
12379 | 0 | if (failed) { |
12380 | 0 | return false; |
12381 | 0 | } |
12382 | 0 | if (!done) { |
12383 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of WebGLRenderingContext.uniform3fv", "Float32Array, UnrestrictedFloatSequence"); |
12384 | 0 | return false; |
12385 | 0 | } |
12386 | 0 | } |
12387 | 0 | self->Uniform3fv(MOZ_KnownLive(Constify(arg0)), Constify(arg1)); |
12388 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12389 | 0 | args.rval().setUndefined(); |
12390 | 0 | return true; |
12391 | 0 | } |
12392 | | |
12393 | | static const JSJitInfo uniform3fv_methodinfo = { |
12394 | | { (JSJitGetterOp)uniform3fv }, |
12395 | | { prototypes::id::WebGLRenderingContext }, |
12396 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
12397 | | JSJitInfo::Method, |
12398 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
12399 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
12400 | | false, /* isInfallible. False in setters. */ |
12401 | | false, /* isMovable. Not relevant for setters. */ |
12402 | | false, /* isEliminatable. Not relevant for setters. */ |
12403 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
12404 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
12405 | | false, /* isTypedMethod. Only relevant for methods. */ |
12406 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
12407 | | }; |
12408 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
12409 | | static_assert(0 < 1, "There is no slot for us"); |
12410 | | |
12411 | | MOZ_CAN_RUN_SCRIPT static bool |
12412 | | uniform4fv(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
12413 | 0 | { |
12414 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniform4fv", DOM, cx); |
12415 | 0 |
|
12416 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
12417 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniform4fv"); |
12418 | 0 | } |
12419 | 0 | mozilla::WebGLUniformLocation* arg0; |
12420 | 0 | if (args[0].isObject()) { |
12421 | 0 | { |
12422 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
12423 | 0 | if (NS_FAILED(rv)) { |
12424 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniform4fv", "WebGLUniformLocation"); |
12425 | 0 | return false; |
12426 | 0 | } |
12427 | 0 | } |
12428 | 0 | } else if (args[0].isNullOrUndefined()) { |
12429 | 0 | arg0 = nullptr; |
12430 | 0 | } else { |
12431 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniform4fv"); |
12432 | 0 | return false; |
12433 | 0 | } |
12434 | 0 | Float32ArrayOrUnrestrictedFloatSequence arg1; |
12435 | 0 | Float32ArrayOrUnrestrictedFloatSequenceArgument arg1_holder(arg1); |
12436 | 0 | { |
12437 | 0 | bool done = false, failed = false, tryNext; |
12438 | 0 | if (args[1].isObject()) { |
12439 | 0 | done = (failed = !arg1_holder.TrySetToFloat32Array(cx, args[1], tryNext, false)) || !tryNext; |
12440 | 0 |
|
12441 | 0 | if (!done) { |
12442 | 0 | done = (failed = !arg1_holder.TrySetToUnrestrictedFloatSequence(cx, args[1], tryNext, false)) || !tryNext; |
12443 | 0 | } |
12444 | 0 | } |
12445 | 0 | if (failed) { |
12446 | 0 | return false; |
12447 | 0 | } |
12448 | 0 | if (!done) { |
12449 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of WebGLRenderingContext.uniform4fv", "Float32Array, UnrestrictedFloatSequence"); |
12450 | 0 | return false; |
12451 | 0 | } |
12452 | 0 | } |
12453 | 0 | self->Uniform4fv(MOZ_KnownLive(Constify(arg0)), Constify(arg1)); |
12454 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12455 | 0 | args.rval().setUndefined(); |
12456 | 0 | return true; |
12457 | 0 | } |
12458 | | |
12459 | | static const JSJitInfo uniform4fv_methodinfo = { |
12460 | | { (JSJitGetterOp)uniform4fv }, |
12461 | | { prototypes::id::WebGLRenderingContext }, |
12462 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
12463 | | JSJitInfo::Method, |
12464 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
12465 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
12466 | | false, /* isInfallible. False in setters. */ |
12467 | | false, /* isMovable. Not relevant for setters. */ |
12468 | | false, /* isEliminatable. Not relevant for setters. */ |
12469 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
12470 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
12471 | | false, /* isTypedMethod. Only relevant for methods. */ |
12472 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
12473 | | }; |
12474 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
12475 | | static_assert(0 < 1, "There is no slot for us"); |
12476 | | |
12477 | | MOZ_CAN_RUN_SCRIPT static bool |
12478 | | uniform1iv(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
12479 | 0 | { |
12480 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniform1iv", DOM, cx); |
12481 | 0 |
|
12482 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
12483 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniform1iv"); |
12484 | 0 | } |
12485 | 0 | mozilla::WebGLUniformLocation* arg0; |
12486 | 0 | if (args[0].isObject()) { |
12487 | 0 | { |
12488 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
12489 | 0 | if (NS_FAILED(rv)) { |
12490 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniform1iv", "WebGLUniformLocation"); |
12491 | 0 | return false; |
12492 | 0 | } |
12493 | 0 | } |
12494 | 0 | } else if (args[0].isNullOrUndefined()) { |
12495 | 0 | arg0 = nullptr; |
12496 | 0 | } else { |
12497 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniform1iv"); |
12498 | 0 | return false; |
12499 | 0 | } |
12500 | 0 | Int32ArrayOrLongSequence arg1; |
12501 | 0 | Int32ArrayOrLongSequenceArgument arg1_holder(arg1); |
12502 | 0 | { |
12503 | 0 | bool done = false, failed = false, tryNext; |
12504 | 0 | if (args[1].isObject()) { |
12505 | 0 | done = (failed = !arg1_holder.TrySetToInt32Array(cx, args[1], tryNext, false)) || !tryNext; |
12506 | 0 |
|
12507 | 0 | if (!done) { |
12508 | 0 | done = (failed = !arg1_holder.TrySetToLongSequence(cx, args[1], tryNext, false)) || !tryNext; |
12509 | 0 | } |
12510 | 0 | } |
12511 | 0 | if (failed) { |
12512 | 0 | return false; |
12513 | 0 | } |
12514 | 0 | if (!done) { |
12515 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of WebGLRenderingContext.uniform1iv", "Int32Array, LongSequence"); |
12516 | 0 | return false; |
12517 | 0 | } |
12518 | 0 | } |
12519 | 0 | self->Uniform1iv(MOZ_KnownLive(Constify(arg0)), Constify(arg1)); |
12520 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12521 | 0 | args.rval().setUndefined(); |
12522 | 0 | return true; |
12523 | 0 | } |
12524 | | |
12525 | | static const JSJitInfo uniform1iv_methodinfo = { |
12526 | | { (JSJitGetterOp)uniform1iv }, |
12527 | | { prototypes::id::WebGLRenderingContext }, |
12528 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
12529 | | JSJitInfo::Method, |
12530 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
12531 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
12532 | | false, /* isInfallible. False in setters. */ |
12533 | | false, /* isMovable. Not relevant for setters. */ |
12534 | | false, /* isEliminatable. Not relevant for setters. */ |
12535 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
12536 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
12537 | | false, /* isTypedMethod. Only relevant for methods. */ |
12538 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
12539 | | }; |
12540 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
12541 | | static_assert(0 < 1, "There is no slot for us"); |
12542 | | |
12543 | | MOZ_CAN_RUN_SCRIPT static bool |
12544 | | uniform2iv(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
12545 | 0 | { |
12546 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniform2iv", DOM, cx); |
12547 | 0 |
|
12548 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
12549 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniform2iv"); |
12550 | 0 | } |
12551 | 0 | mozilla::WebGLUniformLocation* arg0; |
12552 | 0 | if (args[0].isObject()) { |
12553 | 0 | { |
12554 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
12555 | 0 | if (NS_FAILED(rv)) { |
12556 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniform2iv", "WebGLUniformLocation"); |
12557 | 0 | return false; |
12558 | 0 | } |
12559 | 0 | } |
12560 | 0 | } else if (args[0].isNullOrUndefined()) { |
12561 | 0 | arg0 = nullptr; |
12562 | 0 | } else { |
12563 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniform2iv"); |
12564 | 0 | return false; |
12565 | 0 | } |
12566 | 0 | Int32ArrayOrLongSequence arg1; |
12567 | 0 | Int32ArrayOrLongSequenceArgument arg1_holder(arg1); |
12568 | 0 | { |
12569 | 0 | bool done = false, failed = false, tryNext; |
12570 | 0 | if (args[1].isObject()) { |
12571 | 0 | done = (failed = !arg1_holder.TrySetToInt32Array(cx, args[1], tryNext, false)) || !tryNext; |
12572 | 0 |
|
12573 | 0 | if (!done) { |
12574 | 0 | done = (failed = !arg1_holder.TrySetToLongSequence(cx, args[1], tryNext, false)) || !tryNext; |
12575 | 0 | } |
12576 | 0 | } |
12577 | 0 | if (failed) { |
12578 | 0 | return false; |
12579 | 0 | } |
12580 | 0 | if (!done) { |
12581 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of WebGLRenderingContext.uniform2iv", "Int32Array, LongSequence"); |
12582 | 0 | return false; |
12583 | 0 | } |
12584 | 0 | } |
12585 | 0 | self->Uniform2iv(MOZ_KnownLive(Constify(arg0)), Constify(arg1)); |
12586 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12587 | 0 | args.rval().setUndefined(); |
12588 | 0 | return true; |
12589 | 0 | } |
12590 | | |
12591 | | static const JSJitInfo uniform2iv_methodinfo = { |
12592 | | { (JSJitGetterOp)uniform2iv }, |
12593 | | { prototypes::id::WebGLRenderingContext }, |
12594 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
12595 | | JSJitInfo::Method, |
12596 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
12597 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
12598 | | false, /* isInfallible. False in setters. */ |
12599 | | false, /* isMovable. Not relevant for setters. */ |
12600 | | false, /* isEliminatable. Not relevant for setters. */ |
12601 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
12602 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
12603 | | false, /* isTypedMethod. Only relevant for methods. */ |
12604 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
12605 | | }; |
12606 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
12607 | | static_assert(0 < 1, "There is no slot for us"); |
12608 | | |
12609 | | MOZ_CAN_RUN_SCRIPT static bool |
12610 | | uniform3iv(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
12611 | 0 | { |
12612 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniform3iv", DOM, cx); |
12613 | 0 |
|
12614 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
12615 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniform3iv"); |
12616 | 0 | } |
12617 | 0 | mozilla::WebGLUniformLocation* arg0; |
12618 | 0 | if (args[0].isObject()) { |
12619 | 0 | { |
12620 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
12621 | 0 | if (NS_FAILED(rv)) { |
12622 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniform3iv", "WebGLUniformLocation"); |
12623 | 0 | return false; |
12624 | 0 | } |
12625 | 0 | } |
12626 | 0 | } else if (args[0].isNullOrUndefined()) { |
12627 | 0 | arg0 = nullptr; |
12628 | 0 | } else { |
12629 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniform3iv"); |
12630 | 0 | return false; |
12631 | 0 | } |
12632 | 0 | Int32ArrayOrLongSequence arg1; |
12633 | 0 | Int32ArrayOrLongSequenceArgument arg1_holder(arg1); |
12634 | 0 | { |
12635 | 0 | bool done = false, failed = false, tryNext; |
12636 | 0 | if (args[1].isObject()) { |
12637 | 0 | done = (failed = !arg1_holder.TrySetToInt32Array(cx, args[1], tryNext, false)) || !tryNext; |
12638 | 0 |
|
12639 | 0 | if (!done) { |
12640 | 0 | done = (failed = !arg1_holder.TrySetToLongSequence(cx, args[1], tryNext, false)) || !tryNext; |
12641 | 0 | } |
12642 | 0 | } |
12643 | 0 | if (failed) { |
12644 | 0 | return false; |
12645 | 0 | } |
12646 | 0 | if (!done) { |
12647 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of WebGLRenderingContext.uniform3iv", "Int32Array, LongSequence"); |
12648 | 0 | return false; |
12649 | 0 | } |
12650 | 0 | } |
12651 | 0 | self->Uniform3iv(MOZ_KnownLive(Constify(arg0)), Constify(arg1)); |
12652 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12653 | 0 | args.rval().setUndefined(); |
12654 | 0 | return true; |
12655 | 0 | } |
12656 | | |
12657 | | static const JSJitInfo uniform3iv_methodinfo = { |
12658 | | { (JSJitGetterOp)uniform3iv }, |
12659 | | { prototypes::id::WebGLRenderingContext }, |
12660 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
12661 | | JSJitInfo::Method, |
12662 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
12663 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
12664 | | false, /* isInfallible. False in setters. */ |
12665 | | false, /* isMovable. Not relevant for setters. */ |
12666 | | false, /* isEliminatable. Not relevant for setters. */ |
12667 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
12668 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
12669 | | false, /* isTypedMethod. Only relevant for methods. */ |
12670 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
12671 | | }; |
12672 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
12673 | | static_assert(0 < 1, "There is no slot for us"); |
12674 | | |
12675 | | MOZ_CAN_RUN_SCRIPT static bool |
12676 | | uniform4iv(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
12677 | 0 | { |
12678 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniform4iv", DOM, cx); |
12679 | 0 |
|
12680 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
12681 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniform4iv"); |
12682 | 0 | } |
12683 | 0 | mozilla::WebGLUniformLocation* arg0; |
12684 | 0 | if (args[0].isObject()) { |
12685 | 0 | { |
12686 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
12687 | 0 | if (NS_FAILED(rv)) { |
12688 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniform4iv", "WebGLUniformLocation"); |
12689 | 0 | return false; |
12690 | 0 | } |
12691 | 0 | } |
12692 | 0 | } else if (args[0].isNullOrUndefined()) { |
12693 | 0 | arg0 = nullptr; |
12694 | 0 | } else { |
12695 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniform4iv"); |
12696 | 0 | return false; |
12697 | 0 | } |
12698 | 0 | Int32ArrayOrLongSequence arg1; |
12699 | 0 | Int32ArrayOrLongSequenceArgument arg1_holder(arg1); |
12700 | 0 | { |
12701 | 0 | bool done = false, failed = false, tryNext; |
12702 | 0 | if (args[1].isObject()) { |
12703 | 0 | done = (failed = !arg1_holder.TrySetToInt32Array(cx, args[1], tryNext, false)) || !tryNext; |
12704 | 0 |
|
12705 | 0 | if (!done) { |
12706 | 0 | done = (failed = !arg1_holder.TrySetToLongSequence(cx, args[1], tryNext, false)) || !tryNext; |
12707 | 0 | } |
12708 | 0 | } |
12709 | 0 | if (failed) { |
12710 | 0 | return false; |
12711 | 0 | } |
12712 | 0 | if (!done) { |
12713 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of WebGLRenderingContext.uniform4iv", "Int32Array, LongSequence"); |
12714 | 0 | return false; |
12715 | 0 | } |
12716 | 0 | } |
12717 | 0 | self->Uniform4iv(MOZ_KnownLive(Constify(arg0)), Constify(arg1)); |
12718 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12719 | 0 | args.rval().setUndefined(); |
12720 | 0 | return true; |
12721 | 0 | } |
12722 | | |
12723 | | static const JSJitInfo uniform4iv_methodinfo = { |
12724 | | { (JSJitGetterOp)uniform4iv }, |
12725 | | { prototypes::id::WebGLRenderingContext }, |
12726 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
12727 | | JSJitInfo::Method, |
12728 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
12729 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
12730 | | false, /* isInfallible. False in setters. */ |
12731 | | false, /* isMovable. Not relevant for setters. */ |
12732 | | false, /* isEliminatable. Not relevant for setters. */ |
12733 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
12734 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
12735 | | false, /* isTypedMethod. Only relevant for methods. */ |
12736 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
12737 | | }; |
12738 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
12739 | | static_assert(0 < 1, "There is no slot for us"); |
12740 | | |
12741 | | MOZ_CAN_RUN_SCRIPT static bool |
12742 | | uniformMatrix2fv(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
12743 | 0 | { |
12744 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniformMatrix2fv", DOM, cx); |
12745 | 0 |
|
12746 | 0 | if (MOZ_UNLIKELY(args.length() < 3)) { |
12747 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniformMatrix2fv"); |
12748 | 0 | } |
12749 | 0 | mozilla::WebGLUniformLocation* arg0; |
12750 | 0 | if (args[0].isObject()) { |
12751 | 0 | { |
12752 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
12753 | 0 | if (NS_FAILED(rv)) { |
12754 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniformMatrix2fv", "WebGLUniformLocation"); |
12755 | 0 | return false; |
12756 | 0 | } |
12757 | 0 | } |
12758 | 0 | } else if (args[0].isNullOrUndefined()) { |
12759 | 0 | arg0 = nullptr; |
12760 | 0 | } else { |
12761 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniformMatrix2fv"); |
12762 | 0 | return false; |
12763 | 0 | } |
12764 | 0 | bool arg1; |
12765 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) { |
12766 | 0 | return false; |
12767 | 0 | } |
12768 | 0 | Float32ArrayOrUnrestrictedFloatSequence arg2; |
12769 | 0 | Float32ArrayOrUnrestrictedFloatSequenceArgument arg2_holder(arg2); |
12770 | 0 | { |
12771 | 0 | bool done = false, failed = false, tryNext; |
12772 | 0 | if (args[2].isObject()) { |
12773 | 0 | done = (failed = !arg2_holder.TrySetToFloat32Array(cx, args[2], tryNext, false)) || !tryNext; |
12774 | 0 |
|
12775 | 0 | if (!done) { |
12776 | 0 | done = (failed = !arg2_holder.TrySetToUnrestrictedFloatSequence(cx, args[2], tryNext, false)) || !tryNext; |
12777 | 0 | } |
12778 | 0 | } |
12779 | 0 | if (failed) { |
12780 | 0 | return false; |
12781 | 0 | } |
12782 | 0 | if (!done) { |
12783 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 3 of WebGLRenderingContext.uniformMatrix2fv", "Float32Array, UnrestrictedFloatSequence"); |
12784 | 0 | return false; |
12785 | 0 | } |
12786 | 0 | } |
12787 | 0 | self->UniformMatrix2fv(MOZ_KnownLive(Constify(arg0)), arg1, Constify(arg2)); |
12788 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12789 | 0 | args.rval().setUndefined(); |
12790 | 0 | return true; |
12791 | 0 | } |
12792 | | |
12793 | | static const JSJitInfo uniformMatrix2fv_methodinfo = { |
12794 | | { (JSJitGetterOp)uniformMatrix2fv }, |
12795 | | { prototypes::id::WebGLRenderingContext }, |
12796 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
12797 | | JSJitInfo::Method, |
12798 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
12799 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
12800 | | false, /* isInfallible. False in setters. */ |
12801 | | false, /* isMovable. Not relevant for setters. */ |
12802 | | false, /* isEliminatable. Not relevant for setters. */ |
12803 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
12804 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
12805 | | false, /* isTypedMethod. Only relevant for methods. */ |
12806 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
12807 | | }; |
12808 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
12809 | | static_assert(0 < 1, "There is no slot for us"); |
12810 | | |
12811 | | MOZ_CAN_RUN_SCRIPT static bool |
12812 | | uniformMatrix3fv(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
12813 | 0 | { |
12814 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniformMatrix3fv", DOM, cx); |
12815 | 0 |
|
12816 | 0 | if (MOZ_UNLIKELY(args.length() < 3)) { |
12817 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniformMatrix3fv"); |
12818 | 0 | } |
12819 | 0 | mozilla::WebGLUniformLocation* arg0; |
12820 | 0 | if (args[0].isObject()) { |
12821 | 0 | { |
12822 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
12823 | 0 | if (NS_FAILED(rv)) { |
12824 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniformMatrix3fv", "WebGLUniformLocation"); |
12825 | 0 | return false; |
12826 | 0 | } |
12827 | 0 | } |
12828 | 0 | } else if (args[0].isNullOrUndefined()) { |
12829 | 0 | arg0 = nullptr; |
12830 | 0 | } else { |
12831 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniformMatrix3fv"); |
12832 | 0 | return false; |
12833 | 0 | } |
12834 | 0 | bool arg1; |
12835 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) { |
12836 | 0 | return false; |
12837 | 0 | } |
12838 | 0 | Float32ArrayOrUnrestrictedFloatSequence arg2; |
12839 | 0 | Float32ArrayOrUnrestrictedFloatSequenceArgument arg2_holder(arg2); |
12840 | 0 | { |
12841 | 0 | bool done = false, failed = false, tryNext; |
12842 | 0 | if (args[2].isObject()) { |
12843 | 0 | done = (failed = !arg2_holder.TrySetToFloat32Array(cx, args[2], tryNext, false)) || !tryNext; |
12844 | 0 |
|
12845 | 0 | if (!done) { |
12846 | 0 | done = (failed = !arg2_holder.TrySetToUnrestrictedFloatSequence(cx, args[2], tryNext, false)) || !tryNext; |
12847 | 0 | } |
12848 | 0 | } |
12849 | 0 | if (failed) { |
12850 | 0 | return false; |
12851 | 0 | } |
12852 | 0 | if (!done) { |
12853 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 3 of WebGLRenderingContext.uniformMatrix3fv", "Float32Array, UnrestrictedFloatSequence"); |
12854 | 0 | return false; |
12855 | 0 | } |
12856 | 0 | } |
12857 | 0 | self->UniformMatrix3fv(MOZ_KnownLive(Constify(arg0)), arg1, Constify(arg2)); |
12858 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12859 | 0 | args.rval().setUndefined(); |
12860 | 0 | return true; |
12861 | 0 | } |
12862 | | |
12863 | | static const JSJitInfo uniformMatrix3fv_methodinfo = { |
12864 | | { (JSJitGetterOp)uniformMatrix3fv }, |
12865 | | { prototypes::id::WebGLRenderingContext }, |
12866 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
12867 | | JSJitInfo::Method, |
12868 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
12869 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
12870 | | false, /* isInfallible. False in setters. */ |
12871 | | false, /* isMovable. Not relevant for setters. */ |
12872 | | false, /* isEliminatable. Not relevant for setters. */ |
12873 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
12874 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
12875 | | false, /* isTypedMethod. Only relevant for methods. */ |
12876 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
12877 | | }; |
12878 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
12879 | | static_assert(0 < 1, "There is no slot for us"); |
12880 | | |
12881 | | MOZ_CAN_RUN_SCRIPT static bool |
12882 | | uniformMatrix4fv(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
12883 | 0 | { |
12884 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniformMatrix4fv", DOM, cx); |
12885 | 0 |
|
12886 | 0 | if (MOZ_UNLIKELY(args.length() < 3)) { |
12887 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniformMatrix4fv"); |
12888 | 0 | } |
12889 | 0 | mozilla::WebGLUniformLocation* arg0; |
12890 | 0 | if (args[0].isObject()) { |
12891 | 0 | { |
12892 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
12893 | 0 | if (NS_FAILED(rv)) { |
12894 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniformMatrix4fv", "WebGLUniformLocation"); |
12895 | 0 | return false; |
12896 | 0 | } |
12897 | 0 | } |
12898 | 0 | } else if (args[0].isNullOrUndefined()) { |
12899 | 0 | arg0 = nullptr; |
12900 | 0 | } else { |
12901 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniformMatrix4fv"); |
12902 | 0 | return false; |
12903 | 0 | } |
12904 | 0 | bool arg1; |
12905 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) { |
12906 | 0 | return false; |
12907 | 0 | } |
12908 | 0 | Float32ArrayOrUnrestrictedFloatSequence arg2; |
12909 | 0 | Float32ArrayOrUnrestrictedFloatSequenceArgument arg2_holder(arg2); |
12910 | 0 | { |
12911 | 0 | bool done = false, failed = false, tryNext; |
12912 | 0 | if (args[2].isObject()) { |
12913 | 0 | done = (failed = !arg2_holder.TrySetToFloat32Array(cx, args[2], tryNext, false)) || !tryNext; |
12914 | 0 |
|
12915 | 0 | if (!done) { |
12916 | 0 | done = (failed = !arg2_holder.TrySetToUnrestrictedFloatSequence(cx, args[2], tryNext, false)) || !tryNext; |
12917 | 0 | } |
12918 | 0 | } |
12919 | 0 | if (failed) { |
12920 | 0 | return false; |
12921 | 0 | } |
12922 | 0 | if (!done) { |
12923 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 3 of WebGLRenderingContext.uniformMatrix4fv", "Float32Array, UnrestrictedFloatSequence"); |
12924 | 0 | return false; |
12925 | 0 | } |
12926 | 0 | } |
12927 | 0 | self->UniformMatrix4fv(MOZ_KnownLive(Constify(arg0)), arg1, Constify(arg2)); |
12928 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12929 | 0 | args.rval().setUndefined(); |
12930 | 0 | return true; |
12931 | 0 | } |
12932 | | |
12933 | | static const JSJitInfo uniformMatrix4fv_methodinfo = { |
12934 | | { (JSJitGetterOp)uniformMatrix4fv }, |
12935 | | { prototypes::id::WebGLRenderingContext }, |
12936 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
12937 | | JSJitInfo::Method, |
12938 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
12939 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
12940 | | false, /* isInfallible. False in setters. */ |
12941 | | false, /* isMovable. Not relevant for setters. */ |
12942 | | false, /* isEliminatable. Not relevant for setters. */ |
12943 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
12944 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
12945 | | false, /* isTypedMethod. Only relevant for methods. */ |
12946 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
12947 | | }; |
12948 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
12949 | | static_assert(0 < 1, "There is no slot for us"); |
12950 | | |
12951 | | MOZ_CAN_RUN_SCRIPT static bool |
12952 | | commit(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
12953 | 0 | { |
12954 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.commit", DOM, cx); |
12955 | 0 |
|
12956 | 0 | self->Commit(); |
12957 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12958 | 0 | args.rval().setUndefined(); |
12959 | 0 | return true; |
12960 | 0 | } |
12961 | | |
12962 | | static const JSJitInfo commit_methodinfo = { |
12963 | | { (JSJitGetterOp)commit }, |
12964 | | { prototypes::id::WebGLRenderingContext }, |
12965 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
12966 | | JSJitInfo::Method, |
12967 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
12968 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
12969 | | true, /* isInfallible. False in setters. */ |
12970 | | false, /* isMovable. Not relevant for setters. */ |
12971 | | false, /* isEliminatable. Not relevant for setters. */ |
12972 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
12973 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
12974 | | false, /* isTypedMethod. Only relevant for methods. */ |
12975 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
12976 | | }; |
12977 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
12978 | | static_assert(0 < 1, "There is no slot for us"); |
12979 | | |
12980 | | MOZ_CAN_RUN_SCRIPT static bool |
12981 | | get_canvas(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, JSJitGetterCallArgs args) |
12982 | 0 | { |
12983 | 0 | AUTO_PROFILER_LABEL_FAST("get WebGLRenderingContext.canvas", DOM, cx); |
12984 | 0 |
|
12985 | 0 | Nullable<OwningHTMLCanvasElementOrOffscreenCanvas> result; |
12986 | 0 | self->GetCanvas(result); |
12987 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
12988 | 0 | if (result.IsNull()) { |
12989 | 0 | args.rval().setNull(); |
12990 | 0 | return true; |
12991 | 0 | } |
12992 | 0 | if (!result.Value().ToJSVal(cx, obj, args.rval())) { |
12993 | 0 | return false; |
12994 | 0 | } |
12995 | 0 | return true; |
12996 | 0 | } |
12997 | | |
12998 | | static const JSJitInfo canvas_getterinfo = { |
12999 | | { (JSJitGetterOp)get_canvas }, |
13000 | | { prototypes::id::WebGLRenderingContext }, |
13001 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13002 | | JSJitInfo::Getter, |
13003 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13004 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
13005 | | false, /* isInfallible. False in setters. */ |
13006 | | false, /* isMovable. Not relevant for setters. */ |
13007 | | false, /* isEliminatable. Not relevant for setters. */ |
13008 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13009 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13010 | | false, /* isTypedMethod. Only relevant for methods. */ |
13011 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13012 | | }; |
13013 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13014 | | static_assert(0 < 1, "There is no slot for us"); |
13015 | | |
13016 | | MOZ_CAN_RUN_SCRIPT static bool |
13017 | | get_drawingBufferWidth(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, JSJitGetterCallArgs args) |
13018 | 0 | { |
13019 | 0 | AUTO_PROFILER_LABEL_FAST("get WebGLRenderingContext.drawingBufferWidth", DOM, cx); |
13020 | 0 |
|
13021 | 0 | int32_t result(self->DrawingBufferWidth()); |
13022 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13023 | 0 | args.rval().setInt32(int32_t(result)); |
13024 | 0 | return true; |
13025 | 0 | } |
13026 | | |
13027 | | static const JSJitInfo drawingBufferWidth_getterinfo = { |
13028 | | { (JSJitGetterOp)get_drawingBufferWidth }, |
13029 | | { prototypes::id::WebGLRenderingContext }, |
13030 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13031 | | JSJitInfo::Getter, |
13032 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13033 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
13034 | | true, /* isInfallible. False in setters. */ |
13035 | | false, /* isMovable. Not relevant for setters. */ |
13036 | | false, /* isEliminatable. Not relevant for setters. */ |
13037 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13038 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13039 | | false, /* isTypedMethod. Only relevant for methods. */ |
13040 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13041 | | }; |
13042 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13043 | | static_assert(0 < 1, "There is no slot for us"); |
13044 | | |
13045 | | MOZ_CAN_RUN_SCRIPT static bool |
13046 | | get_drawingBufferHeight(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, JSJitGetterCallArgs args) |
13047 | 0 | { |
13048 | 0 | AUTO_PROFILER_LABEL_FAST("get WebGLRenderingContext.drawingBufferHeight", DOM, cx); |
13049 | 0 |
|
13050 | 0 | int32_t result(self->DrawingBufferHeight()); |
13051 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13052 | 0 | args.rval().setInt32(int32_t(result)); |
13053 | 0 | return true; |
13054 | 0 | } |
13055 | | |
13056 | | static const JSJitInfo drawingBufferHeight_getterinfo = { |
13057 | | { (JSJitGetterOp)get_drawingBufferHeight }, |
13058 | | { prototypes::id::WebGLRenderingContext }, |
13059 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13060 | | JSJitInfo::Getter, |
13061 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13062 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
13063 | | true, /* isInfallible. False in setters. */ |
13064 | | false, /* isMovable. Not relevant for setters. */ |
13065 | | false, /* isEliminatable. Not relevant for setters. */ |
13066 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13067 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13068 | | false, /* isTypedMethod. Only relevant for methods. */ |
13069 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13070 | | }; |
13071 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13072 | | static_assert(0 < 1, "There is no slot for us"); |
13073 | | |
13074 | | MOZ_CAN_RUN_SCRIPT static bool |
13075 | | getContextAttributes(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13076 | 0 | { |
13077 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getContextAttributes", DOM, cx); |
13078 | 0 |
|
13079 | 0 | Nullable<WebGLContextAttributes> result; |
13080 | 0 | self->GetContextAttributes(result); |
13081 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13082 | 0 | if (result.IsNull()) { |
13083 | 0 | args.rval().setNull(); |
13084 | 0 | return true; |
13085 | 0 | } |
13086 | 0 | if (!result.Value().ToObjectInternal(cx, args.rval())) { |
13087 | 0 | return false; |
13088 | 0 | } |
13089 | 0 | return true; |
13090 | 0 | } |
13091 | | |
13092 | | static const JSJitInfo getContextAttributes_methodinfo = { |
13093 | | { (JSJitGetterOp)getContextAttributes }, |
13094 | | { prototypes::id::WebGLRenderingContext }, |
13095 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13096 | | JSJitInfo::Method, |
13097 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13098 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
13099 | | false, /* isInfallible. False in setters. */ |
13100 | | false, /* isMovable. Not relevant for setters. */ |
13101 | | false, /* isEliminatable. Not relevant for setters. */ |
13102 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13103 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13104 | | false, /* isTypedMethod. Only relevant for methods. */ |
13105 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13106 | | }; |
13107 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13108 | | static_assert(0 < 1, "There is no slot for us"); |
13109 | | |
13110 | | MOZ_CAN_RUN_SCRIPT static bool |
13111 | | isContextLost(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13112 | 0 | { |
13113 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.isContextLost", DOM, cx); |
13114 | 0 |
|
13115 | 0 | bool result(self->IsContextLost()); |
13116 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13117 | 0 | args.rval().setBoolean(result); |
13118 | 0 | return true; |
13119 | 0 | } |
13120 | | |
13121 | | static const JSJitInfo isContextLost_methodinfo = { |
13122 | | { (JSJitGetterOp)isContextLost }, |
13123 | | { prototypes::id::WebGLRenderingContext }, |
13124 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13125 | | JSJitInfo::Method, |
13126 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13127 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
13128 | | true, /* isInfallible. False in setters. */ |
13129 | | false, /* isMovable. Not relevant for setters. */ |
13130 | | false, /* isEliminatable. Not relevant for setters. */ |
13131 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13132 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13133 | | false, /* isTypedMethod. Only relevant for methods. */ |
13134 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13135 | | }; |
13136 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13137 | | static_assert(0 < 1, "There is no slot for us"); |
13138 | | |
13139 | | MOZ_CAN_RUN_SCRIPT static bool |
13140 | | getSupportedExtensions(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13141 | 0 | { |
13142 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getSupportedExtensions", DOM, cx); |
13143 | 0 |
|
13144 | 0 | Nullable<nsTArray<nsString>> result; |
13145 | 0 | self->GetSupportedExtensions(result, nsContentUtils::ThreadsafeIsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem); |
13146 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13147 | 0 |
|
13148 | 0 | if (result.IsNull()) { |
13149 | 0 | args.rval().setNull(); |
13150 | 0 | return true; |
13151 | 0 | } |
13152 | 0 | |
13153 | 0 | uint32_t length = result.Value().Length(); |
13154 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
13155 | 0 | if (!returnArray) { |
13156 | 0 | return false; |
13157 | 0 | } |
13158 | 0 | // Scope for 'tmp' |
13159 | 0 | { |
13160 | 0 | JS::Rooted<JS::Value> tmp(cx); |
13161 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
13162 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
13163 | 0 | // are different ways to succeed at wrapping the object. |
13164 | 0 | do { |
13165 | 0 | if (!xpc::NonVoidStringToJsval(cx, result.Value()[sequenceIdx0], &tmp)) { |
13166 | 0 | return false; |
13167 | 0 | } |
13168 | 0 | break; |
13169 | 0 | } while (false); |
13170 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
13171 | 0 | JSPROP_ENUMERATE)) { |
13172 | 0 | return false; |
13173 | 0 | } |
13174 | 0 | } |
13175 | 0 | } |
13176 | 0 | args.rval().setObject(*returnArray); |
13177 | 0 | return true; |
13178 | 0 | } |
13179 | | |
13180 | | static const JSJitInfo getSupportedExtensions_methodinfo = { |
13181 | | { (JSJitGetterOp)getSupportedExtensions }, |
13182 | | { prototypes::id::WebGLRenderingContext }, |
13183 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13184 | | JSJitInfo::Method, |
13185 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13186 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
13187 | | false, /* isInfallible. False in setters. */ |
13188 | | false, /* isMovable. Not relevant for setters. */ |
13189 | | false, /* isEliminatable. Not relevant for setters. */ |
13190 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13191 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13192 | | false, /* isTypedMethod. Only relevant for methods. */ |
13193 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13194 | | }; |
13195 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13196 | | static_assert(0 < 1, "There is no slot for us"); |
13197 | | |
13198 | | MOZ_CAN_RUN_SCRIPT static bool |
13199 | | getExtension(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13200 | 0 | { |
13201 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getExtension", DOM, cx); |
13202 | 0 |
|
13203 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
13204 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getExtension"); |
13205 | 0 | } |
13206 | 0 | binding_detail::FakeString arg0; |
13207 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
13208 | 0 | return false; |
13209 | 0 | } |
13210 | 0 | FastErrorResult rv; |
13211 | 0 | JS::Rooted<JSObject*> result(cx); |
13212 | 0 | self->GetExtension(cx, NonNullHelper(Constify(arg0)), &result, nsContentUtils::ThreadsafeIsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv); |
13213 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
13214 | 0 | return false; |
13215 | 0 | } |
13216 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13217 | 0 | if (result) { |
13218 | 0 | JS::ExposeObjectToActiveJS(result); |
13219 | 0 | } |
13220 | 0 | args.rval().setObjectOrNull(result); |
13221 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
13222 | 0 | return false; |
13223 | 0 | } |
13224 | 0 | return true; |
13225 | 0 | } |
13226 | | |
13227 | | static const JSJitInfo getExtension_methodinfo = { |
13228 | | { (JSJitGetterOp)getExtension }, |
13229 | | { prototypes::id::WebGLRenderingContext }, |
13230 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13231 | | JSJitInfo::Method, |
13232 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13233 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
13234 | | false, /* isInfallible. False in setters. */ |
13235 | | false, /* isMovable. Not relevant for setters. */ |
13236 | | false, /* isEliminatable. Not relevant for setters. */ |
13237 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13238 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13239 | | false, /* isTypedMethod. Only relevant for methods. */ |
13240 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13241 | | }; |
13242 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13243 | | static_assert(0 < 1, "There is no slot for us"); |
13244 | | |
13245 | | MOZ_CAN_RUN_SCRIPT static bool |
13246 | | activeTexture(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13247 | 0 | { |
13248 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.activeTexture", DOM, cx); |
13249 | 0 |
|
13250 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
13251 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.activeTexture"); |
13252 | 0 | } |
13253 | 0 | uint32_t arg0; |
13254 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
13255 | 0 | return false; |
13256 | 0 | } |
13257 | 0 | self->ActiveTexture(arg0); |
13258 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13259 | 0 | args.rval().setUndefined(); |
13260 | 0 | return true; |
13261 | 0 | } |
13262 | | |
13263 | | static const JSJitInfo activeTexture_methodinfo = { |
13264 | | { (JSJitGetterOp)activeTexture }, |
13265 | | { prototypes::id::WebGLRenderingContext }, |
13266 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13267 | | JSJitInfo::Method, |
13268 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13269 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
13270 | | false, /* isInfallible. False in setters. */ |
13271 | | false, /* isMovable. Not relevant for setters. */ |
13272 | | false, /* isEliminatable. Not relevant for setters. */ |
13273 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13274 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13275 | | false, /* isTypedMethod. Only relevant for methods. */ |
13276 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13277 | | }; |
13278 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13279 | | static_assert(0 < 1, "There is no slot for us"); |
13280 | | |
13281 | | MOZ_CAN_RUN_SCRIPT static bool |
13282 | | attachShader(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13283 | 0 | { |
13284 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.attachShader", DOM, cx); |
13285 | 0 |
|
13286 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
13287 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.attachShader"); |
13288 | 0 | } |
13289 | 0 | NonNull<mozilla::WebGLProgram> arg0; |
13290 | 0 | if (args[0].isObject()) { |
13291 | 0 | { |
13292 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLProgram, mozilla::WebGLProgram>(args[0], arg0); |
13293 | 0 | if (NS_FAILED(rv)) { |
13294 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.attachShader", "WebGLProgram"); |
13295 | 0 | return false; |
13296 | 0 | } |
13297 | 0 | } |
13298 | 0 | } else { |
13299 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.attachShader"); |
13300 | 0 | return false; |
13301 | 0 | } |
13302 | 0 | NonNull<mozilla::WebGLShader> arg1; |
13303 | 0 | if (args[1].isObject()) { |
13304 | 0 | { |
13305 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLShader, mozilla::WebGLShader>(args[1], arg1); |
13306 | 0 | if (NS_FAILED(rv)) { |
13307 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of WebGLRenderingContext.attachShader", "WebGLShader"); |
13308 | 0 | return false; |
13309 | 0 | } |
13310 | 0 | } |
13311 | 0 | } else { |
13312 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of WebGLRenderingContext.attachShader"); |
13313 | 0 | return false; |
13314 | 0 | } |
13315 | 0 | self->AttachShader(MOZ_KnownLive(NonNullHelper(arg0)), MOZ_KnownLive(NonNullHelper(arg1))); |
13316 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13317 | 0 | args.rval().setUndefined(); |
13318 | 0 | return true; |
13319 | 0 | } |
13320 | | |
13321 | | static const JSJitInfo attachShader_methodinfo = { |
13322 | | { (JSJitGetterOp)attachShader }, |
13323 | | { prototypes::id::WebGLRenderingContext }, |
13324 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13325 | | JSJitInfo::Method, |
13326 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13327 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
13328 | | false, /* isInfallible. False in setters. */ |
13329 | | false, /* isMovable. Not relevant for setters. */ |
13330 | | false, /* isEliminatable. Not relevant for setters. */ |
13331 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13332 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13333 | | false, /* isTypedMethod. Only relevant for methods. */ |
13334 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13335 | | }; |
13336 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13337 | | static_assert(0 < 1, "There is no slot for us"); |
13338 | | |
13339 | | MOZ_CAN_RUN_SCRIPT static bool |
13340 | | bindAttribLocation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13341 | 0 | { |
13342 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.bindAttribLocation", DOM, cx); |
13343 | 0 |
|
13344 | 0 | if (MOZ_UNLIKELY(args.length() < 3)) { |
13345 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.bindAttribLocation"); |
13346 | 0 | } |
13347 | 0 | NonNull<mozilla::WebGLProgram> arg0; |
13348 | 0 | if (args[0].isObject()) { |
13349 | 0 | { |
13350 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLProgram, mozilla::WebGLProgram>(args[0], arg0); |
13351 | 0 | if (NS_FAILED(rv)) { |
13352 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.bindAttribLocation", "WebGLProgram"); |
13353 | 0 | return false; |
13354 | 0 | } |
13355 | 0 | } |
13356 | 0 | } else { |
13357 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.bindAttribLocation"); |
13358 | 0 | return false; |
13359 | 0 | } |
13360 | 0 | uint32_t arg1; |
13361 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
13362 | 0 | return false; |
13363 | 0 | } |
13364 | 0 | binding_detail::FakeString arg2; |
13365 | 0 | if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2)) { |
13366 | 0 | return false; |
13367 | 0 | } |
13368 | 0 | self->BindAttribLocation(MOZ_KnownLive(NonNullHelper(arg0)), arg1, NonNullHelper(Constify(arg2))); |
13369 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13370 | 0 | args.rval().setUndefined(); |
13371 | 0 | return true; |
13372 | 0 | } |
13373 | | |
13374 | | static const JSJitInfo bindAttribLocation_methodinfo = { |
13375 | | { (JSJitGetterOp)bindAttribLocation }, |
13376 | | { prototypes::id::WebGLRenderingContext }, |
13377 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13378 | | JSJitInfo::Method, |
13379 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13380 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
13381 | | false, /* isInfallible. False in setters. */ |
13382 | | false, /* isMovable. Not relevant for setters. */ |
13383 | | false, /* isEliminatable. Not relevant for setters. */ |
13384 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13385 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13386 | | false, /* isTypedMethod. Only relevant for methods. */ |
13387 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13388 | | }; |
13389 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13390 | | static_assert(0 < 1, "There is no slot for us"); |
13391 | | |
13392 | | MOZ_CAN_RUN_SCRIPT static bool |
13393 | | bindBuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13394 | 0 | { |
13395 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.bindBuffer", DOM, cx); |
13396 | 0 |
|
13397 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
13398 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.bindBuffer"); |
13399 | 0 | } |
13400 | 0 | uint32_t arg0; |
13401 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
13402 | 0 | return false; |
13403 | 0 | } |
13404 | 0 | mozilla::WebGLBuffer* arg1; |
13405 | 0 | if (args[1].isObject()) { |
13406 | 0 | { |
13407 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLBuffer, mozilla::WebGLBuffer>(args[1], arg1); |
13408 | 0 | if (NS_FAILED(rv)) { |
13409 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of WebGLRenderingContext.bindBuffer", "WebGLBuffer"); |
13410 | 0 | return false; |
13411 | 0 | } |
13412 | 0 | } |
13413 | 0 | } else if (args[1].isNullOrUndefined()) { |
13414 | 0 | arg1 = nullptr; |
13415 | 0 | } else { |
13416 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of WebGLRenderingContext.bindBuffer"); |
13417 | 0 | return false; |
13418 | 0 | } |
13419 | 0 | self->BindBuffer(arg0, MOZ_KnownLive(Constify(arg1))); |
13420 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13421 | 0 | args.rval().setUndefined(); |
13422 | 0 | return true; |
13423 | 0 | } |
13424 | | |
13425 | | static const JSJitInfo bindBuffer_methodinfo = { |
13426 | | { (JSJitGetterOp)bindBuffer }, |
13427 | | { prototypes::id::WebGLRenderingContext }, |
13428 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13429 | | JSJitInfo::Method, |
13430 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13431 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
13432 | | false, /* isInfallible. False in setters. */ |
13433 | | false, /* isMovable. Not relevant for setters. */ |
13434 | | false, /* isEliminatable. Not relevant for setters. */ |
13435 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13436 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13437 | | false, /* isTypedMethod. Only relevant for methods. */ |
13438 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13439 | | }; |
13440 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13441 | | static_assert(0 < 1, "There is no slot for us"); |
13442 | | |
13443 | | MOZ_CAN_RUN_SCRIPT static bool |
13444 | | bindFramebuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13445 | 0 | { |
13446 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.bindFramebuffer", DOM, cx); |
13447 | 0 |
|
13448 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
13449 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.bindFramebuffer"); |
13450 | 0 | } |
13451 | 0 | uint32_t arg0; |
13452 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
13453 | 0 | return false; |
13454 | 0 | } |
13455 | 0 | mozilla::WebGLFramebuffer* arg1; |
13456 | 0 | if (args[1].isObject()) { |
13457 | 0 | { |
13458 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLFramebuffer, mozilla::WebGLFramebuffer>(args[1], arg1); |
13459 | 0 | if (NS_FAILED(rv)) { |
13460 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of WebGLRenderingContext.bindFramebuffer", "WebGLFramebuffer"); |
13461 | 0 | return false; |
13462 | 0 | } |
13463 | 0 | } |
13464 | 0 | } else if (args[1].isNullOrUndefined()) { |
13465 | 0 | arg1 = nullptr; |
13466 | 0 | } else { |
13467 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of WebGLRenderingContext.bindFramebuffer"); |
13468 | 0 | return false; |
13469 | 0 | } |
13470 | 0 | self->BindFramebuffer(arg0, MOZ_KnownLive(Constify(arg1))); |
13471 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13472 | 0 | args.rval().setUndefined(); |
13473 | 0 | return true; |
13474 | 0 | } |
13475 | | |
13476 | | static const JSJitInfo bindFramebuffer_methodinfo = { |
13477 | | { (JSJitGetterOp)bindFramebuffer }, |
13478 | | { prototypes::id::WebGLRenderingContext }, |
13479 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13480 | | JSJitInfo::Method, |
13481 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13482 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
13483 | | false, /* isInfallible. False in setters. */ |
13484 | | false, /* isMovable. Not relevant for setters. */ |
13485 | | false, /* isEliminatable. Not relevant for setters. */ |
13486 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13487 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13488 | | false, /* isTypedMethod. Only relevant for methods. */ |
13489 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13490 | | }; |
13491 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13492 | | static_assert(0 < 1, "There is no slot for us"); |
13493 | | |
13494 | | MOZ_CAN_RUN_SCRIPT static bool |
13495 | | bindRenderbuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13496 | 0 | { |
13497 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.bindRenderbuffer", DOM, cx); |
13498 | 0 |
|
13499 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
13500 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.bindRenderbuffer"); |
13501 | 0 | } |
13502 | 0 | uint32_t arg0; |
13503 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
13504 | 0 | return false; |
13505 | 0 | } |
13506 | 0 | mozilla::WebGLRenderbuffer* arg1; |
13507 | 0 | if (args[1].isObject()) { |
13508 | 0 | { |
13509 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLRenderbuffer, mozilla::WebGLRenderbuffer>(args[1], arg1); |
13510 | 0 | if (NS_FAILED(rv)) { |
13511 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of WebGLRenderingContext.bindRenderbuffer", "WebGLRenderbuffer"); |
13512 | 0 | return false; |
13513 | 0 | } |
13514 | 0 | } |
13515 | 0 | } else if (args[1].isNullOrUndefined()) { |
13516 | 0 | arg1 = nullptr; |
13517 | 0 | } else { |
13518 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of WebGLRenderingContext.bindRenderbuffer"); |
13519 | 0 | return false; |
13520 | 0 | } |
13521 | 0 | self->BindRenderbuffer(arg0, MOZ_KnownLive(Constify(arg1))); |
13522 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13523 | 0 | args.rval().setUndefined(); |
13524 | 0 | return true; |
13525 | 0 | } |
13526 | | |
13527 | | static const JSJitInfo bindRenderbuffer_methodinfo = { |
13528 | | { (JSJitGetterOp)bindRenderbuffer }, |
13529 | | { prototypes::id::WebGLRenderingContext }, |
13530 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13531 | | JSJitInfo::Method, |
13532 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13533 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
13534 | | false, /* isInfallible. False in setters. */ |
13535 | | false, /* isMovable. Not relevant for setters. */ |
13536 | | false, /* isEliminatable. Not relevant for setters. */ |
13537 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13538 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13539 | | false, /* isTypedMethod. Only relevant for methods. */ |
13540 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13541 | | }; |
13542 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13543 | | static_assert(0 < 1, "There is no slot for us"); |
13544 | | |
13545 | | MOZ_CAN_RUN_SCRIPT static bool |
13546 | | bindTexture(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13547 | 0 | { |
13548 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.bindTexture", DOM, cx); |
13549 | 0 |
|
13550 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
13551 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.bindTexture"); |
13552 | 0 | } |
13553 | 0 | uint32_t arg0; |
13554 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
13555 | 0 | return false; |
13556 | 0 | } |
13557 | 0 | mozilla::WebGLTexture* arg1; |
13558 | 0 | if (args[1].isObject()) { |
13559 | 0 | { |
13560 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLTexture, mozilla::WebGLTexture>(args[1], arg1); |
13561 | 0 | if (NS_FAILED(rv)) { |
13562 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of WebGLRenderingContext.bindTexture", "WebGLTexture"); |
13563 | 0 | return false; |
13564 | 0 | } |
13565 | 0 | } |
13566 | 0 | } else if (args[1].isNullOrUndefined()) { |
13567 | 0 | arg1 = nullptr; |
13568 | 0 | } else { |
13569 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of WebGLRenderingContext.bindTexture"); |
13570 | 0 | return false; |
13571 | 0 | } |
13572 | 0 | self->BindTexture(arg0, MOZ_KnownLive(Constify(arg1))); |
13573 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13574 | 0 | args.rval().setUndefined(); |
13575 | 0 | return true; |
13576 | 0 | } |
13577 | | |
13578 | | static const JSJitInfo bindTexture_methodinfo = { |
13579 | | { (JSJitGetterOp)bindTexture }, |
13580 | | { prototypes::id::WebGLRenderingContext }, |
13581 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13582 | | JSJitInfo::Method, |
13583 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13584 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
13585 | | false, /* isInfallible. False in setters. */ |
13586 | | false, /* isMovable. Not relevant for setters. */ |
13587 | | false, /* isEliminatable. Not relevant for setters. */ |
13588 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13589 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13590 | | false, /* isTypedMethod. Only relevant for methods. */ |
13591 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13592 | | }; |
13593 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13594 | | static_assert(0 < 1, "There is no slot for us"); |
13595 | | |
13596 | | MOZ_CAN_RUN_SCRIPT static bool |
13597 | | blendColor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13598 | 0 | { |
13599 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.blendColor", DOM, cx); |
13600 | 0 |
|
13601 | 0 | if (MOZ_UNLIKELY(args.length() < 4)) { |
13602 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.blendColor"); |
13603 | 0 | } |
13604 | 0 | float arg0; |
13605 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) { |
13606 | 0 | return false; |
13607 | 0 | } |
13608 | 0 | float arg1; |
13609 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[1], &arg1)) { |
13610 | 0 | return false; |
13611 | 0 | } |
13612 | 0 | float arg2; |
13613 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[2], &arg2)) { |
13614 | 0 | return false; |
13615 | 0 | } |
13616 | 0 | float arg3; |
13617 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[3], &arg3)) { |
13618 | 0 | return false; |
13619 | 0 | } |
13620 | 0 | self->BlendColor(arg0, arg1, arg2, arg3); |
13621 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13622 | 0 | args.rval().setUndefined(); |
13623 | 0 | return true; |
13624 | 0 | } |
13625 | | |
13626 | | static const JSJitInfo blendColor_methodinfo = { |
13627 | | { (JSJitGetterOp)blendColor }, |
13628 | | { prototypes::id::WebGLRenderingContext }, |
13629 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13630 | | JSJitInfo::Method, |
13631 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13632 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
13633 | | false, /* isInfallible. False in setters. */ |
13634 | | false, /* isMovable. Not relevant for setters. */ |
13635 | | false, /* isEliminatable. Not relevant for setters. */ |
13636 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13637 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13638 | | false, /* isTypedMethod. Only relevant for methods. */ |
13639 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13640 | | }; |
13641 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13642 | | static_assert(0 < 1, "There is no slot for us"); |
13643 | | |
13644 | | MOZ_CAN_RUN_SCRIPT static bool |
13645 | | blendEquation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13646 | 0 | { |
13647 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.blendEquation", DOM, cx); |
13648 | 0 |
|
13649 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
13650 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.blendEquation"); |
13651 | 0 | } |
13652 | 0 | uint32_t arg0; |
13653 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
13654 | 0 | return false; |
13655 | 0 | } |
13656 | 0 | self->BlendEquation(arg0); |
13657 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13658 | 0 | args.rval().setUndefined(); |
13659 | 0 | return true; |
13660 | 0 | } |
13661 | | |
13662 | | static const JSJitInfo blendEquation_methodinfo = { |
13663 | | { (JSJitGetterOp)blendEquation }, |
13664 | | { prototypes::id::WebGLRenderingContext }, |
13665 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13666 | | JSJitInfo::Method, |
13667 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13668 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
13669 | | false, /* isInfallible. False in setters. */ |
13670 | | false, /* isMovable. Not relevant for setters. */ |
13671 | | false, /* isEliminatable. Not relevant for setters. */ |
13672 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13673 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13674 | | false, /* isTypedMethod. Only relevant for methods. */ |
13675 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13676 | | }; |
13677 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13678 | | static_assert(0 < 1, "There is no slot for us"); |
13679 | | |
13680 | | MOZ_CAN_RUN_SCRIPT static bool |
13681 | | blendEquationSeparate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13682 | 0 | { |
13683 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.blendEquationSeparate", DOM, cx); |
13684 | 0 |
|
13685 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
13686 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.blendEquationSeparate"); |
13687 | 0 | } |
13688 | 0 | uint32_t arg0; |
13689 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
13690 | 0 | return false; |
13691 | 0 | } |
13692 | 0 | uint32_t arg1; |
13693 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
13694 | 0 | return false; |
13695 | 0 | } |
13696 | 0 | self->BlendEquationSeparate(arg0, arg1); |
13697 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13698 | 0 | args.rval().setUndefined(); |
13699 | 0 | return true; |
13700 | 0 | } |
13701 | | |
13702 | | static const JSJitInfo blendEquationSeparate_methodinfo = { |
13703 | | { (JSJitGetterOp)blendEquationSeparate }, |
13704 | | { prototypes::id::WebGLRenderingContext }, |
13705 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13706 | | JSJitInfo::Method, |
13707 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13708 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
13709 | | false, /* isInfallible. False in setters. */ |
13710 | | false, /* isMovable. Not relevant for setters. */ |
13711 | | false, /* isEliminatable. Not relevant for setters. */ |
13712 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13713 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13714 | | false, /* isTypedMethod. Only relevant for methods. */ |
13715 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13716 | | }; |
13717 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13718 | | static_assert(0 < 1, "There is no slot for us"); |
13719 | | |
13720 | | MOZ_CAN_RUN_SCRIPT static bool |
13721 | | blendFunc(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13722 | 0 | { |
13723 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.blendFunc", DOM, cx); |
13724 | 0 |
|
13725 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
13726 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.blendFunc"); |
13727 | 0 | } |
13728 | 0 | uint32_t arg0; |
13729 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
13730 | 0 | return false; |
13731 | 0 | } |
13732 | 0 | uint32_t arg1; |
13733 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
13734 | 0 | return false; |
13735 | 0 | } |
13736 | 0 | self->BlendFunc(arg0, arg1); |
13737 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13738 | 0 | args.rval().setUndefined(); |
13739 | 0 | return true; |
13740 | 0 | } |
13741 | | |
13742 | | static const JSJitInfo blendFunc_methodinfo = { |
13743 | | { (JSJitGetterOp)blendFunc }, |
13744 | | { prototypes::id::WebGLRenderingContext }, |
13745 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13746 | | JSJitInfo::Method, |
13747 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13748 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
13749 | | false, /* isInfallible. False in setters. */ |
13750 | | false, /* isMovable. Not relevant for setters. */ |
13751 | | false, /* isEliminatable. Not relevant for setters. */ |
13752 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13753 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13754 | | false, /* isTypedMethod. Only relevant for methods. */ |
13755 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13756 | | }; |
13757 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13758 | | static_assert(0 < 1, "There is no slot for us"); |
13759 | | |
13760 | | MOZ_CAN_RUN_SCRIPT static bool |
13761 | | blendFuncSeparate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13762 | 0 | { |
13763 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.blendFuncSeparate", DOM, cx); |
13764 | 0 |
|
13765 | 0 | if (MOZ_UNLIKELY(args.length() < 4)) { |
13766 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.blendFuncSeparate"); |
13767 | 0 | } |
13768 | 0 | uint32_t arg0; |
13769 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
13770 | 0 | return false; |
13771 | 0 | } |
13772 | 0 | uint32_t arg1; |
13773 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
13774 | 0 | return false; |
13775 | 0 | } |
13776 | 0 | uint32_t arg2; |
13777 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) { |
13778 | 0 | return false; |
13779 | 0 | } |
13780 | 0 | uint32_t arg3; |
13781 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[3], &arg3)) { |
13782 | 0 | return false; |
13783 | 0 | } |
13784 | 0 | self->BlendFuncSeparate(arg0, arg1, arg2, arg3); |
13785 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13786 | 0 | args.rval().setUndefined(); |
13787 | 0 | return true; |
13788 | 0 | } |
13789 | | |
13790 | | static const JSJitInfo blendFuncSeparate_methodinfo = { |
13791 | | { (JSJitGetterOp)blendFuncSeparate }, |
13792 | | { prototypes::id::WebGLRenderingContext }, |
13793 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13794 | | JSJitInfo::Method, |
13795 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13796 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
13797 | | false, /* isInfallible. False in setters. */ |
13798 | | false, /* isMovable. Not relevant for setters. */ |
13799 | | false, /* isEliminatable. Not relevant for setters. */ |
13800 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13801 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13802 | | false, /* isTypedMethod. Only relevant for methods. */ |
13803 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13804 | | }; |
13805 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13806 | | static_assert(0 < 1, "There is no slot for us"); |
13807 | | |
13808 | | MOZ_CAN_RUN_SCRIPT static bool |
13809 | | checkFramebufferStatus(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13810 | 0 | { |
13811 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.checkFramebufferStatus", DOM, cx); |
13812 | 0 |
|
13813 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
13814 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.checkFramebufferStatus"); |
13815 | 0 | } |
13816 | 0 | uint32_t arg0; |
13817 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
13818 | 0 | return false; |
13819 | 0 | } |
13820 | 0 | uint32_t result(self->CheckFramebufferStatus(arg0)); |
13821 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13822 | 0 | args.rval().setNumber(result); |
13823 | 0 | return true; |
13824 | 0 | } |
13825 | | |
13826 | | static const JSJitInfo checkFramebufferStatus_methodinfo = { |
13827 | | { (JSJitGetterOp)checkFramebufferStatus }, |
13828 | | { prototypes::id::WebGLRenderingContext }, |
13829 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13830 | | JSJitInfo::Method, |
13831 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13832 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
13833 | | false, /* isInfallible. False in setters. */ |
13834 | | false, /* isMovable. Not relevant for setters. */ |
13835 | | false, /* isEliminatable. Not relevant for setters. */ |
13836 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13837 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13838 | | false, /* isTypedMethod. Only relevant for methods. */ |
13839 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13840 | | }; |
13841 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13842 | | static_assert(0 < 1, "There is no slot for us"); |
13843 | | |
13844 | | MOZ_CAN_RUN_SCRIPT static bool |
13845 | | clear(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13846 | 0 | { |
13847 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.clear", DOM, cx); |
13848 | 0 |
|
13849 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
13850 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.clear"); |
13851 | 0 | } |
13852 | 0 | uint32_t arg0; |
13853 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
13854 | 0 | return false; |
13855 | 0 | } |
13856 | 0 | self->Clear(arg0); |
13857 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13858 | 0 | args.rval().setUndefined(); |
13859 | 0 | return true; |
13860 | 0 | } |
13861 | | |
13862 | | static const JSJitInfo clear_methodinfo = { |
13863 | | { (JSJitGetterOp)clear }, |
13864 | | { prototypes::id::WebGLRenderingContext }, |
13865 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13866 | | JSJitInfo::Method, |
13867 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13868 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
13869 | | false, /* isInfallible. False in setters. */ |
13870 | | false, /* isMovable. Not relevant for setters. */ |
13871 | | false, /* isEliminatable. Not relevant for setters. */ |
13872 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13873 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13874 | | false, /* isTypedMethod. Only relevant for methods. */ |
13875 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13876 | | }; |
13877 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13878 | | static_assert(0 < 1, "There is no slot for us"); |
13879 | | |
13880 | | MOZ_CAN_RUN_SCRIPT static bool |
13881 | | clearColor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13882 | 0 | { |
13883 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.clearColor", DOM, cx); |
13884 | 0 |
|
13885 | 0 | if (MOZ_UNLIKELY(args.length() < 4)) { |
13886 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.clearColor"); |
13887 | 0 | } |
13888 | 0 | float arg0; |
13889 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) { |
13890 | 0 | return false; |
13891 | 0 | } |
13892 | 0 | float arg1; |
13893 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[1], &arg1)) { |
13894 | 0 | return false; |
13895 | 0 | } |
13896 | 0 | float arg2; |
13897 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[2], &arg2)) { |
13898 | 0 | return false; |
13899 | 0 | } |
13900 | 0 | float arg3; |
13901 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[3], &arg3)) { |
13902 | 0 | return false; |
13903 | 0 | } |
13904 | 0 | self->ClearColor(arg0, arg1, arg2, arg3); |
13905 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13906 | 0 | args.rval().setUndefined(); |
13907 | 0 | return true; |
13908 | 0 | } |
13909 | | |
13910 | | static const JSJitInfo clearColor_methodinfo = { |
13911 | | { (JSJitGetterOp)clearColor }, |
13912 | | { prototypes::id::WebGLRenderingContext }, |
13913 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13914 | | JSJitInfo::Method, |
13915 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13916 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
13917 | | false, /* isInfallible. False in setters. */ |
13918 | | false, /* isMovable. Not relevant for setters. */ |
13919 | | false, /* isEliminatable. Not relevant for setters. */ |
13920 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13921 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13922 | | false, /* isTypedMethod. Only relevant for methods. */ |
13923 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13924 | | }; |
13925 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13926 | | static_assert(0 < 1, "There is no slot for us"); |
13927 | | |
13928 | | MOZ_CAN_RUN_SCRIPT static bool |
13929 | | clearDepth(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13930 | 0 | { |
13931 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.clearDepth", DOM, cx); |
13932 | 0 |
|
13933 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
13934 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.clearDepth"); |
13935 | 0 | } |
13936 | 0 | float arg0; |
13937 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) { |
13938 | 0 | return false; |
13939 | 0 | } |
13940 | 0 | self->ClearDepth(arg0); |
13941 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13942 | 0 | args.rval().setUndefined(); |
13943 | 0 | return true; |
13944 | 0 | } |
13945 | | |
13946 | | static const JSJitInfo clearDepth_methodinfo = { |
13947 | | { (JSJitGetterOp)clearDepth }, |
13948 | | { prototypes::id::WebGLRenderingContext }, |
13949 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13950 | | JSJitInfo::Method, |
13951 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13952 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
13953 | | false, /* isInfallible. False in setters. */ |
13954 | | false, /* isMovable. Not relevant for setters. */ |
13955 | | false, /* isEliminatable. Not relevant for setters. */ |
13956 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13957 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13958 | | false, /* isTypedMethod. Only relevant for methods. */ |
13959 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13960 | | }; |
13961 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13962 | | static_assert(0 < 1, "There is no slot for us"); |
13963 | | |
13964 | | MOZ_CAN_RUN_SCRIPT static bool |
13965 | | clearStencil(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
13966 | 0 | { |
13967 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.clearStencil", DOM, cx); |
13968 | 0 |
|
13969 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
13970 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.clearStencil"); |
13971 | 0 | } |
13972 | 0 | int32_t arg0; |
13973 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) { |
13974 | 0 | return false; |
13975 | 0 | } |
13976 | 0 | self->ClearStencil(arg0); |
13977 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
13978 | 0 | args.rval().setUndefined(); |
13979 | 0 | return true; |
13980 | 0 | } |
13981 | | |
13982 | | static const JSJitInfo clearStencil_methodinfo = { |
13983 | | { (JSJitGetterOp)clearStencil }, |
13984 | | { prototypes::id::WebGLRenderingContext }, |
13985 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
13986 | | JSJitInfo::Method, |
13987 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
13988 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
13989 | | false, /* isInfallible. False in setters. */ |
13990 | | false, /* isMovable. Not relevant for setters. */ |
13991 | | false, /* isEliminatable. Not relevant for setters. */ |
13992 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
13993 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
13994 | | false, /* isTypedMethod. Only relevant for methods. */ |
13995 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
13996 | | }; |
13997 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
13998 | | static_assert(0 < 1, "There is no slot for us"); |
13999 | | |
14000 | | MOZ_CAN_RUN_SCRIPT static bool |
14001 | | colorMask(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14002 | 0 | { |
14003 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.colorMask", DOM, cx); |
14004 | 0 |
|
14005 | 0 | if (MOZ_UNLIKELY(args.length() < 4)) { |
14006 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.colorMask"); |
14007 | 0 | } |
14008 | 0 | bool arg0; |
14009 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) { |
14010 | 0 | return false; |
14011 | 0 | } |
14012 | 0 | bool arg1; |
14013 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) { |
14014 | 0 | return false; |
14015 | 0 | } |
14016 | 0 | bool arg2; |
14017 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) { |
14018 | 0 | return false; |
14019 | 0 | } |
14020 | 0 | bool arg3; |
14021 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[3], &arg3)) { |
14022 | 0 | return false; |
14023 | 0 | } |
14024 | 0 | self->ColorMask(arg0, arg1, arg2, arg3); |
14025 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14026 | 0 | args.rval().setUndefined(); |
14027 | 0 | return true; |
14028 | 0 | } |
14029 | | |
14030 | | static const JSJitInfo colorMask_methodinfo = { |
14031 | | { (JSJitGetterOp)colorMask }, |
14032 | | { prototypes::id::WebGLRenderingContext }, |
14033 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14034 | | JSJitInfo::Method, |
14035 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14036 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
14037 | | false, /* isInfallible. False in setters. */ |
14038 | | false, /* isMovable. Not relevant for setters. */ |
14039 | | false, /* isEliminatable. Not relevant for setters. */ |
14040 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14041 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14042 | | false, /* isTypedMethod. Only relevant for methods. */ |
14043 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14044 | | }; |
14045 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14046 | | static_assert(0 < 1, "There is no slot for us"); |
14047 | | |
14048 | | MOZ_CAN_RUN_SCRIPT static bool |
14049 | | compileShader(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14050 | 0 | { |
14051 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.compileShader", DOM, cx); |
14052 | 0 |
|
14053 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
14054 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.compileShader"); |
14055 | 0 | } |
14056 | 0 | NonNull<mozilla::WebGLShader> arg0; |
14057 | 0 | if (args[0].isObject()) { |
14058 | 0 | { |
14059 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLShader, mozilla::WebGLShader>(args[0], arg0); |
14060 | 0 | if (NS_FAILED(rv)) { |
14061 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.compileShader", "WebGLShader"); |
14062 | 0 | return false; |
14063 | 0 | } |
14064 | 0 | } |
14065 | 0 | } else { |
14066 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.compileShader"); |
14067 | 0 | return false; |
14068 | 0 | } |
14069 | 0 | self->CompileShader(MOZ_KnownLive(NonNullHelper(arg0))); |
14070 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14071 | 0 | args.rval().setUndefined(); |
14072 | 0 | return true; |
14073 | 0 | } |
14074 | | |
14075 | | static const JSJitInfo compileShader_methodinfo = { |
14076 | | { (JSJitGetterOp)compileShader }, |
14077 | | { prototypes::id::WebGLRenderingContext }, |
14078 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14079 | | JSJitInfo::Method, |
14080 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14081 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
14082 | | false, /* isInfallible. False in setters. */ |
14083 | | false, /* isMovable. Not relevant for setters. */ |
14084 | | false, /* isEliminatable. Not relevant for setters. */ |
14085 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14086 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14087 | | false, /* isTypedMethod. Only relevant for methods. */ |
14088 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14089 | | }; |
14090 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14091 | | static_assert(0 < 1, "There is no slot for us"); |
14092 | | |
14093 | | MOZ_CAN_RUN_SCRIPT static bool |
14094 | | copyTexImage2D(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14095 | 0 | { |
14096 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.copyTexImage2D", DOM, cx); |
14097 | 0 |
|
14098 | 0 | if (MOZ_UNLIKELY(args.length() < 8)) { |
14099 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.copyTexImage2D"); |
14100 | 0 | } |
14101 | 0 | uint32_t arg0; |
14102 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
14103 | 0 | return false; |
14104 | 0 | } |
14105 | 0 | int32_t arg1; |
14106 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
14107 | 0 | return false; |
14108 | 0 | } |
14109 | 0 | uint32_t arg2; |
14110 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) { |
14111 | 0 | return false; |
14112 | 0 | } |
14113 | 0 | int32_t arg3; |
14114 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[3], &arg3)) { |
14115 | 0 | return false; |
14116 | 0 | } |
14117 | 0 | int32_t arg4; |
14118 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) { |
14119 | 0 | return false; |
14120 | 0 | } |
14121 | 0 | int32_t arg5; |
14122 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[5], &arg5)) { |
14123 | 0 | return false; |
14124 | 0 | } |
14125 | 0 | int32_t arg6; |
14126 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[6], &arg6)) { |
14127 | 0 | return false; |
14128 | 0 | } |
14129 | 0 | int32_t arg7; |
14130 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[7], &arg7)) { |
14131 | 0 | return false; |
14132 | 0 | } |
14133 | 0 | self->CopyTexImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); |
14134 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14135 | 0 | args.rval().setUndefined(); |
14136 | 0 | return true; |
14137 | 0 | } |
14138 | | |
14139 | | static const JSJitInfo copyTexImage2D_methodinfo = { |
14140 | | { (JSJitGetterOp)copyTexImage2D }, |
14141 | | { prototypes::id::WebGLRenderingContext }, |
14142 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14143 | | JSJitInfo::Method, |
14144 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14145 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
14146 | | false, /* isInfallible. False in setters. */ |
14147 | | false, /* isMovable. Not relevant for setters. */ |
14148 | | false, /* isEliminatable. Not relevant for setters. */ |
14149 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14150 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14151 | | false, /* isTypedMethod. Only relevant for methods. */ |
14152 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14153 | | }; |
14154 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14155 | | static_assert(0 < 1, "There is no slot for us"); |
14156 | | |
14157 | | MOZ_CAN_RUN_SCRIPT static bool |
14158 | | copyTexSubImage2D(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14159 | 0 | { |
14160 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.copyTexSubImage2D", DOM, cx); |
14161 | 0 |
|
14162 | 0 | if (MOZ_UNLIKELY(args.length() < 8)) { |
14163 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.copyTexSubImage2D"); |
14164 | 0 | } |
14165 | 0 | uint32_t arg0; |
14166 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
14167 | 0 | return false; |
14168 | 0 | } |
14169 | 0 | int32_t arg1; |
14170 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
14171 | 0 | return false; |
14172 | 0 | } |
14173 | 0 | int32_t arg2; |
14174 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
14175 | 0 | return false; |
14176 | 0 | } |
14177 | 0 | int32_t arg3; |
14178 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[3], &arg3)) { |
14179 | 0 | return false; |
14180 | 0 | } |
14181 | 0 | int32_t arg4; |
14182 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) { |
14183 | 0 | return false; |
14184 | 0 | } |
14185 | 0 | int32_t arg5; |
14186 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[5], &arg5)) { |
14187 | 0 | return false; |
14188 | 0 | } |
14189 | 0 | int32_t arg6; |
14190 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[6], &arg6)) { |
14191 | 0 | return false; |
14192 | 0 | } |
14193 | 0 | int32_t arg7; |
14194 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[7], &arg7)) { |
14195 | 0 | return false; |
14196 | 0 | } |
14197 | 0 | self->CopyTexSubImage2D(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); |
14198 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14199 | 0 | args.rval().setUndefined(); |
14200 | 0 | return true; |
14201 | 0 | } |
14202 | | |
14203 | | static const JSJitInfo copyTexSubImage2D_methodinfo = { |
14204 | | { (JSJitGetterOp)copyTexSubImage2D }, |
14205 | | { prototypes::id::WebGLRenderingContext }, |
14206 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14207 | | JSJitInfo::Method, |
14208 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14209 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
14210 | | false, /* isInfallible. False in setters. */ |
14211 | | false, /* isMovable. Not relevant for setters. */ |
14212 | | false, /* isEliminatable. Not relevant for setters. */ |
14213 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14214 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14215 | | false, /* isTypedMethod. Only relevant for methods. */ |
14216 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14217 | | }; |
14218 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14219 | | static_assert(0 < 1, "There is no slot for us"); |
14220 | | |
14221 | | MOZ_CAN_RUN_SCRIPT static bool |
14222 | | createBuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14223 | 0 | { |
14224 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.createBuffer", DOM, cx); |
14225 | 0 |
|
14226 | 0 | auto result(StrongOrRawPtr<mozilla::WebGLBuffer>(self->CreateBuffer())); |
14227 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14228 | 0 | if (!result) { |
14229 | 0 | args.rval().setNull(); |
14230 | 0 | return true; |
14231 | 0 | } |
14232 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
14233 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
14234 | 0 | return false; |
14235 | 0 | } |
14236 | 0 | return true; |
14237 | 0 | } |
14238 | | |
14239 | | static const JSJitInfo createBuffer_methodinfo = { |
14240 | | { (JSJitGetterOp)createBuffer }, |
14241 | | { prototypes::id::WebGLRenderingContext }, |
14242 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14243 | | JSJitInfo::Method, |
14244 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14245 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
14246 | | false, /* isInfallible. False in setters. */ |
14247 | | false, /* isMovable. Not relevant for setters. */ |
14248 | | false, /* isEliminatable. Not relevant for setters. */ |
14249 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14250 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14251 | | false, /* isTypedMethod. Only relevant for methods. */ |
14252 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14253 | | }; |
14254 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14255 | | static_assert(0 < 1, "There is no slot for us"); |
14256 | | |
14257 | | MOZ_CAN_RUN_SCRIPT static bool |
14258 | | createFramebuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14259 | 0 | { |
14260 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.createFramebuffer", DOM, cx); |
14261 | 0 |
|
14262 | 0 | auto result(StrongOrRawPtr<mozilla::WebGLFramebuffer>(self->CreateFramebuffer())); |
14263 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14264 | 0 | if (!result) { |
14265 | 0 | args.rval().setNull(); |
14266 | 0 | return true; |
14267 | 0 | } |
14268 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
14269 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
14270 | 0 | return false; |
14271 | 0 | } |
14272 | 0 | return true; |
14273 | 0 | } |
14274 | | |
14275 | | static const JSJitInfo createFramebuffer_methodinfo = { |
14276 | | { (JSJitGetterOp)createFramebuffer }, |
14277 | | { prototypes::id::WebGLRenderingContext }, |
14278 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14279 | | JSJitInfo::Method, |
14280 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14281 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
14282 | | false, /* isInfallible. False in setters. */ |
14283 | | false, /* isMovable. Not relevant for setters. */ |
14284 | | false, /* isEliminatable. Not relevant for setters. */ |
14285 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14286 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14287 | | false, /* isTypedMethod. Only relevant for methods. */ |
14288 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14289 | | }; |
14290 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14291 | | static_assert(0 < 1, "There is no slot for us"); |
14292 | | |
14293 | | MOZ_CAN_RUN_SCRIPT static bool |
14294 | | createProgram(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14295 | 0 | { |
14296 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.createProgram", DOM, cx); |
14297 | 0 |
|
14298 | 0 | auto result(StrongOrRawPtr<mozilla::WebGLProgram>(self->CreateProgram())); |
14299 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14300 | 0 | if (!result) { |
14301 | 0 | args.rval().setNull(); |
14302 | 0 | return true; |
14303 | 0 | } |
14304 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
14305 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
14306 | 0 | return false; |
14307 | 0 | } |
14308 | 0 | return true; |
14309 | 0 | } |
14310 | | |
14311 | | static const JSJitInfo createProgram_methodinfo = { |
14312 | | { (JSJitGetterOp)createProgram }, |
14313 | | { prototypes::id::WebGLRenderingContext }, |
14314 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14315 | | JSJitInfo::Method, |
14316 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14317 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
14318 | | false, /* isInfallible. False in setters. */ |
14319 | | false, /* isMovable. Not relevant for setters. */ |
14320 | | false, /* isEliminatable. Not relevant for setters. */ |
14321 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14322 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14323 | | false, /* isTypedMethod. Only relevant for methods. */ |
14324 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14325 | | }; |
14326 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14327 | | static_assert(0 < 1, "There is no slot for us"); |
14328 | | |
14329 | | MOZ_CAN_RUN_SCRIPT static bool |
14330 | | createRenderbuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14331 | 0 | { |
14332 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.createRenderbuffer", DOM, cx); |
14333 | 0 |
|
14334 | 0 | auto result(StrongOrRawPtr<mozilla::WebGLRenderbuffer>(self->CreateRenderbuffer())); |
14335 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14336 | 0 | if (!result) { |
14337 | 0 | args.rval().setNull(); |
14338 | 0 | return true; |
14339 | 0 | } |
14340 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
14341 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
14342 | 0 | return false; |
14343 | 0 | } |
14344 | 0 | return true; |
14345 | 0 | } |
14346 | | |
14347 | | static const JSJitInfo createRenderbuffer_methodinfo = { |
14348 | | { (JSJitGetterOp)createRenderbuffer }, |
14349 | | { prototypes::id::WebGLRenderingContext }, |
14350 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14351 | | JSJitInfo::Method, |
14352 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14353 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
14354 | | false, /* isInfallible. False in setters. */ |
14355 | | false, /* isMovable. Not relevant for setters. */ |
14356 | | false, /* isEliminatable. Not relevant for setters. */ |
14357 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14358 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14359 | | false, /* isTypedMethod. Only relevant for methods. */ |
14360 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14361 | | }; |
14362 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14363 | | static_assert(0 < 1, "There is no slot for us"); |
14364 | | |
14365 | | MOZ_CAN_RUN_SCRIPT static bool |
14366 | | createShader(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14367 | 0 | { |
14368 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.createShader", DOM, cx); |
14369 | 0 |
|
14370 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
14371 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.createShader"); |
14372 | 0 | } |
14373 | 0 | uint32_t arg0; |
14374 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
14375 | 0 | return false; |
14376 | 0 | } |
14377 | 0 | auto result(StrongOrRawPtr<mozilla::WebGLShader>(self->CreateShader(arg0))); |
14378 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14379 | 0 | if (!result) { |
14380 | 0 | args.rval().setNull(); |
14381 | 0 | return true; |
14382 | 0 | } |
14383 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
14384 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
14385 | 0 | return false; |
14386 | 0 | } |
14387 | 0 | return true; |
14388 | 0 | } |
14389 | | |
14390 | | static const JSJitInfo createShader_methodinfo = { |
14391 | | { (JSJitGetterOp)createShader }, |
14392 | | { prototypes::id::WebGLRenderingContext }, |
14393 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14394 | | JSJitInfo::Method, |
14395 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14396 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
14397 | | false, /* isInfallible. False in setters. */ |
14398 | | false, /* isMovable. Not relevant for setters. */ |
14399 | | false, /* isEliminatable. Not relevant for setters. */ |
14400 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14401 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14402 | | false, /* isTypedMethod. Only relevant for methods. */ |
14403 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14404 | | }; |
14405 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14406 | | static_assert(0 < 1, "There is no slot for us"); |
14407 | | |
14408 | | MOZ_CAN_RUN_SCRIPT static bool |
14409 | | createTexture(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14410 | 0 | { |
14411 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.createTexture", DOM, cx); |
14412 | 0 |
|
14413 | 0 | auto result(StrongOrRawPtr<mozilla::WebGLTexture>(self->CreateTexture())); |
14414 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14415 | 0 | if (!result) { |
14416 | 0 | args.rval().setNull(); |
14417 | 0 | return true; |
14418 | 0 | } |
14419 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
14420 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
14421 | 0 | return false; |
14422 | 0 | } |
14423 | 0 | return true; |
14424 | 0 | } |
14425 | | |
14426 | | static const JSJitInfo createTexture_methodinfo = { |
14427 | | { (JSJitGetterOp)createTexture }, |
14428 | | { prototypes::id::WebGLRenderingContext }, |
14429 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14430 | | JSJitInfo::Method, |
14431 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14432 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
14433 | | false, /* isInfallible. False in setters. */ |
14434 | | false, /* isMovable. Not relevant for setters. */ |
14435 | | false, /* isEliminatable. Not relevant for setters. */ |
14436 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14437 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14438 | | false, /* isTypedMethod. Only relevant for methods. */ |
14439 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14440 | | }; |
14441 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14442 | | static_assert(0 < 1, "There is no slot for us"); |
14443 | | |
14444 | | MOZ_CAN_RUN_SCRIPT static bool |
14445 | | cullFace(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14446 | 0 | { |
14447 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.cullFace", DOM, cx); |
14448 | 0 |
|
14449 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
14450 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.cullFace"); |
14451 | 0 | } |
14452 | 0 | uint32_t arg0; |
14453 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
14454 | 0 | return false; |
14455 | 0 | } |
14456 | 0 | self->CullFace(arg0); |
14457 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14458 | 0 | args.rval().setUndefined(); |
14459 | 0 | return true; |
14460 | 0 | } |
14461 | | |
14462 | | static const JSJitInfo cullFace_methodinfo = { |
14463 | | { (JSJitGetterOp)cullFace }, |
14464 | | { prototypes::id::WebGLRenderingContext }, |
14465 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14466 | | JSJitInfo::Method, |
14467 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14468 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
14469 | | false, /* isInfallible. False in setters. */ |
14470 | | false, /* isMovable. Not relevant for setters. */ |
14471 | | false, /* isEliminatable. Not relevant for setters. */ |
14472 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14473 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14474 | | false, /* isTypedMethod. Only relevant for methods. */ |
14475 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14476 | | }; |
14477 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14478 | | static_assert(0 < 1, "There is no slot for us"); |
14479 | | |
14480 | | MOZ_CAN_RUN_SCRIPT static bool |
14481 | | deleteBuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14482 | 0 | { |
14483 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.deleteBuffer", DOM, cx); |
14484 | 0 |
|
14485 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
14486 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.deleteBuffer"); |
14487 | 0 | } |
14488 | 0 | mozilla::WebGLBuffer* arg0; |
14489 | 0 | if (args[0].isObject()) { |
14490 | 0 | { |
14491 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLBuffer, mozilla::WebGLBuffer>(args[0], arg0); |
14492 | 0 | if (NS_FAILED(rv)) { |
14493 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.deleteBuffer", "WebGLBuffer"); |
14494 | 0 | return false; |
14495 | 0 | } |
14496 | 0 | } |
14497 | 0 | } else if (args[0].isNullOrUndefined()) { |
14498 | 0 | arg0 = nullptr; |
14499 | 0 | } else { |
14500 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.deleteBuffer"); |
14501 | 0 | return false; |
14502 | 0 | } |
14503 | 0 | self->DeleteBuffer(MOZ_KnownLive(Constify(arg0))); |
14504 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14505 | 0 | args.rval().setUndefined(); |
14506 | 0 | return true; |
14507 | 0 | } |
14508 | | |
14509 | | static const JSJitInfo deleteBuffer_methodinfo = { |
14510 | | { (JSJitGetterOp)deleteBuffer }, |
14511 | | { prototypes::id::WebGLRenderingContext }, |
14512 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14513 | | JSJitInfo::Method, |
14514 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14515 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
14516 | | false, /* isInfallible. False in setters. */ |
14517 | | false, /* isMovable. Not relevant for setters. */ |
14518 | | false, /* isEliminatable. Not relevant for setters. */ |
14519 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14520 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14521 | | false, /* isTypedMethod. Only relevant for methods. */ |
14522 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14523 | | }; |
14524 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14525 | | static_assert(0 < 1, "There is no slot for us"); |
14526 | | |
14527 | | MOZ_CAN_RUN_SCRIPT static bool |
14528 | | deleteFramebuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14529 | 0 | { |
14530 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.deleteFramebuffer", DOM, cx); |
14531 | 0 |
|
14532 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
14533 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.deleteFramebuffer"); |
14534 | 0 | } |
14535 | 0 | mozilla::WebGLFramebuffer* arg0; |
14536 | 0 | if (args[0].isObject()) { |
14537 | 0 | { |
14538 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLFramebuffer, mozilla::WebGLFramebuffer>(args[0], arg0); |
14539 | 0 | if (NS_FAILED(rv)) { |
14540 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.deleteFramebuffer", "WebGLFramebuffer"); |
14541 | 0 | return false; |
14542 | 0 | } |
14543 | 0 | } |
14544 | 0 | } else if (args[0].isNullOrUndefined()) { |
14545 | 0 | arg0 = nullptr; |
14546 | 0 | } else { |
14547 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.deleteFramebuffer"); |
14548 | 0 | return false; |
14549 | 0 | } |
14550 | 0 | self->DeleteFramebuffer(MOZ_KnownLive(Constify(arg0))); |
14551 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14552 | 0 | args.rval().setUndefined(); |
14553 | 0 | return true; |
14554 | 0 | } |
14555 | | |
14556 | | static const JSJitInfo deleteFramebuffer_methodinfo = { |
14557 | | { (JSJitGetterOp)deleteFramebuffer }, |
14558 | | { prototypes::id::WebGLRenderingContext }, |
14559 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14560 | | JSJitInfo::Method, |
14561 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14562 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
14563 | | false, /* isInfallible. False in setters. */ |
14564 | | false, /* isMovable. Not relevant for setters. */ |
14565 | | false, /* isEliminatable. Not relevant for setters. */ |
14566 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14567 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14568 | | false, /* isTypedMethod. Only relevant for methods. */ |
14569 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14570 | | }; |
14571 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14572 | | static_assert(0 < 1, "There is no slot for us"); |
14573 | | |
14574 | | MOZ_CAN_RUN_SCRIPT static bool |
14575 | | deleteProgram(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14576 | 0 | { |
14577 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.deleteProgram", DOM, cx); |
14578 | 0 |
|
14579 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
14580 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.deleteProgram"); |
14581 | 0 | } |
14582 | 0 | mozilla::WebGLProgram* arg0; |
14583 | 0 | if (args[0].isObject()) { |
14584 | 0 | { |
14585 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLProgram, mozilla::WebGLProgram>(args[0], arg0); |
14586 | 0 | if (NS_FAILED(rv)) { |
14587 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.deleteProgram", "WebGLProgram"); |
14588 | 0 | return false; |
14589 | 0 | } |
14590 | 0 | } |
14591 | 0 | } else if (args[0].isNullOrUndefined()) { |
14592 | 0 | arg0 = nullptr; |
14593 | 0 | } else { |
14594 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.deleteProgram"); |
14595 | 0 | return false; |
14596 | 0 | } |
14597 | 0 | self->DeleteProgram(MOZ_KnownLive(Constify(arg0))); |
14598 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14599 | 0 | args.rval().setUndefined(); |
14600 | 0 | return true; |
14601 | 0 | } |
14602 | | |
14603 | | static const JSJitInfo deleteProgram_methodinfo = { |
14604 | | { (JSJitGetterOp)deleteProgram }, |
14605 | | { prototypes::id::WebGLRenderingContext }, |
14606 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14607 | | JSJitInfo::Method, |
14608 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14609 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
14610 | | false, /* isInfallible. False in setters. */ |
14611 | | false, /* isMovable. Not relevant for setters. */ |
14612 | | false, /* isEliminatable. Not relevant for setters. */ |
14613 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14614 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14615 | | false, /* isTypedMethod. Only relevant for methods. */ |
14616 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14617 | | }; |
14618 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14619 | | static_assert(0 < 1, "There is no slot for us"); |
14620 | | |
14621 | | MOZ_CAN_RUN_SCRIPT static bool |
14622 | | deleteRenderbuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14623 | 0 | { |
14624 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.deleteRenderbuffer", DOM, cx); |
14625 | 0 |
|
14626 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
14627 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.deleteRenderbuffer"); |
14628 | 0 | } |
14629 | 0 | mozilla::WebGLRenderbuffer* arg0; |
14630 | 0 | if (args[0].isObject()) { |
14631 | 0 | { |
14632 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLRenderbuffer, mozilla::WebGLRenderbuffer>(args[0], arg0); |
14633 | 0 | if (NS_FAILED(rv)) { |
14634 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.deleteRenderbuffer", "WebGLRenderbuffer"); |
14635 | 0 | return false; |
14636 | 0 | } |
14637 | 0 | } |
14638 | 0 | } else if (args[0].isNullOrUndefined()) { |
14639 | 0 | arg0 = nullptr; |
14640 | 0 | } else { |
14641 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.deleteRenderbuffer"); |
14642 | 0 | return false; |
14643 | 0 | } |
14644 | 0 | self->DeleteRenderbuffer(MOZ_KnownLive(Constify(arg0))); |
14645 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14646 | 0 | args.rval().setUndefined(); |
14647 | 0 | return true; |
14648 | 0 | } |
14649 | | |
14650 | | static const JSJitInfo deleteRenderbuffer_methodinfo = { |
14651 | | { (JSJitGetterOp)deleteRenderbuffer }, |
14652 | | { prototypes::id::WebGLRenderingContext }, |
14653 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14654 | | JSJitInfo::Method, |
14655 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14656 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
14657 | | false, /* isInfallible. False in setters. */ |
14658 | | false, /* isMovable. Not relevant for setters. */ |
14659 | | false, /* isEliminatable. Not relevant for setters. */ |
14660 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14661 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14662 | | false, /* isTypedMethod. Only relevant for methods. */ |
14663 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14664 | | }; |
14665 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14666 | | static_assert(0 < 1, "There is no slot for us"); |
14667 | | |
14668 | | MOZ_CAN_RUN_SCRIPT static bool |
14669 | | deleteShader(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14670 | 0 | { |
14671 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.deleteShader", DOM, cx); |
14672 | 0 |
|
14673 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
14674 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.deleteShader"); |
14675 | 0 | } |
14676 | 0 | mozilla::WebGLShader* arg0; |
14677 | 0 | if (args[0].isObject()) { |
14678 | 0 | { |
14679 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLShader, mozilla::WebGLShader>(args[0], arg0); |
14680 | 0 | if (NS_FAILED(rv)) { |
14681 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.deleteShader", "WebGLShader"); |
14682 | 0 | return false; |
14683 | 0 | } |
14684 | 0 | } |
14685 | 0 | } else if (args[0].isNullOrUndefined()) { |
14686 | 0 | arg0 = nullptr; |
14687 | 0 | } else { |
14688 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.deleteShader"); |
14689 | 0 | return false; |
14690 | 0 | } |
14691 | 0 | self->DeleteShader(MOZ_KnownLive(Constify(arg0))); |
14692 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14693 | 0 | args.rval().setUndefined(); |
14694 | 0 | return true; |
14695 | 0 | } |
14696 | | |
14697 | | static const JSJitInfo deleteShader_methodinfo = { |
14698 | | { (JSJitGetterOp)deleteShader }, |
14699 | | { prototypes::id::WebGLRenderingContext }, |
14700 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14701 | | JSJitInfo::Method, |
14702 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14703 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
14704 | | false, /* isInfallible. False in setters. */ |
14705 | | false, /* isMovable. Not relevant for setters. */ |
14706 | | false, /* isEliminatable. Not relevant for setters. */ |
14707 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14708 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14709 | | false, /* isTypedMethod. Only relevant for methods. */ |
14710 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14711 | | }; |
14712 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14713 | | static_assert(0 < 1, "There is no slot for us"); |
14714 | | |
14715 | | MOZ_CAN_RUN_SCRIPT static bool |
14716 | | deleteTexture(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14717 | 0 | { |
14718 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.deleteTexture", DOM, cx); |
14719 | 0 |
|
14720 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
14721 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.deleteTexture"); |
14722 | 0 | } |
14723 | 0 | mozilla::WebGLTexture* arg0; |
14724 | 0 | if (args[0].isObject()) { |
14725 | 0 | { |
14726 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLTexture, mozilla::WebGLTexture>(args[0], arg0); |
14727 | 0 | if (NS_FAILED(rv)) { |
14728 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.deleteTexture", "WebGLTexture"); |
14729 | 0 | return false; |
14730 | 0 | } |
14731 | 0 | } |
14732 | 0 | } else if (args[0].isNullOrUndefined()) { |
14733 | 0 | arg0 = nullptr; |
14734 | 0 | } else { |
14735 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.deleteTexture"); |
14736 | 0 | return false; |
14737 | 0 | } |
14738 | 0 | self->DeleteTexture(MOZ_KnownLive(Constify(arg0))); |
14739 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14740 | 0 | args.rval().setUndefined(); |
14741 | 0 | return true; |
14742 | 0 | } |
14743 | | |
14744 | | static const JSJitInfo deleteTexture_methodinfo = { |
14745 | | { (JSJitGetterOp)deleteTexture }, |
14746 | | { prototypes::id::WebGLRenderingContext }, |
14747 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14748 | | JSJitInfo::Method, |
14749 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14750 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
14751 | | false, /* isInfallible. False in setters. */ |
14752 | | false, /* isMovable. Not relevant for setters. */ |
14753 | | false, /* isEliminatable. Not relevant for setters. */ |
14754 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14755 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14756 | | false, /* isTypedMethod. Only relevant for methods. */ |
14757 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14758 | | }; |
14759 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14760 | | static_assert(0 < 1, "There is no slot for us"); |
14761 | | |
14762 | | MOZ_CAN_RUN_SCRIPT static bool |
14763 | | depthFunc(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14764 | 0 | { |
14765 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.depthFunc", DOM, cx); |
14766 | 0 |
|
14767 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
14768 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.depthFunc"); |
14769 | 0 | } |
14770 | 0 | uint32_t arg0; |
14771 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
14772 | 0 | return false; |
14773 | 0 | } |
14774 | 0 | self->DepthFunc(arg0); |
14775 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14776 | 0 | args.rval().setUndefined(); |
14777 | 0 | return true; |
14778 | 0 | } |
14779 | | |
14780 | | static const JSJitInfo depthFunc_methodinfo = { |
14781 | | { (JSJitGetterOp)depthFunc }, |
14782 | | { prototypes::id::WebGLRenderingContext }, |
14783 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14784 | | JSJitInfo::Method, |
14785 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14786 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
14787 | | false, /* isInfallible. False in setters. */ |
14788 | | false, /* isMovable. Not relevant for setters. */ |
14789 | | false, /* isEliminatable. Not relevant for setters. */ |
14790 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14791 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14792 | | false, /* isTypedMethod. Only relevant for methods. */ |
14793 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14794 | | }; |
14795 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14796 | | static_assert(0 < 1, "There is no slot for us"); |
14797 | | |
14798 | | MOZ_CAN_RUN_SCRIPT static bool |
14799 | | depthMask(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14800 | 0 | { |
14801 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.depthMask", DOM, cx); |
14802 | 0 |
|
14803 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
14804 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.depthMask"); |
14805 | 0 | } |
14806 | 0 | bool arg0; |
14807 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) { |
14808 | 0 | return false; |
14809 | 0 | } |
14810 | 0 | self->DepthMask(arg0); |
14811 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14812 | 0 | args.rval().setUndefined(); |
14813 | 0 | return true; |
14814 | 0 | } |
14815 | | |
14816 | | static const JSJitInfo depthMask_methodinfo = { |
14817 | | { (JSJitGetterOp)depthMask }, |
14818 | | { prototypes::id::WebGLRenderingContext }, |
14819 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14820 | | JSJitInfo::Method, |
14821 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14822 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
14823 | | false, /* isInfallible. False in setters. */ |
14824 | | false, /* isMovable. Not relevant for setters. */ |
14825 | | false, /* isEliminatable. Not relevant for setters. */ |
14826 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14827 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14828 | | false, /* isTypedMethod. Only relevant for methods. */ |
14829 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14830 | | }; |
14831 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14832 | | static_assert(0 < 1, "There is no slot for us"); |
14833 | | |
14834 | | MOZ_CAN_RUN_SCRIPT static bool |
14835 | | depthRange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14836 | 0 | { |
14837 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.depthRange", DOM, cx); |
14838 | 0 |
|
14839 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
14840 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.depthRange"); |
14841 | 0 | } |
14842 | 0 | float arg0; |
14843 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) { |
14844 | 0 | return false; |
14845 | 0 | } |
14846 | 0 | float arg1; |
14847 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[1], &arg1)) { |
14848 | 0 | return false; |
14849 | 0 | } |
14850 | 0 | self->DepthRange(arg0, arg1); |
14851 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14852 | 0 | args.rval().setUndefined(); |
14853 | 0 | return true; |
14854 | 0 | } |
14855 | | |
14856 | | static const JSJitInfo depthRange_methodinfo = { |
14857 | | { (JSJitGetterOp)depthRange }, |
14858 | | { prototypes::id::WebGLRenderingContext }, |
14859 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14860 | | JSJitInfo::Method, |
14861 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14862 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
14863 | | false, /* isInfallible. False in setters. */ |
14864 | | false, /* isMovable. Not relevant for setters. */ |
14865 | | false, /* isEliminatable. Not relevant for setters. */ |
14866 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14867 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14868 | | false, /* isTypedMethod. Only relevant for methods. */ |
14869 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14870 | | }; |
14871 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14872 | | static_assert(0 < 1, "There is no slot for us"); |
14873 | | |
14874 | | MOZ_CAN_RUN_SCRIPT static bool |
14875 | | detachShader(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14876 | 0 | { |
14877 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.detachShader", DOM, cx); |
14878 | 0 |
|
14879 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
14880 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.detachShader"); |
14881 | 0 | } |
14882 | 0 | NonNull<mozilla::WebGLProgram> arg0; |
14883 | 0 | if (args[0].isObject()) { |
14884 | 0 | { |
14885 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLProgram, mozilla::WebGLProgram>(args[0], arg0); |
14886 | 0 | if (NS_FAILED(rv)) { |
14887 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.detachShader", "WebGLProgram"); |
14888 | 0 | return false; |
14889 | 0 | } |
14890 | 0 | } |
14891 | 0 | } else { |
14892 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.detachShader"); |
14893 | 0 | return false; |
14894 | 0 | } |
14895 | 0 | NonNull<mozilla::WebGLShader> arg1; |
14896 | 0 | if (args[1].isObject()) { |
14897 | 0 | { |
14898 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLShader, mozilla::WebGLShader>(args[1], arg1); |
14899 | 0 | if (NS_FAILED(rv)) { |
14900 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of WebGLRenderingContext.detachShader", "WebGLShader"); |
14901 | 0 | return false; |
14902 | 0 | } |
14903 | 0 | } |
14904 | 0 | } else { |
14905 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of WebGLRenderingContext.detachShader"); |
14906 | 0 | return false; |
14907 | 0 | } |
14908 | 0 | self->DetachShader(MOZ_KnownLive(NonNullHelper(arg0)), MOZ_KnownLive(NonNullHelper(arg1))); |
14909 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14910 | 0 | args.rval().setUndefined(); |
14911 | 0 | return true; |
14912 | 0 | } |
14913 | | |
14914 | | static const JSJitInfo detachShader_methodinfo = { |
14915 | | { (JSJitGetterOp)detachShader }, |
14916 | | { prototypes::id::WebGLRenderingContext }, |
14917 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14918 | | JSJitInfo::Method, |
14919 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14920 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
14921 | | false, /* isInfallible. False in setters. */ |
14922 | | false, /* isMovable. Not relevant for setters. */ |
14923 | | false, /* isEliminatable. Not relevant for setters. */ |
14924 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14925 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14926 | | false, /* isTypedMethod. Only relevant for methods. */ |
14927 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14928 | | }; |
14929 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14930 | | static_assert(0 < 1, "There is no slot for us"); |
14931 | | |
14932 | | MOZ_CAN_RUN_SCRIPT static bool |
14933 | | disable(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14934 | 0 | { |
14935 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.disable", DOM, cx); |
14936 | 0 |
|
14937 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
14938 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.disable"); |
14939 | 0 | } |
14940 | 0 | uint32_t arg0; |
14941 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
14942 | 0 | return false; |
14943 | 0 | } |
14944 | 0 | self->Disable(arg0); |
14945 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14946 | 0 | args.rval().setUndefined(); |
14947 | 0 | return true; |
14948 | 0 | } |
14949 | | |
14950 | | static const JSJitInfo disable_methodinfo = { |
14951 | | { (JSJitGetterOp)disable }, |
14952 | | { prototypes::id::WebGLRenderingContext }, |
14953 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14954 | | JSJitInfo::Method, |
14955 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14956 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
14957 | | false, /* isInfallible. False in setters. */ |
14958 | | false, /* isMovable. Not relevant for setters. */ |
14959 | | false, /* isEliminatable. Not relevant for setters. */ |
14960 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14961 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14962 | | false, /* isTypedMethod. Only relevant for methods. */ |
14963 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
14964 | | }; |
14965 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
14966 | | static_assert(0 < 1, "There is no slot for us"); |
14967 | | |
14968 | | MOZ_CAN_RUN_SCRIPT static bool |
14969 | | disableVertexAttribArray(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
14970 | 0 | { |
14971 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.disableVertexAttribArray", DOM, cx); |
14972 | 0 |
|
14973 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
14974 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.disableVertexAttribArray"); |
14975 | 0 | } |
14976 | 0 | uint32_t arg0; |
14977 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
14978 | 0 | return false; |
14979 | 0 | } |
14980 | 0 | self->DisableVertexAttribArray(arg0); |
14981 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
14982 | 0 | args.rval().setUndefined(); |
14983 | 0 | return true; |
14984 | 0 | } |
14985 | | |
14986 | | static const JSJitInfo disableVertexAttribArray_methodinfo = { |
14987 | | { (JSJitGetterOp)disableVertexAttribArray }, |
14988 | | { prototypes::id::WebGLRenderingContext }, |
14989 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
14990 | | JSJitInfo::Method, |
14991 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
14992 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
14993 | | false, /* isInfallible. False in setters. */ |
14994 | | false, /* isMovable. Not relevant for setters. */ |
14995 | | false, /* isEliminatable. Not relevant for setters. */ |
14996 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
14997 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
14998 | | false, /* isTypedMethod. Only relevant for methods. */ |
14999 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15000 | | }; |
15001 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15002 | | static_assert(0 < 1, "There is no slot for us"); |
15003 | | |
15004 | | MOZ_CAN_RUN_SCRIPT static bool |
15005 | | drawArrays(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15006 | 0 | { |
15007 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.drawArrays", DOM, cx); |
15008 | 0 |
|
15009 | 0 | if (MOZ_UNLIKELY(args.length() < 3)) { |
15010 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.drawArrays"); |
15011 | 0 | } |
15012 | 0 | uint32_t arg0; |
15013 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
15014 | 0 | return false; |
15015 | 0 | } |
15016 | 0 | int32_t arg1; |
15017 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
15018 | 0 | return false; |
15019 | 0 | } |
15020 | 0 | int32_t arg2; |
15021 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
15022 | 0 | return false; |
15023 | 0 | } |
15024 | 0 | self->DrawArrays(arg0, arg1, arg2); |
15025 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15026 | 0 | args.rval().setUndefined(); |
15027 | 0 | return true; |
15028 | 0 | } |
15029 | | |
15030 | | static const JSJitInfo drawArrays_methodinfo = { |
15031 | | { (JSJitGetterOp)drawArrays }, |
15032 | | { prototypes::id::WebGLRenderingContext }, |
15033 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15034 | | JSJitInfo::Method, |
15035 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15036 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
15037 | | false, /* isInfallible. False in setters. */ |
15038 | | false, /* isMovable. Not relevant for setters. */ |
15039 | | false, /* isEliminatable. Not relevant for setters. */ |
15040 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15041 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15042 | | false, /* isTypedMethod. Only relevant for methods. */ |
15043 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15044 | | }; |
15045 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15046 | | static_assert(0 < 1, "There is no slot for us"); |
15047 | | |
15048 | | MOZ_CAN_RUN_SCRIPT static bool |
15049 | | drawElements(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15050 | 0 | { |
15051 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.drawElements", DOM, cx); |
15052 | 0 |
|
15053 | 0 | if (MOZ_UNLIKELY(args.length() < 4)) { |
15054 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.drawElements"); |
15055 | 0 | } |
15056 | 0 | uint32_t arg0; |
15057 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
15058 | 0 | return false; |
15059 | 0 | } |
15060 | 0 | int32_t arg1; |
15061 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
15062 | 0 | return false; |
15063 | 0 | } |
15064 | 0 | uint32_t arg2; |
15065 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) { |
15066 | 0 | return false; |
15067 | 0 | } |
15068 | 0 | int64_t arg3; |
15069 | 0 | if (!ValueToPrimitive<int64_t, eDefault>(cx, args[3], &arg3)) { |
15070 | 0 | return false; |
15071 | 0 | } |
15072 | 0 | self->DrawElements(arg0, arg1, arg2, arg3); |
15073 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15074 | 0 | args.rval().setUndefined(); |
15075 | 0 | return true; |
15076 | 0 | } |
15077 | | |
15078 | | static const JSJitInfo drawElements_methodinfo = { |
15079 | | { (JSJitGetterOp)drawElements }, |
15080 | | { prototypes::id::WebGLRenderingContext }, |
15081 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15082 | | JSJitInfo::Method, |
15083 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15084 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
15085 | | false, /* isInfallible. False in setters. */ |
15086 | | false, /* isMovable. Not relevant for setters. */ |
15087 | | false, /* isEliminatable. Not relevant for setters. */ |
15088 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15089 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15090 | | false, /* isTypedMethod. Only relevant for methods. */ |
15091 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15092 | | }; |
15093 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15094 | | static_assert(0 < 1, "There is no slot for us"); |
15095 | | |
15096 | | MOZ_CAN_RUN_SCRIPT static bool |
15097 | | enable(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15098 | 0 | { |
15099 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.enable", DOM, cx); |
15100 | 0 |
|
15101 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
15102 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.enable"); |
15103 | 0 | } |
15104 | 0 | uint32_t arg0; |
15105 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
15106 | 0 | return false; |
15107 | 0 | } |
15108 | 0 | self->Enable(arg0); |
15109 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15110 | 0 | args.rval().setUndefined(); |
15111 | 0 | return true; |
15112 | 0 | } |
15113 | | |
15114 | | static const JSJitInfo enable_methodinfo = { |
15115 | | { (JSJitGetterOp)enable }, |
15116 | | { prototypes::id::WebGLRenderingContext }, |
15117 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15118 | | JSJitInfo::Method, |
15119 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15120 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
15121 | | false, /* isInfallible. False in setters. */ |
15122 | | false, /* isMovable. Not relevant for setters. */ |
15123 | | false, /* isEliminatable. Not relevant for setters. */ |
15124 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15125 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15126 | | false, /* isTypedMethod. Only relevant for methods. */ |
15127 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15128 | | }; |
15129 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15130 | | static_assert(0 < 1, "There is no slot for us"); |
15131 | | |
15132 | | MOZ_CAN_RUN_SCRIPT static bool |
15133 | | enableVertexAttribArray(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15134 | 0 | { |
15135 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.enableVertexAttribArray", DOM, cx); |
15136 | 0 |
|
15137 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
15138 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.enableVertexAttribArray"); |
15139 | 0 | } |
15140 | 0 | uint32_t arg0; |
15141 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
15142 | 0 | return false; |
15143 | 0 | } |
15144 | 0 | self->EnableVertexAttribArray(arg0); |
15145 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15146 | 0 | args.rval().setUndefined(); |
15147 | 0 | return true; |
15148 | 0 | } |
15149 | | |
15150 | | static const JSJitInfo enableVertexAttribArray_methodinfo = { |
15151 | | { (JSJitGetterOp)enableVertexAttribArray }, |
15152 | | { prototypes::id::WebGLRenderingContext }, |
15153 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15154 | | JSJitInfo::Method, |
15155 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15156 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
15157 | | false, /* isInfallible. False in setters. */ |
15158 | | false, /* isMovable. Not relevant for setters. */ |
15159 | | false, /* isEliminatable. Not relevant for setters. */ |
15160 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15161 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15162 | | false, /* isTypedMethod. Only relevant for methods. */ |
15163 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15164 | | }; |
15165 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15166 | | static_assert(0 < 1, "There is no slot for us"); |
15167 | | |
15168 | | MOZ_CAN_RUN_SCRIPT static bool |
15169 | | finish(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15170 | 0 | { |
15171 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.finish", DOM, cx); |
15172 | 0 |
|
15173 | 0 | self->Finish(); |
15174 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15175 | 0 | args.rval().setUndefined(); |
15176 | 0 | return true; |
15177 | 0 | } |
15178 | | |
15179 | | static const JSJitInfo finish_methodinfo = { |
15180 | | { (JSJitGetterOp)finish }, |
15181 | | { prototypes::id::WebGLRenderingContext }, |
15182 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15183 | | JSJitInfo::Method, |
15184 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15185 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
15186 | | true, /* isInfallible. False in setters. */ |
15187 | | false, /* isMovable. Not relevant for setters. */ |
15188 | | false, /* isEliminatable. Not relevant for setters. */ |
15189 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15190 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15191 | | false, /* isTypedMethod. Only relevant for methods. */ |
15192 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15193 | | }; |
15194 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15195 | | static_assert(0 < 1, "There is no slot for us"); |
15196 | | |
15197 | | MOZ_CAN_RUN_SCRIPT static bool |
15198 | | flush(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15199 | 0 | { |
15200 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.flush", DOM, cx); |
15201 | 0 |
|
15202 | 0 | self->Flush(); |
15203 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15204 | 0 | args.rval().setUndefined(); |
15205 | 0 | return true; |
15206 | 0 | } |
15207 | | |
15208 | | static const JSJitInfo flush_methodinfo = { |
15209 | | { (JSJitGetterOp)flush }, |
15210 | | { prototypes::id::WebGLRenderingContext }, |
15211 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15212 | | JSJitInfo::Method, |
15213 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15214 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
15215 | | true, /* isInfallible. False in setters. */ |
15216 | | false, /* isMovable. Not relevant for setters. */ |
15217 | | false, /* isEliminatable. Not relevant for setters. */ |
15218 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15219 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15220 | | false, /* isTypedMethod. Only relevant for methods. */ |
15221 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15222 | | }; |
15223 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15224 | | static_assert(0 < 1, "There is no slot for us"); |
15225 | | |
15226 | | MOZ_CAN_RUN_SCRIPT static bool |
15227 | | framebufferRenderbuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15228 | 0 | { |
15229 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.framebufferRenderbuffer", DOM, cx); |
15230 | 0 |
|
15231 | 0 | if (MOZ_UNLIKELY(args.length() < 4)) { |
15232 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.framebufferRenderbuffer"); |
15233 | 0 | } |
15234 | 0 | uint32_t arg0; |
15235 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
15236 | 0 | return false; |
15237 | 0 | } |
15238 | 0 | uint32_t arg1; |
15239 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
15240 | 0 | return false; |
15241 | 0 | } |
15242 | 0 | uint32_t arg2; |
15243 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) { |
15244 | 0 | return false; |
15245 | 0 | } |
15246 | 0 | mozilla::WebGLRenderbuffer* arg3; |
15247 | 0 | if (args[3].isObject()) { |
15248 | 0 | { |
15249 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLRenderbuffer, mozilla::WebGLRenderbuffer>(args[3], arg3); |
15250 | 0 | if (NS_FAILED(rv)) { |
15251 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 4 of WebGLRenderingContext.framebufferRenderbuffer", "WebGLRenderbuffer"); |
15252 | 0 | return false; |
15253 | 0 | } |
15254 | 0 | } |
15255 | 0 | } else if (args[3].isNullOrUndefined()) { |
15256 | 0 | arg3 = nullptr; |
15257 | 0 | } else { |
15258 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 4 of WebGLRenderingContext.framebufferRenderbuffer"); |
15259 | 0 | return false; |
15260 | 0 | } |
15261 | 0 | self->FramebufferRenderbuffer(arg0, arg1, arg2, MOZ_KnownLive(Constify(arg3))); |
15262 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15263 | 0 | args.rval().setUndefined(); |
15264 | 0 | return true; |
15265 | 0 | } |
15266 | | |
15267 | | static const JSJitInfo framebufferRenderbuffer_methodinfo = { |
15268 | | { (JSJitGetterOp)framebufferRenderbuffer }, |
15269 | | { prototypes::id::WebGLRenderingContext }, |
15270 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15271 | | JSJitInfo::Method, |
15272 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15273 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
15274 | | false, /* isInfallible. False in setters. */ |
15275 | | false, /* isMovable. Not relevant for setters. */ |
15276 | | false, /* isEliminatable. Not relevant for setters. */ |
15277 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15278 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15279 | | false, /* isTypedMethod. Only relevant for methods. */ |
15280 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15281 | | }; |
15282 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15283 | | static_assert(0 < 1, "There is no slot for us"); |
15284 | | |
15285 | | MOZ_CAN_RUN_SCRIPT static bool |
15286 | | framebufferTexture2D(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15287 | 0 | { |
15288 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.framebufferTexture2D", DOM, cx); |
15289 | 0 |
|
15290 | 0 | if (MOZ_UNLIKELY(args.length() < 5)) { |
15291 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.framebufferTexture2D"); |
15292 | 0 | } |
15293 | 0 | uint32_t arg0; |
15294 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
15295 | 0 | return false; |
15296 | 0 | } |
15297 | 0 | uint32_t arg1; |
15298 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
15299 | 0 | return false; |
15300 | 0 | } |
15301 | 0 | uint32_t arg2; |
15302 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) { |
15303 | 0 | return false; |
15304 | 0 | } |
15305 | 0 | mozilla::WebGLTexture* arg3; |
15306 | 0 | if (args[3].isObject()) { |
15307 | 0 | { |
15308 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLTexture, mozilla::WebGLTexture>(args[3], arg3); |
15309 | 0 | if (NS_FAILED(rv)) { |
15310 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 4 of WebGLRenderingContext.framebufferTexture2D", "WebGLTexture"); |
15311 | 0 | return false; |
15312 | 0 | } |
15313 | 0 | } |
15314 | 0 | } else if (args[3].isNullOrUndefined()) { |
15315 | 0 | arg3 = nullptr; |
15316 | 0 | } else { |
15317 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 4 of WebGLRenderingContext.framebufferTexture2D"); |
15318 | 0 | return false; |
15319 | 0 | } |
15320 | 0 | int32_t arg4; |
15321 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) { |
15322 | 0 | return false; |
15323 | 0 | } |
15324 | 0 | self->FramebufferTexture2D(arg0, arg1, arg2, MOZ_KnownLive(Constify(arg3)), arg4); |
15325 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15326 | 0 | args.rval().setUndefined(); |
15327 | 0 | return true; |
15328 | 0 | } |
15329 | | |
15330 | | static const JSJitInfo framebufferTexture2D_methodinfo = { |
15331 | | { (JSJitGetterOp)framebufferTexture2D }, |
15332 | | { prototypes::id::WebGLRenderingContext }, |
15333 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15334 | | JSJitInfo::Method, |
15335 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15336 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
15337 | | false, /* isInfallible. False in setters. */ |
15338 | | false, /* isMovable. Not relevant for setters. */ |
15339 | | false, /* isEliminatable. Not relevant for setters. */ |
15340 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15341 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15342 | | false, /* isTypedMethod. Only relevant for methods. */ |
15343 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15344 | | }; |
15345 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15346 | | static_assert(0 < 1, "There is no slot for us"); |
15347 | | |
15348 | | MOZ_CAN_RUN_SCRIPT static bool |
15349 | | frontFace(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15350 | 0 | { |
15351 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.frontFace", DOM, cx); |
15352 | 0 |
|
15353 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
15354 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.frontFace"); |
15355 | 0 | } |
15356 | 0 | uint32_t arg0; |
15357 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
15358 | 0 | return false; |
15359 | 0 | } |
15360 | 0 | self->FrontFace(arg0); |
15361 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15362 | 0 | args.rval().setUndefined(); |
15363 | 0 | return true; |
15364 | 0 | } |
15365 | | |
15366 | | static const JSJitInfo frontFace_methodinfo = { |
15367 | | { (JSJitGetterOp)frontFace }, |
15368 | | { prototypes::id::WebGLRenderingContext }, |
15369 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15370 | | JSJitInfo::Method, |
15371 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15372 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
15373 | | false, /* isInfallible. False in setters. */ |
15374 | | false, /* isMovable. Not relevant for setters. */ |
15375 | | false, /* isEliminatable. Not relevant for setters. */ |
15376 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15377 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15378 | | false, /* isTypedMethod. Only relevant for methods. */ |
15379 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15380 | | }; |
15381 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15382 | | static_assert(0 < 1, "There is no slot for us"); |
15383 | | |
15384 | | MOZ_CAN_RUN_SCRIPT static bool |
15385 | | generateMipmap(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15386 | 0 | { |
15387 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.generateMipmap", DOM, cx); |
15388 | 0 |
|
15389 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
15390 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.generateMipmap"); |
15391 | 0 | } |
15392 | 0 | uint32_t arg0; |
15393 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
15394 | 0 | return false; |
15395 | 0 | } |
15396 | 0 | self->GenerateMipmap(arg0); |
15397 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15398 | 0 | args.rval().setUndefined(); |
15399 | 0 | return true; |
15400 | 0 | } |
15401 | | |
15402 | | static const JSJitInfo generateMipmap_methodinfo = { |
15403 | | { (JSJitGetterOp)generateMipmap }, |
15404 | | { prototypes::id::WebGLRenderingContext }, |
15405 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15406 | | JSJitInfo::Method, |
15407 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15408 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
15409 | | false, /* isInfallible. False in setters. */ |
15410 | | false, /* isMovable. Not relevant for setters. */ |
15411 | | false, /* isEliminatable. Not relevant for setters. */ |
15412 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15413 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15414 | | false, /* isTypedMethod. Only relevant for methods. */ |
15415 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15416 | | }; |
15417 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15418 | | static_assert(0 < 1, "There is no slot for us"); |
15419 | | |
15420 | | MOZ_CAN_RUN_SCRIPT static bool |
15421 | | getActiveAttrib(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15422 | 0 | { |
15423 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getActiveAttrib", DOM, cx); |
15424 | 0 |
|
15425 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
15426 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getActiveAttrib"); |
15427 | 0 | } |
15428 | 0 | NonNull<mozilla::WebGLProgram> arg0; |
15429 | 0 | if (args[0].isObject()) { |
15430 | 0 | { |
15431 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLProgram, mozilla::WebGLProgram>(args[0], arg0); |
15432 | 0 | if (NS_FAILED(rv)) { |
15433 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.getActiveAttrib", "WebGLProgram"); |
15434 | 0 | return false; |
15435 | 0 | } |
15436 | 0 | } |
15437 | 0 | } else { |
15438 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.getActiveAttrib"); |
15439 | 0 | return false; |
15440 | 0 | } |
15441 | 0 | uint32_t arg1; |
15442 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
15443 | 0 | return false; |
15444 | 0 | } |
15445 | 0 | auto result(StrongOrRawPtr<mozilla::WebGLActiveInfo>(self->GetActiveAttrib(MOZ_KnownLive(NonNullHelper(arg0)), arg1))); |
15446 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15447 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
15448 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
15449 | 0 | if (!result) { |
15450 | 0 | args.rval().setNull(); |
15451 | 0 | return true; |
15452 | 0 | } |
15453 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
15454 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
15455 | 0 | return false; |
15456 | 0 | } |
15457 | 0 | return true; |
15458 | 0 | } |
15459 | | |
15460 | | static const JSJitInfo getActiveAttrib_methodinfo = { |
15461 | | { (JSJitGetterOp)getActiveAttrib }, |
15462 | | { prototypes::id::WebGLRenderingContext }, |
15463 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15464 | | JSJitInfo::Method, |
15465 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15466 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
15467 | | false, /* isInfallible. False in setters. */ |
15468 | | false, /* isMovable. Not relevant for setters. */ |
15469 | | false, /* isEliminatable. Not relevant for setters. */ |
15470 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15471 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15472 | | false, /* isTypedMethod. Only relevant for methods. */ |
15473 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15474 | | }; |
15475 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15476 | | static_assert(0 < 1, "There is no slot for us"); |
15477 | | |
15478 | | MOZ_CAN_RUN_SCRIPT static bool |
15479 | | getActiveUniform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15480 | 0 | { |
15481 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getActiveUniform", DOM, cx); |
15482 | 0 |
|
15483 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
15484 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getActiveUniform"); |
15485 | 0 | } |
15486 | 0 | NonNull<mozilla::WebGLProgram> arg0; |
15487 | 0 | if (args[0].isObject()) { |
15488 | 0 | { |
15489 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLProgram, mozilla::WebGLProgram>(args[0], arg0); |
15490 | 0 | if (NS_FAILED(rv)) { |
15491 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.getActiveUniform", "WebGLProgram"); |
15492 | 0 | return false; |
15493 | 0 | } |
15494 | 0 | } |
15495 | 0 | } else { |
15496 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.getActiveUniform"); |
15497 | 0 | return false; |
15498 | 0 | } |
15499 | 0 | uint32_t arg1; |
15500 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
15501 | 0 | return false; |
15502 | 0 | } |
15503 | 0 | auto result(StrongOrRawPtr<mozilla::WebGLActiveInfo>(self->GetActiveUniform(MOZ_KnownLive(NonNullHelper(arg0)), arg1))); |
15504 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15505 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
15506 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
15507 | 0 | if (!result) { |
15508 | 0 | args.rval().setNull(); |
15509 | 0 | return true; |
15510 | 0 | } |
15511 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
15512 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
15513 | 0 | return false; |
15514 | 0 | } |
15515 | 0 | return true; |
15516 | 0 | } |
15517 | | |
15518 | | static const JSJitInfo getActiveUniform_methodinfo = { |
15519 | | { (JSJitGetterOp)getActiveUniform }, |
15520 | | { prototypes::id::WebGLRenderingContext }, |
15521 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15522 | | JSJitInfo::Method, |
15523 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15524 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
15525 | | false, /* isInfallible. False in setters. */ |
15526 | | false, /* isMovable. Not relevant for setters. */ |
15527 | | false, /* isEliminatable. Not relevant for setters. */ |
15528 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15529 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15530 | | false, /* isTypedMethod. Only relevant for methods. */ |
15531 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15532 | | }; |
15533 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15534 | | static_assert(0 < 1, "There is no slot for us"); |
15535 | | |
15536 | | MOZ_CAN_RUN_SCRIPT static bool |
15537 | | getAttachedShaders(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15538 | 0 | { |
15539 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getAttachedShaders", DOM, cx); |
15540 | 0 |
|
15541 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
15542 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getAttachedShaders"); |
15543 | 0 | } |
15544 | 0 | NonNull<mozilla::WebGLProgram> arg0; |
15545 | 0 | if (args[0].isObject()) { |
15546 | 0 | { |
15547 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLProgram, mozilla::WebGLProgram>(args[0], arg0); |
15548 | 0 | if (NS_FAILED(rv)) { |
15549 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.getAttachedShaders", "WebGLProgram"); |
15550 | 0 | return false; |
15551 | 0 | } |
15552 | 0 | } |
15553 | 0 | } else { |
15554 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.getAttachedShaders"); |
15555 | 0 | return false; |
15556 | 0 | } |
15557 | 0 | Nullable<nsTArray<StrongPtrForMember<mozilla::WebGLShader>::Type>> result; |
15558 | 0 | self->GetAttachedShaders(MOZ_KnownLive(NonNullHelper(arg0)), result); |
15559 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15560 | 0 |
|
15561 | 0 | if (result.IsNull()) { |
15562 | 0 | args.rval().setNull(); |
15563 | 0 | return true; |
15564 | 0 | } |
15565 | 0 | |
15566 | 0 | uint32_t length = result.Value().Length(); |
15567 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
15568 | 0 | if (!returnArray) { |
15569 | 0 | return false; |
15570 | 0 | } |
15571 | 0 | // Scope for 'tmp' |
15572 | 0 | { |
15573 | 0 | JS::Rooted<JS::Value> tmp(cx); |
15574 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
15575 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
15576 | 0 | // are different ways to succeed at wrapping the object. |
15577 | 0 | do { |
15578 | 0 | if (!GetOrCreateDOMReflector(cx, result.Value()[sequenceIdx0], &tmp)) { |
15579 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
15580 | 0 | return false; |
15581 | 0 | } |
15582 | 0 | break; |
15583 | 0 | } while (false); |
15584 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
15585 | 0 | JSPROP_ENUMERATE)) { |
15586 | 0 | return false; |
15587 | 0 | } |
15588 | 0 | } |
15589 | 0 | } |
15590 | 0 | args.rval().setObject(*returnArray); |
15591 | 0 | return true; |
15592 | 0 | } |
15593 | | |
15594 | | static const JSJitInfo getAttachedShaders_methodinfo = { |
15595 | | { (JSJitGetterOp)getAttachedShaders }, |
15596 | | { prototypes::id::WebGLRenderingContext }, |
15597 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15598 | | JSJitInfo::Method, |
15599 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15600 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
15601 | | false, /* isInfallible. False in setters. */ |
15602 | | false, /* isMovable. Not relevant for setters. */ |
15603 | | false, /* isEliminatable. Not relevant for setters. */ |
15604 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15605 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15606 | | false, /* isTypedMethod. Only relevant for methods. */ |
15607 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15608 | | }; |
15609 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15610 | | static_assert(0 < 1, "There is no slot for us"); |
15611 | | |
15612 | | MOZ_CAN_RUN_SCRIPT static bool |
15613 | | getAttribLocation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15614 | 0 | { |
15615 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getAttribLocation", DOM, cx); |
15616 | 0 |
|
15617 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
15618 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getAttribLocation"); |
15619 | 0 | } |
15620 | 0 | NonNull<mozilla::WebGLProgram> arg0; |
15621 | 0 | if (args[0].isObject()) { |
15622 | 0 | { |
15623 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLProgram, mozilla::WebGLProgram>(args[0], arg0); |
15624 | 0 | if (NS_FAILED(rv)) { |
15625 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.getAttribLocation", "WebGLProgram"); |
15626 | 0 | return false; |
15627 | 0 | } |
15628 | 0 | } |
15629 | 0 | } else { |
15630 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.getAttribLocation"); |
15631 | 0 | return false; |
15632 | 0 | } |
15633 | 0 | binding_detail::FakeString arg1; |
15634 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
15635 | 0 | return false; |
15636 | 0 | } |
15637 | 0 | int32_t result(self->GetAttribLocation(MOZ_KnownLive(NonNullHelper(arg0)), NonNullHelper(Constify(arg1)))); |
15638 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15639 | 0 | args.rval().setInt32(int32_t(result)); |
15640 | 0 | return true; |
15641 | 0 | } |
15642 | | |
15643 | | static const JSJitInfo getAttribLocation_methodinfo = { |
15644 | | { (JSJitGetterOp)getAttribLocation }, |
15645 | | { prototypes::id::WebGLRenderingContext }, |
15646 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15647 | | JSJitInfo::Method, |
15648 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15649 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
15650 | | false, /* isInfallible. False in setters. */ |
15651 | | false, /* isMovable. Not relevant for setters. */ |
15652 | | false, /* isEliminatable. Not relevant for setters. */ |
15653 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15654 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15655 | | false, /* isTypedMethod. Only relevant for methods. */ |
15656 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15657 | | }; |
15658 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15659 | | static_assert(0 < 1, "There is no slot for us"); |
15660 | | |
15661 | | MOZ_CAN_RUN_SCRIPT static bool |
15662 | | getBufferParameter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15663 | 0 | { |
15664 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getBufferParameter", DOM, cx); |
15665 | 0 |
|
15666 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
15667 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getBufferParameter"); |
15668 | 0 | } |
15669 | 0 | uint32_t arg0; |
15670 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
15671 | 0 | return false; |
15672 | 0 | } |
15673 | 0 | uint32_t arg1; |
15674 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
15675 | 0 | return false; |
15676 | 0 | } |
15677 | 0 | JS::Rooted<JS::Value> result(cx); |
15678 | 0 | self->GetBufferParameter(cx, arg0, arg1, &result); |
15679 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15680 | 0 | JS::ExposeValueToActiveJS(result); |
15681 | 0 | args.rval().set(result); |
15682 | 0 | if (!MaybeWrapValue(cx, args.rval())) { |
15683 | 0 | return false; |
15684 | 0 | } |
15685 | 0 | return true; |
15686 | 0 | } |
15687 | | |
15688 | | static const JSJitInfo getBufferParameter_methodinfo = { |
15689 | | { (JSJitGetterOp)getBufferParameter }, |
15690 | | { prototypes::id::WebGLRenderingContext }, |
15691 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15692 | | JSJitInfo::Method, |
15693 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15694 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
15695 | | false, /* isInfallible. False in setters. */ |
15696 | | false, /* isMovable. Not relevant for setters. */ |
15697 | | false, /* isEliminatable. Not relevant for setters. */ |
15698 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15699 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15700 | | false, /* isTypedMethod. Only relevant for methods. */ |
15701 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15702 | | }; |
15703 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15704 | | static_assert(0 < 1, "There is no slot for us"); |
15705 | | |
15706 | | MOZ_CAN_RUN_SCRIPT static bool |
15707 | | getParameter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15708 | 0 | { |
15709 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getParameter", DOM, cx); |
15710 | 0 |
|
15711 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
15712 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getParameter"); |
15713 | 0 | } |
15714 | 0 | uint32_t arg0; |
15715 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
15716 | 0 | return false; |
15717 | 0 | } |
15718 | 0 | FastErrorResult rv; |
15719 | 0 | JS::Rooted<JS::Value> result(cx); |
15720 | 0 | self->GetParameter(cx, arg0, &result, rv); |
15721 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
15722 | 0 | return false; |
15723 | 0 | } |
15724 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15725 | 0 | JS::ExposeValueToActiveJS(result); |
15726 | 0 | args.rval().set(result); |
15727 | 0 | if (!MaybeWrapValue(cx, args.rval())) { |
15728 | 0 | return false; |
15729 | 0 | } |
15730 | 0 | return true; |
15731 | 0 | } |
15732 | | |
15733 | | static const JSJitInfo getParameter_methodinfo = { |
15734 | | { (JSJitGetterOp)getParameter }, |
15735 | | { prototypes::id::WebGLRenderingContext }, |
15736 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15737 | | JSJitInfo::Method, |
15738 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15739 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
15740 | | false, /* isInfallible. False in setters. */ |
15741 | | false, /* isMovable. Not relevant for setters. */ |
15742 | | false, /* isEliminatable. Not relevant for setters. */ |
15743 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15744 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15745 | | false, /* isTypedMethod. Only relevant for methods. */ |
15746 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15747 | | }; |
15748 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15749 | | static_assert(0 < 1, "There is no slot for us"); |
15750 | | |
15751 | | MOZ_CAN_RUN_SCRIPT static bool |
15752 | | getError(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15753 | 0 | { |
15754 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getError", DOM, cx); |
15755 | 0 |
|
15756 | 0 | uint32_t result(self->GetError()); |
15757 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15758 | 0 | args.rval().setNumber(result); |
15759 | 0 | return true; |
15760 | 0 | } |
15761 | | |
15762 | | static const JSJitInfo getError_methodinfo = { |
15763 | | { (JSJitGetterOp)getError }, |
15764 | | { prototypes::id::WebGLRenderingContext }, |
15765 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15766 | | JSJitInfo::Method, |
15767 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15768 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
15769 | | true, /* isInfallible. False in setters. */ |
15770 | | false, /* isMovable. Not relevant for setters. */ |
15771 | | false, /* isEliminatable. Not relevant for setters. */ |
15772 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15773 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15774 | | false, /* isTypedMethod. Only relevant for methods. */ |
15775 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15776 | | }; |
15777 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15778 | | static_assert(0 < 1, "There is no slot for us"); |
15779 | | |
15780 | | MOZ_CAN_RUN_SCRIPT static bool |
15781 | | getFramebufferAttachmentParameter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15782 | 0 | { |
15783 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getFramebufferAttachmentParameter", DOM, cx); |
15784 | 0 |
|
15785 | 0 | if (MOZ_UNLIKELY(args.length() < 3)) { |
15786 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getFramebufferAttachmentParameter"); |
15787 | 0 | } |
15788 | 0 | uint32_t arg0; |
15789 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
15790 | 0 | return false; |
15791 | 0 | } |
15792 | 0 | uint32_t arg1; |
15793 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
15794 | 0 | return false; |
15795 | 0 | } |
15796 | 0 | uint32_t arg2; |
15797 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) { |
15798 | 0 | return false; |
15799 | 0 | } |
15800 | 0 | FastErrorResult rv; |
15801 | 0 | JS::Rooted<JS::Value> result(cx); |
15802 | 0 | self->GetFramebufferAttachmentParameter(cx, arg0, arg1, arg2, &result, rv); |
15803 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
15804 | 0 | return false; |
15805 | 0 | } |
15806 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15807 | 0 | JS::ExposeValueToActiveJS(result); |
15808 | 0 | args.rval().set(result); |
15809 | 0 | if (!MaybeWrapValue(cx, args.rval())) { |
15810 | 0 | return false; |
15811 | 0 | } |
15812 | 0 | return true; |
15813 | 0 | } |
15814 | | |
15815 | | static const JSJitInfo getFramebufferAttachmentParameter_methodinfo = { |
15816 | | { (JSJitGetterOp)getFramebufferAttachmentParameter }, |
15817 | | { prototypes::id::WebGLRenderingContext }, |
15818 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15819 | | JSJitInfo::Method, |
15820 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15821 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
15822 | | false, /* isInfallible. False in setters. */ |
15823 | | false, /* isMovable. Not relevant for setters. */ |
15824 | | false, /* isEliminatable. Not relevant for setters. */ |
15825 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15826 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15827 | | false, /* isTypedMethod. Only relevant for methods. */ |
15828 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15829 | | }; |
15830 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15831 | | static_assert(0 < 1, "There is no slot for us"); |
15832 | | |
15833 | | MOZ_CAN_RUN_SCRIPT static bool |
15834 | | getProgramParameter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15835 | 0 | { |
15836 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getProgramParameter", DOM, cx); |
15837 | 0 |
|
15838 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
15839 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getProgramParameter"); |
15840 | 0 | } |
15841 | 0 | NonNull<mozilla::WebGLProgram> arg0; |
15842 | 0 | if (args[0].isObject()) { |
15843 | 0 | { |
15844 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLProgram, mozilla::WebGLProgram>(args[0], arg0); |
15845 | 0 | if (NS_FAILED(rv)) { |
15846 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.getProgramParameter", "WebGLProgram"); |
15847 | 0 | return false; |
15848 | 0 | } |
15849 | 0 | } |
15850 | 0 | } else { |
15851 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.getProgramParameter"); |
15852 | 0 | return false; |
15853 | 0 | } |
15854 | 0 | uint32_t arg1; |
15855 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
15856 | 0 | return false; |
15857 | 0 | } |
15858 | 0 | JS::Rooted<JS::Value> result(cx); |
15859 | 0 | self->GetProgramParameter(cx, MOZ_KnownLive(NonNullHelper(arg0)), arg1, &result); |
15860 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15861 | 0 | JS::ExposeValueToActiveJS(result); |
15862 | 0 | args.rval().set(result); |
15863 | 0 | if (!MaybeWrapValue(cx, args.rval())) { |
15864 | 0 | return false; |
15865 | 0 | } |
15866 | 0 | return true; |
15867 | 0 | } |
15868 | | |
15869 | | static const JSJitInfo getProgramParameter_methodinfo = { |
15870 | | { (JSJitGetterOp)getProgramParameter }, |
15871 | | { prototypes::id::WebGLRenderingContext }, |
15872 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15873 | | JSJitInfo::Method, |
15874 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15875 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
15876 | | false, /* isInfallible. False in setters. */ |
15877 | | false, /* isMovable. Not relevant for setters. */ |
15878 | | false, /* isEliminatable. Not relevant for setters. */ |
15879 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15880 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15881 | | false, /* isTypedMethod. Only relevant for methods. */ |
15882 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15883 | | }; |
15884 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15885 | | static_assert(0 < 1, "There is no slot for us"); |
15886 | | |
15887 | | MOZ_CAN_RUN_SCRIPT static bool |
15888 | | getProgramInfoLog(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15889 | 0 | { |
15890 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getProgramInfoLog", DOM, cx); |
15891 | 0 |
|
15892 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
15893 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getProgramInfoLog"); |
15894 | 0 | } |
15895 | 0 | NonNull<mozilla::WebGLProgram> arg0; |
15896 | 0 | if (args[0].isObject()) { |
15897 | 0 | { |
15898 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLProgram, mozilla::WebGLProgram>(args[0], arg0); |
15899 | 0 | if (NS_FAILED(rv)) { |
15900 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.getProgramInfoLog", "WebGLProgram"); |
15901 | 0 | return false; |
15902 | 0 | } |
15903 | 0 | } |
15904 | 0 | } else { |
15905 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.getProgramInfoLog"); |
15906 | 0 | return false; |
15907 | 0 | } |
15908 | 0 | DOMString result; |
15909 | 0 | self->GetProgramInfoLog(MOZ_KnownLive(NonNullHelper(arg0)), result); |
15910 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15911 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
15912 | 0 | return false; |
15913 | 0 | } |
15914 | 0 | return true; |
15915 | 0 | } |
15916 | | |
15917 | | static const JSJitInfo getProgramInfoLog_methodinfo = { |
15918 | | { (JSJitGetterOp)getProgramInfoLog }, |
15919 | | { prototypes::id::WebGLRenderingContext }, |
15920 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15921 | | JSJitInfo::Method, |
15922 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15923 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
15924 | | false, /* isInfallible. False in setters. */ |
15925 | | false, /* isMovable. Not relevant for setters. */ |
15926 | | false, /* isEliminatable. Not relevant for setters. */ |
15927 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15928 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15929 | | false, /* isTypedMethod. Only relevant for methods. */ |
15930 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15931 | | }; |
15932 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15933 | | static_assert(0 < 1, "There is no slot for us"); |
15934 | | |
15935 | | MOZ_CAN_RUN_SCRIPT static bool |
15936 | | getRenderbufferParameter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15937 | 0 | { |
15938 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getRenderbufferParameter", DOM, cx); |
15939 | 0 |
|
15940 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
15941 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getRenderbufferParameter"); |
15942 | 0 | } |
15943 | 0 | uint32_t arg0; |
15944 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
15945 | 0 | return false; |
15946 | 0 | } |
15947 | 0 | uint32_t arg1; |
15948 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
15949 | 0 | return false; |
15950 | 0 | } |
15951 | 0 | JS::Rooted<JS::Value> result(cx); |
15952 | 0 | self->GetRenderbufferParameter(cx, arg0, arg1, &result); |
15953 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
15954 | 0 | JS::ExposeValueToActiveJS(result); |
15955 | 0 | args.rval().set(result); |
15956 | 0 | if (!MaybeWrapValue(cx, args.rval())) { |
15957 | 0 | return false; |
15958 | 0 | } |
15959 | 0 | return true; |
15960 | 0 | } |
15961 | | |
15962 | | static const JSJitInfo getRenderbufferParameter_methodinfo = { |
15963 | | { (JSJitGetterOp)getRenderbufferParameter }, |
15964 | | { prototypes::id::WebGLRenderingContext }, |
15965 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
15966 | | JSJitInfo::Method, |
15967 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
15968 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
15969 | | false, /* isInfallible. False in setters. */ |
15970 | | false, /* isMovable. Not relevant for setters. */ |
15971 | | false, /* isEliminatable. Not relevant for setters. */ |
15972 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
15973 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
15974 | | false, /* isTypedMethod. Only relevant for methods. */ |
15975 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
15976 | | }; |
15977 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
15978 | | static_assert(0 < 1, "There is no slot for us"); |
15979 | | |
15980 | | MOZ_CAN_RUN_SCRIPT static bool |
15981 | | getShaderParameter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
15982 | 0 | { |
15983 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getShaderParameter", DOM, cx); |
15984 | 0 |
|
15985 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
15986 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getShaderParameter"); |
15987 | 0 | } |
15988 | 0 | NonNull<mozilla::WebGLShader> arg0; |
15989 | 0 | if (args[0].isObject()) { |
15990 | 0 | { |
15991 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLShader, mozilla::WebGLShader>(args[0], arg0); |
15992 | 0 | if (NS_FAILED(rv)) { |
15993 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.getShaderParameter", "WebGLShader"); |
15994 | 0 | return false; |
15995 | 0 | } |
15996 | 0 | } |
15997 | 0 | } else { |
15998 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.getShaderParameter"); |
15999 | 0 | return false; |
16000 | 0 | } |
16001 | 0 | uint32_t arg1; |
16002 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
16003 | 0 | return false; |
16004 | 0 | } |
16005 | 0 | JS::Rooted<JS::Value> result(cx); |
16006 | 0 | self->GetShaderParameter(cx, MOZ_KnownLive(NonNullHelper(arg0)), arg1, &result); |
16007 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16008 | 0 | JS::ExposeValueToActiveJS(result); |
16009 | 0 | args.rval().set(result); |
16010 | 0 | if (!MaybeWrapValue(cx, args.rval())) { |
16011 | 0 | return false; |
16012 | 0 | } |
16013 | 0 | return true; |
16014 | 0 | } |
16015 | | |
16016 | | static const JSJitInfo getShaderParameter_methodinfo = { |
16017 | | { (JSJitGetterOp)getShaderParameter }, |
16018 | | { prototypes::id::WebGLRenderingContext }, |
16019 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16020 | | JSJitInfo::Method, |
16021 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16022 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
16023 | | false, /* isInfallible. False in setters. */ |
16024 | | false, /* isMovable. Not relevant for setters. */ |
16025 | | false, /* isEliminatable. Not relevant for setters. */ |
16026 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16027 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16028 | | false, /* isTypedMethod. Only relevant for methods. */ |
16029 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16030 | | }; |
16031 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16032 | | static_assert(0 < 1, "There is no slot for us"); |
16033 | | |
16034 | | MOZ_CAN_RUN_SCRIPT static bool |
16035 | | getShaderPrecisionFormat(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16036 | 0 | { |
16037 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getShaderPrecisionFormat", DOM, cx); |
16038 | 0 |
|
16039 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
16040 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getShaderPrecisionFormat"); |
16041 | 0 | } |
16042 | 0 | uint32_t arg0; |
16043 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
16044 | 0 | return false; |
16045 | 0 | } |
16046 | 0 | uint32_t arg1; |
16047 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
16048 | 0 | return false; |
16049 | 0 | } |
16050 | 0 | auto result(StrongOrRawPtr<mozilla::WebGLShaderPrecisionFormat>(self->GetShaderPrecisionFormat(arg0, arg1))); |
16051 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16052 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
16053 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
16054 | 0 | if (!result) { |
16055 | 0 | args.rval().setNull(); |
16056 | 0 | return true; |
16057 | 0 | } |
16058 | 0 | if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) { |
16059 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
16060 | 0 | return false; |
16061 | 0 | } |
16062 | 0 | return true; |
16063 | 0 | } |
16064 | | |
16065 | | static const JSJitInfo getShaderPrecisionFormat_methodinfo = { |
16066 | | { (JSJitGetterOp)getShaderPrecisionFormat }, |
16067 | | { prototypes::id::WebGLRenderingContext }, |
16068 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16069 | | JSJitInfo::Method, |
16070 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16071 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
16072 | | false, /* isInfallible. False in setters. */ |
16073 | | false, /* isMovable. Not relevant for setters. */ |
16074 | | false, /* isEliminatable. Not relevant for setters. */ |
16075 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16076 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16077 | | false, /* isTypedMethod. Only relevant for methods. */ |
16078 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16079 | | }; |
16080 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16081 | | static_assert(0 < 1, "There is no slot for us"); |
16082 | | |
16083 | | MOZ_CAN_RUN_SCRIPT static bool |
16084 | | getShaderInfoLog(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16085 | 0 | { |
16086 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getShaderInfoLog", DOM, cx); |
16087 | 0 |
|
16088 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
16089 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getShaderInfoLog"); |
16090 | 0 | } |
16091 | 0 | NonNull<mozilla::WebGLShader> arg0; |
16092 | 0 | if (args[0].isObject()) { |
16093 | 0 | { |
16094 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLShader, mozilla::WebGLShader>(args[0], arg0); |
16095 | 0 | if (NS_FAILED(rv)) { |
16096 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.getShaderInfoLog", "WebGLShader"); |
16097 | 0 | return false; |
16098 | 0 | } |
16099 | 0 | } |
16100 | 0 | } else { |
16101 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.getShaderInfoLog"); |
16102 | 0 | return false; |
16103 | 0 | } |
16104 | 0 | DOMString result; |
16105 | 0 | self->GetShaderInfoLog(MOZ_KnownLive(NonNullHelper(arg0)), result); |
16106 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16107 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
16108 | 0 | return false; |
16109 | 0 | } |
16110 | 0 | return true; |
16111 | 0 | } |
16112 | | |
16113 | | static const JSJitInfo getShaderInfoLog_methodinfo = { |
16114 | | { (JSJitGetterOp)getShaderInfoLog }, |
16115 | | { prototypes::id::WebGLRenderingContext }, |
16116 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16117 | | JSJitInfo::Method, |
16118 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16119 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
16120 | | false, /* isInfallible. False in setters. */ |
16121 | | false, /* isMovable. Not relevant for setters. */ |
16122 | | false, /* isEliminatable. Not relevant for setters. */ |
16123 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16124 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16125 | | false, /* isTypedMethod. Only relevant for methods. */ |
16126 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16127 | | }; |
16128 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16129 | | static_assert(0 < 1, "There is no slot for us"); |
16130 | | |
16131 | | MOZ_CAN_RUN_SCRIPT static bool |
16132 | | getShaderSource(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16133 | 0 | { |
16134 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getShaderSource", DOM, cx); |
16135 | 0 |
|
16136 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
16137 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getShaderSource"); |
16138 | 0 | } |
16139 | 0 | NonNull<mozilla::WebGLShader> arg0; |
16140 | 0 | if (args[0].isObject()) { |
16141 | 0 | { |
16142 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLShader, mozilla::WebGLShader>(args[0], arg0); |
16143 | 0 | if (NS_FAILED(rv)) { |
16144 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.getShaderSource", "WebGLShader"); |
16145 | 0 | return false; |
16146 | 0 | } |
16147 | 0 | } |
16148 | 0 | } else { |
16149 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.getShaderSource"); |
16150 | 0 | return false; |
16151 | 0 | } |
16152 | 0 | DOMString result; |
16153 | 0 | self->GetShaderSource(MOZ_KnownLive(NonNullHelper(arg0)), result); |
16154 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16155 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
16156 | 0 | return false; |
16157 | 0 | } |
16158 | 0 | return true; |
16159 | 0 | } |
16160 | | |
16161 | | static const JSJitInfo getShaderSource_methodinfo = { |
16162 | | { (JSJitGetterOp)getShaderSource }, |
16163 | | { prototypes::id::WebGLRenderingContext }, |
16164 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16165 | | JSJitInfo::Method, |
16166 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16167 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
16168 | | false, /* isInfallible. False in setters. */ |
16169 | | false, /* isMovable. Not relevant for setters. */ |
16170 | | false, /* isEliminatable. Not relevant for setters. */ |
16171 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16172 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16173 | | false, /* isTypedMethod. Only relevant for methods. */ |
16174 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16175 | | }; |
16176 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16177 | | static_assert(0 < 1, "There is no slot for us"); |
16178 | | |
16179 | | MOZ_CAN_RUN_SCRIPT static bool |
16180 | | getTexParameter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16181 | 0 | { |
16182 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getTexParameter", DOM, cx); |
16183 | 0 |
|
16184 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
16185 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getTexParameter"); |
16186 | 0 | } |
16187 | 0 | uint32_t arg0; |
16188 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
16189 | 0 | return false; |
16190 | 0 | } |
16191 | 0 | uint32_t arg1; |
16192 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
16193 | 0 | return false; |
16194 | 0 | } |
16195 | 0 | JS::Rooted<JS::Value> result(cx); |
16196 | 0 | self->GetTexParameter(cx, arg0, arg1, &result); |
16197 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16198 | 0 | JS::ExposeValueToActiveJS(result); |
16199 | 0 | args.rval().set(result); |
16200 | 0 | if (!MaybeWrapValue(cx, args.rval())) { |
16201 | 0 | return false; |
16202 | 0 | } |
16203 | 0 | return true; |
16204 | 0 | } |
16205 | | |
16206 | | static const JSJitInfo getTexParameter_methodinfo = { |
16207 | | { (JSJitGetterOp)getTexParameter }, |
16208 | | { prototypes::id::WebGLRenderingContext }, |
16209 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16210 | | JSJitInfo::Method, |
16211 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16212 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
16213 | | false, /* isInfallible. False in setters. */ |
16214 | | false, /* isMovable. Not relevant for setters. */ |
16215 | | false, /* isEliminatable. Not relevant for setters. */ |
16216 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16217 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16218 | | false, /* isTypedMethod. Only relevant for methods. */ |
16219 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16220 | | }; |
16221 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16222 | | static_assert(0 < 1, "There is no slot for us"); |
16223 | | |
16224 | | MOZ_CAN_RUN_SCRIPT static bool |
16225 | | getUniform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16226 | 0 | { |
16227 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getUniform", DOM, cx); |
16228 | 0 |
|
16229 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
16230 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getUniform"); |
16231 | 0 | } |
16232 | 0 | NonNull<mozilla::WebGLProgram> arg0; |
16233 | 0 | if (args[0].isObject()) { |
16234 | 0 | { |
16235 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLProgram, mozilla::WebGLProgram>(args[0], arg0); |
16236 | 0 | if (NS_FAILED(rv)) { |
16237 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.getUniform", "WebGLProgram"); |
16238 | 0 | return false; |
16239 | 0 | } |
16240 | 0 | } |
16241 | 0 | } else { |
16242 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.getUniform"); |
16243 | 0 | return false; |
16244 | 0 | } |
16245 | 0 | NonNull<mozilla::WebGLUniformLocation> arg1; |
16246 | 0 | if (args[1].isObject()) { |
16247 | 0 | { |
16248 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[1], arg1); |
16249 | 0 | if (NS_FAILED(rv)) { |
16250 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of WebGLRenderingContext.getUniform", "WebGLUniformLocation"); |
16251 | 0 | return false; |
16252 | 0 | } |
16253 | 0 | } |
16254 | 0 | } else { |
16255 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of WebGLRenderingContext.getUniform"); |
16256 | 0 | return false; |
16257 | 0 | } |
16258 | 0 | JS::Rooted<JS::Value> result(cx); |
16259 | 0 | self->GetUniform(cx, MOZ_KnownLive(NonNullHelper(arg0)), MOZ_KnownLive(NonNullHelper(arg1)), &result); |
16260 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16261 | 0 | JS::ExposeValueToActiveJS(result); |
16262 | 0 | args.rval().set(result); |
16263 | 0 | if (!MaybeWrapValue(cx, args.rval())) { |
16264 | 0 | return false; |
16265 | 0 | } |
16266 | 0 | return true; |
16267 | 0 | } |
16268 | | |
16269 | | static const JSJitInfo getUniform_methodinfo = { |
16270 | | { (JSJitGetterOp)getUniform }, |
16271 | | { prototypes::id::WebGLRenderingContext }, |
16272 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16273 | | JSJitInfo::Method, |
16274 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16275 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
16276 | | false, /* isInfallible. False in setters. */ |
16277 | | false, /* isMovable. Not relevant for setters. */ |
16278 | | false, /* isEliminatable. Not relevant for setters. */ |
16279 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16280 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16281 | | false, /* isTypedMethod. Only relevant for methods. */ |
16282 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16283 | | }; |
16284 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16285 | | static_assert(0 < 1, "There is no slot for us"); |
16286 | | |
16287 | | MOZ_CAN_RUN_SCRIPT static bool |
16288 | | getUniformLocation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16289 | 0 | { |
16290 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getUniformLocation", DOM, cx); |
16291 | 0 |
|
16292 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
16293 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getUniformLocation"); |
16294 | 0 | } |
16295 | 0 | NonNull<mozilla::WebGLProgram> arg0; |
16296 | 0 | if (args[0].isObject()) { |
16297 | 0 | { |
16298 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLProgram, mozilla::WebGLProgram>(args[0], arg0); |
16299 | 0 | if (NS_FAILED(rv)) { |
16300 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.getUniformLocation", "WebGLProgram"); |
16301 | 0 | return false; |
16302 | 0 | } |
16303 | 0 | } |
16304 | 0 | } else { |
16305 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.getUniformLocation"); |
16306 | 0 | return false; |
16307 | 0 | } |
16308 | 0 | binding_detail::FakeString arg1; |
16309 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
16310 | 0 | return false; |
16311 | 0 | } |
16312 | 0 | auto result(StrongOrRawPtr<mozilla::WebGLUniformLocation>(self->GetUniformLocation(MOZ_KnownLive(NonNullHelper(arg0)), NonNullHelper(Constify(arg1))))); |
16313 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16314 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
16315 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
16316 | 0 | if (!result) { |
16317 | 0 | args.rval().setNull(); |
16318 | 0 | return true; |
16319 | 0 | } |
16320 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
16321 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
16322 | 0 | return false; |
16323 | 0 | } |
16324 | 0 | return true; |
16325 | 0 | } |
16326 | | |
16327 | | static const JSJitInfo getUniformLocation_methodinfo = { |
16328 | | { (JSJitGetterOp)getUniformLocation }, |
16329 | | { prototypes::id::WebGLRenderingContext }, |
16330 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16331 | | JSJitInfo::Method, |
16332 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16333 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
16334 | | false, /* isInfallible. False in setters. */ |
16335 | | false, /* isMovable. Not relevant for setters. */ |
16336 | | false, /* isEliminatable. Not relevant for setters. */ |
16337 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16338 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16339 | | false, /* isTypedMethod. Only relevant for methods. */ |
16340 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16341 | | }; |
16342 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16343 | | static_assert(0 < 1, "There is no slot for us"); |
16344 | | |
16345 | | MOZ_CAN_RUN_SCRIPT static bool |
16346 | | getVertexAttrib(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16347 | 0 | { |
16348 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getVertexAttrib", DOM, cx); |
16349 | 0 |
|
16350 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
16351 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getVertexAttrib"); |
16352 | 0 | } |
16353 | 0 | uint32_t arg0; |
16354 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
16355 | 0 | return false; |
16356 | 0 | } |
16357 | 0 | uint32_t arg1; |
16358 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
16359 | 0 | return false; |
16360 | 0 | } |
16361 | 0 | FastErrorResult rv; |
16362 | 0 | JS::Rooted<JS::Value> result(cx); |
16363 | 0 | self->GetVertexAttrib(cx, arg0, arg1, &result, rv); |
16364 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
16365 | 0 | return false; |
16366 | 0 | } |
16367 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16368 | 0 | JS::ExposeValueToActiveJS(result); |
16369 | 0 | args.rval().set(result); |
16370 | 0 | if (!MaybeWrapValue(cx, args.rval())) { |
16371 | 0 | return false; |
16372 | 0 | } |
16373 | 0 | return true; |
16374 | 0 | } |
16375 | | |
16376 | | static const JSJitInfo getVertexAttrib_methodinfo = { |
16377 | | { (JSJitGetterOp)getVertexAttrib }, |
16378 | | { prototypes::id::WebGLRenderingContext }, |
16379 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16380 | | JSJitInfo::Method, |
16381 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16382 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
16383 | | false, /* isInfallible. False in setters. */ |
16384 | | false, /* isMovable. Not relevant for setters. */ |
16385 | | false, /* isEliminatable. Not relevant for setters. */ |
16386 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16387 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16388 | | false, /* isTypedMethod. Only relevant for methods. */ |
16389 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16390 | | }; |
16391 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16392 | | static_assert(0 < 1, "There is no slot for us"); |
16393 | | |
16394 | | MOZ_CAN_RUN_SCRIPT static bool |
16395 | | getVertexAttribOffset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16396 | 0 | { |
16397 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.getVertexAttribOffset", DOM, cx); |
16398 | 0 |
|
16399 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
16400 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.getVertexAttribOffset"); |
16401 | 0 | } |
16402 | 0 | uint32_t arg0; |
16403 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
16404 | 0 | return false; |
16405 | 0 | } |
16406 | 0 | uint32_t arg1; |
16407 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
16408 | 0 | return false; |
16409 | 0 | } |
16410 | 0 | int64_t result(self->GetVertexAttribOffset(arg0, arg1)); |
16411 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16412 | 0 | args.rval().set(JS_NumberValue(double(result))); |
16413 | 0 | return true; |
16414 | 0 | } |
16415 | | |
16416 | | static const JSJitInfo getVertexAttribOffset_methodinfo = { |
16417 | | { (JSJitGetterOp)getVertexAttribOffset }, |
16418 | | { prototypes::id::WebGLRenderingContext }, |
16419 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16420 | | JSJitInfo::Method, |
16421 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16422 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
16423 | | false, /* isInfallible. False in setters. */ |
16424 | | false, /* isMovable. Not relevant for setters. */ |
16425 | | false, /* isEliminatable. Not relevant for setters. */ |
16426 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16427 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16428 | | false, /* isTypedMethod. Only relevant for methods. */ |
16429 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16430 | | }; |
16431 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16432 | | static_assert(0 < 1, "There is no slot for us"); |
16433 | | |
16434 | | MOZ_CAN_RUN_SCRIPT static bool |
16435 | | hint(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16436 | 0 | { |
16437 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.hint", DOM, cx); |
16438 | 0 |
|
16439 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
16440 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.hint"); |
16441 | 0 | } |
16442 | 0 | uint32_t arg0; |
16443 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
16444 | 0 | return false; |
16445 | 0 | } |
16446 | 0 | uint32_t arg1; |
16447 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
16448 | 0 | return false; |
16449 | 0 | } |
16450 | 0 | self->Hint(arg0, arg1); |
16451 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16452 | 0 | args.rval().setUndefined(); |
16453 | 0 | return true; |
16454 | 0 | } |
16455 | | |
16456 | | static const JSJitInfo hint_methodinfo = { |
16457 | | { (JSJitGetterOp)hint }, |
16458 | | { prototypes::id::WebGLRenderingContext }, |
16459 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16460 | | JSJitInfo::Method, |
16461 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16462 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
16463 | | false, /* isInfallible. False in setters. */ |
16464 | | false, /* isMovable. Not relevant for setters. */ |
16465 | | false, /* isEliminatable. Not relevant for setters. */ |
16466 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16467 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16468 | | false, /* isTypedMethod. Only relevant for methods. */ |
16469 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16470 | | }; |
16471 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16472 | | static_assert(0 < 1, "There is no slot for us"); |
16473 | | |
16474 | | MOZ_CAN_RUN_SCRIPT static bool |
16475 | | isBuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16476 | 0 | { |
16477 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.isBuffer", DOM, cx); |
16478 | 0 |
|
16479 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
16480 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.isBuffer"); |
16481 | 0 | } |
16482 | 0 | mozilla::WebGLBuffer* arg0; |
16483 | 0 | if (args[0].isObject()) { |
16484 | 0 | { |
16485 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLBuffer, mozilla::WebGLBuffer>(args[0], arg0); |
16486 | 0 | if (NS_FAILED(rv)) { |
16487 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.isBuffer", "WebGLBuffer"); |
16488 | 0 | return false; |
16489 | 0 | } |
16490 | 0 | } |
16491 | 0 | } else if (args[0].isNullOrUndefined()) { |
16492 | 0 | arg0 = nullptr; |
16493 | 0 | } else { |
16494 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.isBuffer"); |
16495 | 0 | return false; |
16496 | 0 | } |
16497 | 0 | bool result(self->IsBuffer(MOZ_KnownLive(Constify(arg0)))); |
16498 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16499 | 0 | args.rval().setBoolean(result); |
16500 | 0 | return true; |
16501 | 0 | } |
16502 | | |
16503 | | static const JSJitInfo isBuffer_methodinfo = { |
16504 | | { (JSJitGetterOp)isBuffer }, |
16505 | | { prototypes::id::WebGLRenderingContext }, |
16506 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16507 | | JSJitInfo::Method, |
16508 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16509 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
16510 | | false, /* isInfallible. False in setters. */ |
16511 | | false, /* isMovable. Not relevant for setters. */ |
16512 | | false, /* isEliminatable. Not relevant for setters. */ |
16513 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16514 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16515 | | false, /* isTypedMethod. Only relevant for methods. */ |
16516 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16517 | | }; |
16518 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16519 | | static_assert(0 < 1, "There is no slot for us"); |
16520 | | |
16521 | | MOZ_CAN_RUN_SCRIPT static bool |
16522 | | isEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16523 | 0 | { |
16524 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.isEnabled", DOM, cx); |
16525 | 0 |
|
16526 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
16527 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.isEnabled"); |
16528 | 0 | } |
16529 | 0 | uint32_t arg0; |
16530 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
16531 | 0 | return false; |
16532 | 0 | } |
16533 | 0 | bool result(self->IsEnabled(arg0)); |
16534 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16535 | 0 | args.rval().setBoolean(result); |
16536 | 0 | return true; |
16537 | 0 | } |
16538 | | |
16539 | | static const JSJitInfo isEnabled_methodinfo = { |
16540 | | { (JSJitGetterOp)isEnabled }, |
16541 | | { prototypes::id::WebGLRenderingContext }, |
16542 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16543 | | JSJitInfo::Method, |
16544 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16545 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
16546 | | false, /* isInfallible. False in setters. */ |
16547 | | false, /* isMovable. Not relevant for setters. */ |
16548 | | false, /* isEliminatable. Not relevant for setters. */ |
16549 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16550 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16551 | | false, /* isTypedMethod. Only relevant for methods. */ |
16552 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16553 | | }; |
16554 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16555 | | static_assert(0 < 1, "There is no slot for us"); |
16556 | | |
16557 | | MOZ_CAN_RUN_SCRIPT static bool |
16558 | | isFramebuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16559 | 0 | { |
16560 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.isFramebuffer", DOM, cx); |
16561 | 0 |
|
16562 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
16563 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.isFramebuffer"); |
16564 | 0 | } |
16565 | 0 | mozilla::WebGLFramebuffer* arg0; |
16566 | 0 | if (args[0].isObject()) { |
16567 | 0 | { |
16568 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLFramebuffer, mozilla::WebGLFramebuffer>(args[0], arg0); |
16569 | 0 | if (NS_FAILED(rv)) { |
16570 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.isFramebuffer", "WebGLFramebuffer"); |
16571 | 0 | return false; |
16572 | 0 | } |
16573 | 0 | } |
16574 | 0 | } else if (args[0].isNullOrUndefined()) { |
16575 | 0 | arg0 = nullptr; |
16576 | 0 | } else { |
16577 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.isFramebuffer"); |
16578 | 0 | return false; |
16579 | 0 | } |
16580 | 0 | bool result(self->IsFramebuffer(MOZ_KnownLive(Constify(arg0)))); |
16581 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16582 | 0 | args.rval().setBoolean(result); |
16583 | 0 | return true; |
16584 | 0 | } |
16585 | | |
16586 | | static const JSJitInfo isFramebuffer_methodinfo = { |
16587 | | { (JSJitGetterOp)isFramebuffer }, |
16588 | | { prototypes::id::WebGLRenderingContext }, |
16589 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16590 | | JSJitInfo::Method, |
16591 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16592 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
16593 | | false, /* isInfallible. False in setters. */ |
16594 | | false, /* isMovable. Not relevant for setters. */ |
16595 | | false, /* isEliminatable. Not relevant for setters. */ |
16596 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16597 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16598 | | false, /* isTypedMethod. Only relevant for methods. */ |
16599 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16600 | | }; |
16601 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16602 | | static_assert(0 < 1, "There is no slot for us"); |
16603 | | |
16604 | | MOZ_CAN_RUN_SCRIPT static bool |
16605 | | isProgram(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16606 | 0 | { |
16607 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.isProgram", DOM, cx); |
16608 | 0 |
|
16609 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
16610 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.isProgram"); |
16611 | 0 | } |
16612 | 0 | mozilla::WebGLProgram* arg0; |
16613 | 0 | if (args[0].isObject()) { |
16614 | 0 | { |
16615 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLProgram, mozilla::WebGLProgram>(args[0], arg0); |
16616 | 0 | if (NS_FAILED(rv)) { |
16617 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.isProgram", "WebGLProgram"); |
16618 | 0 | return false; |
16619 | 0 | } |
16620 | 0 | } |
16621 | 0 | } else if (args[0].isNullOrUndefined()) { |
16622 | 0 | arg0 = nullptr; |
16623 | 0 | } else { |
16624 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.isProgram"); |
16625 | 0 | return false; |
16626 | 0 | } |
16627 | 0 | bool result(self->IsProgram(MOZ_KnownLive(Constify(arg0)))); |
16628 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16629 | 0 | args.rval().setBoolean(result); |
16630 | 0 | return true; |
16631 | 0 | } |
16632 | | |
16633 | | static const JSJitInfo isProgram_methodinfo = { |
16634 | | { (JSJitGetterOp)isProgram }, |
16635 | | { prototypes::id::WebGLRenderingContext }, |
16636 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16637 | | JSJitInfo::Method, |
16638 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16639 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
16640 | | false, /* isInfallible. False in setters. */ |
16641 | | false, /* isMovable. Not relevant for setters. */ |
16642 | | false, /* isEliminatable. Not relevant for setters. */ |
16643 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16644 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16645 | | false, /* isTypedMethod. Only relevant for methods. */ |
16646 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16647 | | }; |
16648 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16649 | | static_assert(0 < 1, "There is no slot for us"); |
16650 | | |
16651 | | MOZ_CAN_RUN_SCRIPT static bool |
16652 | | isRenderbuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16653 | 0 | { |
16654 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.isRenderbuffer", DOM, cx); |
16655 | 0 |
|
16656 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
16657 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.isRenderbuffer"); |
16658 | 0 | } |
16659 | 0 | mozilla::WebGLRenderbuffer* arg0; |
16660 | 0 | if (args[0].isObject()) { |
16661 | 0 | { |
16662 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLRenderbuffer, mozilla::WebGLRenderbuffer>(args[0], arg0); |
16663 | 0 | if (NS_FAILED(rv)) { |
16664 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.isRenderbuffer", "WebGLRenderbuffer"); |
16665 | 0 | return false; |
16666 | 0 | } |
16667 | 0 | } |
16668 | 0 | } else if (args[0].isNullOrUndefined()) { |
16669 | 0 | arg0 = nullptr; |
16670 | 0 | } else { |
16671 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.isRenderbuffer"); |
16672 | 0 | return false; |
16673 | 0 | } |
16674 | 0 | bool result(self->IsRenderbuffer(MOZ_KnownLive(Constify(arg0)))); |
16675 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16676 | 0 | args.rval().setBoolean(result); |
16677 | 0 | return true; |
16678 | 0 | } |
16679 | | |
16680 | | static const JSJitInfo isRenderbuffer_methodinfo = { |
16681 | | { (JSJitGetterOp)isRenderbuffer }, |
16682 | | { prototypes::id::WebGLRenderingContext }, |
16683 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16684 | | JSJitInfo::Method, |
16685 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16686 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
16687 | | false, /* isInfallible. False in setters. */ |
16688 | | false, /* isMovable. Not relevant for setters. */ |
16689 | | false, /* isEliminatable. Not relevant for setters. */ |
16690 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16691 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16692 | | false, /* isTypedMethod. Only relevant for methods. */ |
16693 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16694 | | }; |
16695 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16696 | | static_assert(0 < 1, "There is no slot for us"); |
16697 | | |
16698 | | MOZ_CAN_RUN_SCRIPT static bool |
16699 | | isShader(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16700 | 0 | { |
16701 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.isShader", DOM, cx); |
16702 | 0 |
|
16703 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
16704 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.isShader"); |
16705 | 0 | } |
16706 | 0 | mozilla::WebGLShader* arg0; |
16707 | 0 | if (args[0].isObject()) { |
16708 | 0 | { |
16709 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLShader, mozilla::WebGLShader>(args[0], arg0); |
16710 | 0 | if (NS_FAILED(rv)) { |
16711 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.isShader", "WebGLShader"); |
16712 | 0 | return false; |
16713 | 0 | } |
16714 | 0 | } |
16715 | 0 | } else if (args[0].isNullOrUndefined()) { |
16716 | 0 | arg0 = nullptr; |
16717 | 0 | } else { |
16718 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.isShader"); |
16719 | 0 | return false; |
16720 | 0 | } |
16721 | 0 | bool result(self->IsShader(MOZ_KnownLive(Constify(arg0)))); |
16722 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16723 | 0 | args.rval().setBoolean(result); |
16724 | 0 | return true; |
16725 | 0 | } |
16726 | | |
16727 | | static const JSJitInfo isShader_methodinfo = { |
16728 | | { (JSJitGetterOp)isShader }, |
16729 | | { prototypes::id::WebGLRenderingContext }, |
16730 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16731 | | JSJitInfo::Method, |
16732 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16733 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
16734 | | false, /* isInfallible. False in setters. */ |
16735 | | false, /* isMovable. Not relevant for setters. */ |
16736 | | false, /* isEliminatable. Not relevant for setters. */ |
16737 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16738 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16739 | | false, /* isTypedMethod. Only relevant for methods. */ |
16740 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16741 | | }; |
16742 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16743 | | static_assert(0 < 1, "There is no slot for us"); |
16744 | | |
16745 | | MOZ_CAN_RUN_SCRIPT static bool |
16746 | | isTexture(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16747 | 0 | { |
16748 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.isTexture", DOM, cx); |
16749 | 0 |
|
16750 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
16751 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.isTexture"); |
16752 | 0 | } |
16753 | 0 | mozilla::WebGLTexture* arg0; |
16754 | 0 | if (args[0].isObject()) { |
16755 | 0 | { |
16756 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLTexture, mozilla::WebGLTexture>(args[0], arg0); |
16757 | 0 | if (NS_FAILED(rv)) { |
16758 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.isTexture", "WebGLTexture"); |
16759 | 0 | return false; |
16760 | 0 | } |
16761 | 0 | } |
16762 | 0 | } else if (args[0].isNullOrUndefined()) { |
16763 | 0 | arg0 = nullptr; |
16764 | 0 | } else { |
16765 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.isTexture"); |
16766 | 0 | return false; |
16767 | 0 | } |
16768 | 0 | bool result(self->IsTexture(MOZ_KnownLive(Constify(arg0)))); |
16769 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16770 | 0 | args.rval().setBoolean(result); |
16771 | 0 | return true; |
16772 | 0 | } |
16773 | | |
16774 | | static const JSJitInfo isTexture_methodinfo = { |
16775 | | { (JSJitGetterOp)isTexture }, |
16776 | | { prototypes::id::WebGLRenderingContext }, |
16777 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16778 | | JSJitInfo::Method, |
16779 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16780 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
16781 | | false, /* isInfallible. False in setters. */ |
16782 | | false, /* isMovable. Not relevant for setters. */ |
16783 | | false, /* isEliminatable. Not relevant for setters. */ |
16784 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16785 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16786 | | false, /* isTypedMethod. Only relevant for methods. */ |
16787 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16788 | | }; |
16789 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16790 | | static_assert(0 < 1, "There is no slot for us"); |
16791 | | |
16792 | | MOZ_CAN_RUN_SCRIPT static bool |
16793 | | lineWidth(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16794 | 0 | { |
16795 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.lineWidth", DOM, cx); |
16796 | 0 |
|
16797 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
16798 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.lineWidth"); |
16799 | 0 | } |
16800 | 0 | float arg0; |
16801 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) { |
16802 | 0 | return false; |
16803 | 0 | } |
16804 | 0 | self->LineWidth(arg0); |
16805 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16806 | 0 | args.rval().setUndefined(); |
16807 | 0 | return true; |
16808 | 0 | } |
16809 | | |
16810 | | static const JSJitInfo lineWidth_methodinfo = { |
16811 | | { (JSJitGetterOp)lineWidth }, |
16812 | | { prototypes::id::WebGLRenderingContext }, |
16813 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16814 | | JSJitInfo::Method, |
16815 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16816 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
16817 | | false, /* isInfallible. False in setters. */ |
16818 | | false, /* isMovable. Not relevant for setters. */ |
16819 | | false, /* isEliminatable. Not relevant for setters. */ |
16820 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16821 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16822 | | false, /* isTypedMethod. Only relevant for methods. */ |
16823 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16824 | | }; |
16825 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16826 | | static_assert(0 < 1, "There is no slot for us"); |
16827 | | |
16828 | | MOZ_CAN_RUN_SCRIPT static bool |
16829 | | linkProgram(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16830 | 0 | { |
16831 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.linkProgram", DOM, cx); |
16832 | 0 |
|
16833 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
16834 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.linkProgram"); |
16835 | 0 | } |
16836 | 0 | NonNull<mozilla::WebGLProgram> arg0; |
16837 | 0 | if (args[0].isObject()) { |
16838 | 0 | { |
16839 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLProgram, mozilla::WebGLProgram>(args[0], arg0); |
16840 | 0 | if (NS_FAILED(rv)) { |
16841 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.linkProgram", "WebGLProgram"); |
16842 | 0 | return false; |
16843 | 0 | } |
16844 | 0 | } |
16845 | 0 | } else { |
16846 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.linkProgram"); |
16847 | 0 | return false; |
16848 | 0 | } |
16849 | 0 | self->LinkProgram(MOZ_KnownLive(NonNullHelper(arg0))); |
16850 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16851 | 0 | args.rval().setUndefined(); |
16852 | 0 | return true; |
16853 | 0 | } |
16854 | | |
16855 | | static const JSJitInfo linkProgram_methodinfo = { |
16856 | | { (JSJitGetterOp)linkProgram }, |
16857 | | { prototypes::id::WebGLRenderingContext }, |
16858 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16859 | | JSJitInfo::Method, |
16860 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16861 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
16862 | | false, /* isInfallible. False in setters. */ |
16863 | | false, /* isMovable. Not relevant for setters. */ |
16864 | | false, /* isEliminatable. Not relevant for setters. */ |
16865 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16866 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16867 | | false, /* isTypedMethod. Only relevant for methods. */ |
16868 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16869 | | }; |
16870 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16871 | | static_assert(0 < 1, "There is no slot for us"); |
16872 | | |
16873 | | MOZ_CAN_RUN_SCRIPT static bool |
16874 | | pixelStorei(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16875 | 0 | { |
16876 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.pixelStorei", DOM, cx); |
16877 | 0 |
|
16878 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
16879 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.pixelStorei"); |
16880 | 0 | } |
16881 | 0 | uint32_t arg0; |
16882 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
16883 | 0 | return false; |
16884 | 0 | } |
16885 | 0 | int32_t arg1; |
16886 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
16887 | 0 | return false; |
16888 | 0 | } |
16889 | 0 | self->PixelStorei(arg0, arg1); |
16890 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16891 | 0 | args.rval().setUndefined(); |
16892 | 0 | return true; |
16893 | 0 | } |
16894 | | |
16895 | | static const JSJitInfo pixelStorei_methodinfo = { |
16896 | | { (JSJitGetterOp)pixelStorei }, |
16897 | | { prototypes::id::WebGLRenderingContext }, |
16898 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16899 | | JSJitInfo::Method, |
16900 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16901 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
16902 | | false, /* isInfallible. False in setters. */ |
16903 | | false, /* isMovable. Not relevant for setters. */ |
16904 | | false, /* isEliminatable. Not relevant for setters. */ |
16905 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16906 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16907 | | false, /* isTypedMethod. Only relevant for methods. */ |
16908 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16909 | | }; |
16910 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16911 | | static_assert(0 < 1, "There is no slot for us"); |
16912 | | |
16913 | | MOZ_CAN_RUN_SCRIPT static bool |
16914 | | polygonOffset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16915 | 0 | { |
16916 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.polygonOffset", DOM, cx); |
16917 | 0 |
|
16918 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
16919 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.polygonOffset"); |
16920 | 0 | } |
16921 | 0 | float arg0; |
16922 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) { |
16923 | 0 | return false; |
16924 | 0 | } |
16925 | 0 | float arg1; |
16926 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[1], &arg1)) { |
16927 | 0 | return false; |
16928 | 0 | } |
16929 | 0 | self->PolygonOffset(arg0, arg1); |
16930 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16931 | 0 | args.rval().setUndefined(); |
16932 | 0 | return true; |
16933 | 0 | } |
16934 | | |
16935 | | static const JSJitInfo polygonOffset_methodinfo = { |
16936 | | { (JSJitGetterOp)polygonOffset }, |
16937 | | { prototypes::id::WebGLRenderingContext }, |
16938 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16939 | | JSJitInfo::Method, |
16940 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16941 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
16942 | | false, /* isInfallible. False in setters. */ |
16943 | | false, /* isMovable. Not relevant for setters. */ |
16944 | | false, /* isEliminatable. Not relevant for setters. */ |
16945 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16946 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16947 | | false, /* isTypedMethod. Only relevant for methods. */ |
16948 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16949 | | }; |
16950 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16951 | | static_assert(0 < 1, "There is no slot for us"); |
16952 | | |
16953 | | MOZ_CAN_RUN_SCRIPT static bool |
16954 | | renderbufferStorage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
16955 | 0 | { |
16956 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.renderbufferStorage", DOM, cx); |
16957 | 0 |
|
16958 | 0 | if (MOZ_UNLIKELY(args.length() < 4)) { |
16959 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.renderbufferStorage"); |
16960 | 0 | } |
16961 | 0 | uint32_t arg0; |
16962 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
16963 | 0 | return false; |
16964 | 0 | } |
16965 | 0 | uint32_t arg1; |
16966 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
16967 | 0 | return false; |
16968 | 0 | } |
16969 | 0 | int32_t arg2; |
16970 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
16971 | 0 | return false; |
16972 | 0 | } |
16973 | 0 | int32_t arg3; |
16974 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[3], &arg3)) { |
16975 | 0 | return false; |
16976 | 0 | } |
16977 | 0 | self->RenderbufferStorage(arg0, arg1, arg2, arg3); |
16978 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
16979 | 0 | args.rval().setUndefined(); |
16980 | 0 | return true; |
16981 | 0 | } |
16982 | | |
16983 | | static const JSJitInfo renderbufferStorage_methodinfo = { |
16984 | | { (JSJitGetterOp)renderbufferStorage }, |
16985 | | { prototypes::id::WebGLRenderingContext }, |
16986 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
16987 | | JSJitInfo::Method, |
16988 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
16989 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
16990 | | false, /* isInfallible. False in setters. */ |
16991 | | false, /* isMovable. Not relevant for setters. */ |
16992 | | false, /* isEliminatable. Not relevant for setters. */ |
16993 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
16994 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
16995 | | false, /* isTypedMethod. Only relevant for methods. */ |
16996 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
16997 | | }; |
16998 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
16999 | | static_assert(0 < 1, "There is no slot for us"); |
17000 | | |
17001 | | MOZ_CAN_RUN_SCRIPT static bool |
17002 | | sampleCoverage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17003 | 0 | { |
17004 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.sampleCoverage", DOM, cx); |
17005 | 0 |
|
17006 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
17007 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.sampleCoverage"); |
17008 | 0 | } |
17009 | 0 | float arg0; |
17010 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) { |
17011 | 0 | return false; |
17012 | 0 | } |
17013 | 0 | bool arg1; |
17014 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) { |
17015 | 0 | return false; |
17016 | 0 | } |
17017 | 0 | self->SampleCoverage(arg0, arg1); |
17018 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17019 | 0 | args.rval().setUndefined(); |
17020 | 0 | return true; |
17021 | 0 | } |
17022 | | |
17023 | | static const JSJitInfo sampleCoverage_methodinfo = { |
17024 | | { (JSJitGetterOp)sampleCoverage }, |
17025 | | { prototypes::id::WebGLRenderingContext }, |
17026 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17027 | | JSJitInfo::Method, |
17028 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17029 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17030 | | false, /* isInfallible. False in setters. */ |
17031 | | false, /* isMovable. Not relevant for setters. */ |
17032 | | false, /* isEliminatable. Not relevant for setters. */ |
17033 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17034 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17035 | | false, /* isTypedMethod. Only relevant for methods. */ |
17036 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17037 | | }; |
17038 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17039 | | static_assert(0 < 1, "There is no slot for us"); |
17040 | | |
17041 | | MOZ_CAN_RUN_SCRIPT static bool |
17042 | | scissor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17043 | 0 | { |
17044 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.scissor", DOM, cx); |
17045 | 0 |
|
17046 | 0 | if (MOZ_UNLIKELY(args.length() < 4)) { |
17047 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.scissor"); |
17048 | 0 | } |
17049 | 0 | int32_t arg0; |
17050 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) { |
17051 | 0 | return false; |
17052 | 0 | } |
17053 | 0 | int32_t arg1; |
17054 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
17055 | 0 | return false; |
17056 | 0 | } |
17057 | 0 | int32_t arg2; |
17058 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
17059 | 0 | return false; |
17060 | 0 | } |
17061 | 0 | int32_t arg3; |
17062 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[3], &arg3)) { |
17063 | 0 | return false; |
17064 | 0 | } |
17065 | 0 | self->Scissor(arg0, arg1, arg2, arg3); |
17066 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17067 | 0 | args.rval().setUndefined(); |
17068 | 0 | return true; |
17069 | 0 | } |
17070 | | |
17071 | | static const JSJitInfo scissor_methodinfo = { |
17072 | | { (JSJitGetterOp)scissor }, |
17073 | | { prototypes::id::WebGLRenderingContext }, |
17074 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17075 | | JSJitInfo::Method, |
17076 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17077 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17078 | | false, /* isInfallible. False in setters. */ |
17079 | | false, /* isMovable. Not relevant for setters. */ |
17080 | | false, /* isEliminatable. Not relevant for setters. */ |
17081 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17082 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17083 | | false, /* isTypedMethod. Only relevant for methods. */ |
17084 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17085 | | }; |
17086 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17087 | | static_assert(0 < 1, "There is no slot for us"); |
17088 | | |
17089 | | MOZ_CAN_RUN_SCRIPT static bool |
17090 | | shaderSource(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17091 | 0 | { |
17092 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.shaderSource", DOM, cx); |
17093 | 0 |
|
17094 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
17095 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.shaderSource"); |
17096 | 0 | } |
17097 | 0 | NonNull<mozilla::WebGLShader> arg0; |
17098 | 0 | if (args[0].isObject()) { |
17099 | 0 | { |
17100 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLShader, mozilla::WebGLShader>(args[0], arg0); |
17101 | 0 | if (NS_FAILED(rv)) { |
17102 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.shaderSource", "WebGLShader"); |
17103 | 0 | return false; |
17104 | 0 | } |
17105 | 0 | } |
17106 | 0 | } else { |
17107 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.shaderSource"); |
17108 | 0 | return false; |
17109 | 0 | } |
17110 | 0 | binding_detail::FakeString arg1; |
17111 | 0 | if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) { |
17112 | 0 | return false; |
17113 | 0 | } |
17114 | 0 | self->ShaderSource(MOZ_KnownLive(NonNullHelper(arg0)), NonNullHelper(Constify(arg1))); |
17115 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17116 | 0 | args.rval().setUndefined(); |
17117 | 0 | return true; |
17118 | 0 | } |
17119 | | |
17120 | | static const JSJitInfo shaderSource_methodinfo = { |
17121 | | { (JSJitGetterOp)shaderSource }, |
17122 | | { prototypes::id::WebGLRenderingContext }, |
17123 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17124 | | JSJitInfo::Method, |
17125 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17126 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17127 | | false, /* isInfallible. False in setters. */ |
17128 | | false, /* isMovable. Not relevant for setters. */ |
17129 | | false, /* isEliminatable. Not relevant for setters. */ |
17130 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17131 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17132 | | false, /* isTypedMethod. Only relevant for methods. */ |
17133 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17134 | | }; |
17135 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17136 | | static_assert(0 < 1, "There is no slot for us"); |
17137 | | |
17138 | | MOZ_CAN_RUN_SCRIPT static bool |
17139 | | stencilFunc(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17140 | 0 | { |
17141 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.stencilFunc", DOM, cx); |
17142 | 0 |
|
17143 | 0 | if (MOZ_UNLIKELY(args.length() < 3)) { |
17144 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.stencilFunc"); |
17145 | 0 | } |
17146 | 0 | uint32_t arg0; |
17147 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
17148 | 0 | return false; |
17149 | 0 | } |
17150 | 0 | int32_t arg1; |
17151 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
17152 | 0 | return false; |
17153 | 0 | } |
17154 | 0 | uint32_t arg2; |
17155 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) { |
17156 | 0 | return false; |
17157 | 0 | } |
17158 | 0 | self->StencilFunc(arg0, arg1, arg2); |
17159 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17160 | 0 | args.rval().setUndefined(); |
17161 | 0 | return true; |
17162 | 0 | } |
17163 | | |
17164 | | static const JSJitInfo stencilFunc_methodinfo = { |
17165 | | { (JSJitGetterOp)stencilFunc }, |
17166 | | { prototypes::id::WebGLRenderingContext }, |
17167 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17168 | | JSJitInfo::Method, |
17169 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17170 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17171 | | false, /* isInfallible. False in setters. */ |
17172 | | false, /* isMovable. Not relevant for setters. */ |
17173 | | false, /* isEliminatable. Not relevant for setters. */ |
17174 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17175 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17176 | | false, /* isTypedMethod. Only relevant for methods. */ |
17177 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17178 | | }; |
17179 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17180 | | static_assert(0 < 1, "There is no slot for us"); |
17181 | | |
17182 | | MOZ_CAN_RUN_SCRIPT static bool |
17183 | | stencilFuncSeparate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17184 | 0 | { |
17185 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.stencilFuncSeparate", DOM, cx); |
17186 | 0 |
|
17187 | 0 | if (MOZ_UNLIKELY(args.length() < 4)) { |
17188 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.stencilFuncSeparate"); |
17189 | 0 | } |
17190 | 0 | uint32_t arg0; |
17191 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
17192 | 0 | return false; |
17193 | 0 | } |
17194 | 0 | uint32_t arg1; |
17195 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
17196 | 0 | return false; |
17197 | 0 | } |
17198 | 0 | int32_t arg2; |
17199 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
17200 | 0 | return false; |
17201 | 0 | } |
17202 | 0 | uint32_t arg3; |
17203 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[3], &arg3)) { |
17204 | 0 | return false; |
17205 | 0 | } |
17206 | 0 | self->StencilFuncSeparate(arg0, arg1, arg2, arg3); |
17207 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17208 | 0 | args.rval().setUndefined(); |
17209 | 0 | return true; |
17210 | 0 | } |
17211 | | |
17212 | | static const JSJitInfo stencilFuncSeparate_methodinfo = { |
17213 | | { (JSJitGetterOp)stencilFuncSeparate }, |
17214 | | { prototypes::id::WebGLRenderingContext }, |
17215 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17216 | | JSJitInfo::Method, |
17217 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17218 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17219 | | false, /* isInfallible. False in setters. */ |
17220 | | false, /* isMovable. Not relevant for setters. */ |
17221 | | false, /* isEliminatable. Not relevant for setters. */ |
17222 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17223 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17224 | | false, /* isTypedMethod. Only relevant for methods. */ |
17225 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17226 | | }; |
17227 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17228 | | static_assert(0 < 1, "There is no slot for us"); |
17229 | | |
17230 | | MOZ_CAN_RUN_SCRIPT static bool |
17231 | | stencilMask(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17232 | 0 | { |
17233 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.stencilMask", DOM, cx); |
17234 | 0 |
|
17235 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
17236 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.stencilMask"); |
17237 | 0 | } |
17238 | 0 | uint32_t arg0; |
17239 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
17240 | 0 | return false; |
17241 | 0 | } |
17242 | 0 | self->StencilMask(arg0); |
17243 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17244 | 0 | args.rval().setUndefined(); |
17245 | 0 | return true; |
17246 | 0 | } |
17247 | | |
17248 | | static const JSJitInfo stencilMask_methodinfo = { |
17249 | | { (JSJitGetterOp)stencilMask }, |
17250 | | { prototypes::id::WebGLRenderingContext }, |
17251 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17252 | | JSJitInfo::Method, |
17253 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17254 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17255 | | false, /* isInfallible. False in setters. */ |
17256 | | false, /* isMovable. Not relevant for setters. */ |
17257 | | false, /* isEliminatable. Not relevant for setters. */ |
17258 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17259 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17260 | | false, /* isTypedMethod. Only relevant for methods. */ |
17261 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17262 | | }; |
17263 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17264 | | static_assert(0 < 1, "There is no slot for us"); |
17265 | | |
17266 | | MOZ_CAN_RUN_SCRIPT static bool |
17267 | | stencilMaskSeparate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17268 | 0 | { |
17269 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.stencilMaskSeparate", DOM, cx); |
17270 | 0 |
|
17271 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
17272 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.stencilMaskSeparate"); |
17273 | 0 | } |
17274 | 0 | uint32_t arg0; |
17275 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
17276 | 0 | return false; |
17277 | 0 | } |
17278 | 0 | uint32_t arg1; |
17279 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
17280 | 0 | return false; |
17281 | 0 | } |
17282 | 0 | self->StencilMaskSeparate(arg0, arg1); |
17283 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17284 | 0 | args.rval().setUndefined(); |
17285 | 0 | return true; |
17286 | 0 | } |
17287 | | |
17288 | | static const JSJitInfo stencilMaskSeparate_methodinfo = { |
17289 | | { (JSJitGetterOp)stencilMaskSeparate }, |
17290 | | { prototypes::id::WebGLRenderingContext }, |
17291 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17292 | | JSJitInfo::Method, |
17293 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17294 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17295 | | false, /* isInfallible. False in setters. */ |
17296 | | false, /* isMovable. Not relevant for setters. */ |
17297 | | false, /* isEliminatable. Not relevant for setters. */ |
17298 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17299 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17300 | | false, /* isTypedMethod. Only relevant for methods. */ |
17301 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17302 | | }; |
17303 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17304 | | static_assert(0 < 1, "There is no slot for us"); |
17305 | | |
17306 | | MOZ_CAN_RUN_SCRIPT static bool |
17307 | | stencilOp(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17308 | 0 | { |
17309 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.stencilOp", DOM, cx); |
17310 | 0 |
|
17311 | 0 | if (MOZ_UNLIKELY(args.length() < 3)) { |
17312 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.stencilOp"); |
17313 | 0 | } |
17314 | 0 | uint32_t arg0; |
17315 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
17316 | 0 | return false; |
17317 | 0 | } |
17318 | 0 | uint32_t arg1; |
17319 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
17320 | 0 | return false; |
17321 | 0 | } |
17322 | 0 | uint32_t arg2; |
17323 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) { |
17324 | 0 | return false; |
17325 | 0 | } |
17326 | 0 | self->StencilOp(arg0, arg1, arg2); |
17327 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17328 | 0 | args.rval().setUndefined(); |
17329 | 0 | return true; |
17330 | 0 | } |
17331 | | |
17332 | | static const JSJitInfo stencilOp_methodinfo = { |
17333 | | { (JSJitGetterOp)stencilOp }, |
17334 | | { prototypes::id::WebGLRenderingContext }, |
17335 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17336 | | JSJitInfo::Method, |
17337 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17338 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17339 | | false, /* isInfallible. False in setters. */ |
17340 | | false, /* isMovable. Not relevant for setters. */ |
17341 | | false, /* isEliminatable. Not relevant for setters. */ |
17342 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17343 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17344 | | false, /* isTypedMethod. Only relevant for methods. */ |
17345 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17346 | | }; |
17347 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17348 | | static_assert(0 < 1, "There is no slot for us"); |
17349 | | |
17350 | | MOZ_CAN_RUN_SCRIPT static bool |
17351 | | stencilOpSeparate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17352 | 0 | { |
17353 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.stencilOpSeparate", DOM, cx); |
17354 | 0 |
|
17355 | 0 | if (MOZ_UNLIKELY(args.length() < 4)) { |
17356 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.stencilOpSeparate"); |
17357 | 0 | } |
17358 | 0 | uint32_t arg0; |
17359 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
17360 | 0 | return false; |
17361 | 0 | } |
17362 | 0 | uint32_t arg1; |
17363 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
17364 | 0 | return false; |
17365 | 0 | } |
17366 | 0 | uint32_t arg2; |
17367 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) { |
17368 | 0 | return false; |
17369 | 0 | } |
17370 | 0 | uint32_t arg3; |
17371 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[3], &arg3)) { |
17372 | 0 | return false; |
17373 | 0 | } |
17374 | 0 | self->StencilOpSeparate(arg0, arg1, arg2, arg3); |
17375 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17376 | 0 | args.rval().setUndefined(); |
17377 | 0 | return true; |
17378 | 0 | } |
17379 | | |
17380 | | static const JSJitInfo stencilOpSeparate_methodinfo = { |
17381 | | { (JSJitGetterOp)stencilOpSeparate }, |
17382 | | { prototypes::id::WebGLRenderingContext }, |
17383 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17384 | | JSJitInfo::Method, |
17385 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17386 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17387 | | false, /* isInfallible. False in setters. */ |
17388 | | false, /* isMovable. Not relevant for setters. */ |
17389 | | false, /* isEliminatable. Not relevant for setters. */ |
17390 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17391 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17392 | | false, /* isTypedMethod. Only relevant for methods. */ |
17393 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17394 | | }; |
17395 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17396 | | static_assert(0 < 1, "There is no slot for us"); |
17397 | | |
17398 | | MOZ_CAN_RUN_SCRIPT static bool |
17399 | | texParameterf(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17400 | 0 | { |
17401 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.texParameterf", DOM, cx); |
17402 | 0 |
|
17403 | 0 | if (MOZ_UNLIKELY(args.length() < 3)) { |
17404 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.texParameterf"); |
17405 | 0 | } |
17406 | 0 | uint32_t arg0; |
17407 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
17408 | 0 | return false; |
17409 | 0 | } |
17410 | 0 | uint32_t arg1; |
17411 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
17412 | 0 | return false; |
17413 | 0 | } |
17414 | 0 | float arg2; |
17415 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[2], &arg2)) { |
17416 | 0 | return false; |
17417 | 0 | } |
17418 | 0 | self->TexParameterf(arg0, arg1, arg2); |
17419 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17420 | 0 | args.rval().setUndefined(); |
17421 | 0 | return true; |
17422 | 0 | } |
17423 | | |
17424 | | static const JSJitInfo texParameterf_methodinfo = { |
17425 | | { (JSJitGetterOp)texParameterf }, |
17426 | | { prototypes::id::WebGLRenderingContext }, |
17427 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17428 | | JSJitInfo::Method, |
17429 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17430 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17431 | | false, /* isInfallible. False in setters. */ |
17432 | | false, /* isMovable. Not relevant for setters. */ |
17433 | | false, /* isEliminatable. Not relevant for setters. */ |
17434 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17435 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17436 | | false, /* isTypedMethod. Only relevant for methods. */ |
17437 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17438 | | }; |
17439 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17440 | | static_assert(0 < 1, "There is no slot for us"); |
17441 | | |
17442 | | MOZ_CAN_RUN_SCRIPT static bool |
17443 | | texParameteri(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17444 | 0 | { |
17445 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.texParameteri", DOM, cx); |
17446 | 0 |
|
17447 | 0 | if (MOZ_UNLIKELY(args.length() < 3)) { |
17448 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.texParameteri"); |
17449 | 0 | } |
17450 | 0 | uint32_t arg0; |
17451 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
17452 | 0 | return false; |
17453 | 0 | } |
17454 | 0 | uint32_t arg1; |
17455 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
17456 | 0 | return false; |
17457 | 0 | } |
17458 | 0 | int32_t arg2; |
17459 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
17460 | 0 | return false; |
17461 | 0 | } |
17462 | 0 | self->TexParameteri(arg0, arg1, arg2); |
17463 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17464 | 0 | args.rval().setUndefined(); |
17465 | 0 | return true; |
17466 | 0 | } |
17467 | | |
17468 | | static const JSJitInfo texParameteri_methodinfo = { |
17469 | | { (JSJitGetterOp)texParameteri }, |
17470 | | { prototypes::id::WebGLRenderingContext }, |
17471 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17472 | | JSJitInfo::Method, |
17473 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17474 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17475 | | false, /* isInfallible. False in setters. */ |
17476 | | false, /* isMovable. Not relevant for setters. */ |
17477 | | false, /* isEliminatable. Not relevant for setters. */ |
17478 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17479 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17480 | | false, /* isTypedMethod. Only relevant for methods. */ |
17481 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17482 | | }; |
17483 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17484 | | static_assert(0 < 1, "There is no slot for us"); |
17485 | | |
17486 | | MOZ_CAN_RUN_SCRIPT static bool |
17487 | | uniform1f(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17488 | 0 | { |
17489 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniform1f", DOM, cx); |
17490 | 0 |
|
17491 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
17492 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniform1f"); |
17493 | 0 | } |
17494 | 0 | mozilla::WebGLUniformLocation* arg0; |
17495 | 0 | if (args[0].isObject()) { |
17496 | 0 | { |
17497 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
17498 | 0 | if (NS_FAILED(rv)) { |
17499 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniform1f", "WebGLUniformLocation"); |
17500 | 0 | return false; |
17501 | 0 | } |
17502 | 0 | } |
17503 | 0 | } else if (args[0].isNullOrUndefined()) { |
17504 | 0 | arg0 = nullptr; |
17505 | 0 | } else { |
17506 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniform1f"); |
17507 | 0 | return false; |
17508 | 0 | } |
17509 | 0 | float arg1; |
17510 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[1], &arg1)) { |
17511 | 0 | return false; |
17512 | 0 | } |
17513 | 0 | self->Uniform1f(MOZ_KnownLive(Constify(arg0)), arg1); |
17514 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17515 | 0 | args.rval().setUndefined(); |
17516 | 0 | return true; |
17517 | 0 | } |
17518 | | |
17519 | | static const JSJitInfo uniform1f_methodinfo = { |
17520 | | { (JSJitGetterOp)uniform1f }, |
17521 | | { prototypes::id::WebGLRenderingContext }, |
17522 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17523 | | JSJitInfo::Method, |
17524 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17525 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17526 | | false, /* isInfallible. False in setters. */ |
17527 | | false, /* isMovable. Not relevant for setters. */ |
17528 | | false, /* isEliminatable. Not relevant for setters. */ |
17529 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17530 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17531 | | false, /* isTypedMethod. Only relevant for methods. */ |
17532 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17533 | | }; |
17534 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17535 | | static_assert(0 < 1, "There is no slot for us"); |
17536 | | |
17537 | | MOZ_CAN_RUN_SCRIPT static bool |
17538 | | uniform2f(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17539 | 0 | { |
17540 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniform2f", DOM, cx); |
17541 | 0 |
|
17542 | 0 | if (MOZ_UNLIKELY(args.length() < 3)) { |
17543 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniform2f"); |
17544 | 0 | } |
17545 | 0 | mozilla::WebGLUniformLocation* arg0; |
17546 | 0 | if (args[0].isObject()) { |
17547 | 0 | { |
17548 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
17549 | 0 | if (NS_FAILED(rv)) { |
17550 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniform2f", "WebGLUniformLocation"); |
17551 | 0 | return false; |
17552 | 0 | } |
17553 | 0 | } |
17554 | 0 | } else if (args[0].isNullOrUndefined()) { |
17555 | 0 | arg0 = nullptr; |
17556 | 0 | } else { |
17557 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniform2f"); |
17558 | 0 | return false; |
17559 | 0 | } |
17560 | 0 | float arg1; |
17561 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[1], &arg1)) { |
17562 | 0 | return false; |
17563 | 0 | } |
17564 | 0 | float arg2; |
17565 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[2], &arg2)) { |
17566 | 0 | return false; |
17567 | 0 | } |
17568 | 0 | self->Uniform2f(MOZ_KnownLive(Constify(arg0)), arg1, arg2); |
17569 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17570 | 0 | args.rval().setUndefined(); |
17571 | 0 | return true; |
17572 | 0 | } |
17573 | | |
17574 | | static const JSJitInfo uniform2f_methodinfo = { |
17575 | | { (JSJitGetterOp)uniform2f }, |
17576 | | { prototypes::id::WebGLRenderingContext }, |
17577 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17578 | | JSJitInfo::Method, |
17579 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17580 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17581 | | false, /* isInfallible. False in setters. */ |
17582 | | false, /* isMovable. Not relevant for setters. */ |
17583 | | false, /* isEliminatable. Not relevant for setters. */ |
17584 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17585 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17586 | | false, /* isTypedMethod. Only relevant for methods. */ |
17587 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17588 | | }; |
17589 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17590 | | static_assert(0 < 1, "There is no slot for us"); |
17591 | | |
17592 | | MOZ_CAN_RUN_SCRIPT static bool |
17593 | | uniform3f(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17594 | 0 | { |
17595 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniform3f", DOM, cx); |
17596 | 0 |
|
17597 | 0 | if (MOZ_UNLIKELY(args.length() < 4)) { |
17598 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniform3f"); |
17599 | 0 | } |
17600 | 0 | mozilla::WebGLUniformLocation* arg0; |
17601 | 0 | if (args[0].isObject()) { |
17602 | 0 | { |
17603 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
17604 | 0 | if (NS_FAILED(rv)) { |
17605 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniform3f", "WebGLUniformLocation"); |
17606 | 0 | return false; |
17607 | 0 | } |
17608 | 0 | } |
17609 | 0 | } else if (args[0].isNullOrUndefined()) { |
17610 | 0 | arg0 = nullptr; |
17611 | 0 | } else { |
17612 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniform3f"); |
17613 | 0 | return false; |
17614 | 0 | } |
17615 | 0 | float arg1; |
17616 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[1], &arg1)) { |
17617 | 0 | return false; |
17618 | 0 | } |
17619 | 0 | float arg2; |
17620 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[2], &arg2)) { |
17621 | 0 | return false; |
17622 | 0 | } |
17623 | 0 | float arg3; |
17624 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[3], &arg3)) { |
17625 | 0 | return false; |
17626 | 0 | } |
17627 | 0 | self->Uniform3f(MOZ_KnownLive(Constify(arg0)), arg1, arg2, arg3); |
17628 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17629 | 0 | args.rval().setUndefined(); |
17630 | 0 | return true; |
17631 | 0 | } |
17632 | | |
17633 | | static const JSJitInfo uniform3f_methodinfo = { |
17634 | | { (JSJitGetterOp)uniform3f }, |
17635 | | { prototypes::id::WebGLRenderingContext }, |
17636 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17637 | | JSJitInfo::Method, |
17638 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17639 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17640 | | false, /* isInfallible. False in setters. */ |
17641 | | false, /* isMovable. Not relevant for setters. */ |
17642 | | false, /* isEliminatable. Not relevant for setters. */ |
17643 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17644 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17645 | | false, /* isTypedMethod. Only relevant for methods. */ |
17646 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17647 | | }; |
17648 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17649 | | static_assert(0 < 1, "There is no slot for us"); |
17650 | | |
17651 | | MOZ_CAN_RUN_SCRIPT static bool |
17652 | | uniform4f(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17653 | 0 | { |
17654 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniform4f", DOM, cx); |
17655 | 0 |
|
17656 | 0 | if (MOZ_UNLIKELY(args.length() < 5)) { |
17657 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniform4f"); |
17658 | 0 | } |
17659 | 0 | mozilla::WebGLUniformLocation* arg0; |
17660 | 0 | if (args[0].isObject()) { |
17661 | 0 | { |
17662 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
17663 | 0 | if (NS_FAILED(rv)) { |
17664 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniform4f", "WebGLUniformLocation"); |
17665 | 0 | return false; |
17666 | 0 | } |
17667 | 0 | } |
17668 | 0 | } else if (args[0].isNullOrUndefined()) { |
17669 | 0 | arg0 = nullptr; |
17670 | 0 | } else { |
17671 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniform4f"); |
17672 | 0 | return false; |
17673 | 0 | } |
17674 | 0 | float arg1; |
17675 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[1], &arg1)) { |
17676 | 0 | return false; |
17677 | 0 | } |
17678 | 0 | float arg2; |
17679 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[2], &arg2)) { |
17680 | 0 | return false; |
17681 | 0 | } |
17682 | 0 | float arg3; |
17683 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[3], &arg3)) { |
17684 | 0 | return false; |
17685 | 0 | } |
17686 | 0 | float arg4; |
17687 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[4], &arg4)) { |
17688 | 0 | return false; |
17689 | 0 | } |
17690 | 0 | self->Uniform4f(MOZ_KnownLive(Constify(arg0)), arg1, arg2, arg3, arg4); |
17691 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17692 | 0 | args.rval().setUndefined(); |
17693 | 0 | return true; |
17694 | 0 | } |
17695 | | |
17696 | | static const JSJitInfo uniform4f_methodinfo = { |
17697 | | { (JSJitGetterOp)uniform4f }, |
17698 | | { prototypes::id::WebGLRenderingContext }, |
17699 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17700 | | JSJitInfo::Method, |
17701 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17702 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17703 | | false, /* isInfallible. False in setters. */ |
17704 | | false, /* isMovable. Not relevant for setters. */ |
17705 | | false, /* isEliminatable. Not relevant for setters. */ |
17706 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17707 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17708 | | false, /* isTypedMethod. Only relevant for methods. */ |
17709 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17710 | | }; |
17711 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17712 | | static_assert(0 < 1, "There is no slot for us"); |
17713 | | |
17714 | | MOZ_CAN_RUN_SCRIPT static bool |
17715 | | uniform1i(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17716 | 0 | { |
17717 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniform1i", DOM, cx); |
17718 | 0 |
|
17719 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
17720 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniform1i"); |
17721 | 0 | } |
17722 | 0 | mozilla::WebGLUniformLocation* arg0; |
17723 | 0 | if (args[0].isObject()) { |
17724 | 0 | { |
17725 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
17726 | 0 | if (NS_FAILED(rv)) { |
17727 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniform1i", "WebGLUniformLocation"); |
17728 | 0 | return false; |
17729 | 0 | } |
17730 | 0 | } |
17731 | 0 | } else if (args[0].isNullOrUndefined()) { |
17732 | 0 | arg0 = nullptr; |
17733 | 0 | } else { |
17734 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniform1i"); |
17735 | 0 | return false; |
17736 | 0 | } |
17737 | 0 | int32_t arg1; |
17738 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
17739 | 0 | return false; |
17740 | 0 | } |
17741 | 0 | self->Uniform1i(MOZ_KnownLive(Constify(arg0)), arg1); |
17742 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17743 | 0 | args.rval().setUndefined(); |
17744 | 0 | return true; |
17745 | 0 | } |
17746 | | |
17747 | | static const JSJitInfo uniform1i_methodinfo = { |
17748 | | { (JSJitGetterOp)uniform1i }, |
17749 | | { prototypes::id::WebGLRenderingContext }, |
17750 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17751 | | JSJitInfo::Method, |
17752 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17753 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17754 | | false, /* isInfallible. False in setters. */ |
17755 | | false, /* isMovable. Not relevant for setters. */ |
17756 | | false, /* isEliminatable. Not relevant for setters. */ |
17757 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17758 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17759 | | false, /* isTypedMethod. Only relevant for methods. */ |
17760 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17761 | | }; |
17762 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17763 | | static_assert(0 < 1, "There is no slot for us"); |
17764 | | |
17765 | | MOZ_CAN_RUN_SCRIPT static bool |
17766 | | uniform2i(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17767 | 0 | { |
17768 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniform2i", DOM, cx); |
17769 | 0 |
|
17770 | 0 | if (MOZ_UNLIKELY(args.length() < 3)) { |
17771 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniform2i"); |
17772 | 0 | } |
17773 | 0 | mozilla::WebGLUniformLocation* arg0; |
17774 | 0 | if (args[0].isObject()) { |
17775 | 0 | { |
17776 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
17777 | 0 | if (NS_FAILED(rv)) { |
17778 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniform2i", "WebGLUniformLocation"); |
17779 | 0 | return false; |
17780 | 0 | } |
17781 | 0 | } |
17782 | 0 | } else if (args[0].isNullOrUndefined()) { |
17783 | 0 | arg0 = nullptr; |
17784 | 0 | } else { |
17785 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniform2i"); |
17786 | 0 | return false; |
17787 | 0 | } |
17788 | 0 | int32_t arg1; |
17789 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
17790 | 0 | return false; |
17791 | 0 | } |
17792 | 0 | int32_t arg2; |
17793 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
17794 | 0 | return false; |
17795 | 0 | } |
17796 | 0 | self->Uniform2i(MOZ_KnownLive(Constify(arg0)), arg1, arg2); |
17797 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17798 | 0 | args.rval().setUndefined(); |
17799 | 0 | return true; |
17800 | 0 | } |
17801 | | |
17802 | | static const JSJitInfo uniform2i_methodinfo = { |
17803 | | { (JSJitGetterOp)uniform2i }, |
17804 | | { prototypes::id::WebGLRenderingContext }, |
17805 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17806 | | JSJitInfo::Method, |
17807 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17808 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17809 | | false, /* isInfallible. False in setters. */ |
17810 | | false, /* isMovable. Not relevant for setters. */ |
17811 | | false, /* isEliminatable. Not relevant for setters. */ |
17812 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17813 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17814 | | false, /* isTypedMethod. Only relevant for methods. */ |
17815 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17816 | | }; |
17817 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17818 | | static_assert(0 < 1, "There is no slot for us"); |
17819 | | |
17820 | | MOZ_CAN_RUN_SCRIPT static bool |
17821 | | uniform3i(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17822 | 0 | { |
17823 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniform3i", DOM, cx); |
17824 | 0 |
|
17825 | 0 | if (MOZ_UNLIKELY(args.length() < 4)) { |
17826 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniform3i"); |
17827 | 0 | } |
17828 | 0 | mozilla::WebGLUniformLocation* arg0; |
17829 | 0 | if (args[0].isObject()) { |
17830 | 0 | { |
17831 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
17832 | 0 | if (NS_FAILED(rv)) { |
17833 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniform3i", "WebGLUniformLocation"); |
17834 | 0 | return false; |
17835 | 0 | } |
17836 | 0 | } |
17837 | 0 | } else if (args[0].isNullOrUndefined()) { |
17838 | 0 | arg0 = nullptr; |
17839 | 0 | } else { |
17840 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniform3i"); |
17841 | 0 | return false; |
17842 | 0 | } |
17843 | 0 | int32_t arg1; |
17844 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
17845 | 0 | return false; |
17846 | 0 | } |
17847 | 0 | int32_t arg2; |
17848 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
17849 | 0 | return false; |
17850 | 0 | } |
17851 | 0 | int32_t arg3; |
17852 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[3], &arg3)) { |
17853 | 0 | return false; |
17854 | 0 | } |
17855 | 0 | self->Uniform3i(MOZ_KnownLive(Constify(arg0)), arg1, arg2, arg3); |
17856 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17857 | 0 | args.rval().setUndefined(); |
17858 | 0 | return true; |
17859 | 0 | } |
17860 | | |
17861 | | static const JSJitInfo uniform3i_methodinfo = { |
17862 | | { (JSJitGetterOp)uniform3i }, |
17863 | | { prototypes::id::WebGLRenderingContext }, |
17864 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17865 | | JSJitInfo::Method, |
17866 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17867 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17868 | | false, /* isInfallible. False in setters. */ |
17869 | | false, /* isMovable. Not relevant for setters. */ |
17870 | | false, /* isEliminatable. Not relevant for setters. */ |
17871 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17872 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17873 | | false, /* isTypedMethod. Only relevant for methods. */ |
17874 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17875 | | }; |
17876 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17877 | | static_assert(0 < 1, "There is no slot for us"); |
17878 | | |
17879 | | MOZ_CAN_RUN_SCRIPT static bool |
17880 | | uniform4i(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17881 | 0 | { |
17882 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.uniform4i", DOM, cx); |
17883 | 0 |
|
17884 | 0 | if (MOZ_UNLIKELY(args.length() < 5)) { |
17885 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.uniform4i"); |
17886 | 0 | } |
17887 | 0 | mozilla::WebGLUniformLocation* arg0; |
17888 | 0 | if (args[0].isObject()) { |
17889 | 0 | { |
17890 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLUniformLocation, mozilla::WebGLUniformLocation>(args[0], arg0); |
17891 | 0 | if (NS_FAILED(rv)) { |
17892 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.uniform4i", "WebGLUniformLocation"); |
17893 | 0 | return false; |
17894 | 0 | } |
17895 | 0 | } |
17896 | 0 | } else if (args[0].isNullOrUndefined()) { |
17897 | 0 | arg0 = nullptr; |
17898 | 0 | } else { |
17899 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.uniform4i"); |
17900 | 0 | return false; |
17901 | 0 | } |
17902 | 0 | int32_t arg1; |
17903 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
17904 | 0 | return false; |
17905 | 0 | } |
17906 | 0 | int32_t arg2; |
17907 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
17908 | 0 | return false; |
17909 | 0 | } |
17910 | 0 | int32_t arg3; |
17911 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[3], &arg3)) { |
17912 | 0 | return false; |
17913 | 0 | } |
17914 | 0 | int32_t arg4; |
17915 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) { |
17916 | 0 | return false; |
17917 | 0 | } |
17918 | 0 | self->Uniform4i(MOZ_KnownLive(Constify(arg0)), arg1, arg2, arg3, arg4); |
17919 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17920 | 0 | args.rval().setUndefined(); |
17921 | 0 | return true; |
17922 | 0 | } |
17923 | | |
17924 | | static const JSJitInfo uniform4i_methodinfo = { |
17925 | | { (JSJitGetterOp)uniform4i }, |
17926 | | { prototypes::id::WebGLRenderingContext }, |
17927 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17928 | | JSJitInfo::Method, |
17929 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17930 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17931 | | false, /* isInfallible. False in setters. */ |
17932 | | false, /* isMovable. Not relevant for setters. */ |
17933 | | false, /* isEliminatable. Not relevant for setters. */ |
17934 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17935 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17936 | | false, /* isTypedMethod. Only relevant for methods. */ |
17937 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17938 | | }; |
17939 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17940 | | static_assert(0 < 1, "There is no slot for us"); |
17941 | | |
17942 | | MOZ_CAN_RUN_SCRIPT static bool |
17943 | | useProgram(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17944 | 0 | { |
17945 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.useProgram", DOM, cx); |
17946 | 0 |
|
17947 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
17948 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.useProgram"); |
17949 | 0 | } |
17950 | 0 | mozilla::WebGLProgram* arg0; |
17951 | 0 | if (args[0].isObject()) { |
17952 | 0 | { |
17953 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLProgram, mozilla::WebGLProgram>(args[0], arg0); |
17954 | 0 | if (NS_FAILED(rv)) { |
17955 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.useProgram", "WebGLProgram"); |
17956 | 0 | return false; |
17957 | 0 | } |
17958 | 0 | } |
17959 | 0 | } else if (args[0].isNullOrUndefined()) { |
17960 | 0 | arg0 = nullptr; |
17961 | 0 | } else { |
17962 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.useProgram"); |
17963 | 0 | return false; |
17964 | 0 | } |
17965 | 0 | self->UseProgram(MOZ_KnownLive(Constify(arg0))); |
17966 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
17967 | 0 | args.rval().setUndefined(); |
17968 | 0 | return true; |
17969 | 0 | } |
17970 | | |
17971 | | static const JSJitInfo useProgram_methodinfo = { |
17972 | | { (JSJitGetterOp)useProgram }, |
17973 | | { prototypes::id::WebGLRenderingContext }, |
17974 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
17975 | | JSJitInfo::Method, |
17976 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
17977 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
17978 | | false, /* isInfallible. False in setters. */ |
17979 | | false, /* isMovable. Not relevant for setters. */ |
17980 | | false, /* isEliminatable. Not relevant for setters. */ |
17981 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
17982 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
17983 | | false, /* isTypedMethod. Only relevant for methods. */ |
17984 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
17985 | | }; |
17986 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
17987 | | static_assert(0 < 1, "There is no slot for us"); |
17988 | | |
17989 | | MOZ_CAN_RUN_SCRIPT static bool |
17990 | | validateProgram(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
17991 | 0 | { |
17992 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.validateProgram", DOM, cx); |
17993 | 0 |
|
17994 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
17995 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.validateProgram"); |
17996 | 0 | } |
17997 | 0 | NonNull<mozilla::WebGLProgram> arg0; |
17998 | 0 | if (args[0].isObject()) { |
17999 | 0 | { |
18000 | 0 | nsresult rv = UnwrapObject<prototypes::id::WebGLProgram, mozilla::WebGLProgram>(args[0], arg0); |
18001 | 0 | if (NS_FAILED(rv)) { |
18002 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of WebGLRenderingContext.validateProgram", "WebGLProgram"); |
18003 | 0 | return false; |
18004 | 0 | } |
18005 | 0 | } |
18006 | 0 | } else { |
18007 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebGLRenderingContext.validateProgram"); |
18008 | 0 | return false; |
18009 | 0 | } |
18010 | 0 | self->ValidateProgram(MOZ_KnownLive(NonNullHelper(arg0))); |
18011 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
18012 | 0 | args.rval().setUndefined(); |
18013 | 0 | return true; |
18014 | 0 | } |
18015 | | |
18016 | | static const JSJitInfo validateProgram_methodinfo = { |
18017 | | { (JSJitGetterOp)validateProgram }, |
18018 | | { prototypes::id::WebGLRenderingContext }, |
18019 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
18020 | | JSJitInfo::Method, |
18021 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
18022 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
18023 | | false, /* isInfallible. False in setters. */ |
18024 | | false, /* isMovable. Not relevant for setters. */ |
18025 | | false, /* isEliminatable. Not relevant for setters. */ |
18026 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
18027 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
18028 | | false, /* isTypedMethod. Only relevant for methods. */ |
18029 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
18030 | | }; |
18031 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
18032 | | static_assert(0 < 1, "There is no slot for us"); |
18033 | | |
18034 | | MOZ_CAN_RUN_SCRIPT static bool |
18035 | | vertexAttrib1f(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
18036 | 0 | { |
18037 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.vertexAttrib1f", DOM, cx); |
18038 | 0 |
|
18039 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
18040 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.vertexAttrib1f"); |
18041 | 0 | } |
18042 | 0 | uint32_t arg0; |
18043 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
18044 | 0 | return false; |
18045 | 0 | } |
18046 | 0 | float arg1; |
18047 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[1], &arg1)) { |
18048 | 0 | return false; |
18049 | 0 | } |
18050 | 0 | self->VertexAttrib1f(arg0, arg1); |
18051 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
18052 | 0 | args.rval().setUndefined(); |
18053 | 0 | return true; |
18054 | 0 | } |
18055 | | |
18056 | | static const JSJitInfo vertexAttrib1f_methodinfo = { |
18057 | | { (JSJitGetterOp)vertexAttrib1f }, |
18058 | | { prototypes::id::WebGLRenderingContext }, |
18059 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
18060 | | JSJitInfo::Method, |
18061 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
18062 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
18063 | | false, /* isInfallible. False in setters. */ |
18064 | | false, /* isMovable. Not relevant for setters. */ |
18065 | | false, /* isEliminatable. Not relevant for setters. */ |
18066 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
18067 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
18068 | | false, /* isTypedMethod. Only relevant for methods. */ |
18069 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
18070 | | }; |
18071 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
18072 | | static_assert(0 < 1, "There is no slot for us"); |
18073 | | |
18074 | | MOZ_CAN_RUN_SCRIPT static bool |
18075 | | vertexAttrib1fv(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
18076 | 0 | { |
18077 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.vertexAttrib1fv", DOM, cx); |
18078 | 0 |
|
18079 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
18080 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.vertexAttrib1fv"); |
18081 | 0 | } |
18082 | 0 | uint32_t arg0; |
18083 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
18084 | 0 | return false; |
18085 | 0 | } |
18086 | 0 | Float32ArrayOrUnrestrictedFloatSequence arg1; |
18087 | 0 | Float32ArrayOrUnrestrictedFloatSequenceArgument arg1_holder(arg1); |
18088 | 0 | { |
18089 | 0 | bool done = false, failed = false, tryNext; |
18090 | 0 | if (args[1].isObject()) { |
18091 | 0 | done = (failed = !arg1_holder.TrySetToFloat32Array(cx, args[1], tryNext, false)) || !tryNext; |
18092 | 0 |
|
18093 | 0 | if (!done) { |
18094 | 0 | done = (failed = !arg1_holder.TrySetToUnrestrictedFloatSequence(cx, args[1], tryNext, false)) || !tryNext; |
18095 | 0 | } |
18096 | 0 | } |
18097 | 0 | if (failed) { |
18098 | 0 | return false; |
18099 | 0 | } |
18100 | 0 | if (!done) { |
18101 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of WebGLRenderingContext.vertexAttrib1fv", "Float32Array, UnrestrictedFloatSequence"); |
18102 | 0 | return false; |
18103 | 0 | } |
18104 | 0 | } |
18105 | 0 | self->VertexAttrib1fv(arg0, Constify(arg1)); |
18106 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
18107 | 0 | args.rval().setUndefined(); |
18108 | 0 | return true; |
18109 | 0 | } |
18110 | | |
18111 | | static const JSJitInfo vertexAttrib1fv_methodinfo = { |
18112 | | { (JSJitGetterOp)vertexAttrib1fv }, |
18113 | | { prototypes::id::WebGLRenderingContext }, |
18114 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
18115 | | JSJitInfo::Method, |
18116 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
18117 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
18118 | | false, /* isInfallible. False in setters. */ |
18119 | | false, /* isMovable. Not relevant for setters. */ |
18120 | | false, /* isEliminatable. Not relevant for setters. */ |
18121 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
18122 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
18123 | | false, /* isTypedMethod. Only relevant for methods. */ |
18124 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
18125 | | }; |
18126 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
18127 | | static_assert(0 < 1, "There is no slot for us"); |
18128 | | |
18129 | | MOZ_CAN_RUN_SCRIPT static bool |
18130 | | vertexAttrib2f(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
18131 | 0 | { |
18132 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.vertexAttrib2f", DOM, cx); |
18133 | 0 |
|
18134 | 0 | if (MOZ_UNLIKELY(args.length() < 3)) { |
18135 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.vertexAttrib2f"); |
18136 | 0 | } |
18137 | 0 | uint32_t arg0; |
18138 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
18139 | 0 | return false; |
18140 | 0 | } |
18141 | 0 | float arg1; |
18142 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[1], &arg1)) { |
18143 | 0 | return false; |
18144 | 0 | } |
18145 | 0 | float arg2; |
18146 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[2], &arg2)) { |
18147 | 0 | return false; |
18148 | 0 | } |
18149 | 0 | self->VertexAttrib2f(arg0, arg1, arg2); |
18150 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
18151 | 0 | args.rval().setUndefined(); |
18152 | 0 | return true; |
18153 | 0 | } |
18154 | | |
18155 | | static const JSJitInfo vertexAttrib2f_methodinfo = { |
18156 | | { (JSJitGetterOp)vertexAttrib2f }, |
18157 | | { prototypes::id::WebGLRenderingContext }, |
18158 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
18159 | | JSJitInfo::Method, |
18160 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
18161 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
18162 | | false, /* isInfallible. False in setters. */ |
18163 | | false, /* isMovable. Not relevant for setters. */ |
18164 | | false, /* isEliminatable. Not relevant for setters. */ |
18165 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
18166 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
18167 | | false, /* isTypedMethod. Only relevant for methods. */ |
18168 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
18169 | | }; |
18170 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
18171 | | static_assert(0 < 1, "There is no slot for us"); |
18172 | | |
18173 | | MOZ_CAN_RUN_SCRIPT static bool |
18174 | | vertexAttrib2fv(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
18175 | 0 | { |
18176 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.vertexAttrib2fv", DOM, cx); |
18177 | 0 |
|
18178 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
18179 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.vertexAttrib2fv"); |
18180 | 0 | } |
18181 | 0 | uint32_t arg0; |
18182 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
18183 | 0 | return false; |
18184 | 0 | } |
18185 | 0 | Float32ArrayOrUnrestrictedFloatSequence arg1; |
18186 | 0 | Float32ArrayOrUnrestrictedFloatSequenceArgument arg1_holder(arg1); |
18187 | 0 | { |
18188 | 0 | bool done = false, failed = false, tryNext; |
18189 | 0 | if (args[1].isObject()) { |
18190 | 0 | done = (failed = !arg1_holder.TrySetToFloat32Array(cx, args[1], tryNext, false)) || !tryNext; |
18191 | 0 |
|
18192 | 0 | if (!done) { |
18193 | 0 | done = (failed = !arg1_holder.TrySetToUnrestrictedFloatSequence(cx, args[1], tryNext, false)) || !tryNext; |
18194 | 0 | } |
18195 | 0 | } |
18196 | 0 | if (failed) { |
18197 | 0 | return false; |
18198 | 0 | } |
18199 | 0 | if (!done) { |
18200 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of WebGLRenderingContext.vertexAttrib2fv", "Float32Array, UnrestrictedFloatSequence"); |
18201 | 0 | return false; |
18202 | 0 | } |
18203 | 0 | } |
18204 | 0 | self->VertexAttrib2fv(arg0, Constify(arg1)); |
18205 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
18206 | 0 | args.rval().setUndefined(); |
18207 | 0 | return true; |
18208 | 0 | } |
18209 | | |
18210 | | static const JSJitInfo vertexAttrib2fv_methodinfo = { |
18211 | | { (JSJitGetterOp)vertexAttrib2fv }, |
18212 | | { prototypes::id::WebGLRenderingContext }, |
18213 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
18214 | | JSJitInfo::Method, |
18215 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
18216 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
18217 | | false, /* isInfallible. False in setters. */ |
18218 | | false, /* isMovable. Not relevant for setters. */ |
18219 | | false, /* isEliminatable. Not relevant for setters. */ |
18220 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
18221 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
18222 | | false, /* isTypedMethod. Only relevant for methods. */ |
18223 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
18224 | | }; |
18225 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
18226 | | static_assert(0 < 1, "There is no slot for us"); |
18227 | | |
18228 | | MOZ_CAN_RUN_SCRIPT static bool |
18229 | | vertexAttrib3f(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
18230 | 0 | { |
18231 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.vertexAttrib3f", DOM, cx); |
18232 | 0 |
|
18233 | 0 | if (MOZ_UNLIKELY(args.length() < 4)) { |
18234 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.vertexAttrib3f"); |
18235 | 0 | } |
18236 | 0 | uint32_t arg0; |
18237 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
18238 | 0 | return false; |
18239 | 0 | } |
18240 | 0 | float arg1; |
18241 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[1], &arg1)) { |
18242 | 0 | return false; |
18243 | 0 | } |
18244 | 0 | float arg2; |
18245 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[2], &arg2)) { |
18246 | 0 | return false; |
18247 | 0 | } |
18248 | 0 | float arg3; |
18249 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[3], &arg3)) { |
18250 | 0 | return false; |
18251 | 0 | } |
18252 | 0 | self->VertexAttrib3f(arg0, arg1, arg2, arg3); |
18253 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
18254 | 0 | args.rval().setUndefined(); |
18255 | 0 | return true; |
18256 | 0 | } |
18257 | | |
18258 | | static const JSJitInfo vertexAttrib3f_methodinfo = { |
18259 | | { (JSJitGetterOp)vertexAttrib3f }, |
18260 | | { prototypes::id::WebGLRenderingContext }, |
18261 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
18262 | | JSJitInfo::Method, |
18263 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
18264 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
18265 | | false, /* isInfallible. False in setters. */ |
18266 | | false, /* isMovable. Not relevant for setters. */ |
18267 | | false, /* isEliminatable. Not relevant for setters. */ |
18268 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
18269 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
18270 | | false, /* isTypedMethod. Only relevant for methods. */ |
18271 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
18272 | | }; |
18273 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
18274 | | static_assert(0 < 1, "There is no slot for us"); |
18275 | | |
18276 | | MOZ_CAN_RUN_SCRIPT static bool |
18277 | | vertexAttrib3fv(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
18278 | 0 | { |
18279 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.vertexAttrib3fv", DOM, cx); |
18280 | 0 |
|
18281 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
18282 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.vertexAttrib3fv"); |
18283 | 0 | } |
18284 | 0 | uint32_t arg0; |
18285 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
18286 | 0 | return false; |
18287 | 0 | } |
18288 | 0 | Float32ArrayOrUnrestrictedFloatSequence arg1; |
18289 | 0 | Float32ArrayOrUnrestrictedFloatSequenceArgument arg1_holder(arg1); |
18290 | 0 | { |
18291 | 0 | bool done = false, failed = false, tryNext; |
18292 | 0 | if (args[1].isObject()) { |
18293 | 0 | done = (failed = !arg1_holder.TrySetToFloat32Array(cx, args[1], tryNext, false)) || !tryNext; |
18294 | 0 |
|
18295 | 0 | if (!done) { |
18296 | 0 | done = (failed = !arg1_holder.TrySetToUnrestrictedFloatSequence(cx, args[1], tryNext, false)) || !tryNext; |
18297 | 0 | } |
18298 | 0 | } |
18299 | 0 | if (failed) { |
18300 | 0 | return false; |
18301 | 0 | } |
18302 | 0 | if (!done) { |
18303 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of WebGLRenderingContext.vertexAttrib3fv", "Float32Array, UnrestrictedFloatSequence"); |
18304 | 0 | return false; |
18305 | 0 | } |
18306 | 0 | } |
18307 | 0 | self->VertexAttrib3fv(arg0, Constify(arg1)); |
18308 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
18309 | 0 | args.rval().setUndefined(); |
18310 | 0 | return true; |
18311 | 0 | } |
18312 | | |
18313 | | static const JSJitInfo vertexAttrib3fv_methodinfo = { |
18314 | | { (JSJitGetterOp)vertexAttrib3fv }, |
18315 | | { prototypes::id::WebGLRenderingContext }, |
18316 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
18317 | | JSJitInfo::Method, |
18318 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
18319 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
18320 | | false, /* isInfallible. False in setters. */ |
18321 | | false, /* isMovable. Not relevant for setters. */ |
18322 | | false, /* isEliminatable. Not relevant for setters. */ |
18323 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
18324 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
18325 | | false, /* isTypedMethod. Only relevant for methods. */ |
18326 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
18327 | | }; |
18328 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
18329 | | static_assert(0 < 1, "There is no slot for us"); |
18330 | | |
18331 | | MOZ_CAN_RUN_SCRIPT static bool |
18332 | | vertexAttrib4f(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
18333 | 0 | { |
18334 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.vertexAttrib4f", DOM, cx); |
18335 | 0 |
|
18336 | 0 | if (MOZ_UNLIKELY(args.length() < 5)) { |
18337 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.vertexAttrib4f"); |
18338 | 0 | } |
18339 | 0 | uint32_t arg0; |
18340 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
18341 | 0 | return false; |
18342 | 0 | } |
18343 | 0 | float arg1; |
18344 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[1], &arg1)) { |
18345 | 0 | return false; |
18346 | 0 | } |
18347 | 0 | float arg2; |
18348 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[2], &arg2)) { |
18349 | 0 | return false; |
18350 | 0 | } |
18351 | 0 | float arg3; |
18352 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[3], &arg3)) { |
18353 | 0 | return false; |
18354 | 0 | } |
18355 | 0 | float arg4; |
18356 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[4], &arg4)) { |
18357 | 0 | return false; |
18358 | 0 | } |
18359 | 0 | self->VertexAttrib4f(arg0, arg1, arg2, arg3, arg4); |
18360 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
18361 | 0 | args.rval().setUndefined(); |
18362 | 0 | return true; |
18363 | 0 | } |
18364 | | |
18365 | | static const JSJitInfo vertexAttrib4f_methodinfo = { |
18366 | | { (JSJitGetterOp)vertexAttrib4f }, |
18367 | | { prototypes::id::WebGLRenderingContext }, |
18368 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
18369 | | JSJitInfo::Method, |
18370 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
18371 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
18372 | | false, /* isInfallible. False in setters. */ |
18373 | | false, /* isMovable. Not relevant for setters. */ |
18374 | | false, /* isEliminatable. Not relevant for setters. */ |
18375 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
18376 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
18377 | | false, /* isTypedMethod. Only relevant for methods. */ |
18378 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
18379 | | }; |
18380 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
18381 | | static_assert(0 < 1, "There is no slot for us"); |
18382 | | |
18383 | | MOZ_CAN_RUN_SCRIPT static bool |
18384 | | vertexAttrib4fv(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
18385 | 0 | { |
18386 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.vertexAttrib4fv", DOM, cx); |
18387 | 0 |
|
18388 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
18389 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.vertexAttrib4fv"); |
18390 | 0 | } |
18391 | 0 | uint32_t arg0; |
18392 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
18393 | 0 | return false; |
18394 | 0 | } |
18395 | 0 | Float32ArrayOrUnrestrictedFloatSequence arg1; |
18396 | 0 | Float32ArrayOrUnrestrictedFloatSequenceArgument arg1_holder(arg1); |
18397 | 0 | { |
18398 | 0 | bool done = false, failed = false, tryNext; |
18399 | 0 | if (args[1].isObject()) { |
18400 | 0 | done = (failed = !arg1_holder.TrySetToFloat32Array(cx, args[1], tryNext, false)) || !tryNext; |
18401 | 0 |
|
18402 | 0 | if (!done) { |
18403 | 0 | done = (failed = !arg1_holder.TrySetToUnrestrictedFloatSequence(cx, args[1], tryNext, false)) || !tryNext; |
18404 | 0 | } |
18405 | 0 | } |
18406 | 0 | if (failed) { |
18407 | 0 | return false; |
18408 | 0 | } |
18409 | 0 | if (!done) { |
18410 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of WebGLRenderingContext.vertexAttrib4fv", "Float32Array, UnrestrictedFloatSequence"); |
18411 | 0 | return false; |
18412 | 0 | } |
18413 | 0 | } |
18414 | 0 | self->VertexAttrib4fv(arg0, Constify(arg1)); |
18415 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
18416 | 0 | args.rval().setUndefined(); |
18417 | 0 | return true; |
18418 | 0 | } |
18419 | | |
18420 | | static const JSJitInfo vertexAttrib4fv_methodinfo = { |
18421 | | { (JSJitGetterOp)vertexAttrib4fv }, |
18422 | | { prototypes::id::WebGLRenderingContext }, |
18423 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
18424 | | JSJitInfo::Method, |
18425 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
18426 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
18427 | | false, /* isInfallible. False in setters. */ |
18428 | | false, /* isMovable. Not relevant for setters. */ |
18429 | | false, /* isEliminatable. Not relevant for setters. */ |
18430 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
18431 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
18432 | | false, /* isTypedMethod. Only relevant for methods. */ |
18433 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
18434 | | }; |
18435 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
18436 | | static_assert(0 < 1, "There is no slot for us"); |
18437 | | |
18438 | | MOZ_CAN_RUN_SCRIPT static bool |
18439 | | vertexAttribPointer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
18440 | 0 | { |
18441 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.vertexAttribPointer", DOM, cx); |
18442 | 0 |
|
18443 | 0 | if (MOZ_UNLIKELY(args.length() < 6)) { |
18444 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.vertexAttribPointer"); |
18445 | 0 | } |
18446 | 0 | uint32_t arg0; |
18447 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
18448 | 0 | return false; |
18449 | 0 | } |
18450 | 0 | int32_t arg1; |
18451 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
18452 | 0 | return false; |
18453 | 0 | } |
18454 | 0 | uint32_t arg2; |
18455 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) { |
18456 | 0 | return false; |
18457 | 0 | } |
18458 | 0 | bool arg3; |
18459 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[3], &arg3)) { |
18460 | 0 | return false; |
18461 | 0 | } |
18462 | 0 | int32_t arg4; |
18463 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[4], &arg4)) { |
18464 | 0 | return false; |
18465 | 0 | } |
18466 | 0 | int64_t arg5; |
18467 | 0 | if (!ValueToPrimitive<int64_t, eDefault>(cx, args[5], &arg5)) { |
18468 | 0 | return false; |
18469 | 0 | } |
18470 | 0 | self->VertexAttribPointer(arg0, arg1, arg2, arg3, arg4, arg5); |
18471 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
18472 | 0 | args.rval().setUndefined(); |
18473 | 0 | return true; |
18474 | 0 | } |
18475 | | |
18476 | | static const JSJitInfo vertexAttribPointer_methodinfo = { |
18477 | | { (JSJitGetterOp)vertexAttribPointer }, |
18478 | | { prototypes::id::WebGLRenderingContext }, |
18479 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
18480 | | JSJitInfo::Method, |
18481 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
18482 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
18483 | | false, /* isInfallible. False in setters. */ |
18484 | | false, /* isMovable. Not relevant for setters. */ |
18485 | | false, /* isEliminatable. Not relevant for setters. */ |
18486 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
18487 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
18488 | | false, /* isTypedMethod. Only relevant for methods. */ |
18489 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
18490 | | }; |
18491 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
18492 | | static_assert(0 < 1, "There is no slot for us"); |
18493 | | |
18494 | | MOZ_CAN_RUN_SCRIPT static bool |
18495 | | viewport(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLContext* self, const JSJitMethodCallArgs& args) |
18496 | 0 | { |
18497 | 0 | AUTO_PROFILER_LABEL_FAST("WebGLRenderingContext.viewport", DOM, cx); |
18498 | 0 |
|
18499 | 0 | if (MOZ_UNLIKELY(args.length() < 4)) { |
18500 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebGLRenderingContext.viewport"); |
18501 | 0 | } |
18502 | 0 | int32_t arg0; |
18503 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) { |
18504 | 0 | return false; |
18505 | 0 | } |
18506 | 0 | int32_t arg1; |
18507 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[1], &arg1)) { |
18508 | 0 | return false; |
18509 | 0 | } |
18510 | 0 | int32_t arg2; |
18511 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[2], &arg2)) { |
18512 | 0 | return false; |
18513 | 0 | } |
18514 | 0 | int32_t arg3; |
18515 | 0 | if (!ValueToPrimitive<int32_t, eDefault>(cx, args[3], &arg3)) { |
18516 | 0 | return false; |
18517 | 0 | } |
18518 | 0 | self->Viewport(arg0, arg1, arg2, arg3); |
18519 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
18520 | 0 | args.rval().setUndefined(); |
18521 | 0 | return true; |
18522 | 0 | } |
18523 | | |
18524 | | static const JSJitInfo viewport_methodinfo = { |
18525 | | { (JSJitGetterOp)viewport }, |
18526 | | { prototypes::id::WebGLRenderingContext }, |
18527 | | { PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth }, |
18528 | | JSJitInfo::Method, |
18529 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
18530 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
18531 | | false, /* isInfallible. False in setters. */ |
18532 | | false, /* isMovable. Not relevant for setters. */ |
18533 | | false, /* isEliminatable. Not relevant for setters. */ |
18534 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
18535 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
18536 | | false, /* isTypedMethod. Only relevant for methods. */ |
18537 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
18538 | | }; |
18539 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
18540 | | static_assert(0 < 1, "There is no slot for us"); |
18541 | | |
18542 | | static bool |
18543 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
18544 | 0 | { |
18545 | 0 | mozilla::WebGLContext* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLContext>(obj); |
18546 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
18547 | 0 | // obviously can't preserve if we're not initialized. |
18548 | 0 | if (self && self->GetWrapperPreserveColor()) { |
18549 | 0 | PreserveWrapper(self); |
18550 | 0 | } |
18551 | 0 | return true; |
18552 | 0 | } |
18553 | | |
18554 | | static void |
18555 | | _finalize(js::FreeOp* fop, JSObject* obj) |
18556 | 0 | { |
18557 | 0 | mozilla::WebGLContext* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLContext>(obj); |
18558 | 0 | if (self) { |
18559 | 0 | ClearWrapper(self, self, obj); |
18560 | 0 | AddForDeferredFinalization<mozilla::WebGLContext>(self); |
18561 | 0 | } |
18562 | 0 | } |
18563 | | |
18564 | | static size_t |
18565 | | _objectMoved(JSObject* obj, JSObject* old) |
18566 | 0 | { |
18567 | 0 | mozilla::WebGLContext* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLContext>(obj); |
18568 | 0 | if (self) { |
18569 | 0 | UpdateWrapper(self, self, obj, old); |
18570 | 0 | } |
18571 | 0 |
|
18572 | 0 | return 0; |
18573 | 0 | } |
18574 | | |
18575 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
18576 | | #if defined(__clang__) |
18577 | | #pragma clang diagnostic push |
18578 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
18579 | | #endif |
18580 | | static const JSFunctionSpec sMethods_specs[] = { |
18581 | | JS_FNSPEC("bufferData", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&bufferData_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
18582 | | JS_FNSPEC("bufferSubData", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&bufferSubData_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
18583 | | JS_FNSPEC("compressedTexImage2D", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&compressedTexImage2D_methodinfo), 7, JSPROP_ENUMERATE, nullptr), |
18584 | | JS_FNSPEC("compressedTexSubImage2D", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&compressedTexSubImage2D_methodinfo), 8, JSPROP_ENUMERATE, nullptr), |
18585 | | JS_FNSPEC("readPixels", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&readPixels_methodinfo), 7, JSPROP_ENUMERATE, nullptr), |
18586 | | JS_FNSPEC("texImage2D", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&texImage2D_methodinfo), 6, JSPROP_ENUMERATE, nullptr), |
18587 | | JS_FNSPEC("texSubImage2D", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&texSubImage2D_methodinfo), 7, JSPROP_ENUMERATE, nullptr), |
18588 | | JS_FNSPEC("uniform1fv", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniform1fv_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18589 | | JS_FNSPEC("uniform2fv", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniform2fv_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18590 | | JS_FNSPEC("uniform3fv", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniform3fv_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18591 | | JS_FNSPEC("uniform4fv", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniform4fv_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18592 | | JS_FNSPEC("uniform1iv", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniform1iv_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18593 | | JS_FNSPEC("uniform2iv", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniform2iv_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18594 | | JS_FNSPEC("uniform3iv", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniform3iv_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18595 | | JS_FNSPEC("uniform4iv", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniform4iv_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18596 | | JS_FNSPEC("uniformMatrix2fv", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniformMatrix2fv_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
18597 | | JS_FNSPEC("uniformMatrix3fv", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniformMatrix3fv_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
18598 | | JS_FNSPEC("uniformMatrix4fv", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniformMatrix4fv_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
18599 | | JS_FS_END, |
18600 | | JS_FNSPEC("commit", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&commit_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
18601 | | JS_FS_END, |
18602 | | JS_FNSPEC("getContextAttributes", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getContextAttributes_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
18603 | | JS_FNSPEC("isContextLost", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&isContextLost_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
18604 | | JS_FNSPEC("getSupportedExtensions", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getSupportedExtensions_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
18605 | | JS_FNSPEC("getExtension", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getExtension_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18606 | | JS_FNSPEC("activeTexture", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&activeTexture_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18607 | | JS_FNSPEC("attachShader", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&attachShader_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18608 | | JS_FNSPEC("bindAttribLocation", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&bindAttribLocation_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
18609 | | JS_FNSPEC("bindBuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&bindBuffer_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18610 | | JS_FNSPEC("bindFramebuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&bindFramebuffer_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18611 | | JS_FNSPEC("bindRenderbuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&bindRenderbuffer_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18612 | | JS_FNSPEC("bindTexture", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&bindTexture_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18613 | | JS_FNSPEC("blendColor", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&blendColor_methodinfo), 4, JSPROP_ENUMERATE, nullptr), |
18614 | | JS_FNSPEC("blendEquation", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&blendEquation_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18615 | | JS_FNSPEC("blendEquationSeparate", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&blendEquationSeparate_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18616 | | JS_FNSPEC("blendFunc", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&blendFunc_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18617 | | JS_FNSPEC("blendFuncSeparate", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&blendFuncSeparate_methodinfo), 4, JSPROP_ENUMERATE, nullptr), |
18618 | | JS_FNSPEC("checkFramebufferStatus", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&checkFramebufferStatus_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18619 | | JS_FNSPEC("clear", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&clear_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18620 | | JS_FNSPEC("clearColor", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&clearColor_methodinfo), 4, JSPROP_ENUMERATE, nullptr), |
18621 | | JS_FNSPEC("clearDepth", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&clearDepth_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18622 | | JS_FNSPEC("clearStencil", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&clearStencil_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18623 | | JS_FNSPEC("colorMask", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&colorMask_methodinfo), 4, JSPROP_ENUMERATE, nullptr), |
18624 | | JS_FNSPEC("compileShader", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&compileShader_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18625 | | JS_FNSPEC("copyTexImage2D", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(©TexImage2D_methodinfo), 8, JSPROP_ENUMERATE, nullptr), |
18626 | | JS_FNSPEC("copyTexSubImage2D", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(©TexSubImage2D_methodinfo), 8, JSPROP_ENUMERATE, nullptr), |
18627 | | JS_FNSPEC("createBuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createBuffer_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
18628 | | JS_FNSPEC("createFramebuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createFramebuffer_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
18629 | | JS_FNSPEC("createProgram", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createProgram_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
18630 | | JS_FNSPEC("createRenderbuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createRenderbuffer_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
18631 | | JS_FNSPEC("createShader", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createShader_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18632 | | JS_FNSPEC("createTexture", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&createTexture_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
18633 | | JS_FNSPEC("cullFace", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&cullFace_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18634 | | JS_FNSPEC("deleteBuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&deleteBuffer_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18635 | | JS_FNSPEC("deleteFramebuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&deleteFramebuffer_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18636 | | JS_FNSPEC("deleteProgram", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&deleteProgram_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18637 | | JS_FNSPEC("deleteRenderbuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&deleteRenderbuffer_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18638 | | JS_FNSPEC("deleteShader", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&deleteShader_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18639 | | JS_FNSPEC("deleteTexture", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&deleteTexture_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18640 | | JS_FNSPEC("depthFunc", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&depthFunc_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18641 | | JS_FNSPEC("depthMask", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&depthMask_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18642 | | JS_FNSPEC("depthRange", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&depthRange_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18643 | | JS_FNSPEC("detachShader", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&detachShader_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18644 | | JS_FNSPEC("disable", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&disable_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18645 | | JS_FNSPEC("disableVertexAttribArray", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&disableVertexAttribArray_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18646 | | JS_FNSPEC("drawArrays", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&drawArrays_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
18647 | | JS_FNSPEC("drawElements", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&drawElements_methodinfo), 4, JSPROP_ENUMERATE, nullptr), |
18648 | | JS_FNSPEC("enable", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&enable_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18649 | | JS_FNSPEC("enableVertexAttribArray", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&enableVertexAttribArray_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18650 | | JS_FNSPEC("finish", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&finish_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
18651 | | JS_FNSPEC("flush", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&flush_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
18652 | | JS_FNSPEC("framebufferRenderbuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&framebufferRenderbuffer_methodinfo), 4, JSPROP_ENUMERATE, nullptr), |
18653 | | JS_FNSPEC("framebufferTexture2D", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&framebufferTexture2D_methodinfo), 5, JSPROP_ENUMERATE, nullptr), |
18654 | | JS_FNSPEC("frontFace", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&frontFace_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18655 | | JS_FNSPEC("generateMipmap", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&generateMipmap_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18656 | | JS_FNSPEC("getActiveAttrib", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getActiveAttrib_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18657 | | JS_FNSPEC("getActiveUniform", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getActiveUniform_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18658 | | JS_FNSPEC("getAttachedShaders", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getAttachedShaders_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18659 | | JS_FNSPEC("getAttribLocation", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getAttribLocation_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18660 | | JS_FNSPEC("getBufferParameter", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getBufferParameter_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18661 | | JS_FNSPEC("getParameter", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getParameter_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18662 | | JS_FNSPEC("getError", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getError_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
18663 | | JS_FNSPEC("getFramebufferAttachmentParameter", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getFramebufferAttachmentParameter_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
18664 | | JS_FNSPEC("getProgramParameter", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getProgramParameter_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18665 | | JS_FNSPEC("getProgramInfoLog", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getProgramInfoLog_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18666 | | JS_FNSPEC("getRenderbufferParameter", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getRenderbufferParameter_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18667 | | JS_FNSPEC("getShaderParameter", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getShaderParameter_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18668 | | JS_FNSPEC("getShaderPrecisionFormat", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getShaderPrecisionFormat_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18669 | | JS_FNSPEC("getShaderInfoLog", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getShaderInfoLog_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18670 | | JS_FNSPEC("getShaderSource", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getShaderSource_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18671 | | JS_FNSPEC("getTexParameter", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getTexParameter_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18672 | | JS_FNSPEC("getUniform", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getUniform_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18673 | | JS_FNSPEC("getUniformLocation", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getUniformLocation_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18674 | | JS_FNSPEC("getVertexAttrib", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getVertexAttrib_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18675 | | JS_FNSPEC("getVertexAttribOffset", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getVertexAttribOffset_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18676 | | JS_FNSPEC("hint", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&hint_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18677 | | JS_FNSPEC("isBuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&isBuffer_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18678 | | JS_FNSPEC("isEnabled", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&isEnabled_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18679 | | JS_FNSPEC("isFramebuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&isFramebuffer_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18680 | | JS_FNSPEC("isProgram", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&isProgram_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18681 | | JS_FNSPEC("isRenderbuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&isRenderbuffer_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18682 | | JS_FNSPEC("isShader", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&isShader_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18683 | | JS_FNSPEC("isTexture", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&isTexture_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18684 | | JS_FNSPEC("lineWidth", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&lineWidth_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18685 | | JS_FNSPEC("linkProgram", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&linkProgram_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18686 | | JS_FNSPEC("pixelStorei", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&pixelStorei_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18687 | | JS_FNSPEC("polygonOffset", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&polygonOffset_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18688 | | JS_FNSPEC("renderbufferStorage", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&renderbufferStorage_methodinfo), 4, JSPROP_ENUMERATE, nullptr), |
18689 | | JS_FNSPEC("sampleCoverage", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&sampleCoverage_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18690 | | JS_FNSPEC("scissor", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&scissor_methodinfo), 4, JSPROP_ENUMERATE, nullptr), |
18691 | | JS_FNSPEC("shaderSource", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&shaderSource_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18692 | | JS_FNSPEC("stencilFunc", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&stencilFunc_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
18693 | | JS_FNSPEC("stencilFuncSeparate", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&stencilFuncSeparate_methodinfo), 4, JSPROP_ENUMERATE, nullptr), |
18694 | | JS_FNSPEC("stencilMask", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&stencilMask_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18695 | | JS_FNSPEC("stencilMaskSeparate", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&stencilMaskSeparate_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18696 | | JS_FNSPEC("stencilOp", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&stencilOp_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
18697 | | JS_FNSPEC("stencilOpSeparate", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&stencilOpSeparate_methodinfo), 4, JSPROP_ENUMERATE, nullptr), |
18698 | | JS_FNSPEC("texParameterf", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&texParameterf_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
18699 | | JS_FNSPEC("texParameteri", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&texParameteri_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
18700 | | JS_FNSPEC("uniform1f", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniform1f_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18701 | | JS_FNSPEC("uniform2f", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniform2f_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
18702 | | JS_FNSPEC("uniform3f", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniform3f_methodinfo), 4, JSPROP_ENUMERATE, nullptr), |
18703 | | JS_FNSPEC("uniform4f", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniform4f_methodinfo), 5, JSPROP_ENUMERATE, nullptr), |
18704 | | JS_FNSPEC("uniform1i", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniform1i_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18705 | | JS_FNSPEC("uniform2i", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniform2i_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
18706 | | JS_FNSPEC("uniform3i", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniform3i_methodinfo), 4, JSPROP_ENUMERATE, nullptr), |
18707 | | JS_FNSPEC("uniform4i", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&uniform4i_methodinfo), 5, JSPROP_ENUMERATE, nullptr), |
18708 | | JS_FNSPEC("useProgram", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&useProgram_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18709 | | JS_FNSPEC("validateProgram", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&validateProgram_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
18710 | | JS_FNSPEC("vertexAttrib1f", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&vertexAttrib1f_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18711 | | JS_FNSPEC("vertexAttrib1fv", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&vertexAttrib1fv_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18712 | | JS_FNSPEC("vertexAttrib2f", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&vertexAttrib2f_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
18713 | | JS_FNSPEC("vertexAttrib2fv", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&vertexAttrib2fv_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18714 | | JS_FNSPEC("vertexAttrib3f", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&vertexAttrib3f_methodinfo), 4, JSPROP_ENUMERATE, nullptr), |
18715 | | JS_FNSPEC("vertexAttrib3fv", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&vertexAttrib3fv_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18716 | | JS_FNSPEC("vertexAttrib4f", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&vertexAttrib4f_methodinfo), 5, JSPROP_ENUMERATE, nullptr), |
18717 | | JS_FNSPEC("vertexAttrib4fv", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&vertexAttrib4fv_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
18718 | | JS_FNSPEC("vertexAttribPointer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&vertexAttribPointer_methodinfo), 6, JSPROP_ENUMERATE, nullptr), |
18719 | | JS_FNSPEC("viewport", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&viewport_methodinfo), 4, JSPROP_ENUMERATE, nullptr), |
18720 | | JS_FS_END |
18721 | | }; |
18722 | | #if defined(__clang__) |
18723 | | #pragma clang diagnostic pop |
18724 | | #endif |
18725 | | |
18726 | | // Can't be const because the pref-enabled boolean needs to be writable |
18727 | | static PrefableDisablers sMethods_disablers19 = { |
18728 | | true, false, 0, &mozilla::dom::DOMPrefs::gfx_offscreencanvas_enabled |
18729 | | }; |
18730 | | |
18731 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
18732 | | { nullptr, &sMethods_specs[0] }, |
18733 | | { &sMethods_disablers19, &sMethods_specs[19] }, |
18734 | | { nullptr, &sMethods_specs[21] }, |
18735 | | { nullptr, nullptr } |
18736 | | }; |
18737 | | |
18738 | | static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
18739 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
18740 | | static_assert(118 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
18741 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
18742 | | |
18743 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
18744 | | #if defined(__clang__) |
18745 | | #pragma clang diagnostic push |
18746 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
18747 | | #endif |
18748 | | static const JSPropertySpec sAttributes_specs[] = { |
18749 | | { "canvas", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &canvas_getterinfo, nullptr, nullptr }, |
18750 | | { "drawingBufferWidth", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &drawingBufferWidth_getterinfo, nullptr, nullptr }, |
18751 | | { "drawingBufferHeight", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &drawingBufferHeight_getterinfo, nullptr, nullptr }, |
18752 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
18753 | | }; |
18754 | | #if defined(__clang__) |
18755 | | #pragma clang diagnostic pop |
18756 | | #endif |
18757 | | |
18758 | | |
18759 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
18760 | | { nullptr, &sAttributes_specs[0] }, |
18761 | | { nullptr, nullptr } |
18762 | | }; |
18763 | | |
18764 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
18765 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
18766 | | static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
18767 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
18768 | | |
18769 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
18770 | | #if defined(__clang__) |
18771 | | #pragma clang diagnostic push |
18772 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
18773 | | #endif |
18774 | | static const ConstantSpec sConstants_specs[] = { |
18775 | | { "DEPTH_BUFFER_BIT", JS::NumberValue(256U) }, |
18776 | | { "STENCIL_BUFFER_BIT", JS::NumberValue(1024U) }, |
18777 | | { "COLOR_BUFFER_BIT", JS::NumberValue(16384U) }, |
18778 | | { "POINTS", JS::NumberValue(0U) }, |
18779 | | { "LINES", JS::NumberValue(1U) }, |
18780 | | { "LINE_LOOP", JS::NumberValue(2U) }, |
18781 | | { "LINE_STRIP", JS::NumberValue(3U) }, |
18782 | | { "TRIANGLES", JS::NumberValue(4U) }, |
18783 | | { "TRIANGLE_STRIP", JS::NumberValue(5U) }, |
18784 | | { "TRIANGLE_FAN", JS::NumberValue(6U) }, |
18785 | | { "ZERO", JS::NumberValue(0U) }, |
18786 | | { "ONE", JS::NumberValue(1U) }, |
18787 | | { "SRC_COLOR", JS::NumberValue(768U) }, |
18788 | | { "ONE_MINUS_SRC_COLOR", JS::NumberValue(769U) }, |
18789 | | { "SRC_ALPHA", JS::NumberValue(770U) }, |
18790 | | { "ONE_MINUS_SRC_ALPHA", JS::NumberValue(771U) }, |
18791 | | { "DST_ALPHA", JS::NumberValue(772U) }, |
18792 | | { "ONE_MINUS_DST_ALPHA", JS::NumberValue(773U) }, |
18793 | | { "DST_COLOR", JS::NumberValue(774U) }, |
18794 | | { "ONE_MINUS_DST_COLOR", JS::NumberValue(775U) }, |
18795 | | { "SRC_ALPHA_SATURATE", JS::NumberValue(776U) }, |
18796 | | { "FUNC_ADD", JS::NumberValue(32774U) }, |
18797 | | { "BLEND_EQUATION", JS::NumberValue(32777U) }, |
18798 | | { "BLEND_EQUATION_RGB", JS::NumberValue(32777U) }, |
18799 | | { "BLEND_EQUATION_ALPHA", JS::NumberValue(34877U) }, |
18800 | | { "FUNC_SUBTRACT", JS::NumberValue(32778U) }, |
18801 | | { "FUNC_REVERSE_SUBTRACT", JS::NumberValue(32779U) }, |
18802 | | { "BLEND_DST_RGB", JS::NumberValue(32968U) }, |
18803 | | { "BLEND_SRC_RGB", JS::NumberValue(32969U) }, |
18804 | | { "BLEND_DST_ALPHA", JS::NumberValue(32970U) }, |
18805 | | { "BLEND_SRC_ALPHA", JS::NumberValue(32971U) }, |
18806 | | { "CONSTANT_COLOR", JS::NumberValue(32769U) }, |
18807 | | { "ONE_MINUS_CONSTANT_COLOR", JS::NumberValue(32770U) }, |
18808 | | { "CONSTANT_ALPHA", JS::NumberValue(32771U) }, |
18809 | | { "ONE_MINUS_CONSTANT_ALPHA", JS::NumberValue(32772U) }, |
18810 | | { "BLEND_COLOR", JS::NumberValue(32773U) }, |
18811 | | { "ARRAY_BUFFER", JS::NumberValue(34962U) }, |
18812 | | { "ELEMENT_ARRAY_BUFFER", JS::NumberValue(34963U) }, |
18813 | | { "ARRAY_BUFFER_BINDING", JS::NumberValue(34964U) }, |
18814 | | { "ELEMENT_ARRAY_BUFFER_BINDING", JS::NumberValue(34965U) }, |
18815 | | { "STREAM_DRAW", JS::NumberValue(35040U) }, |
18816 | | { "STATIC_DRAW", JS::NumberValue(35044U) }, |
18817 | | { "DYNAMIC_DRAW", JS::NumberValue(35048U) }, |
18818 | | { "BUFFER_SIZE", JS::NumberValue(34660U) }, |
18819 | | { "BUFFER_USAGE", JS::NumberValue(34661U) }, |
18820 | | { "CURRENT_VERTEX_ATTRIB", JS::NumberValue(34342U) }, |
18821 | | { "FRONT", JS::NumberValue(1028U) }, |
18822 | | { "BACK", JS::NumberValue(1029U) }, |
18823 | | { "FRONT_AND_BACK", JS::NumberValue(1032U) }, |
18824 | | { "CULL_FACE", JS::NumberValue(2884U) }, |
18825 | | { "BLEND", JS::NumberValue(3042U) }, |
18826 | | { "DITHER", JS::NumberValue(3024U) }, |
18827 | | { "STENCIL_TEST", JS::NumberValue(2960U) }, |
18828 | | { "DEPTH_TEST", JS::NumberValue(2929U) }, |
18829 | | { "SCISSOR_TEST", JS::NumberValue(3089U) }, |
18830 | | { "POLYGON_OFFSET_FILL", JS::NumberValue(32823U) }, |
18831 | | { "SAMPLE_ALPHA_TO_COVERAGE", JS::NumberValue(32926U) }, |
18832 | | { "SAMPLE_COVERAGE", JS::NumberValue(32928U) }, |
18833 | | { "NO_ERROR", JS::NumberValue(0U) }, |
18834 | | { "INVALID_ENUM", JS::NumberValue(1280U) }, |
18835 | | { "INVALID_VALUE", JS::NumberValue(1281U) }, |
18836 | | { "INVALID_OPERATION", JS::NumberValue(1282U) }, |
18837 | | { "OUT_OF_MEMORY", JS::NumberValue(1285U) }, |
18838 | | { "CW", JS::NumberValue(2304U) }, |
18839 | | { "CCW", JS::NumberValue(2305U) }, |
18840 | | { "LINE_WIDTH", JS::NumberValue(2849U) }, |
18841 | | { "ALIASED_POINT_SIZE_RANGE", JS::NumberValue(33901U) }, |
18842 | | { "ALIASED_LINE_WIDTH_RANGE", JS::NumberValue(33902U) }, |
18843 | | { "CULL_FACE_MODE", JS::NumberValue(2885U) }, |
18844 | | { "FRONT_FACE", JS::NumberValue(2886U) }, |
18845 | | { "DEPTH_RANGE", JS::NumberValue(2928U) }, |
18846 | | { "DEPTH_WRITEMASK", JS::NumberValue(2930U) }, |
18847 | | { "DEPTH_CLEAR_VALUE", JS::NumberValue(2931U) }, |
18848 | | { "DEPTH_FUNC", JS::NumberValue(2932U) }, |
18849 | | { "STENCIL_CLEAR_VALUE", JS::NumberValue(2961U) }, |
18850 | | { "STENCIL_FUNC", JS::NumberValue(2962U) }, |
18851 | | { "STENCIL_FAIL", JS::NumberValue(2964U) }, |
18852 | | { "STENCIL_PASS_DEPTH_FAIL", JS::NumberValue(2965U) }, |
18853 | | { "STENCIL_PASS_DEPTH_PASS", JS::NumberValue(2966U) }, |
18854 | | { "STENCIL_REF", JS::NumberValue(2967U) }, |
18855 | | { "STENCIL_VALUE_MASK", JS::NumberValue(2963U) }, |
18856 | | { "STENCIL_WRITEMASK", JS::NumberValue(2968U) }, |
18857 | | { "STENCIL_BACK_FUNC", JS::NumberValue(34816U) }, |
18858 | | { "STENCIL_BACK_FAIL", JS::NumberValue(34817U) }, |
18859 | | { "STENCIL_BACK_PASS_DEPTH_FAIL", JS::NumberValue(34818U) }, |
18860 | | { "STENCIL_BACK_PASS_DEPTH_PASS", JS::NumberValue(34819U) }, |
18861 | | { "STENCIL_BACK_REF", JS::NumberValue(36003U) }, |
18862 | | { "STENCIL_BACK_VALUE_MASK", JS::NumberValue(36004U) }, |
18863 | | { "STENCIL_BACK_WRITEMASK", JS::NumberValue(36005U) }, |
18864 | | { "VIEWPORT", JS::NumberValue(2978U) }, |
18865 | | { "SCISSOR_BOX", JS::NumberValue(3088U) }, |
18866 | | { "COLOR_CLEAR_VALUE", JS::NumberValue(3106U) }, |
18867 | | { "COLOR_WRITEMASK", JS::NumberValue(3107U) }, |
18868 | | { "UNPACK_ALIGNMENT", JS::NumberValue(3317U) }, |
18869 | | { "PACK_ALIGNMENT", JS::NumberValue(3333U) }, |
18870 | | { "MAX_TEXTURE_SIZE", JS::NumberValue(3379U) }, |
18871 | | { "MAX_VIEWPORT_DIMS", JS::NumberValue(3386U) }, |
18872 | | { "SUBPIXEL_BITS", JS::NumberValue(3408U) }, |
18873 | | { "RED_BITS", JS::NumberValue(3410U) }, |
18874 | | { "GREEN_BITS", JS::NumberValue(3411U) }, |
18875 | | { "BLUE_BITS", JS::NumberValue(3412U) }, |
18876 | | { "ALPHA_BITS", JS::NumberValue(3413U) }, |
18877 | | { "DEPTH_BITS", JS::NumberValue(3414U) }, |
18878 | | { "STENCIL_BITS", JS::NumberValue(3415U) }, |
18879 | | { "POLYGON_OFFSET_UNITS", JS::NumberValue(10752U) }, |
18880 | | { "POLYGON_OFFSET_FACTOR", JS::NumberValue(32824U) }, |
18881 | | { "TEXTURE_BINDING_2D", JS::NumberValue(32873U) }, |
18882 | | { "SAMPLE_BUFFERS", JS::NumberValue(32936U) }, |
18883 | | { "SAMPLES", JS::NumberValue(32937U) }, |
18884 | | { "SAMPLE_COVERAGE_VALUE", JS::NumberValue(32938U) }, |
18885 | | { "SAMPLE_COVERAGE_INVERT", JS::NumberValue(32939U) }, |
18886 | | { "COMPRESSED_TEXTURE_FORMATS", JS::NumberValue(34467U) }, |
18887 | | { "DONT_CARE", JS::NumberValue(4352U) }, |
18888 | | { "FASTEST", JS::NumberValue(4353U) }, |
18889 | | { "NICEST", JS::NumberValue(4354U) }, |
18890 | | { "GENERATE_MIPMAP_HINT", JS::NumberValue(33170U) }, |
18891 | | { "BYTE", JS::NumberValue(5120U) }, |
18892 | | { "UNSIGNED_BYTE", JS::NumberValue(5121U) }, |
18893 | | { "SHORT", JS::NumberValue(5122U) }, |
18894 | | { "UNSIGNED_SHORT", JS::NumberValue(5123U) }, |
18895 | | { "INT", JS::NumberValue(5124U) }, |
18896 | | { "UNSIGNED_INT", JS::NumberValue(5125U) }, |
18897 | | { "FLOAT", JS::NumberValue(5126U) }, |
18898 | | { "DEPTH_COMPONENT", JS::NumberValue(6402U) }, |
18899 | | { "ALPHA", JS::NumberValue(6406U) }, |
18900 | | { "RGB", JS::NumberValue(6407U) }, |
18901 | | { "RGBA", JS::NumberValue(6408U) }, |
18902 | | { "LUMINANCE", JS::NumberValue(6409U) }, |
18903 | | { "LUMINANCE_ALPHA", JS::NumberValue(6410U) }, |
18904 | | { "UNSIGNED_SHORT_4_4_4_4", JS::NumberValue(32819U) }, |
18905 | | { "UNSIGNED_SHORT_5_5_5_1", JS::NumberValue(32820U) }, |
18906 | | { "UNSIGNED_SHORT_5_6_5", JS::NumberValue(33635U) }, |
18907 | | { "FRAGMENT_SHADER", JS::NumberValue(35632U) }, |
18908 | | { "VERTEX_SHADER", JS::NumberValue(35633U) }, |
18909 | | { "MAX_VERTEX_ATTRIBS", JS::NumberValue(34921U) }, |
18910 | | { "MAX_VERTEX_UNIFORM_VECTORS", JS::NumberValue(36347U) }, |
18911 | | { "MAX_VARYING_VECTORS", JS::NumberValue(36348U) }, |
18912 | | { "MAX_COMBINED_TEXTURE_IMAGE_UNITS", JS::NumberValue(35661U) }, |
18913 | | { "MAX_VERTEX_TEXTURE_IMAGE_UNITS", JS::NumberValue(35660U) }, |
18914 | | { "MAX_TEXTURE_IMAGE_UNITS", JS::NumberValue(34930U) }, |
18915 | | { "MAX_FRAGMENT_UNIFORM_VECTORS", JS::NumberValue(36349U) }, |
18916 | | { "SHADER_TYPE", JS::NumberValue(35663U) }, |
18917 | | { "DELETE_STATUS", JS::NumberValue(35712U) }, |
18918 | | { "LINK_STATUS", JS::NumberValue(35714U) }, |
18919 | | { "VALIDATE_STATUS", JS::NumberValue(35715U) }, |
18920 | | { "ATTACHED_SHADERS", JS::NumberValue(35717U) }, |
18921 | | { "ACTIVE_UNIFORMS", JS::NumberValue(35718U) }, |
18922 | | { "ACTIVE_ATTRIBUTES", JS::NumberValue(35721U) }, |
18923 | | { "SHADING_LANGUAGE_VERSION", JS::NumberValue(35724U) }, |
18924 | | { "CURRENT_PROGRAM", JS::NumberValue(35725U) }, |
18925 | | { "NEVER", JS::NumberValue(512U) }, |
18926 | | { "LESS", JS::NumberValue(513U) }, |
18927 | | { "EQUAL", JS::NumberValue(514U) }, |
18928 | | { "LEQUAL", JS::NumberValue(515U) }, |
18929 | | { "GREATER", JS::NumberValue(516U) }, |
18930 | | { "NOTEQUAL", JS::NumberValue(517U) }, |
18931 | | { "GEQUAL", JS::NumberValue(518U) }, |
18932 | | { "ALWAYS", JS::NumberValue(519U) }, |
18933 | | { "KEEP", JS::NumberValue(7680U) }, |
18934 | | { "REPLACE", JS::NumberValue(7681U) }, |
18935 | | { "INCR", JS::NumberValue(7682U) }, |
18936 | | { "DECR", JS::NumberValue(7683U) }, |
18937 | | { "INVERT", JS::NumberValue(5386U) }, |
18938 | | { "INCR_WRAP", JS::NumberValue(34055U) }, |
18939 | | { "DECR_WRAP", JS::NumberValue(34056U) }, |
18940 | | { "VENDOR", JS::NumberValue(7936U) }, |
18941 | | { "RENDERER", JS::NumberValue(7937U) }, |
18942 | | { "VERSION", JS::NumberValue(7938U) }, |
18943 | | { "NEAREST", JS::NumberValue(9728U) }, |
18944 | | { "LINEAR", JS::NumberValue(9729U) }, |
18945 | | { "NEAREST_MIPMAP_NEAREST", JS::NumberValue(9984U) }, |
18946 | | { "LINEAR_MIPMAP_NEAREST", JS::NumberValue(9985U) }, |
18947 | | { "NEAREST_MIPMAP_LINEAR", JS::NumberValue(9986U) }, |
18948 | | { "LINEAR_MIPMAP_LINEAR", JS::NumberValue(9987U) }, |
18949 | | { "TEXTURE_MAG_FILTER", JS::NumberValue(10240U) }, |
18950 | | { "TEXTURE_MIN_FILTER", JS::NumberValue(10241U) }, |
18951 | | { "TEXTURE_WRAP_S", JS::NumberValue(10242U) }, |
18952 | | { "TEXTURE_WRAP_T", JS::NumberValue(10243U) }, |
18953 | | { "TEXTURE_2D", JS::NumberValue(3553U) }, |
18954 | | { "TEXTURE", JS::NumberValue(5890U) }, |
18955 | | { "TEXTURE_CUBE_MAP", JS::NumberValue(34067U) }, |
18956 | | { "TEXTURE_BINDING_CUBE_MAP", JS::NumberValue(34068U) }, |
18957 | | { "TEXTURE_CUBE_MAP_POSITIVE_X", JS::NumberValue(34069U) }, |
18958 | | { "TEXTURE_CUBE_MAP_NEGATIVE_X", JS::NumberValue(34070U) }, |
18959 | | { "TEXTURE_CUBE_MAP_POSITIVE_Y", JS::NumberValue(34071U) }, |
18960 | | { "TEXTURE_CUBE_MAP_NEGATIVE_Y", JS::NumberValue(34072U) }, |
18961 | | { "TEXTURE_CUBE_MAP_POSITIVE_Z", JS::NumberValue(34073U) }, |
18962 | | { "TEXTURE_CUBE_MAP_NEGATIVE_Z", JS::NumberValue(34074U) }, |
18963 | | { "MAX_CUBE_MAP_TEXTURE_SIZE", JS::NumberValue(34076U) }, |
18964 | | { "TEXTURE0", JS::NumberValue(33984U) }, |
18965 | | { "TEXTURE1", JS::NumberValue(33985U) }, |
18966 | | { "TEXTURE2", JS::NumberValue(33986U) }, |
18967 | | { "TEXTURE3", JS::NumberValue(33987U) }, |
18968 | | { "TEXTURE4", JS::NumberValue(33988U) }, |
18969 | | { "TEXTURE5", JS::NumberValue(33989U) }, |
18970 | | { "TEXTURE6", JS::NumberValue(33990U) }, |
18971 | | { "TEXTURE7", JS::NumberValue(33991U) }, |
18972 | | { "TEXTURE8", JS::NumberValue(33992U) }, |
18973 | | { "TEXTURE9", JS::NumberValue(33993U) }, |
18974 | | { "TEXTURE10", JS::NumberValue(33994U) }, |
18975 | | { "TEXTURE11", JS::NumberValue(33995U) }, |
18976 | | { "TEXTURE12", JS::NumberValue(33996U) }, |
18977 | | { "TEXTURE13", JS::NumberValue(33997U) }, |
18978 | | { "TEXTURE14", JS::NumberValue(33998U) }, |
18979 | | { "TEXTURE15", JS::NumberValue(33999U) }, |
18980 | | { "TEXTURE16", JS::NumberValue(34000U) }, |
18981 | | { "TEXTURE17", JS::NumberValue(34001U) }, |
18982 | | { "TEXTURE18", JS::NumberValue(34002U) }, |
18983 | | { "TEXTURE19", JS::NumberValue(34003U) }, |
18984 | | { "TEXTURE20", JS::NumberValue(34004U) }, |
18985 | | { "TEXTURE21", JS::NumberValue(34005U) }, |
18986 | | { "TEXTURE22", JS::NumberValue(34006U) }, |
18987 | | { "TEXTURE23", JS::NumberValue(34007U) }, |
18988 | | { "TEXTURE24", JS::NumberValue(34008U) }, |
18989 | | { "TEXTURE25", JS::NumberValue(34009U) }, |
18990 | | { "TEXTURE26", JS::NumberValue(34010U) }, |
18991 | | { "TEXTURE27", JS::NumberValue(34011U) }, |
18992 | | { "TEXTURE28", JS::NumberValue(34012U) }, |
18993 | | { "TEXTURE29", JS::NumberValue(34013U) }, |
18994 | | { "TEXTURE30", JS::NumberValue(34014U) }, |
18995 | | { "TEXTURE31", JS::NumberValue(34015U) }, |
18996 | | { "ACTIVE_TEXTURE", JS::NumberValue(34016U) }, |
18997 | | { "REPEAT", JS::NumberValue(10497U) }, |
18998 | | { "CLAMP_TO_EDGE", JS::NumberValue(33071U) }, |
18999 | | { "MIRRORED_REPEAT", JS::NumberValue(33648U) }, |
19000 | | { "FLOAT_VEC2", JS::NumberValue(35664U) }, |
19001 | | { "FLOAT_VEC3", JS::NumberValue(35665U) }, |
19002 | | { "FLOAT_VEC4", JS::NumberValue(35666U) }, |
19003 | | { "INT_VEC2", JS::NumberValue(35667U) }, |
19004 | | { "INT_VEC3", JS::NumberValue(35668U) }, |
19005 | | { "INT_VEC4", JS::NumberValue(35669U) }, |
19006 | | { "BOOL", JS::NumberValue(35670U) }, |
19007 | | { "BOOL_VEC2", JS::NumberValue(35671U) }, |
19008 | | { "BOOL_VEC3", JS::NumberValue(35672U) }, |
19009 | | { "BOOL_VEC4", JS::NumberValue(35673U) }, |
19010 | | { "FLOAT_MAT2", JS::NumberValue(35674U) }, |
19011 | | { "FLOAT_MAT3", JS::NumberValue(35675U) }, |
19012 | | { "FLOAT_MAT4", JS::NumberValue(35676U) }, |
19013 | | { "SAMPLER_2D", JS::NumberValue(35678U) }, |
19014 | | { "SAMPLER_CUBE", JS::NumberValue(35680U) }, |
19015 | | { "VERTEX_ATTRIB_ARRAY_ENABLED", JS::NumberValue(34338U) }, |
19016 | | { "VERTEX_ATTRIB_ARRAY_SIZE", JS::NumberValue(34339U) }, |
19017 | | { "VERTEX_ATTRIB_ARRAY_STRIDE", JS::NumberValue(34340U) }, |
19018 | | { "VERTEX_ATTRIB_ARRAY_TYPE", JS::NumberValue(34341U) }, |
19019 | | { "VERTEX_ATTRIB_ARRAY_NORMALIZED", JS::NumberValue(34922U) }, |
19020 | | { "VERTEX_ATTRIB_ARRAY_POINTER", JS::NumberValue(34373U) }, |
19021 | | { "VERTEX_ATTRIB_ARRAY_BUFFER_BINDING", JS::NumberValue(34975U) }, |
19022 | | { "IMPLEMENTATION_COLOR_READ_TYPE", JS::NumberValue(35738U) }, |
19023 | | { "IMPLEMENTATION_COLOR_READ_FORMAT", JS::NumberValue(35739U) }, |
19024 | | { "COMPILE_STATUS", JS::NumberValue(35713U) }, |
19025 | | { "LOW_FLOAT", JS::NumberValue(36336U) }, |
19026 | | { "MEDIUM_FLOAT", JS::NumberValue(36337U) }, |
19027 | | { "HIGH_FLOAT", JS::NumberValue(36338U) }, |
19028 | | { "LOW_INT", JS::NumberValue(36339U) }, |
19029 | | { "MEDIUM_INT", JS::NumberValue(36340U) }, |
19030 | | { "HIGH_INT", JS::NumberValue(36341U) }, |
19031 | | { "FRAMEBUFFER", JS::NumberValue(36160U) }, |
19032 | | { "RENDERBUFFER", JS::NumberValue(36161U) }, |
19033 | | { "RGBA4", JS::NumberValue(32854U) }, |
19034 | | { "RGB5_A1", JS::NumberValue(32855U) }, |
19035 | | { "RGB565", JS::NumberValue(36194U) }, |
19036 | | { "DEPTH_COMPONENT16", JS::NumberValue(33189U) }, |
19037 | | { "STENCIL_INDEX8", JS::NumberValue(36168U) }, |
19038 | | { "DEPTH_STENCIL", JS::NumberValue(34041U) }, |
19039 | | { "RENDERBUFFER_WIDTH", JS::NumberValue(36162U) }, |
19040 | | { "RENDERBUFFER_HEIGHT", JS::NumberValue(36163U) }, |
19041 | | { "RENDERBUFFER_INTERNAL_FORMAT", JS::NumberValue(36164U) }, |
19042 | | { "RENDERBUFFER_RED_SIZE", JS::NumberValue(36176U) }, |
19043 | | { "RENDERBUFFER_GREEN_SIZE", JS::NumberValue(36177U) }, |
19044 | | { "RENDERBUFFER_BLUE_SIZE", JS::NumberValue(36178U) }, |
19045 | | { "RENDERBUFFER_ALPHA_SIZE", JS::NumberValue(36179U) }, |
19046 | | { "RENDERBUFFER_DEPTH_SIZE", JS::NumberValue(36180U) }, |
19047 | | { "RENDERBUFFER_STENCIL_SIZE", JS::NumberValue(36181U) }, |
19048 | | { "FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE", JS::NumberValue(36048U) }, |
19049 | | { "FRAMEBUFFER_ATTACHMENT_OBJECT_NAME", JS::NumberValue(36049U) }, |
19050 | | { "FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL", JS::NumberValue(36050U) }, |
19051 | | { "FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE", JS::NumberValue(36051U) }, |
19052 | | { "COLOR_ATTACHMENT0", JS::NumberValue(36064U) }, |
19053 | | { "DEPTH_ATTACHMENT", JS::NumberValue(36096U) }, |
19054 | | { "STENCIL_ATTACHMENT", JS::NumberValue(36128U) }, |
19055 | | { "DEPTH_STENCIL_ATTACHMENT", JS::NumberValue(33306U) }, |
19056 | | { "NONE", JS::NumberValue(0U) }, |
19057 | | { "FRAMEBUFFER_COMPLETE", JS::NumberValue(36053U) }, |
19058 | | { "FRAMEBUFFER_INCOMPLETE_ATTACHMENT", JS::NumberValue(36054U) }, |
19059 | | { "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT", JS::NumberValue(36055U) }, |
19060 | | { "FRAMEBUFFER_INCOMPLETE_DIMENSIONS", JS::NumberValue(36057U) }, |
19061 | | { "FRAMEBUFFER_UNSUPPORTED", JS::NumberValue(36061U) }, |
19062 | | { "FRAMEBUFFER_BINDING", JS::NumberValue(36006U) }, |
19063 | | { "RENDERBUFFER_BINDING", JS::NumberValue(36007U) }, |
19064 | | { "MAX_RENDERBUFFER_SIZE", JS::NumberValue(34024U) }, |
19065 | | { "INVALID_FRAMEBUFFER_OPERATION", JS::NumberValue(1286U) }, |
19066 | | { "UNPACK_FLIP_Y_WEBGL", JS::NumberValue(37440U) }, |
19067 | | { "UNPACK_PREMULTIPLY_ALPHA_WEBGL", JS::NumberValue(37441U) }, |
19068 | | { "CONTEXT_LOST_WEBGL", JS::NumberValue(37442U) }, |
19069 | | { "UNPACK_COLORSPACE_CONVERSION_WEBGL", JS::NumberValue(37443U) }, |
19070 | | { "BROWSER_DEFAULT_WEBGL", JS::NumberValue(37444U) }, |
19071 | | { 0, JS::UndefinedValue() } |
19072 | | }; |
19073 | | #if defined(__clang__) |
19074 | | #pragma clang diagnostic pop |
19075 | | #endif |
19076 | | |
19077 | | |
19078 | | static const Prefable<const ConstantSpec> sConstants[] = { |
19079 | | { nullptr, &sConstants_specs[0] }, |
19080 | | { nullptr, nullptr } |
19081 | | }; |
19082 | | |
19083 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
19084 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
19085 | | static_assert(296 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
19086 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
19087 | | |
19088 | | |
19089 | | static uint16_t sNativeProperties_sortedPropertyIndices[436]; |
19090 | | static PropertyInfo sNativeProperties_propertyInfos[436]; |
19091 | | |
19092 | | static const NativePropertiesN<3> sNativeProperties = { |
19093 | | false, 0, |
19094 | | false, 0, |
19095 | | true, 0 /* sMethods */, |
19096 | | true, 1 /* sAttributes */, |
19097 | | false, 0, |
19098 | | false, 0, |
19099 | | true, 2 /* sConstants */, |
19100 | | -1, |
19101 | | 436, |
19102 | | sNativeProperties_sortedPropertyIndices, |
19103 | | { |
19104 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
19105 | | { sAttributes, &sNativeProperties_propertyInfos[137] }, |
19106 | | { sConstants, &sNativeProperties_propertyInfos[140] } |
19107 | | } |
19108 | | }; |
19109 | | static_assert(436 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
19110 | | "We have a property info count that is oversized"); |
19111 | | |
19112 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
19113 | | { |
19114 | | "Function", |
19115 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
19116 | | &sBoringInterfaceObjectClassClassOps, |
19117 | | JS_NULL_CLASS_SPEC, |
19118 | | JS_NULL_CLASS_EXT, |
19119 | | &sInterfaceObjectClassObjectOps |
19120 | | }, |
19121 | | eInterface, |
19122 | | true, |
19123 | | prototypes::id::WebGLRenderingContext, |
19124 | | PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth, |
19125 | | sNativePropertyHooks, |
19126 | | "function WebGLRenderingContext() {\n [native code]\n}", |
19127 | | JS::GetRealmFunctionPrototype |
19128 | | }; |
19129 | | |
19130 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
19131 | | { |
19132 | | "WebGLRenderingContextPrototype", |
19133 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
19134 | | JS_NULL_CLASS_OPS, |
19135 | | JS_NULL_CLASS_SPEC, |
19136 | | JS_NULL_CLASS_EXT, |
19137 | | JS_NULL_OBJECT_OPS |
19138 | | }, |
19139 | | eInterfacePrototype, |
19140 | | false, |
19141 | | prototypes::id::WebGLRenderingContext, |
19142 | | PrototypeTraits<prototypes::id::WebGLRenderingContext>::Depth, |
19143 | | sNativePropertyHooks, |
19144 | | "[object WebGLRenderingContextPrototype]", |
19145 | | JS::GetRealmObjectPrototype |
19146 | | }; |
19147 | | |
19148 | | bool |
19149 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
19150 | 0 | { |
19151 | 0 | return mozilla::dom::OffscreenCanvas::PrefEnabledOnWorkerThread(aCx, aObj); |
19152 | 0 | } |
19153 | | |
19154 | | static const js::ClassOps sClassOps = { |
19155 | | _addProperty, /* addProperty */ |
19156 | | nullptr, /* delProperty */ |
19157 | | nullptr, /* enumerate */ |
19158 | | nullptr, /* newEnumerate */ |
19159 | | nullptr, /* resolve */ |
19160 | | nullptr, /* mayResolve */ |
19161 | | _finalize, /* finalize */ |
19162 | | nullptr, /* call */ |
19163 | | nullptr, /* hasInstance */ |
19164 | | nullptr, /* construct */ |
19165 | | nullptr, /* trace */ |
19166 | | }; |
19167 | | |
19168 | | static const js::ClassExtension sClassExtension = { |
19169 | | nullptr, /* weakmapKeyDelegateOp */ |
19170 | | _objectMoved /* objectMovedOp */ |
19171 | | }; |
19172 | | |
19173 | | static const DOMJSClass sClass = { |
19174 | | { "WebGLRenderingContext", |
19175 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
19176 | | &sClassOps, |
19177 | | JS_NULL_CLASS_SPEC, |
19178 | | &sClassExtension, |
19179 | | JS_NULL_OBJECT_OPS |
19180 | | }, |
19181 | | { prototypes::id::WebGLRenderingContext, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
19182 | | IsBaseOf<nsISupports, mozilla::WebGLContext >::value, |
19183 | | sNativePropertyHooks, |
19184 | | FindAssociatedGlobalForNative<mozilla::WebGLContext>::Get, |
19185 | | GetProtoObjectHandle, |
19186 | | GetCCParticipant<mozilla::WebGLContext>::Get() |
19187 | | }; |
19188 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
19189 | | "Must have the right minimal number of reserved slots."); |
19190 | | static_assert(1 >= 1, |
19191 | | "Must have enough reserved slots."); |
19192 | | |
19193 | | const JSClass* |
19194 | | GetJSClass() |
19195 | 0 | { |
19196 | 0 | return sClass.ToJSClass(); |
19197 | 0 | } |
19198 | | |
19199 | | bool |
19200 | | Wrap(JSContext* aCx, mozilla::WebGLContext* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
19201 | 0 | { |
19202 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLContext>::value, |
19203 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
19204 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLContext*>(aObject) == |
19205 | 0 | reinterpret_cast<mozilla::WebGLContext*>(aObject), |
19206 | 0 | "Multiple inheritance for mozilla::WebGLContext is broken."); |
19207 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
19208 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
19209 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
19210 | 0 | "You should probably not be using Wrap() directly; use " |
19211 | 0 | "GetOrCreateDOMReflector instead"); |
19212 | 0 |
|
19213 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
19214 | 0 | "nsISupports must be on our primary inheritance chain"); |
19215 | 0 |
|
19216 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
19217 | 0 | if (!global) { |
19218 | 0 | return false; |
19219 | 0 | } |
19220 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
19221 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
19222 | 0 |
|
19223 | 0 | // That might have ended up wrapping us already, due to the wonders |
19224 | 0 | // of XBL. Check for that, and bail out as needed. |
19225 | 0 | aReflector.set(aCache->GetWrapper()); |
19226 | 0 | if (aReflector) { |
19227 | | #ifdef DEBUG |
19228 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
19229 | | #endif // DEBUG |
19230 | | return true; |
19231 | 0 | } |
19232 | 0 |
|
19233 | 0 | JSAutoRealm ar(aCx, global); |
19234 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
19235 | 0 | if (!canonicalProto) { |
19236 | 0 | return false; |
19237 | 0 | } |
19238 | 0 | JS::Rooted<JSObject*> proto(aCx); |
19239 | 0 | if (aGivenProto) { |
19240 | 0 | proto = aGivenProto; |
19241 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
19242 | 0 | // coming in, we changed compartments to that of "parent" so may need |
19243 | 0 | // to wrap the proto here. |
19244 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
19245 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
19246 | 0 | return false; |
19247 | 0 | } |
19248 | 0 | } |
19249 | 0 | } else { |
19250 | 0 | proto = canonicalProto; |
19251 | 0 | } |
19252 | 0 |
|
19253 | 0 | BindingJSObjectCreator<mozilla::WebGLContext> creator(aCx); |
19254 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
19255 | 0 | if (!aReflector) { |
19256 | 0 | return false; |
19257 | 0 | } |
19258 | 0 | |
19259 | 0 | aCache->SetWrapper(aReflector); |
19260 | 0 | creator.InitializationSucceeded(); |
19261 | 0 |
|
19262 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
19263 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
19264 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
19265 | 0 | // otherwise we won't be able to properly recreate it later, since |
19266 | 0 | // we won't know what proto to use. Note that we don't check |
19267 | 0 | // aGivenProto here, since it's entirely possible (and even |
19268 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
19269 | 0 | // same as canonicalProto. |
19270 | 0 | if (proto != canonicalProto) { |
19271 | 0 | PreserveWrapper(aObject); |
19272 | 0 | } |
19273 | 0 |
|
19274 | 0 | return true; |
19275 | 0 | } |
19276 | | |
19277 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
19278 | | nullptr, |
19279 | | nullptr, |
19280 | | nullptr, |
19281 | | { sNativeProperties.Upcast(), nullptr }, |
19282 | | prototypes::id::WebGLRenderingContext, |
19283 | | constructors::id::WebGLRenderingContext, |
19284 | | nullptr, |
19285 | | &DefaultXrayExpandoObjectClass |
19286 | | } }; |
19287 | | |
19288 | | void |
19289 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
19290 | 0 | { |
19291 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
19292 | 0 | if (!parentProto) { |
19293 | 0 | return; |
19294 | 0 | } |
19295 | 0 | |
19296 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
19297 | 0 | if (!constructorProto) { |
19298 | 0 | return; |
19299 | 0 | } |
19300 | 0 | |
19301 | 0 | static bool sIdsInited = false; |
19302 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
19303 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
19304 | 0 | return; |
19305 | 0 | } |
19306 | 0 | sIdsInited = true; |
19307 | 0 | } |
19308 | 0 |
|
19309 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WebGLRenderingContext); |
19310 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WebGLRenderingContext); |
19311 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
19312 | 0 | &sPrototypeClass.mBase, protoCache, |
19313 | 0 | nullptr, |
19314 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
19315 | 0 | interfaceCache, |
19316 | 0 | sNativeProperties.Upcast(), |
19317 | 0 | nullptr, |
19318 | 0 | "WebGLRenderingContext", aDefineOnGlobal, |
19319 | 0 | nullptr, |
19320 | 0 | false); |
19321 | 0 | } |
19322 | | |
19323 | | JSObject* |
19324 | | GetConstructorObject(JSContext* aCx) |
19325 | 0 | { |
19326 | 0 | return GetConstructorObjectHandle(aCx); |
19327 | 0 | } |
19328 | | |
19329 | | } // namespace WebGLRenderingContext_Binding |
19330 | | |
19331 | | |
19332 | | |
19333 | | namespace WebGLShader_Binding { |
19334 | | |
19335 | | static bool |
19336 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
19337 | 0 | { |
19338 | 0 | mozilla::WebGLShader* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLShader>(obj); |
19339 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
19340 | 0 | // obviously can't preserve if we're not initialized. |
19341 | 0 | if (self && self->GetWrapperPreserveColor()) { |
19342 | 0 | PreserveWrapper(self); |
19343 | 0 | } |
19344 | 0 | return true; |
19345 | 0 | } |
19346 | | |
19347 | | static void |
19348 | | _finalize(js::FreeOp* fop, JSObject* obj) |
19349 | 0 | { |
19350 | 0 | mozilla::WebGLShader* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLShader>(obj); |
19351 | 0 | if (self) { |
19352 | 0 | ClearWrapper(self, self, obj); |
19353 | 0 | AddForDeferredFinalization<mozilla::WebGLShader>(self); |
19354 | 0 | } |
19355 | 0 | } |
19356 | | |
19357 | | static size_t |
19358 | | _objectMoved(JSObject* obj, JSObject* old) |
19359 | 0 | { |
19360 | 0 | mozilla::WebGLShader* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLShader>(obj); |
19361 | 0 | if (self) { |
19362 | 0 | UpdateWrapper(self, self, obj, old); |
19363 | 0 | } |
19364 | 0 |
|
19365 | 0 | return 0; |
19366 | 0 | } |
19367 | | |
19368 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
19369 | | { |
19370 | | "Function", |
19371 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
19372 | | &sBoringInterfaceObjectClassClassOps, |
19373 | | JS_NULL_CLASS_SPEC, |
19374 | | JS_NULL_CLASS_EXT, |
19375 | | &sInterfaceObjectClassObjectOps |
19376 | | }, |
19377 | | eInterface, |
19378 | | true, |
19379 | | prototypes::id::WebGLShader, |
19380 | | PrototypeTraits<prototypes::id::WebGLShader>::Depth, |
19381 | | sNativePropertyHooks, |
19382 | | "function WebGLShader() {\n [native code]\n}", |
19383 | | JS::GetRealmFunctionPrototype |
19384 | | }; |
19385 | | |
19386 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
19387 | | { |
19388 | | "WebGLShaderPrototype", |
19389 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
19390 | | JS_NULL_CLASS_OPS, |
19391 | | JS_NULL_CLASS_SPEC, |
19392 | | JS_NULL_CLASS_EXT, |
19393 | | JS_NULL_OBJECT_OPS |
19394 | | }, |
19395 | | eInterfacePrototype, |
19396 | | false, |
19397 | | prototypes::id::WebGLShader, |
19398 | | PrototypeTraits<prototypes::id::WebGLShader>::Depth, |
19399 | | sNativePropertyHooks, |
19400 | | "[object WebGLShaderPrototype]", |
19401 | | JS::GetRealmObjectPrototype |
19402 | | }; |
19403 | | |
19404 | | bool |
19405 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
19406 | 0 | { |
19407 | 0 | return mozilla::dom::OffscreenCanvas::PrefEnabledOnWorkerThread(aCx, aObj); |
19408 | 0 | } |
19409 | | |
19410 | | static const js::ClassOps sClassOps = { |
19411 | | _addProperty, /* addProperty */ |
19412 | | nullptr, /* delProperty */ |
19413 | | nullptr, /* enumerate */ |
19414 | | nullptr, /* newEnumerate */ |
19415 | | nullptr, /* resolve */ |
19416 | | nullptr, /* mayResolve */ |
19417 | | _finalize, /* finalize */ |
19418 | | nullptr, /* call */ |
19419 | | nullptr, /* hasInstance */ |
19420 | | nullptr, /* construct */ |
19421 | | nullptr, /* trace */ |
19422 | | }; |
19423 | | |
19424 | | static const js::ClassExtension sClassExtension = { |
19425 | | nullptr, /* weakmapKeyDelegateOp */ |
19426 | | _objectMoved /* objectMovedOp */ |
19427 | | }; |
19428 | | |
19429 | | static const DOMJSClass sClass = { |
19430 | | { "WebGLShader", |
19431 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
19432 | | &sClassOps, |
19433 | | JS_NULL_CLASS_SPEC, |
19434 | | &sClassExtension, |
19435 | | JS_NULL_OBJECT_OPS |
19436 | | }, |
19437 | | { prototypes::id::WebGLShader, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
19438 | | IsBaseOf<nsISupports, mozilla::WebGLShader >::value, |
19439 | | sNativePropertyHooks, |
19440 | | FindAssociatedGlobalForNative<mozilla::WebGLShader>::Get, |
19441 | | GetProtoObjectHandle, |
19442 | | GetCCParticipant<mozilla::WebGLShader>::Get() |
19443 | | }; |
19444 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
19445 | | "Must have the right minimal number of reserved slots."); |
19446 | | static_assert(1 >= 1, |
19447 | | "Must have enough reserved slots."); |
19448 | | |
19449 | | const JSClass* |
19450 | | GetJSClass() |
19451 | 0 | { |
19452 | 0 | return sClass.ToJSClass(); |
19453 | 0 | } |
19454 | | |
19455 | | bool |
19456 | | Wrap(JSContext* aCx, mozilla::WebGLShader* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
19457 | 0 | { |
19458 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLShader>::value, |
19459 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
19460 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLShader*>(aObject) == |
19461 | 0 | reinterpret_cast<mozilla::WebGLShader*>(aObject), |
19462 | 0 | "Multiple inheritance for mozilla::WebGLShader is broken."); |
19463 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
19464 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
19465 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
19466 | 0 | "You should probably not be using Wrap() directly; use " |
19467 | 0 | "GetOrCreateDOMReflector instead"); |
19468 | 0 |
|
19469 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
19470 | 0 | "nsISupports must be on our primary inheritance chain"); |
19471 | 0 |
|
19472 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
19473 | 0 | if (!global) { |
19474 | 0 | return false; |
19475 | 0 | } |
19476 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
19477 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
19478 | 0 |
|
19479 | 0 | // That might have ended up wrapping us already, due to the wonders |
19480 | 0 | // of XBL. Check for that, and bail out as needed. |
19481 | 0 | aReflector.set(aCache->GetWrapper()); |
19482 | 0 | if (aReflector) { |
19483 | | #ifdef DEBUG |
19484 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
19485 | | #endif // DEBUG |
19486 | | return true; |
19487 | 0 | } |
19488 | 0 |
|
19489 | 0 | JSAutoRealm ar(aCx, global); |
19490 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
19491 | 0 | if (!canonicalProto) { |
19492 | 0 | return false; |
19493 | 0 | } |
19494 | 0 | JS::Rooted<JSObject*> proto(aCx); |
19495 | 0 | if (aGivenProto) { |
19496 | 0 | proto = aGivenProto; |
19497 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
19498 | 0 | // coming in, we changed compartments to that of "parent" so may need |
19499 | 0 | // to wrap the proto here. |
19500 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
19501 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
19502 | 0 | return false; |
19503 | 0 | } |
19504 | 0 | } |
19505 | 0 | } else { |
19506 | 0 | proto = canonicalProto; |
19507 | 0 | } |
19508 | 0 |
|
19509 | 0 | BindingJSObjectCreator<mozilla::WebGLShader> creator(aCx); |
19510 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
19511 | 0 | if (!aReflector) { |
19512 | 0 | return false; |
19513 | 0 | } |
19514 | 0 | |
19515 | 0 | aCache->SetWrapper(aReflector); |
19516 | 0 | creator.InitializationSucceeded(); |
19517 | 0 |
|
19518 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
19519 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
19520 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
19521 | 0 | // otherwise we won't be able to properly recreate it later, since |
19522 | 0 | // we won't know what proto to use. Note that we don't check |
19523 | 0 | // aGivenProto here, since it's entirely possible (and even |
19524 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
19525 | 0 | // same as canonicalProto. |
19526 | 0 | if (proto != canonicalProto) { |
19527 | 0 | PreserveWrapper(aObject); |
19528 | 0 | } |
19529 | 0 |
|
19530 | 0 | return true; |
19531 | 0 | } |
19532 | | |
19533 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
19534 | | nullptr, |
19535 | | nullptr, |
19536 | | nullptr, |
19537 | | { nullptr, nullptr }, |
19538 | | prototypes::id::WebGLShader, |
19539 | | constructors::id::WebGLShader, |
19540 | | nullptr, |
19541 | | &DefaultXrayExpandoObjectClass |
19542 | | } }; |
19543 | | |
19544 | | void |
19545 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
19546 | 0 | { |
19547 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
19548 | 0 | if (!parentProto) { |
19549 | 0 | return; |
19550 | 0 | } |
19551 | 0 | |
19552 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
19553 | 0 | if (!constructorProto) { |
19554 | 0 | return; |
19555 | 0 | } |
19556 | 0 | |
19557 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WebGLShader); |
19558 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WebGLShader); |
19559 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
19560 | 0 | &sPrototypeClass.mBase, protoCache, |
19561 | 0 | nullptr, |
19562 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
19563 | 0 | interfaceCache, |
19564 | 0 | nullptr, |
19565 | 0 | nullptr, |
19566 | 0 | "WebGLShader", aDefineOnGlobal, |
19567 | 0 | nullptr, |
19568 | 0 | false); |
19569 | 0 | } |
19570 | | |
19571 | | JSObject* |
19572 | | GetConstructorObject(JSContext* aCx) |
19573 | 0 | { |
19574 | 0 | return GetConstructorObjectHandle(aCx); |
19575 | 0 | } |
19576 | | |
19577 | | } // namespace WebGLShader_Binding |
19578 | | |
19579 | | |
19580 | | |
19581 | | namespace WebGLShaderPrecisionFormat_Binding { |
19582 | | |
19583 | | MOZ_CAN_RUN_SCRIPT static bool |
19584 | | get_rangeMin(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLShaderPrecisionFormat* self, JSJitGetterCallArgs args) |
19585 | 0 | { |
19586 | 0 | AUTO_PROFILER_LABEL_FAST("get WebGLShaderPrecisionFormat.rangeMin", DOM, cx); |
19587 | 0 |
|
19588 | 0 | int32_t result(self->RangeMin()); |
19589 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
19590 | 0 | args.rval().setInt32(int32_t(result)); |
19591 | 0 | return true; |
19592 | 0 | } |
19593 | | |
19594 | | static const JSJitInfo rangeMin_getterinfo = { |
19595 | | { (JSJitGetterOp)get_rangeMin }, |
19596 | | { prototypes::id::WebGLShaderPrecisionFormat }, |
19597 | | { PrototypeTraits<prototypes::id::WebGLShaderPrecisionFormat>::Depth }, |
19598 | | JSJitInfo::Getter, |
19599 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
19600 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
19601 | | true, /* isInfallible. False in setters. */ |
19602 | | false, /* isMovable. Not relevant for setters. */ |
19603 | | false, /* isEliminatable. Not relevant for setters. */ |
19604 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
19605 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
19606 | | false, /* isTypedMethod. Only relevant for methods. */ |
19607 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
19608 | | }; |
19609 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
19610 | | static_assert(0 < 1, "There is no slot for us"); |
19611 | | |
19612 | | MOZ_CAN_RUN_SCRIPT static bool |
19613 | | get_rangeMax(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLShaderPrecisionFormat* self, JSJitGetterCallArgs args) |
19614 | 0 | { |
19615 | 0 | AUTO_PROFILER_LABEL_FAST("get WebGLShaderPrecisionFormat.rangeMax", DOM, cx); |
19616 | 0 |
|
19617 | 0 | int32_t result(self->RangeMax()); |
19618 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
19619 | 0 | args.rval().setInt32(int32_t(result)); |
19620 | 0 | return true; |
19621 | 0 | } |
19622 | | |
19623 | | static const JSJitInfo rangeMax_getterinfo = { |
19624 | | { (JSJitGetterOp)get_rangeMax }, |
19625 | | { prototypes::id::WebGLShaderPrecisionFormat }, |
19626 | | { PrototypeTraits<prototypes::id::WebGLShaderPrecisionFormat>::Depth }, |
19627 | | JSJitInfo::Getter, |
19628 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
19629 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
19630 | | true, /* isInfallible. False in setters. */ |
19631 | | false, /* isMovable. Not relevant for setters. */ |
19632 | | false, /* isEliminatable. Not relevant for setters. */ |
19633 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
19634 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
19635 | | false, /* isTypedMethod. Only relevant for methods. */ |
19636 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
19637 | | }; |
19638 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
19639 | | static_assert(0 < 1, "There is no slot for us"); |
19640 | | |
19641 | | MOZ_CAN_RUN_SCRIPT static bool |
19642 | | get_precision(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::WebGLShaderPrecisionFormat* self, JSJitGetterCallArgs args) |
19643 | 0 | { |
19644 | 0 | AUTO_PROFILER_LABEL_FAST("get WebGLShaderPrecisionFormat.precision", DOM, cx); |
19645 | 0 |
|
19646 | 0 | int32_t result(self->Precision()); |
19647 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
19648 | 0 | args.rval().setInt32(int32_t(result)); |
19649 | 0 | return true; |
19650 | 0 | } |
19651 | | |
19652 | | static const JSJitInfo precision_getterinfo = { |
19653 | | { (JSJitGetterOp)get_precision }, |
19654 | | { prototypes::id::WebGLShaderPrecisionFormat }, |
19655 | | { PrototypeTraits<prototypes::id::WebGLShaderPrecisionFormat>::Depth }, |
19656 | | JSJitInfo::Getter, |
19657 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
19658 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
19659 | | true, /* isInfallible. False in setters. */ |
19660 | | false, /* isMovable. Not relevant for setters. */ |
19661 | | false, /* isEliminatable. Not relevant for setters. */ |
19662 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
19663 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
19664 | | false, /* isTypedMethod. Only relevant for methods. */ |
19665 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
19666 | | }; |
19667 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
19668 | | static_assert(0 < 1, "There is no slot for us"); |
19669 | | |
19670 | | static void |
19671 | | _finalize(js::FreeOp* fop, JSObject* obj) |
19672 | 0 | { |
19673 | 0 | mozilla::WebGLShaderPrecisionFormat* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLShaderPrecisionFormat>(obj); |
19674 | 0 | if (self) { |
19675 | 0 | AddForDeferredFinalization<mozilla::WebGLShaderPrecisionFormat>(self); |
19676 | 0 | } |
19677 | 0 | } |
19678 | | |
19679 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
19680 | | #if defined(__clang__) |
19681 | | #pragma clang diagnostic push |
19682 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
19683 | | #endif |
19684 | | static const JSPropertySpec sAttributes_specs[] = { |
19685 | | { "rangeMin", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &rangeMin_getterinfo, nullptr, nullptr }, |
19686 | | { "rangeMax", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &rangeMax_getterinfo, nullptr, nullptr }, |
19687 | | { "precision", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &precision_getterinfo, nullptr, nullptr }, |
19688 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
19689 | | }; |
19690 | | #if defined(__clang__) |
19691 | | #pragma clang diagnostic pop |
19692 | | #endif |
19693 | | |
19694 | | |
19695 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
19696 | | { nullptr, &sAttributes_specs[0] }, |
19697 | | { nullptr, nullptr } |
19698 | | }; |
19699 | | |
19700 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
19701 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
19702 | | static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
19703 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
19704 | | |
19705 | | |
19706 | | static uint16_t sNativeProperties_sortedPropertyIndices[3]; |
19707 | | static PropertyInfo sNativeProperties_propertyInfos[3]; |
19708 | | |
19709 | | static const NativePropertiesN<1> sNativeProperties = { |
19710 | | false, 0, |
19711 | | false, 0, |
19712 | | false, 0, |
19713 | | true, 0 /* sAttributes */, |
19714 | | false, 0, |
19715 | | false, 0, |
19716 | | false, 0, |
19717 | | -1, |
19718 | | 3, |
19719 | | sNativeProperties_sortedPropertyIndices, |
19720 | | { |
19721 | | { sAttributes, &sNativeProperties_propertyInfos[0] } |
19722 | | } |
19723 | | }; |
19724 | | static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
19725 | | "We have a property info count that is oversized"); |
19726 | | |
19727 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
19728 | | { |
19729 | | "Function", |
19730 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
19731 | | &sBoringInterfaceObjectClassClassOps, |
19732 | | JS_NULL_CLASS_SPEC, |
19733 | | JS_NULL_CLASS_EXT, |
19734 | | &sInterfaceObjectClassObjectOps |
19735 | | }, |
19736 | | eInterface, |
19737 | | true, |
19738 | | prototypes::id::WebGLShaderPrecisionFormat, |
19739 | | PrototypeTraits<prototypes::id::WebGLShaderPrecisionFormat>::Depth, |
19740 | | sNativePropertyHooks, |
19741 | | "function WebGLShaderPrecisionFormat() {\n [native code]\n}", |
19742 | | JS::GetRealmFunctionPrototype |
19743 | | }; |
19744 | | |
19745 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
19746 | | { |
19747 | | "WebGLShaderPrecisionFormatPrototype", |
19748 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
19749 | | JS_NULL_CLASS_OPS, |
19750 | | JS_NULL_CLASS_SPEC, |
19751 | | JS_NULL_CLASS_EXT, |
19752 | | JS_NULL_OBJECT_OPS |
19753 | | }, |
19754 | | eInterfacePrototype, |
19755 | | false, |
19756 | | prototypes::id::WebGLShaderPrecisionFormat, |
19757 | | PrototypeTraits<prototypes::id::WebGLShaderPrecisionFormat>::Depth, |
19758 | | sNativePropertyHooks, |
19759 | | "[object WebGLShaderPrecisionFormatPrototype]", |
19760 | | JS::GetRealmObjectPrototype |
19761 | | }; |
19762 | | |
19763 | | bool |
19764 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
19765 | 0 | { |
19766 | 0 | return mozilla::dom::OffscreenCanvas::PrefEnabledOnWorkerThread(aCx, aObj); |
19767 | 0 | } |
19768 | | |
19769 | | static const js::ClassOps sClassOps = { |
19770 | | nullptr, /* addProperty */ |
19771 | | nullptr, /* delProperty */ |
19772 | | nullptr, /* enumerate */ |
19773 | | nullptr, /* newEnumerate */ |
19774 | | nullptr, /* resolve */ |
19775 | | nullptr, /* mayResolve */ |
19776 | | _finalize, /* finalize */ |
19777 | | nullptr, /* call */ |
19778 | | nullptr, /* hasInstance */ |
19779 | | nullptr, /* construct */ |
19780 | | nullptr, /* trace */ |
19781 | | }; |
19782 | | |
19783 | | static const js::ClassExtension sClassExtension = { |
19784 | | nullptr, /* weakmapKeyDelegateOp */ |
19785 | | nullptr /* objectMovedOp */ |
19786 | | }; |
19787 | | |
19788 | | static const DOMJSClass sClass = { |
19789 | | { "WebGLShaderPrecisionFormat", |
19790 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
19791 | | &sClassOps, |
19792 | | JS_NULL_CLASS_SPEC, |
19793 | | &sClassExtension, |
19794 | | JS_NULL_OBJECT_OPS |
19795 | | }, |
19796 | | { prototypes::id::WebGLShaderPrecisionFormat, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
19797 | | IsBaseOf<nsISupports, mozilla::WebGLShaderPrecisionFormat >::value, |
19798 | | sNativePropertyHooks, |
19799 | | FindAssociatedGlobalForNative<mozilla::WebGLShaderPrecisionFormat>::Get, |
19800 | | GetProtoObjectHandle, |
19801 | | GetCCParticipant<mozilla::WebGLShaderPrecisionFormat>::Get() |
19802 | | }; |
19803 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
19804 | | "Must have the right minimal number of reserved slots."); |
19805 | | static_assert(1 >= 1, |
19806 | | "Must have enough reserved slots."); |
19807 | | |
19808 | | const JSClass* |
19809 | | GetJSClass() |
19810 | 0 | { |
19811 | 0 | return sClass.ToJSClass(); |
19812 | 0 | } |
19813 | | |
19814 | | bool |
19815 | | Wrap(JSContext* aCx, mozilla::WebGLShaderPrecisionFormat* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
19816 | 0 | { |
19817 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLShaderPrecisionFormat*>(aObject) == |
19818 | 0 | reinterpret_cast<mozilla::WebGLShaderPrecisionFormat*>(aObject), |
19819 | 0 | "Multiple inheritance for mozilla::WebGLShaderPrecisionFormat is broken."); |
19820 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
19821 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
19822 | 0 |
|
19823 | 0 | JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx)); |
19824 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
19825 | 0 | if (!canonicalProto) { |
19826 | 0 | return false; |
19827 | 0 | } |
19828 | 0 | JS::Rooted<JSObject*> proto(aCx); |
19829 | 0 | if (aGivenProto) { |
19830 | 0 | proto = aGivenProto; |
19831 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
19832 | 0 | // coming in, we changed compartments to that of "parent" so may need |
19833 | 0 | // to wrap the proto here. |
19834 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
19835 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
19836 | 0 | return false; |
19837 | 0 | } |
19838 | 0 | } |
19839 | 0 | } else { |
19840 | 0 | proto = canonicalProto; |
19841 | 0 | } |
19842 | 0 |
|
19843 | 0 | BindingJSObjectCreator<mozilla::WebGLShaderPrecisionFormat> creator(aCx); |
19844 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
19845 | 0 | if (!aReflector) { |
19846 | 0 | return false; |
19847 | 0 | } |
19848 | 0 | |
19849 | 0 | |
19850 | 0 | |
19851 | 0 | creator.InitializationSucceeded(); |
19852 | 0 | return true; |
19853 | 0 | } |
19854 | | |
19855 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
19856 | | nullptr, |
19857 | | nullptr, |
19858 | | nullptr, |
19859 | | { sNativeProperties.Upcast(), nullptr }, |
19860 | | prototypes::id::WebGLShaderPrecisionFormat, |
19861 | | constructors::id::WebGLShaderPrecisionFormat, |
19862 | | nullptr, |
19863 | | &DefaultXrayExpandoObjectClass |
19864 | | } }; |
19865 | | |
19866 | | void |
19867 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
19868 | 0 | { |
19869 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
19870 | 0 | if (!parentProto) { |
19871 | 0 | return; |
19872 | 0 | } |
19873 | 0 | |
19874 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
19875 | 0 | if (!constructorProto) { |
19876 | 0 | return; |
19877 | 0 | } |
19878 | 0 | |
19879 | 0 | static bool sIdsInited = false; |
19880 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
19881 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
19882 | 0 | return; |
19883 | 0 | } |
19884 | 0 | sIdsInited = true; |
19885 | 0 | } |
19886 | 0 |
|
19887 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WebGLShaderPrecisionFormat); |
19888 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WebGLShaderPrecisionFormat); |
19889 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
19890 | 0 | &sPrototypeClass.mBase, protoCache, |
19891 | 0 | nullptr, |
19892 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
19893 | 0 | interfaceCache, |
19894 | 0 | sNativeProperties.Upcast(), |
19895 | 0 | nullptr, |
19896 | 0 | "WebGLShaderPrecisionFormat", aDefineOnGlobal, |
19897 | 0 | nullptr, |
19898 | 0 | false); |
19899 | 0 | } |
19900 | | |
19901 | | JSObject* |
19902 | | GetConstructorObject(JSContext* aCx) |
19903 | 0 | { |
19904 | 0 | return GetConstructorObjectHandle(aCx); |
19905 | 0 | } |
19906 | | |
19907 | | } // namespace WebGLShaderPrecisionFormat_Binding |
19908 | | |
19909 | | |
19910 | | |
19911 | | namespace WebGLTexture_Binding { |
19912 | | |
19913 | | static bool |
19914 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
19915 | 0 | { |
19916 | 0 | mozilla::WebGLTexture* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLTexture>(obj); |
19917 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
19918 | 0 | // obviously can't preserve if we're not initialized. |
19919 | 0 | if (self && self->GetWrapperPreserveColor()) { |
19920 | 0 | PreserveWrapper(self); |
19921 | 0 | } |
19922 | 0 | return true; |
19923 | 0 | } |
19924 | | |
19925 | | static void |
19926 | | _finalize(js::FreeOp* fop, JSObject* obj) |
19927 | 0 | { |
19928 | 0 | mozilla::WebGLTexture* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLTexture>(obj); |
19929 | 0 | if (self) { |
19930 | 0 | ClearWrapper(self, self, obj); |
19931 | 0 | AddForDeferredFinalization<mozilla::WebGLTexture>(self); |
19932 | 0 | } |
19933 | 0 | } |
19934 | | |
19935 | | static size_t |
19936 | | _objectMoved(JSObject* obj, JSObject* old) |
19937 | 0 | { |
19938 | 0 | mozilla::WebGLTexture* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLTexture>(obj); |
19939 | 0 | if (self) { |
19940 | 0 | UpdateWrapper(self, self, obj, old); |
19941 | 0 | } |
19942 | 0 |
|
19943 | 0 | return 0; |
19944 | 0 | } |
19945 | | |
19946 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
19947 | | { |
19948 | | "Function", |
19949 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
19950 | | &sBoringInterfaceObjectClassClassOps, |
19951 | | JS_NULL_CLASS_SPEC, |
19952 | | JS_NULL_CLASS_EXT, |
19953 | | &sInterfaceObjectClassObjectOps |
19954 | | }, |
19955 | | eInterface, |
19956 | | true, |
19957 | | prototypes::id::WebGLTexture, |
19958 | | PrototypeTraits<prototypes::id::WebGLTexture>::Depth, |
19959 | | sNativePropertyHooks, |
19960 | | "function WebGLTexture() {\n [native code]\n}", |
19961 | | JS::GetRealmFunctionPrototype |
19962 | | }; |
19963 | | |
19964 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
19965 | | { |
19966 | | "WebGLTexturePrototype", |
19967 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
19968 | | JS_NULL_CLASS_OPS, |
19969 | | JS_NULL_CLASS_SPEC, |
19970 | | JS_NULL_CLASS_EXT, |
19971 | | JS_NULL_OBJECT_OPS |
19972 | | }, |
19973 | | eInterfacePrototype, |
19974 | | false, |
19975 | | prototypes::id::WebGLTexture, |
19976 | | PrototypeTraits<prototypes::id::WebGLTexture>::Depth, |
19977 | | sNativePropertyHooks, |
19978 | | "[object WebGLTexturePrototype]", |
19979 | | JS::GetRealmObjectPrototype |
19980 | | }; |
19981 | | |
19982 | | bool |
19983 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
19984 | 0 | { |
19985 | 0 | return mozilla::dom::OffscreenCanvas::PrefEnabledOnWorkerThread(aCx, aObj); |
19986 | 0 | } |
19987 | | |
19988 | | static const js::ClassOps sClassOps = { |
19989 | | _addProperty, /* addProperty */ |
19990 | | nullptr, /* delProperty */ |
19991 | | nullptr, /* enumerate */ |
19992 | | nullptr, /* newEnumerate */ |
19993 | | nullptr, /* resolve */ |
19994 | | nullptr, /* mayResolve */ |
19995 | | _finalize, /* finalize */ |
19996 | | nullptr, /* call */ |
19997 | | nullptr, /* hasInstance */ |
19998 | | nullptr, /* construct */ |
19999 | | nullptr, /* trace */ |
20000 | | }; |
20001 | | |
20002 | | static const js::ClassExtension sClassExtension = { |
20003 | | nullptr, /* weakmapKeyDelegateOp */ |
20004 | | _objectMoved /* objectMovedOp */ |
20005 | | }; |
20006 | | |
20007 | | static const DOMJSClass sClass = { |
20008 | | { "WebGLTexture", |
20009 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
20010 | | &sClassOps, |
20011 | | JS_NULL_CLASS_SPEC, |
20012 | | &sClassExtension, |
20013 | | JS_NULL_OBJECT_OPS |
20014 | | }, |
20015 | | { prototypes::id::WebGLTexture, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
20016 | | IsBaseOf<nsISupports, mozilla::WebGLTexture >::value, |
20017 | | sNativePropertyHooks, |
20018 | | FindAssociatedGlobalForNative<mozilla::WebGLTexture>::Get, |
20019 | | GetProtoObjectHandle, |
20020 | | GetCCParticipant<mozilla::WebGLTexture>::Get() |
20021 | | }; |
20022 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
20023 | | "Must have the right minimal number of reserved slots."); |
20024 | | static_assert(1 >= 1, |
20025 | | "Must have enough reserved slots."); |
20026 | | |
20027 | | const JSClass* |
20028 | | GetJSClass() |
20029 | 0 | { |
20030 | 0 | return sClass.ToJSClass(); |
20031 | 0 | } |
20032 | | |
20033 | | bool |
20034 | | Wrap(JSContext* aCx, mozilla::WebGLTexture* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
20035 | 0 | { |
20036 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLTexture>::value, |
20037 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
20038 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLTexture*>(aObject) == |
20039 | 0 | reinterpret_cast<mozilla::WebGLTexture*>(aObject), |
20040 | 0 | "Multiple inheritance for mozilla::WebGLTexture is broken."); |
20041 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
20042 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
20043 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
20044 | 0 | "You should probably not be using Wrap() directly; use " |
20045 | 0 | "GetOrCreateDOMReflector instead"); |
20046 | 0 |
|
20047 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
20048 | 0 | "nsISupports must be on our primary inheritance chain"); |
20049 | 0 |
|
20050 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
20051 | 0 | if (!global) { |
20052 | 0 | return false; |
20053 | 0 | } |
20054 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
20055 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
20056 | 0 |
|
20057 | 0 | // That might have ended up wrapping us already, due to the wonders |
20058 | 0 | // of XBL. Check for that, and bail out as needed. |
20059 | 0 | aReflector.set(aCache->GetWrapper()); |
20060 | 0 | if (aReflector) { |
20061 | | #ifdef DEBUG |
20062 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
20063 | | #endif // DEBUG |
20064 | | return true; |
20065 | 0 | } |
20066 | 0 |
|
20067 | 0 | JSAutoRealm ar(aCx, global); |
20068 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
20069 | 0 | if (!canonicalProto) { |
20070 | 0 | return false; |
20071 | 0 | } |
20072 | 0 | JS::Rooted<JSObject*> proto(aCx); |
20073 | 0 | if (aGivenProto) { |
20074 | 0 | proto = aGivenProto; |
20075 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
20076 | 0 | // coming in, we changed compartments to that of "parent" so may need |
20077 | 0 | // to wrap the proto here. |
20078 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
20079 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
20080 | 0 | return false; |
20081 | 0 | } |
20082 | 0 | } |
20083 | 0 | } else { |
20084 | 0 | proto = canonicalProto; |
20085 | 0 | } |
20086 | 0 |
|
20087 | 0 | BindingJSObjectCreator<mozilla::WebGLTexture> creator(aCx); |
20088 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
20089 | 0 | if (!aReflector) { |
20090 | 0 | return false; |
20091 | 0 | } |
20092 | 0 | |
20093 | 0 | aCache->SetWrapper(aReflector); |
20094 | 0 | creator.InitializationSucceeded(); |
20095 | 0 |
|
20096 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
20097 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
20098 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
20099 | 0 | // otherwise we won't be able to properly recreate it later, since |
20100 | 0 | // we won't know what proto to use. Note that we don't check |
20101 | 0 | // aGivenProto here, since it's entirely possible (and even |
20102 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
20103 | 0 | // same as canonicalProto. |
20104 | 0 | if (proto != canonicalProto) { |
20105 | 0 | PreserveWrapper(aObject); |
20106 | 0 | } |
20107 | 0 |
|
20108 | 0 | return true; |
20109 | 0 | } |
20110 | | |
20111 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
20112 | | nullptr, |
20113 | | nullptr, |
20114 | | nullptr, |
20115 | | { nullptr, nullptr }, |
20116 | | prototypes::id::WebGLTexture, |
20117 | | constructors::id::WebGLTexture, |
20118 | | nullptr, |
20119 | | &DefaultXrayExpandoObjectClass |
20120 | | } }; |
20121 | | |
20122 | | void |
20123 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
20124 | 0 | { |
20125 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
20126 | 0 | if (!parentProto) { |
20127 | 0 | return; |
20128 | 0 | } |
20129 | 0 | |
20130 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
20131 | 0 | if (!constructorProto) { |
20132 | 0 | return; |
20133 | 0 | } |
20134 | 0 | |
20135 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WebGLTexture); |
20136 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WebGLTexture); |
20137 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
20138 | 0 | &sPrototypeClass.mBase, protoCache, |
20139 | 0 | nullptr, |
20140 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
20141 | 0 | interfaceCache, |
20142 | 0 | nullptr, |
20143 | 0 | nullptr, |
20144 | 0 | "WebGLTexture", aDefineOnGlobal, |
20145 | 0 | nullptr, |
20146 | 0 | false); |
20147 | 0 | } |
20148 | | |
20149 | | JSObject* |
20150 | | GetConstructorObject(JSContext* aCx) |
20151 | 0 | { |
20152 | 0 | return GetConstructorObjectHandle(aCx); |
20153 | 0 | } |
20154 | | |
20155 | | } // namespace WebGLTexture_Binding |
20156 | | |
20157 | | |
20158 | | |
20159 | | namespace WebGLUniformLocation_Binding { |
20160 | | |
20161 | | static bool |
20162 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
20163 | 0 | { |
20164 | 0 | mozilla::WebGLUniformLocation* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLUniformLocation>(obj); |
20165 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
20166 | 0 | // obviously can't preserve if we're not initialized. |
20167 | 0 | if (self && self->GetWrapperPreserveColor()) { |
20168 | 0 | PreserveWrapper(self); |
20169 | 0 | } |
20170 | 0 | return true; |
20171 | 0 | } |
20172 | | |
20173 | | static void |
20174 | | _finalize(js::FreeOp* fop, JSObject* obj) |
20175 | 0 | { |
20176 | 0 | mozilla::WebGLUniformLocation* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLUniformLocation>(obj); |
20177 | 0 | if (self) { |
20178 | 0 | ClearWrapper(self, self, obj); |
20179 | 0 | AddForDeferredFinalization<mozilla::WebGLUniformLocation>(self); |
20180 | 0 | } |
20181 | 0 | } |
20182 | | |
20183 | | static size_t |
20184 | | _objectMoved(JSObject* obj, JSObject* old) |
20185 | 0 | { |
20186 | 0 | mozilla::WebGLUniformLocation* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLUniformLocation>(obj); |
20187 | 0 | if (self) { |
20188 | 0 | UpdateWrapper(self, self, obj, old); |
20189 | 0 | } |
20190 | 0 |
|
20191 | 0 | return 0; |
20192 | 0 | } |
20193 | | |
20194 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
20195 | | { |
20196 | | "Function", |
20197 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
20198 | | &sBoringInterfaceObjectClassClassOps, |
20199 | | JS_NULL_CLASS_SPEC, |
20200 | | JS_NULL_CLASS_EXT, |
20201 | | &sInterfaceObjectClassObjectOps |
20202 | | }, |
20203 | | eInterface, |
20204 | | true, |
20205 | | prototypes::id::WebGLUniformLocation, |
20206 | | PrototypeTraits<prototypes::id::WebGLUniformLocation>::Depth, |
20207 | | sNativePropertyHooks, |
20208 | | "function WebGLUniformLocation() {\n [native code]\n}", |
20209 | | JS::GetRealmFunctionPrototype |
20210 | | }; |
20211 | | |
20212 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
20213 | | { |
20214 | | "WebGLUniformLocationPrototype", |
20215 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
20216 | | JS_NULL_CLASS_OPS, |
20217 | | JS_NULL_CLASS_SPEC, |
20218 | | JS_NULL_CLASS_EXT, |
20219 | | JS_NULL_OBJECT_OPS |
20220 | | }, |
20221 | | eInterfacePrototype, |
20222 | | false, |
20223 | | prototypes::id::WebGLUniformLocation, |
20224 | | PrototypeTraits<prototypes::id::WebGLUniformLocation>::Depth, |
20225 | | sNativePropertyHooks, |
20226 | | "[object WebGLUniformLocationPrototype]", |
20227 | | JS::GetRealmObjectPrototype |
20228 | | }; |
20229 | | |
20230 | | bool |
20231 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
20232 | 0 | { |
20233 | 0 | return mozilla::dom::OffscreenCanvas::PrefEnabledOnWorkerThread(aCx, aObj); |
20234 | 0 | } |
20235 | | |
20236 | | static const js::ClassOps sClassOps = { |
20237 | | _addProperty, /* addProperty */ |
20238 | | nullptr, /* delProperty */ |
20239 | | nullptr, /* enumerate */ |
20240 | | nullptr, /* newEnumerate */ |
20241 | | nullptr, /* resolve */ |
20242 | | nullptr, /* mayResolve */ |
20243 | | _finalize, /* finalize */ |
20244 | | nullptr, /* call */ |
20245 | | nullptr, /* hasInstance */ |
20246 | | nullptr, /* construct */ |
20247 | | nullptr, /* trace */ |
20248 | | }; |
20249 | | |
20250 | | static const js::ClassExtension sClassExtension = { |
20251 | | nullptr, /* weakmapKeyDelegateOp */ |
20252 | | _objectMoved /* objectMovedOp */ |
20253 | | }; |
20254 | | |
20255 | | static const DOMJSClass sClass = { |
20256 | | { "WebGLUniformLocation", |
20257 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
20258 | | &sClassOps, |
20259 | | JS_NULL_CLASS_SPEC, |
20260 | | &sClassExtension, |
20261 | | JS_NULL_OBJECT_OPS |
20262 | | }, |
20263 | | { prototypes::id::WebGLUniformLocation, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
20264 | | IsBaseOf<nsISupports, mozilla::WebGLUniformLocation >::value, |
20265 | | sNativePropertyHooks, |
20266 | | FindAssociatedGlobalForNative<mozilla::WebGLUniformLocation>::Get, |
20267 | | GetProtoObjectHandle, |
20268 | | GetCCParticipant<mozilla::WebGLUniformLocation>::Get() |
20269 | | }; |
20270 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
20271 | | "Must have the right minimal number of reserved slots."); |
20272 | | static_assert(1 >= 1, |
20273 | | "Must have enough reserved slots."); |
20274 | | |
20275 | | const JSClass* |
20276 | | GetJSClass() |
20277 | 0 | { |
20278 | 0 | return sClass.ToJSClass(); |
20279 | 0 | } |
20280 | | |
20281 | | bool |
20282 | | Wrap(JSContext* aCx, mozilla::WebGLUniformLocation* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
20283 | 0 | { |
20284 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLUniformLocation>::value, |
20285 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
20286 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLUniformLocation*>(aObject) == |
20287 | 0 | reinterpret_cast<mozilla::WebGLUniformLocation*>(aObject), |
20288 | 0 | "Multiple inheritance for mozilla::WebGLUniformLocation is broken."); |
20289 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
20290 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
20291 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
20292 | 0 | "You should probably not be using Wrap() directly; use " |
20293 | 0 | "GetOrCreateDOMReflector instead"); |
20294 | 0 |
|
20295 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
20296 | 0 | "nsISupports must be on our primary inheritance chain"); |
20297 | 0 |
|
20298 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
20299 | 0 | if (!global) { |
20300 | 0 | return false; |
20301 | 0 | } |
20302 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
20303 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
20304 | 0 |
|
20305 | 0 | // That might have ended up wrapping us already, due to the wonders |
20306 | 0 | // of XBL. Check for that, and bail out as needed. |
20307 | 0 | aReflector.set(aCache->GetWrapper()); |
20308 | 0 | if (aReflector) { |
20309 | | #ifdef DEBUG |
20310 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
20311 | | #endif // DEBUG |
20312 | | return true; |
20313 | 0 | } |
20314 | 0 |
|
20315 | 0 | JSAutoRealm ar(aCx, global); |
20316 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
20317 | 0 | if (!canonicalProto) { |
20318 | 0 | return false; |
20319 | 0 | } |
20320 | 0 | JS::Rooted<JSObject*> proto(aCx); |
20321 | 0 | if (aGivenProto) { |
20322 | 0 | proto = aGivenProto; |
20323 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
20324 | 0 | // coming in, we changed compartments to that of "parent" so may need |
20325 | 0 | // to wrap the proto here. |
20326 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
20327 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
20328 | 0 | return false; |
20329 | 0 | } |
20330 | 0 | } |
20331 | 0 | } else { |
20332 | 0 | proto = canonicalProto; |
20333 | 0 | } |
20334 | 0 |
|
20335 | 0 | BindingJSObjectCreator<mozilla::WebGLUniformLocation> creator(aCx); |
20336 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
20337 | 0 | if (!aReflector) { |
20338 | 0 | return false; |
20339 | 0 | } |
20340 | 0 | |
20341 | 0 | aCache->SetWrapper(aReflector); |
20342 | 0 | creator.InitializationSucceeded(); |
20343 | 0 |
|
20344 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
20345 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
20346 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
20347 | 0 | // otherwise we won't be able to properly recreate it later, since |
20348 | 0 | // we won't know what proto to use. Note that we don't check |
20349 | 0 | // aGivenProto here, since it's entirely possible (and even |
20350 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
20351 | 0 | // same as canonicalProto. |
20352 | 0 | if (proto != canonicalProto) { |
20353 | 0 | PreserveWrapper(aObject); |
20354 | 0 | } |
20355 | 0 |
|
20356 | 0 | return true; |
20357 | 0 | } |
20358 | | |
20359 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
20360 | | nullptr, |
20361 | | nullptr, |
20362 | | nullptr, |
20363 | | { nullptr, nullptr }, |
20364 | | prototypes::id::WebGLUniformLocation, |
20365 | | constructors::id::WebGLUniformLocation, |
20366 | | nullptr, |
20367 | | &DefaultXrayExpandoObjectClass |
20368 | | } }; |
20369 | | |
20370 | | void |
20371 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
20372 | 0 | { |
20373 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
20374 | 0 | if (!parentProto) { |
20375 | 0 | return; |
20376 | 0 | } |
20377 | 0 | |
20378 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
20379 | 0 | if (!constructorProto) { |
20380 | 0 | return; |
20381 | 0 | } |
20382 | 0 | |
20383 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WebGLUniformLocation); |
20384 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WebGLUniformLocation); |
20385 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
20386 | 0 | &sPrototypeClass.mBase, protoCache, |
20387 | 0 | nullptr, |
20388 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
20389 | 0 | interfaceCache, |
20390 | 0 | nullptr, |
20391 | 0 | nullptr, |
20392 | 0 | "WebGLUniformLocation", aDefineOnGlobal, |
20393 | 0 | nullptr, |
20394 | 0 | false); |
20395 | 0 | } |
20396 | | |
20397 | | JSObject* |
20398 | | GetConstructorObject(JSContext* aCx) |
20399 | 0 | { |
20400 | 0 | return GetConstructorObjectHandle(aCx); |
20401 | 0 | } |
20402 | | |
20403 | | } // namespace WebGLUniformLocation_Binding |
20404 | | |
20405 | | |
20406 | | |
20407 | | namespace WebGLVertexArrayObject_Binding { |
20408 | | |
20409 | | static bool |
20410 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
20411 | 0 | { |
20412 | 0 | mozilla::WebGLVertexArray* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLVertexArray>(obj); |
20413 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
20414 | 0 | // obviously can't preserve if we're not initialized. |
20415 | 0 | if (self && self->GetWrapperPreserveColor()) { |
20416 | 0 | PreserveWrapper(self); |
20417 | 0 | } |
20418 | 0 | return true; |
20419 | 0 | } |
20420 | | |
20421 | | static void |
20422 | | _finalize(js::FreeOp* fop, JSObject* obj) |
20423 | 0 | { |
20424 | 0 | mozilla::WebGLVertexArray* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLVertexArray>(obj); |
20425 | 0 | if (self) { |
20426 | 0 | ClearWrapper(self, self, obj); |
20427 | 0 | AddForDeferredFinalization<mozilla::WebGLVertexArray>(self); |
20428 | 0 | } |
20429 | 0 | } |
20430 | | |
20431 | | static size_t |
20432 | | _objectMoved(JSObject* obj, JSObject* old) |
20433 | 0 | { |
20434 | 0 | mozilla::WebGLVertexArray* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::WebGLVertexArray>(obj); |
20435 | 0 | if (self) { |
20436 | 0 | UpdateWrapper(self, self, obj, old); |
20437 | 0 | } |
20438 | 0 |
|
20439 | 0 | return 0; |
20440 | 0 | } |
20441 | | |
20442 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
20443 | | { |
20444 | | "Function", |
20445 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
20446 | | &sBoringInterfaceObjectClassClassOps, |
20447 | | JS_NULL_CLASS_SPEC, |
20448 | | JS_NULL_CLASS_EXT, |
20449 | | &sInterfaceObjectClassObjectOps |
20450 | | }, |
20451 | | eInterface, |
20452 | | true, |
20453 | | prototypes::id::WebGLVertexArrayObject, |
20454 | | PrototypeTraits<prototypes::id::WebGLVertexArrayObject>::Depth, |
20455 | | sNativePropertyHooks, |
20456 | | "function WebGLVertexArrayObject() {\n [native code]\n}", |
20457 | | JS::GetRealmFunctionPrototype |
20458 | | }; |
20459 | | |
20460 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
20461 | | { |
20462 | | "WebGLVertexArrayObjectPrototype", |
20463 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
20464 | | JS_NULL_CLASS_OPS, |
20465 | | JS_NULL_CLASS_SPEC, |
20466 | | JS_NULL_CLASS_EXT, |
20467 | | JS_NULL_OBJECT_OPS |
20468 | | }, |
20469 | | eInterfacePrototype, |
20470 | | false, |
20471 | | prototypes::id::WebGLVertexArrayObject, |
20472 | | PrototypeTraits<prototypes::id::WebGLVertexArrayObject>::Depth, |
20473 | | sNativePropertyHooks, |
20474 | | "[object WebGLVertexArrayObjectPrototype]", |
20475 | | JS::GetRealmObjectPrototype |
20476 | | }; |
20477 | | |
20478 | | static const js::ClassOps sClassOps = { |
20479 | | _addProperty, /* addProperty */ |
20480 | | nullptr, /* delProperty */ |
20481 | | nullptr, /* enumerate */ |
20482 | | nullptr, /* newEnumerate */ |
20483 | | nullptr, /* resolve */ |
20484 | | nullptr, /* mayResolve */ |
20485 | | _finalize, /* finalize */ |
20486 | | nullptr, /* call */ |
20487 | | nullptr, /* hasInstance */ |
20488 | | nullptr, /* construct */ |
20489 | | nullptr, /* trace */ |
20490 | | }; |
20491 | | |
20492 | | static const js::ClassExtension sClassExtension = { |
20493 | | nullptr, /* weakmapKeyDelegateOp */ |
20494 | | _objectMoved /* objectMovedOp */ |
20495 | | }; |
20496 | | |
20497 | | static const DOMJSClass sClass = { |
20498 | | { "WebGLVertexArrayObject", |
20499 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
20500 | | &sClassOps, |
20501 | | JS_NULL_CLASS_SPEC, |
20502 | | &sClassExtension, |
20503 | | JS_NULL_OBJECT_OPS |
20504 | | }, |
20505 | | { prototypes::id::WebGLVertexArrayObject, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
20506 | | IsBaseOf<nsISupports, mozilla::WebGLVertexArray >::value, |
20507 | | sNativePropertyHooks, |
20508 | | FindAssociatedGlobalForNative<mozilla::WebGLVertexArray>::Get, |
20509 | | GetProtoObjectHandle, |
20510 | | GetCCParticipant<mozilla::WebGLVertexArray>::Get() |
20511 | | }; |
20512 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
20513 | | "Must have the right minimal number of reserved slots."); |
20514 | | static_assert(1 >= 1, |
20515 | | "Must have enough reserved slots."); |
20516 | | |
20517 | | const JSClass* |
20518 | | GetJSClass() |
20519 | 0 | { |
20520 | 0 | return sClass.ToJSClass(); |
20521 | 0 | } |
20522 | | |
20523 | | bool |
20524 | | Wrap(JSContext* aCx, mozilla::WebGLVertexArray* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
20525 | 0 | { |
20526 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::WebGLVertexArray>::value, |
20527 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
20528 | 0 | MOZ_ASSERT(static_cast<mozilla::WebGLVertexArray*>(aObject) == |
20529 | 0 | reinterpret_cast<mozilla::WebGLVertexArray*>(aObject), |
20530 | 0 | "Multiple inheritance for mozilla::WebGLVertexArray is broken."); |
20531 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
20532 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
20533 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
20534 | 0 | "You should probably not be using Wrap() directly; use " |
20535 | 0 | "GetOrCreateDOMReflector instead"); |
20536 | 0 |
|
20537 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
20538 | 0 | "nsISupports must be on our primary inheritance chain"); |
20539 | 0 |
|
20540 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
20541 | 0 | if (!global) { |
20542 | 0 | return false; |
20543 | 0 | } |
20544 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
20545 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
20546 | 0 |
|
20547 | 0 | // That might have ended up wrapping us already, due to the wonders |
20548 | 0 | // of XBL. Check for that, and bail out as needed. |
20549 | 0 | aReflector.set(aCache->GetWrapper()); |
20550 | 0 | if (aReflector) { |
20551 | | #ifdef DEBUG |
20552 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
20553 | | #endif // DEBUG |
20554 | | return true; |
20555 | 0 | } |
20556 | 0 |
|
20557 | 0 | JSAutoRealm ar(aCx, global); |
20558 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
20559 | 0 | if (!canonicalProto) { |
20560 | 0 | return false; |
20561 | 0 | } |
20562 | 0 | JS::Rooted<JSObject*> proto(aCx); |
20563 | 0 | if (aGivenProto) { |
20564 | 0 | proto = aGivenProto; |
20565 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
20566 | 0 | // coming in, we changed compartments to that of "parent" so may need |
20567 | 0 | // to wrap the proto here. |
20568 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
20569 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
20570 | 0 | return false; |
20571 | 0 | } |
20572 | 0 | } |
20573 | 0 | } else { |
20574 | 0 | proto = canonicalProto; |
20575 | 0 | } |
20576 | 0 |
|
20577 | 0 | BindingJSObjectCreator<mozilla::WebGLVertexArray> creator(aCx); |
20578 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
20579 | 0 | if (!aReflector) { |
20580 | 0 | return false; |
20581 | 0 | } |
20582 | 0 | |
20583 | 0 | aCache->SetWrapper(aReflector); |
20584 | 0 | creator.InitializationSucceeded(); |
20585 | 0 |
|
20586 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
20587 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
20588 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
20589 | 0 | // otherwise we won't be able to properly recreate it later, since |
20590 | 0 | // we won't know what proto to use. Note that we don't check |
20591 | 0 | // aGivenProto here, since it's entirely possible (and even |
20592 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
20593 | 0 | // same as canonicalProto. |
20594 | 0 | if (proto != canonicalProto) { |
20595 | 0 | PreserveWrapper(aObject); |
20596 | 0 | } |
20597 | 0 |
|
20598 | 0 | return true; |
20599 | 0 | } |
20600 | | |
20601 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
20602 | | nullptr, |
20603 | | nullptr, |
20604 | | nullptr, |
20605 | | { nullptr, nullptr }, |
20606 | | prototypes::id::WebGLVertexArrayObject, |
20607 | | constructors::id::WebGLVertexArrayObject, |
20608 | | nullptr, |
20609 | | &DefaultXrayExpandoObjectClass |
20610 | | } }; |
20611 | | |
20612 | | void |
20613 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
20614 | 0 | { |
20615 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
20616 | 0 | if (!parentProto) { |
20617 | 0 | return; |
20618 | 0 | } |
20619 | 0 | |
20620 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
20621 | 0 | if (!constructorProto) { |
20622 | 0 | return; |
20623 | 0 | } |
20624 | 0 | |
20625 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WebGLVertexArrayObject); |
20626 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WebGLVertexArrayObject); |
20627 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
20628 | 0 | &sPrototypeClass.mBase, protoCache, |
20629 | 0 | nullptr, |
20630 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
20631 | 0 | interfaceCache, |
20632 | 0 | nullptr, |
20633 | 0 | nullptr, |
20634 | 0 | "WebGLVertexArrayObject", aDefineOnGlobal, |
20635 | 0 | nullptr, |
20636 | 0 | false); |
20637 | 0 | } |
20638 | | |
20639 | | JSObject* |
20640 | | GetConstructorObject(JSContext* aCx) |
20641 | 0 | { |
20642 | 0 | return GetConstructorObjectHandle(aCx); |
20643 | 0 | } |
20644 | | |
20645 | | } // namespace WebGLVertexArrayObject_Binding |
20646 | | |
20647 | | |
20648 | | |
20649 | | } // namespace dom |
20650 | | } // namespace mozilla |