| /* |
| This file is part of the WebKit open source project. |
| This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| |
| This library is free software; you can redistribute it and/or |
| modify it under the terms of the GNU Library General Public |
| License as published by the Free Software Foundation; either |
| version 2 of the License, or (at your option) any later version. |
| |
| This library is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| Library General Public License for more details. |
| |
| You should have received a copy of the GNU Library General Public License |
| along with this library; see the file COPYING.LIB. If not, write to |
| the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| Boston, MA 02110-1301, USA. |
| */ |
| |
| #include "config.h" |
| #include "JSTestNode.h" |
| |
| #include "ExceptionCode.h" |
| #include "JSDOMBinding.h" |
| #include "JSDOMConstructor.h" |
| #include "JSDOMIterator.h" |
| #include "RuntimeEnabledFeatures.h" |
| #include "URL.h" |
| #include <runtime/Error.h> |
| #include <runtime/JSString.h> |
| #include <wtf/GetPtr.h> |
| |
| using namespace JSC; |
| |
| namespace WebCore { |
| |
| // Functions |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionSymbolIterator(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionEntries(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionKeys(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionValues(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionForEach(JSC::ExecState*); |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsTestNodeName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSTestNodeName(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsTestNodeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSTestNodeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSTestNodePrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSTestNodePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSTestNodePrototype* ptr = new (NotNull, JSC::allocateCell<JSTestNodePrototype>(vm.heap)) JSTestNodePrototype(vm, globalObject, structure); |
| ptr->finishCreation(vm); |
| return ptr; |
| } |
| |
| DECLARE_INFO; |
| static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| { |
| return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| } |
| |
| private: |
| JSTestNodePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| typedef JSDOMConstructor<JSTestNode> JSTestNodeConstructor; |
| |
| template<> EncodedJSValue JSC_HOST_CALL JSTestNodeConstructor::construct(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| auto* castedThis = jsCast<JSTestNodeConstructor*>(state->callee()); |
| ASSERT(castedThis); |
| auto object = TestNode::create(); |
| return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))); |
| } |
| |
| template<> JSValue JSTestNodeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| { |
| return JSNode::getConstructor(vm, &globalObject); |
| } |
| |
| template<> void JSTestNodeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| { |
| putDirect(vm, vm.propertyNames->prototype, JSTestNode::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TestNode"))), ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum); |
| } |
| |
| template<> const ClassInfo JSTestNodeConstructor::s_info = { "TestNode", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestNodeConstructor) }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSTestNodePrototypeTableValues[] = |
| { |
| { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNodeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNodeConstructor) } }, |
| { "name", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNodeName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNodeName) } }, |
| { "entries", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionEntries), (intptr_t) (0) } }, |
| { "keys", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionKeys), (intptr_t) (0) } }, |
| { "values", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionValues), (intptr_t) (0) } }, |
| { "forEach", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNodePrototypeFunctionForEach), (intptr_t) (1) } }, |
| }; |
| |
| const ClassInfo JSTestNodePrototype::s_info = { "TestNodePrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestNodePrototype) }; |
| |
| void JSTestNodePrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSTestNodePrototypeTableValues, *this); |
| if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) { |
| Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("entries"), strlen("entries")); |
| VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| } |
| if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) { |
| Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("keys"), strlen("keys")); |
| VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| } |
| if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) { |
| Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("values"), strlen("values")); |
| VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| } |
| if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) { |
| Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("forEach"), strlen("forEach")); |
| VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| } |
| if (RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) { |
| putDirect(vm, vm.propertyNames->iteratorSymbol, JSFunction::create(vm, globalObject(), 0, ASCIILiteral("[Symbol.Iterator]"), jsTestNodePrototypeFunctionSymbolIterator), DontEnum); |
| } |
| } |
| |
| const ClassInfo JSTestNode::s_info = { "TestNode", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestNode) }; |
| |
| JSTestNode::JSTestNode(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestNode>&& impl) |
| : JSNode(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSTestNode::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSTestNodePrototype::create(vm, globalObject, JSTestNodePrototype::createStructure(vm, globalObject, JSNode::prototype(vm, globalObject))); |
| } |
| |
| JSObject* JSTestNode::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSTestNode>(vm, globalObject); |
| } |
| |
| EncodedJSValue jsTestNodeName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSTestNode*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "TestNode", "name"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.name()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsTestNodeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSTestNodePrototype* domObject = jsDynamicCast<JSTestNodePrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) |
| return throwVMTypeError(state, throwScope); |
| return JSValue::encode(JSTestNode::getConstructor(state->vm(), domObject->globalObject())); |
| } |
| |
| bool setJSTestNodeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSTestNodePrototype* domObject = jsDynamicCast<JSTestNodePrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) { |
| throwVMTypeError(state, throwScope); |
| return false; |
| } |
| // Shadowing a built-in constructor |
| return domObject->putDirect(state->vm(), state->propertyNames().constructor, value); |
| } |
| |
| bool setJSTestNodeName(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue value = JSValue::decode(encodedValue); |
| UNUSED_PARAM(thisValue); |
| JSTestNode* castedThis = jsDynamicCast<JSTestNode*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "TestNode", "name"); |
| } |
| auto& impl = castedThis->wrapped(); |
| auto nativeValue = value.toWTFString(state); |
| if (UNLIKELY(throwScope.exception())) |
| return false; |
| impl.setName(WTFMove(nativeValue)); |
| return true; |
| } |
| |
| |
| JSValue JSTestNode::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| { |
| return getDOMConstructor<JSTestNodeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| } |
| |
| using TestNodeIterator = JSDOMIterator<JSTestNode>; |
| using TestNodeIteratorPrototype = JSDOMIteratorPrototype<JSTestNode>; |
| |
| template<> |
| const JSC::ClassInfo TestNodeIterator::s_info = { "TestNode Iterator", &Base::s_info, 0, CREATE_METHOD_TABLE(TestNodeIterator) }; |
| |
| template<> |
| const JSC::ClassInfo TestNodeIteratorPrototype::s_info = { "TestNode Iterator", &Base::s_info, 0, CREATE_METHOD_TABLE(TestNodeIteratorPrototype) }; |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionSymbolIterator(JSC::ExecState* state) |
| { |
| return iteratorCreate<JSTestNode>(*state, IterationKind::Value, "[Symbol.Iterator]"); |
| } |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionEntries(JSC::ExecState* state) |
| { |
| return iteratorCreate<JSTestNode>(*state, IterationKind::KeyValue, "entries"); |
| } |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionKeys(JSC::ExecState* state) |
| { |
| return iteratorCreate<JSTestNode>(*state, IterationKind::Key, "keys"); |
| } |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionValues(JSC::ExecState* state) |
| { |
| return iteratorCreate<JSTestNode>(*state, IterationKind::Value, "values"); |
| } |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionForEach(JSC::ExecState* state) |
| { |
| return iteratorForEach<JSTestNode>(*state, "forEach"); |
| } |
| |
| void JSTestNode::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| { |
| auto* thisObject = jsCast<JSTestNode*>(cell); |
| ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| Base::visitChildren(thisObject, visitor); |
| thisObject->wrapped().visitJSEventListeners(visitor); |
| } |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| #if PLATFORM(WIN) |
| #pragma warning(disable: 4483) |
| extern "C" { extern void (*const __identifier("??_7TestNode@WebCore@@6B@")[])(); } |
| #else |
| extern "C" { extern void* _ZTVN7WebCore8TestNodeE[]; } |
| #endif |
| #endif |
| |
| JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestNode>&& impl) |
| { |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| #if PLATFORM(WIN) |
| void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestNode@WebCore@@6B@")); |
| #else |
| void* expectedVTablePointer = &_ZTVN7WebCore8TestNodeE[2]; |
| #if COMPILER(CLANG) |
| // If this fails TestNode does not have a vtable, so you need to add the |
| // ImplementationLacksVTable attribute to the interface definition |
| static_assert(__is_polymorphic(TestNode), "TestNode is not polymorphic"); |
| #endif |
| #endif |
| // If you hit this assertion you either have a use after free bug, or |
| // TestNode has subclasses. If TestNode has subclasses that get passed |
| // to toJS() we currently require TestNode you to opt out of binding hardening |
| // by adding the SkipVTableValidation attribute to the interface IDL definition |
| RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| #endif |
| return createWrapper<TestNode>(globalObject, WTFMove(impl)); |
| } |
| |
| JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestNode& impl) |
| { |
| return wrap(state, globalObject, impl); |
| } |
| |
| |
| } |