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