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