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