1/*
2 This file is part of the WebKit open source project.
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include "config.h"
22
23#if ENABLE(WEBGL)
24
25#include "JSWebGLDrawBuffers.h"
26
27#include "JSDOMBinding.h"
28#include "JSDOMConvertNumbers.h"
29#include "JSDOMConvertSequences.h"
30#include "JSDOMExceptionHandling.h"
31#include "JSDOMOperation.h"
32#include "JSDOMWrapperCache.h"
33#include "ScriptExecutionContext.h"
34#include <JavaScriptCore/HeapSnapshotBuilder.h>
35#include <JavaScriptCore/JSArray.h>
36#include <JavaScriptCore/JSCInlines.h>
37#include <wtf/GetPtr.h>
38#include <wtf/PointerPreparations.h>
39#include <wtf/URL.h>
40
41
42namespace WebCore {
43using namespace JSC;
44
45// Functions
46
47JSC::EncodedJSValue JSC_HOST_CALL jsWebGLDrawBuffersPrototypeFunctionDrawBuffersWEBGL(JSC::ExecState*);
48
49class JSWebGLDrawBuffersPrototype : public JSC::JSNonFinalObject {
50public:
51 using Base = JSC::JSNonFinalObject;
52 static JSWebGLDrawBuffersPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
53 {
54 JSWebGLDrawBuffersPrototype* ptr = new (NotNull, JSC::allocateCell<JSWebGLDrawBuffersPrototype>(vm.heap)) JSWebGLDrawBuffersPrototype(vm, globalObject, structure);
55 ptr->finishCreation(vm);
56 return ptr;
57 }
58
59 DECLARE_INFO;
60 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
61 {
62 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
63 }
64
65private:
66 JSWebGLDrawBuffersPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
67 : JSC::JSNonFinalObject(vm, structure)
68 {
69 }
70
71 void finishCreation(JSC::VM&);
72};
73
74/* Hash table for prototype */
75
76static const HashTableValue JSWebGLDrawBuffersPrototypeTableValues[] =
77{
78 { "drawBuffersWEBGL", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGLDrawBuffersPrototypeFunctionDrawBuffersWEBGL), (intptr_t) (1) } },
79 { "COLOR_ATTACHMENT0_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8CE0) } },
80 { "COLOR_ATTACHMENT1_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8CE1) } },
81 { "COLOR_ATTACHMENT2_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8CE2) } },
82 { "COLOR_ATTACHMENT3_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8CE3) } },
83 { "COLOR_ATTACHMENT4_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8CE4) } },
84 { "COLOR_ATTACHMENT5_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8CE5) } },
85 { "COLOR_ATTACHMENT6_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8CE6) } },
86 { "COLOR_ATTACHMENT7_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8CE7) } },
87 { "COLOR_ATTACHMENT8_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8CE8) } },
88 { "COLOR_ATTACHMENT9_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8CE9) } },
89 { "COLOR_ATTACHMENT10_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8CEA) } },
90 { "COLOR_ATTACHMENT11_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8CEB) } },
91 { "COLOR_ATTACHMENT12_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8CEC) } },
92 { "COLOR_ATTACHMENT13_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8CED) } },
93 { "COLOR_ATTACHMENT14_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8CEE) } },
94 { "COLOR_ATTACHMENT15_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8CEF) } },
95 { "DRAW_BUFFER0_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8825) } },
96 { "DRAW_BUFFER1_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8826) } },
97 { "DRAW_BUFFER2_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8827) } },
98 { "DRAW_BUFFER3_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8828) } },
99 { "DRAW_BUFFER4_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8829) } },
100 { "DRAW_BUFFER5_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x882A) } },
101 { "DRAW_BUFFER6_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x882B) } },
102 { "DRAW_BUFFER7_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x882C) } },
103 { "DRAW_BUFFER8_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x882D) } },
104 { "DRAW_BUFFER9_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x882E) } },
105 { "DRAW_BUFFER10_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x882F) } },
106 { "DRAW_BUFFER11_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8830) } },
107 { "DRAW_BUFFER12_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8831) } },
108 { "DRAW_BUFFER13_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8832) } },
109 { "DRAW_BUFFER14_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8833) } },
110 { "DRAW_BUFFER15_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8834) } },
111 { "MAX_COLOR_ATTACHMENTS_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8CDF) } },
112 { "MAX_DRAW_BUFFERS_WEBGL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x8824) } },
113};
114
115const ClassInfo JSWebGLDrawBuffersPrototype::s_info = { "WebGLDrawBuffersPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGLDrawBuffersPrototype) };
116
117void JSWebGLDrawBuffersPrototype::finishCreation(VM& vm)
118{
119 Base::finishCreation(vm);
120 reifyStaticProperties(vm, JSWebGLDrawBuffers::info(), JSWebGLDrawBuffersPrototypeTableValues, *this);
121}
122
123const ClassInfo JSWebGLDrawBuffers::s_info = { "WebGLDrawBuffers", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGLDrawBuffers) };
124
125JSWebGLDrawBuffers::JSWebGLDrawBuffers(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WebGLDrawBuffers>&& impl)
126 : JSDOMWrapper<WebGLDrawBuffers>(structure, globalObject, WTFMove(impl))
127{
128}
129
130void JSWebGLDrawBuffers::finishCreation(VM& vm)
131{
132 Base::finishCreation(vm);
133 ASSERT(inherits(vm, info()));
134
135}
136
137JSObject* JSWebGLDrawBuffers::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
138{
139 return JSWebGLDrawBuffersPrototype::create(vm, &globalObject, JSWebGLDrawBuffersPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
140}
141
142JSObject* JSWebGLDrawBuffers::prototype(VM& vm, JSDOMGlobalObject& globalObject)
143{
144 return getDOMPrototype<JSWebGLDrawBuffers>(vm, globalObject);
145}
146
147void JSWebGLDrawBuffers::destroy(JSC::JSCell* cell)
148{
149 JSWebGLDrawBuffers* thisObject = static_cast<JSWebGLDrawBuffers*>(cell);
150 thisObject->JSWebGLDrawBuffers::~JSWebGLDrawBuffers();
151}
152
153template<> inline JSWebGLDrawBuffers* IDLOperation<JSWebGLDrawBuffers>::cast(ExecState& state)
154{
155 return jsDynamicCast<JSWebGLDrawBuffers*>(state.vm(), state.thisValue());
156}
157
158static inline JSC::EncodedJSValue jsWebGLDrawBuffersPrototypeFunctionDrawBuffersWEBGLBody(JSC::ExecState* state, typename IDLOperation<JSWebGLDrawBuffers>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
159{
160 UNUSED_PARAM(state);
161 UNUSED_PARAM(throwScope);
162 auto& impl = castedThis->wrapped();
163 if (UNLIKELY(state->argumentCount() < 1))
164 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
165 auto buffers = convert<IDLSequence<IDLUnsignedLong>>(*state, state->uncheckedArgument(0));
166 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
167 impl.drawBuffersWEBGL(WTFMove(buffers));
168 return JSValue::encode(jsUndefined());
169}
170
171EncodedJSValue JSC_HOST_CALL jsWebGLDrawBuffersPrototypeFunctionDrawBuffersWEBGL(ExecState* state)
172{
173 return IDLOperation<JSWebGLDrawBuffers>::call<jsWebGLDrawBuffersPrototypeFunctionDrawBuffersWEBGLBody>(*state, "drawBuffersWEBGL");
174}
175
176void JSWebGLDrawBuffers::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
177{
178 auto* thisObject = jsCast<JSWebGLDrawBuffers*>(cell);
179 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
180 if (thisObject->scriptExecutionContext())
181 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
182 Base::heapSnapshot(cell, builder);
183}
184
185bool JSWebGLDrawBuffersOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
186{
187 auto* jsWebGLDrawBuffers = jsCast<JSWebGLDrawBuffers*>(handle.slot()->asCell());
188 WebGLRenderingContextBase* root = WTF::getPtr(jsWebGLDrawBuffers->wrapped().context());
189 if (UNLIKELY(reason))
190 *reason = "Reachable from WebGLDrawBuffers";
191 return visitor.containsOpaqueRoot(root);
192}
193
194void JSWebGLDrawBuffersOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
195{
196 auto* jsWebGLDrawBuffers = static_cast<JSWebGLDrawBuffers*>(handle.slot()->asCell());
197 auto& world = *static_cast<DOMWrapperWorld*>(context);
198 uncacheWrapper(world, &jsWebGLDrawBuffers->wrapped(), jsWebGLDrawBuffers);
199}
200
201#if ENABLE(BINDING_INTEGRITY)
202#if PLATFORM(WIN)
203#pragma warning(disable: 4483)
204extern "C" { extern void (*const __identifier("??_7WebGLDrawBuffers@WebCore@@6B@")[])(); }
205#else
206extern "C" { extern void* _ZTVN7WebCore16WebGLDrawBuffersE[]; }
207#endif
208#endif
209
210JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<WebGLDrawBuffers>&& impl)
211{
212
213#if ENABLE(BINDING_INTEGRITY)
214 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
215#if PLATFORM(WIN)
216 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7WebGLDrawBuffers@WebCore@@6B@"));
217#else
218 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore16WebGLDrawBuffersE[2]);
219#endif
220
221 // If this fails WebGLDrawBuffers does not have a vtable, so you need to add the
222 // ImplementationLacksVTable attribute to the interface definition
223 static_assert(std::is_polymorphic<WebGLDrawBuffers>::value, "WebGLDrawBuffers is not polymorphic");
224
225 // If you hit this assertion you either have a use after free bug, or
226 // WebGLDrawBuffers has subclasses. If WebGLDrawBuffers has subclasses that get passed
227 // to toJS() we currently require WebGLDrawBuffers you to opt out of binding hardening
228 // by adding the SkipVTableValidation attribute to the interface IDL definition
229 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
230#endif
231 return createWrapper<WebGLDrawBuffers>(globalObject, WTFMove(impl));
232}
233
234JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, WebGLDrawBuffers& impl)
235{
236 return wrap(state, globalObject, impl);
237}
238
239WebGLDrawBuffers* JSWebGLDrawBuffers::toWrapped(JSC::VM& vm, JSC::JSValue value)
240{
241 if (auto* wrapper = jsDynamicCast<JSWebGLDrawBuffers*>(vm, value))
242 return &wrapper->wrapped();
243 return nullptr;
244}
245
246}
247
248#endif // ENABLE(WEBGL)
249