| 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 "JSWebGLDebugRendererInfo.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 JSWebGLDebugRendererInfoPrototype : public JSC::JSNonFinalObject { |
| 42 | public: |
| 43 | using Base = JSC::JSNonFinalObject; |
| 44 | static JSWebGLDebugRendererInfoPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 45 | { |
| 46 | JSWebGLDebugRendererInfoPrototype* ptr = new (NotNull, JSC::allocateCell<JSWebGLDebugRendererInfoPrototype>(vm.heap)) JSWebGLDebugRendererInfoPrototype(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 | JSWebGLDebugRendererInfoPrototype(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 JSWebGLDebugRendererInfoPrototypeTableValues[] = |
| 69 | { |
| 70 | { "UNMASKED_VENDOR_WEBGL" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x9245) } }, |
| 71 | { "UNMASKED_RENDERER_WEBGL" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x9246) } }, |
| 72 | }; |
| 73 | |
| 74 | const ClassInfo JSWebGLDebugRendererInfoPrototype::s_info = { "WebGLDebugRendererInfoPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGLDebugRendererInfoPrototype) }; |
| 75 | |
| 76 | void JSWebGLDebugRendererInfoPrototype::finishCreation(VM& vm) |
| 77 | { |
| 78 | Base::finishCreation(vm); |
| 79 | reifyStaticProperties(vm, JSWebGLDebugRendererInfo::info(), JSWebGLDebugRendererInfoPrototypeTableValues, *this); |
| 80 | } |
| 81 | |
| 82 | const ClassInfo JSWebGLDebugRendererInfo::s_info = { "WebGLDebugRendererInfo" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGLDebugRendererInfo) }; |
| 83 | |
| 84 | JSWebGLDebugRendererInfo::JSWebGLDebugRendererInfo(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WebGLDebugRendererInfo>&& impl) |
| 85 | : JSDOMWrapper<WebGLDebugRendererInfo>(structure, globalObject, WTFMove(impl)) |
| 86 | { |
| 87 | } |
| 88 | |
| 89 | void JSWebGLDebugRendererInfo::finishCreation(VM& vm) |
| 90 | { |
| 91 | Base::finishCreation(vm); |
| 92 | ASSERT(inherits(vm, info())); |
| 93 | |
| 94 | } |
| 95 | |
| 96 | JSObject* JSWebGLDebugRendererInfo::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 97 | { |
| 98 | return JSWebGLDebugRendererInfoPrototype::create(vm, &globalObject, JSWebGLDebugRendererInfoPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 99 | } |
| 100 | |
| 101 | JSObject* JSWebGLDebugRendererInfo::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 102 | { |
| 103 | return getDOMPrototype<JSWebGLDebugRendererInfo>(vm, globalObject); |
| 104 | } |
| 105 | |
| 106 | void JSWebGLDebugRendererInfo::destroy(JSC::JSCell* cell) |
| 107 | { |
| 108 | JSWebGLDebugRendererInfo* thisObject = static_cast<JSWebGLDebugRendererInfo*>(cell); |
| 109 | thisObject->JSWebGLDebugRendererInfo::~JSWebGLDebugRendererInfo(); |
| 110 | } |
| 111 | |
| 112 | void JSWebGLDebugRendererInfo::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 113 | { |
| 114 | auto* thisObject = jsCast<JSWebGLDebugRendererInfo*>(cell); |
| 115 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 116 | if (thisObject->scriptExecutionContext()) |
| 117 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 118 | Base::heapSnapshot(cell, builder); |
| 119 | } |
| 120 | |
| 121 | bool JSWebGLDebugRendererInfoOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 122 | { |
| 123 | auto* jsWebGLDebugRendererInfo = jsCast<JSWebGLDebugRendererInfo*>(handle.slot()->asCell()); |
| 124 | WebGLRenderingContextBase* root = WTF::getPtr(jsWebGLDebugRendererInfo->wrapped().context()); |
| 125 | if (UNLIKELY(reason)) |
| 126 | *reason = "Reachable from WebGLDebugRendererInfo" ; |
| 127 | return visitor.containsOpaqueRoot(root); |
| 128 | } |
| 129 | |
| 130 | void JSWebGLDebugRendererInfoOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 131 | { |
| 132 | auto* jsWebGLDebugRendererInfo = static_cast<JSWebGLDebugRendererInfo*>(handle.slot()->asCell()); |
| 133 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 134 | uncacheWrapper(world, &jsWebGLDebugRendererInfo->wrapped(), jsWebGLDebugRendererInfo); |
| 135 | } |
| 136 | |
| 137 | #if ENABLE(BINDING_INTEGRITY) |
| 138 | #if PLATFORM(WIN) |
| 139 | #pragma warning(disable: 4483) |
| 140 | extern "C" { extern void (*const __identifier("??_7WebGLDebugRendererInfo@WebCore@@6B@" )[])(); } |
| 141 | #else |
| 142 | extern "C" { extern void* _ZTVN7WebCore22WebGLDebugRendererInfoE[]; } |
| 143 | #endif |
| 144 | #endif |
| 145 | |
| 146 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<WebGLDebugRendererInfo>&& impl) |
| 147 | { |
| 148 | |
| 149 | #if ENABLE(BINDING_INTEGRITY) |
| 150 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 151 | #if PLATFORM(WIN) |
| 152 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7WebGLDebugRendererInfo@WebCore@@6B@" )); |
| 153 | #else |
| 154 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore22WebGLDebugRendererInfoE[2]); |
| 155 | #endif |
| 156 | |
| 157 | // If this fails WebGLDebugRendererInfo does not have a vtable, so you need to add the |
| 158 | // ImplementationLacksVTable attribute to the interface definition |
| 159 | static_assert(std::is_polymorphic<WebGLDebugRendererInfo>::value, "WebGLDebugRendererInfo is not polymorphic" ); |
| 160 | |
| 161 | // If you hit this assertion you either have a use after free bug, or |
| 162 | // WebGLDebugRendererInfo has subclasses. If WebGLDebugRendererInfo has subclasses that get passed |
| 163 | // to toJS() we currently require WebGLDebugRendererInfo you to opt out of binding hardening |
| 164 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 165 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 166 | #endif |
| 167 | return createWrapper<WebGLDebugRendererInfo>(globalObject, WTFMove(impl)); |
| 168 | } |
| 169 | |
| 170 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, WebGLDebugRendererInfo& impl) |
| 171 | { |
| 172 | return wrap(state, globalObject, impl); |
| 173 | } |
| 174 | |
| 175 | WebGLDebugRendererInfo* JSWebGLDebugRendererInfo::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 176 | { |
| 177 | if (auto* wrapper = jsDynamicCast<JSWebGLDebugRendererInfo*>(vm, value)) |
| 178 | return &wrapper->wrapped(); |
| 179 | return nullptr; |
| 180 | } |
| 181 | |
| 182 | } |
| 183 | |
| 184 | #endif // ENABLE(WEBGL) |
| 185 | |