| /* |
| 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" |
| |
| #if ENABLE(CUSTOM_ELEMENTS) |
| |
| #include "JSCustomElementRegistry.h" |
| |
| #include "CustomElementReactionQueue.h" |
| #include "ExceptionCode.h" |
| #include "JSDOMBinding.h" |
| #include "JSDOMConstructor.h" |
| #include "JSDOMPromise.h" |
| #include <runtime/Error.h> |
| #include <runtime/FunctionPrototype.h> |
| #include <wtf/GetPtr.h> |
| |
| using namespace JSC; |
| |
| namespace WebCore { |
| |
| // Functions |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsCustomElementRegistryPrototypeFunctionDefine(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsCustomElementRegistryPrototypeFunctionGet(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsCustomElementRegistryPrototypeFunctionWhenDefined(JSC::ExecState*); |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsCustomElementRegistryConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSCustomElementRegistryConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSCustomElementRegistryPrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSCustomElementRegistryPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSCustomElementRegistryPrototype* ptr = new (NotNull, JSC::allocateCell<JSCustomElementRegistryPrototype>(vm.heap)) JSCustomElementRegistryPrototype(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: |
| JSCustomElementRegistryPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| typedef JSDOMConstructorNotConstructable<JSCustomElementRegistry> JSCustomElementRegistryConstructor; |
| |
| template<> JSValue JSCustomElementRegistryConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| { |
| UNUSED_PARAM(vm); |
| return globalObject.functionPrototype(); |
| } |
| |
| template<> void JSCustomElementRegistryConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| { |
| putDirect(vm, vm.propertyNames->prototype, JSCustomElementRegistry::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("CustomElementRegistry"))), ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum); |
| } |
| |
| template<> const ClassInfo JSCustomElementRegistryConstructor::s_info = { "CustomElementRegistry", &Base::s_info, 0, CREATE_METHOD_TABLE(JSCustomElementRegistryConstructor) }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSCustomElementRegistryPrototypeTableValues[] = |
| { |
| { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCustomElementRegistryConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCustomElementRegistryConstructor) } }, |
| { "define", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsCustomElementRegistryPrototypeFunctionDefine), (intptr_t) (2) } }, |
| { "get", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsCustomElementRegistryPrototypeFunctionGet), (intptr_t) (1) } }, |
| { "whenDefined", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsCustomElementRegistryPrototypeFunctionWhenDefined), (intptr_t) (1) } }, |
| }; |
| |
| const ClassInfo JSCustomElementRegistryPrototype::s_info = { "CustomElementRegistryPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSCustomElementRegistryPrototype) }; |
| |
| void JSCustomElementRegistryPrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSCustomElementRegistryPrototypeTableValues, *this); |
| } |
| |
| const ClassInfo JSCustomElementRegistry::s_info = { "CustomElementRegistry", &Base::s_info, 0, CREATE_METHOD_TABLE(JSCustomElementRegistry) }; |
| |
| JSCustomElementRegistry::JSCustomElementRegistry(Structure* structure, JSDOMGlobalObject& globalObject, Ref<CustomElementRegistry>&& impl) |
| : JSDOMWrapper<CustomElementRegistry>(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSCustomElementRegistry::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSCustomElementRegistryPrototype::create(vm, globalObject, JSCustomElementRegistryPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); |
| } |
| |
| JSObject* JSCustomElementRegistry::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSCustomElementRegistry>(vm, globalObject); |
| } |
| |
| void JSCustomElementRegistry::destroy(JSC::JSCell* cell) |
| { |
| JSCustomElementRegistry* thisObject = static_cast<JSCustomElementRegistry*>(cell); |
| thisObject->JSCustomElementRegistry::~JSCustomElementRegistry(); |
| } |
| |
| EncodedJSValue jsCustomElementRegistryConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSCustomElementRegistryPrototype* domObject = jsDynamicCast<JSCustomElementRegistryPrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) |
| return throwVMTypeError(state, throwScope); |
| return JSValue::encode(JSCustomElementRegistry::getConstructor(state->vm(), domObject->globalObject())); |
| } |
| |
| bool setJSCustomElementRegistryConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSCustomElementRegistryPrototype* domObject = jsDynamicCast<JSCustomElementRegistryPrototype*>(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); |
| } |
| |
| JSValue JSCustomElementRegistry::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| { |
| return getDOMConstructor<JSCustomElementRegistryConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsCustomElementRegistryPrototypeFunctionDefine(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| #if ENABLE(CUSTOM_ELEMENTS) |
| CustomElementReactionStack customElementReactionStack; |
| #endif |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSCustomElementRegistry*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "CustomElementRegistry", "define"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSCustomElementRegistry::info()); |
| return JSValue::encode(castedThis->define(*state)); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsCustomElementRegistryPrototypeFunctionGet(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSCustomElementRegistry*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "CustomElementRegistry", "get"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSCustomElementRegistry::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| auto name = state->uncheckedArgument(0).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| JSValue result = impl.get(WTFMove(name)); |
| return JSValue::encode(result); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsCustomElementRegistryPrototypeFunctionWhenDefined(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSCustomElementRegistry*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return createRejectedPromiseWithTypeError(*state, makeThisTypeErrorMessage("CustomElementRegistry", "whenDefined")); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSCustomElementRegistry::info()); |
| return JSValue::encode(castedThis->whenDefined(*state)); |
| } |
| |
| bool JSCustomElementRegistryOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) |
| { |
| UNUSED_PARAM(handle); |
| UNUSED_PARAM(visitor); |
| return false; |
| } |
| |
| void JSCustomElementRegistryOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| { |
| auto* jsCustomElementRegistry = jsCast<JSCustomElementRegistry*>(handle.slot()->asCell()); |
| auto& world = *static_cast<DOMWrapperWorld*>(context); |
| uncacheWrapper(world, &jsCustomElementRegistry->wrapped(), jsCustomElementRegistry); |
| } |
| |
| JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<CustomElementRegistry>&& impl) |
| { |
| #if COMPILER(CLANG) |
| // If you hit this failure the interface definition has the ImplementationLacksVTable |
| // attribute. You should remove that attribute. If the class has subclasses |
| // that may be passed through this toJS() function you should use the SkipVTableValidation |
| // attribute to CustomElementRegistry. |
| static_assert(!__is_polymorphic(CustomElementRegistry), "CustomElementRegistry is polymorphic but the IDL claims it is not"); |
| #endif |
| return createWrapper<CustomElementRegistry>(globalObject, WTFMove(impl)); |
| } |
| |
| JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, CustomElementRegistry& impl) |
| { |
| return wrap(state, globalObject, impl); |
| } |
| |
| CustomElementRegistry* JSCustomElementRegistry::toWrapped(JSC::JSValue value) |
| { |
| if (auto* wrapper = jsDynamicCast<JSCustomElementRegistry*>(value)) |
| return &wrapper->wrapped(); |
| return nullptr; |
| } |
| |
| } |
| |
| #endif // ENABLE(CUSTOM_ELEMENTS) |