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 "JSWebGLDebugShaders.h" |
26 | |
27 | #include "JSDOMBinding.h" |
28 | #include "JSDOMConvertInterface.h" |
29 | #include "JSDOMConvertNullable.h" |
30 | #include "JSDOMConvertStrings.h" |
31 | #include "JSDOMExceptionHandling.h" |
32 | #include "JSDOMOperation.h" |
33 | #include "JSDOMWrapperCache.h" |
34 | #include "JSWebGLShader.h" |
35 | #include "ScriptExecutionContext.h" |
36 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
37 | #include <JavaScriptCore/JSCInlines.h> |
38 | #include <wtf/GetPtr.h> |
39 | #include <wtf/PointerPreparations.h> |
40 | #include <wtf/URL.h> |
41 | |
42 | |
43 | namespace WebCore { |
44 | using namespace JSC; |
45 | |
46 | // Functions |
47 | |
48 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGLDebugShadersPrototypeFunctionGetTranslatedShaderSource(JSC::ExecState*); |
49 | |
50 | class JSWebGLDebugShadersPrototype : public JSC::JSNonFinalObject { |
51 | public: |
52 | using Base = JSC::JSNonFinalObject; |
53 | static JSWebGLDebugShadersPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
54 | { |
55 | JSWebGLDebugShadersPrototype* ptr = new (NotNull, JSC::allocateCell<JSWebGLDebugShadersPrototype>(vm.heap)) JSWebGLDebugShadersPrototype(vm, globalObject, structure); |
56 | ptr->finishCreation(vm); |
57 | return ptr; |
58 | } |
59 | |
60 | DECLARE_INFO; |
61 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
62 | { |
63 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
64 | } |
65 | |
66 | private: |
67 | JSWebGLDebugShadersPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
68 | : JSC::JSNonFinalObject(vm, structure) |
69 | { |
70 | } |
71 | |
72 | void finishCreation(JSC::VM&); |
73 | }; |
74 | |
75 | /* Hash table for prototype */ |
76 | |
77 | static const HashTableValue JSWebGLDebugShadersPrototypeTableValues[] = |
78 | { |
79 | { "getTranslatedShaderSource" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGLDebugShadersPrototypeFunctionGetTranslatedShaderSource), (intptr_t) (1) } }, |
80 | }; |
81 | |
82 | const ClassInfo JSWebGLDebugShadersPrototype::s_info = { "WebGLDebugShadersPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGLDebugShadersPrototype) }; |
83 | |
84 | void JSWebGLDebugShadersPrototype::finishCreation(VM& vm) |
85 | { |
86 | Base::finishCreation(vm); |
87 | reifyStaticProperties(vm, JSWebGLDebugShaders::info(), JSWebGLDebugShadersPrototypeTableValues, *this); |
88 | } |
89 | |
90 | const ClassInfo JSWebGLDebugShaders::s_info = { "WebGLDebugShaders" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGLDebugShaders) }; |
91 | |
92 | JSWebGLDebugShaders::JSWebGLDebugShaders(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WebGLDebugShaders>&& impl) |
93 | : JSDOMWrapper<WebGLDebugShaders>(structure, globalObject, WTFMove(impl)) |
94 | { |
95 | } |
96 | |
97 | void JSWebGLDebugShaders::finishCreation(VM& vm) |
98 | { |
99 | Base::finishCreation(vm); |
100 | ASSERT(inherits(vm, info())); |
101 | |
102 | } |
103 | |
104 | JSObject* JSWebGLDebugShaders::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
105 | { |
106 | return JSWebGLDebugShadersPrototype::create(vm, &globalObject, JSWebGLDebugShadersPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
107 | } |
108 | |
109 | JSObject* JSWebGLDebugShaders::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
110 | { |
111 | return getDOMPrototype<JSWebGLDebugShaders>(vm, globalObject); |
112 | } |
113 | |
114 | void JSWebGLDebugShaders::destroy(JSC::JSCell* cell) |
115 | { |
116 | JSWebGLDebugShaders* thisObject = static_cast<JSWebGLDebugShaders*>(cell); |
117 | thisObject->JSWebGLDebugShaders::~JSWebGLDebugShaders(); |
118 | } |
119 | |
120 | template<> inline JSWebGLDebugShaders* IDLOperation<JSWebGLDebugShaders>::cast(ExecState& state) |
121 | { |
122 | return jsDynamicCast<JSWebGLDebugShaders*>(state.vm(), state.thisValue()); |
123 | } |
124 | |
125 | static inline JSC::EncodedJSValue jsWebGLDebugShadersPrototypeFunctionGetTranslatedShaderSourceBody(JSC::ExecState* state, typename IDLOperation<JSWebGLDebugShaders>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
126 | { |
127 | UNUSED_PARAM(state); |
128 | UNUSED_PARAM(throwScope); |
129 | auto& impl = castedThis->wrapped(); |
130 | if (UNLIKELY(state->argumentCount() < 1)) |
131 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
132 | auto shader = convert<IDLNullable<IDLInterface<WebGLShader>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "shader" , "WebGLDebugShaders" , "getTranslatedShaderSource" , "WebGLShader" ); }); |
133 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
134 | return JSValue::encode(toJS<IDLNullable<IDLDOMString>>(*state, impl.getTranslatedShaderSource(WTFMove(shader)))); |
135 | } |
136 | |
137 | EncodedJSValue JSC_HOST_CALL jsWebGLDebugShadersPrototypeFunctionGetTranslatedShaderSource(ExecState* state) |
138 | { |
139 | return IDLOperation<JSWebGLDebugShaders>::call<jsWebGLDebugShadersPrototypeFunctionGetTranslatedShaderSourceBody>(*state, "getTranslatedShaderSource" ); |
140 | } |
141 | |
142 | void JSWebGLDebugShaders::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
143 | { |
144 | auto* thisObject = jsCast<JSWebGLDebugShaders*>(cell); |
145 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
146 | if (thisObject->scriptExecutionContext()) |
147 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
148 | Base::heapSnapshot(cell, builder); |
149 | } |
150 | |
151 | bool JSWebGLDebugShadersOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
152 | { |
153 | auto* jsWebGLDebugShaders = jsCast<JSWebGLDebugShaders*>(handle.slot()->asCell()); |
154 | WebGLRenderingContextBase* root = WTF::getPtr(jsWebGLDebugShaders->wrapped().context()); |
155 | if (UNLIKELY(reason)) |
156 | *reason = "Reachable from WebGLDebugShaders" ; |
157 | return visitor.containsOpaqueRoot(root); |
158 | } |
159 | |
160 | void JSWebGLDebugShadersOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
161 | { |
162 | auto* jsWebGLDebugShaders = static_cast<JSWebGLDebugShaders*>(handle.slot()->asCell()); |
163 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
164 | uncacheWrapper(world, &jsWebGLDebugShaders->wrapped(), jsWebGLDebugShaders); |
165 | } |
166 | |
167 | #if ENABLE(BINDING_INTEGRITY) |
168 | #if PLATFORM(WIN) |
169 | #pragma warning(disable: 4483) |
170 | extern "C" { extern void (*const __identifier("??_7WebGLDebugShaders@WebCore@@6B@" )[])(); } |
171 | #else |
172 | extern "C" { extern void* _ZTVN7WebCore17WebGLDebugShadersE[]; } |
173 | #endif |
174 | #endif |
175 | |
176 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<WebGLDebugShaders>&& impl) |
177 | { |
178 | |
179 | #if ENABLE(BINDING_INTEGRITY) |
180 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
181 | #if PLATFORM(WIN) |
182 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7WebGLDebugShaders@WebCore@@6B@" )); |
183 | #else |
184 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore17WebGLDebugShadersE[2]); |
185 | #endif |
186 | |
187 | // If this fails WebGLDebugShaders does not have a vtable, so you need to add the |
188 | // ImplementationLacksVTable attribute to the interface definition |
189 | static_assert(std::is_polymorphic<WebGLDebugShaders>::value, "WebGLDebugShaders is not polymorphic" ); |
190 | |
191 | // If you hit this assertion you either have a use after free bug, or |
192 | // WebGLDebugShaders has subclasses. If WebGLDebugShaders has subclasses that get passed |
193 | // to toJS() we currently require WebGLDebugShaders you to opt out of binding hardening |
194 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
195 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
196 | #endif |
197 | return createWrapper<WebGLDebugShaders>(globalObject, WTFMove(impl)); |
198 | } |
199 | |
200 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, WebGLDebugShaders& impl) |
201 | { |
202 | return wrap(state, globalObject, impl); |
203 | } |
204 | |
205 | WebGLDebugShaders* JSWebGLDebugShaders::toWrapped(JSC::VM& vm, JSC::JSValue value) |
206 | { |
207 | if (auto* wrapper = jsDynamicCast<JSWebGLDebugShaders*>(vm, value)) |
208 | return &wrapper->wrapped(); |
209 | return nullptr; |
210 | } |
211 | |
212 | } |
213 | |
214 | #endif // ENABLE(WEBGL) |
215 | |