| 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 "JSANGLEInstancedArrays.h" |
| 26 | |
| 27 | #include "JSDOMBinding.h" |
| 28 | #include "JSDOMConvertNumbers.h" |
| 29 | #include "JSDOMExceptionHandling.h" |
| 30 | #include "JSDOMOperation.h" |
| 31 | #include "JSDOMWrapperCache.h" |
| 32 | #include "ScriptExecutionContext.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 | // Functions |
| 44 | |
| 45 | JSC::EncodedJSValue JSC_HOST_CALL jsANGLEInstancedArraysPrototypeFunctionDrawArraysInstancedANGLE(JSC::ExecState*); |
| 46 | JSC::EncodedJSValue JSC_HOST_CALL jsANGLEInstancedArraysPrototypeFunctionDrawElementsInstancedANGLE(JSC::ExecState*); |
| 47 | JSC::EncodedJSValue JSC_HOST_CALL jsANGLEInstancedArraysPrototypeFunctionVertexAttribDivisorANGLE(JSC::ExecState*); |
| 48 | |
| 49 | class JSANGLEInstancedArraysPrototype : public JSC::JSNonFinalObject { |
| 50 | public: |
| 51 | using Base = JSC::JSNonFinalObject; |
| 52 | static JSANGLEInstancedArraysPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 53 | { |
| 54 | JSANGLEInstancedArraysPrototype* ptr = new (NotNull, JSC::allocateCell<JSANGLEInstancedArraysPrototype>(vm.heap)) JSANGLEInstancedArraysPrototype(vm, globalObject, structure); |
| 55 | ptr->finishCreation(vm); |
| 56 | return ptr; |
| 57 | } |
| 58 | |
| 59 | DECLARE_INFO; |
| 60 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 61 | { |
| 62 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 63 | } |
| 64 | |
| 65 | private: |
| 66 | JSANGLEInstancedArraysPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 67 | : JSC::JSNonFinalObject(vm, structure) |
| 68 | { |
| 69 | } |
| 70 | |
| 71 | void finishCreation(JSC::VM&); |
| 72 | }; |
| 73 | |
| 74 | /* Hash table for prototype */ |
| 75 | |
| 76 | static const HashTableValue JSANGLEInstancedArraysPrototypeTableValues[] = |
| 77 | { |
| 78 | { "drawArraysInstancedANGLE" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsANGLEInstancedArraysPrototypeFunctionDrawArraysInstancedANGLE), (intptr_t) (4) } }, |
| 79 | { "drawElementsInstancedANGLE" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsANGLEInstancedArraysPrototypeFunctionDrawElementsInstancedANGLE), (intptr_t) (5) } }, |
| 80 | { "vertexAttribDivisorANGLE" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsANGLEInstancedArraysPrototypeFunctionVertexAttribDivisorANGLE), (intptr_t) (2) } }, |
| 81 | { "VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x88FE) } }, |
| 82 | }; |
| 83 | |
| 84 | const ClassInfo JSANGLEInstancedArraysPrototype::s_info = { "ANGLEInstancedArraysPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSANGLEInstancedArraysPrototype) }; |
| 85 | |
| 86 | void JSANGLEInstancedArraysPrototype::finishCreation(VM& vm) |
| 87 | { |
| 88 | Base::finishCreation(vm); |
| 89 | reifyStaticProperties(vm, JSANGLEInstancedArrays::info(), JSANGLEInstancedArraysPrototypeTableValues, *this); |
| 90 | } |
| 91 | |
| 92 | const ClassInfo JSANGLEInstancedArrays::s_info = { "ANGLEInstancedArrays" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSANGLEInstancedArrays) }; |
| 93 | |
| 94 | JSANGLEInstancedArrays::JSANGLEInstancedArrays(Structure* structure, JSDOMGlobalObject& globalObject, Ref<ANGLEInstancedArrays>&& impl) |
| 95 | : JSDOMWrapper<ANGLEInstancedArrays>(structure, globalObject, WTFMove(impl)) |
| 96 | { |
| 97 | } |
| 98 | |
| 99 | void JSANGLEInstancedArrays::finishCreation(VM& vm) |
| 100 | { |
| 101 | Base::finishCreation(vm); |
| 102 | ASSERT(inherits(vm, info())); |
| 103 | |
| 104 | } |
| 105 | |
| 106 | JSObject* JSANGLEInstancedArrays::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 107 | { |
| 108 | return JSANGLEInstancedArraysPrototype::create(vm, &globalObject, JSANGLEInstancedArraysPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 109 | } |
| 110 | |
| 111 | JSObject* JSANGLEInstancedArrays::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 112 | { |
| 113 | return getDOMPrototype<JSANGLEInstancedArrays>(vm, globalObject); |
| 114 | } |
| 115 | |
| 116 | void JSANGLEInstancedArrays::destroy(JSC::JSCell* cell) |
| 117 | { |
| 118 | JSANGLEInstancedArrays* thisObject = static_cast<JSANGLEInstancedArrays*>(cell); |
| 119 | thisObject->JSANGLEInstancedArrays::~JSANGLEInstancedArrays(); |
| 120 | } |
| 121 | |
| 122 | template<> inline JSANGLEInstancedArrays* IDLOperation<JSANGLEInstancedArrays>::cast(ExecState& state) |
| 123 | { |
| 124 | return jsDynamicCast<JSANGLEInstancedArrays*>(state.vm(), state.thisValue()); |
| 125 | } |
| 126 | |
| 127 | static inline JSC::EncodedJSValue jsANGLEInstancedArraysPrototypeFunctionDrawArraysInstancedANGLEBody(JSC::ExecState* state, typename IDLOperation<JSANGLEInstancedArrays>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 128 | { |
| 129 | UNUSED_PARAM(state); |
| 130 | UNUSED_PARAM(throwScope); |
| 131 | auto& impl = castedThis->wrapped(); |
| 132 | if (UNLIKELY(state->argumentCount() < 4)) |
| 133 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 134 | auto mode = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
| 135 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 136 | auto first = convert<IDLLong>(*state, state->uncheckedArgument(1)); |
| 137 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 138 | auto count = convert<IDLLong>(*state, state->uncheckedArgument(2)); |
| 139 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 140 | auto primcount = convert<IDLLong>(*state, state->uncheckedArgument(3)); |
| 141 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 142 | impl.drawArraysInstancedANGLE(WTFMove(mode), WTFMove(first), WTFMove(count), WTFMove(primcount)); |
| 143 | return JSValue::encode(jsUndefined()); |
| 144 | } |
| 145 | |
| 146 | EncodedJSValue JSC_HOST_CALL jsANGLEInstancedArraysPrototypeFunctionDrawArraysInstancedANGLE(ExecState* state) |
| 147 | { |
| 148 | return IDLOperation<JSANGLEInstancedArrays>::call<jsANGLEInstancedArraysPrototypeFunctionDrawArraysInstancedANGLEBody>(*state, "drawArraysInstancedANGLE" ); |
| 149 | } |
| 150 | |
| 151 | static inline JSC::EncodedJSValue jsANGLEInstancedArraysPrototypeFunctionDrawElementsInstancedANGLEBody(JSC::ExecState* state, typename IDLOperation<JSANGLEInstancedArrays>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 152 | { |
| 153 | UNUSED_PARAM(state); |
| 154 | UNUSED_PARAM(throwScope); |
| 155 | auto& impl = castedThis->wrapped(); |
| 156 | if (UNLIKELY(state->argumentCount() < 5)) |
| 157 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 158 | auto mode = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
| 159 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 160 | auto count = convert<IDLLong>(*state, state->uncheckedArgument(1)); |
| 161 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 162 | auto type = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(2)); |
| 163 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 164 | auto offset = convert<IDLLongLong>(*state, state->uncheckedArgument(3)); |
| 165 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 166 | auto primcount = convert<IDLLong>(*state, state->uncheckedArgument(4)); |
| 167 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 168 | impl.drawElementsInstancedANGLE(WTFMove(mode), WTFMove(count), WTFMove(type), WTFMove(offset), WTFMove(primcount)); |
| 169 | return JSValue::encode(jsUndefined()); |
| 170 | } |
| 171 | |
| 172 | EncodedJSValue JSC_HOST_CALL jsANGLEInstancedArraysPrototypeFunctionDrawElementsInstancedANGLE(ExecState* state) |
| 173 | { |
| 174 | return IDLOperation<JSANGLEInstancedArrays>::call<jsANGLEInstancedArraysPrototypeFunctionDrawElementsInstancedANGLEBody>(*state, "drawElementsInstancedANGLE" ); |
| 175 | } |
| 176 | |
| 177 | static inline JSC::EncodedJSValue jsANGLEInstancedArraysPrototypeFunctionVertexAttribDivisorANGLEBody(JSC::ExecState* state, typename IDLOperation<JSANGLEInstancedArrays>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 178 | { |
| 179 | UNUSED_PARAM(state); |
| 180 | UNUSED_PARAM(throwScope); |
| 181 | auto& impl = castedThis->wrapped(); |
| 182 | if (UNLIKELY(state->argumentCount() < 2)) |
| 183 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 184 | auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
| 185 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 186 | auto divisor = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(1)); |
| 187 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 188 | impl.vertexAttribDivisorANGLE(WTFMove(index), WTFMove(divisor)); |
| 189 | return JSValue::encode(jsUndefined()); |
| 190 | } |
| 191 | |
| 192 | EncodedJSValue JSC_HOST_CALL jsANGLEInstancedArraysPrototypeFunctionVertexAttribDivisorANGLE(ExecState* state) |
| 193 | { |
| 194 | return IDLOperation<JSANGLEInstancedArrays>::call<jsANGLEInstancedArraysPrototypeFunctionVertexAttribDivisorANGLEBody>(*state, "vertexAttribDivisorANGLE" ); |
| 195 | } |
| 196 | |
| 197 | void JSANGLEInstancedArrays::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 198 | { |
| 199 | auto* thisObject = jsCast<JSANGLEInstancedArrays*>(cell); |
| 200 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 201 | if (thisObject->scriptExecutionContext()) |
| 202 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 203 | Base::heapSnapshot(cell, builder); |
| 204 | } |
| 205 | |
| 206 | bool JSANGLEInstancedArraysOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 207 | { |
| 208 | auto* jsANGLEInstancedArrays = jsCast<JSANGLEInstancedArrays*>(handle.slot()->asCell()); |
| 209 | WebGLRenderingContextBase* root = WTF::getPtr(jsANGLEInstancedArrays->wrapped().context()); |
| 210 | if (UNLIKELY(reason)) |
| 211 | *reason = "Reachable from ANGLEInstancedArrays" ; |
| 212 | return visitor.containsOpaqueRoot(root); |
| 213 | } |
| 214 | |
| 215 | void JSANGLEInstancedArraysOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 216 | { |
| 217 | auto* jsANGLEInstancedArrays = static_cast<JSANGLEInstancedArrays*>(handle.slot()->asCell()); |
| 218 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 219 | uncacheWrapper(world, &jsANGLEInstancedArrays->wrapped(), jsANGLEInstancedArrays); |
| 220 | } |
| 221 | |
| 222 | #if ENABLE(BINDING_INTEGRITY) |
| 223 | #if PLATFORM(WIN) |
| 224 | #pragma warning(disable: 4483) |
| 225 | extern "C" { extern void (*const __identifier("??_7ANGLEInstancedArrays@WebCore@@6B@" )[])(); } |
| 226 | #else |
| 227 | extern "C" { extern void* _ZTVN7WebCore20ANGLEInstancedArraysE[]; } |
| 228 | #endif |
| 229 | #endif |
| 230 | |
| 231 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<ANGLEInstancedArrays>&& impl) |
| 232 | { |
| 233 | |
| 234 | #if ENABLE(BINDING_INTEGRITY) |
| 235 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 236 | #if PLATFORM(WIN) |
| 237 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7ANGLEInstancedArrays@WebCore@@6B@" )); |
| 238 | #else |
| 239 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore20ANGLEInstancedArraysE[2]); |
| 240 | #endif |
| 241 | |
| 242 | // If this fails ANGLEInstancedArrays does not have a vtable, so you need to add the |
| 243 | // ImplementationLacksVTable attribute to the interface definition |
| 244 | static_assert(std::is_polymorphic<ANGLEInstancedArrays>::value, "ANGLEInstancedArrays is not polymorphic" ); |
| 245 | |
| 246 | // If you hit this assertion you either have a use after free bug, or |
| 247 | // ANGLEInstancedArrays has subclasses. If ANGLEInstancedArrays has subclasses that get passed |
| 248 | // to toJS() we currently require ANGLEInstancedArrays you to opt out of binding hardening |
| 249 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 250 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 251 | #endif |
| 252 | return createWrapper<ANGLEInstancedArrays>(globalObject, WTFMove(impl)); |
| 253 | } |
| 254 | |
| 255 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, ANGLEInstancedArrays& impl) |
| 256 | { |
| 257 | return wrap(state, globalObject, impl); |
| 258 | } |
| 259 | |
| 260 | ANGLEInstancedArrays* JSANGLEInstancedArrays::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 261 | { |
| 262 | if (auto* wrapper = jsDynamicCast<JSANGLEInstancedArrays*>(vm, value)) |
| 263 | return &wrapper->wrapped(); |
| 264 | return nullptr; |
| 265 | } |
| 266 | |
| 267 | } |
| 268 | |
| 269 | #endif // ENABLE(WEBGL) |
| 270 | |