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#include "JSTestEventConstructor.h" 23 24#include "JSDOMBinding.h" 25#include "JSDictionary.h" 26#include "ScriptExecutionContext.h" 27#include "TestEventConstructor.h" 28#include "URL.h" 29#include <runtime/Error.h> 30#include <runtime/JSString.h> 31#include <wtf/GetPtr.h> 32 33using namespace JSC; 34 35namespace WebCore { 36 37// Attributes 38 39JSC::EncodedJSValue jsTestEventConstructorAttr1(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName); 40JSC::EncodedJSValue jsTestEventConstructorAttr2(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName); 41JSC::EncodedJSValue jsTestEventConstructorConstructor(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName); 42 43class JSTestEventConstructorPrototype : public JSC::JSNonFinalObject { 44public: 45 typedef JSC::JSNonFinalObject Base; 46 static JSTestEventConstructorPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) 47 { 48 JSTestEventConstructorPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestEventConstructorPrototype>(vm.heap)) JSTestEventConstructorPrototype(vm, globalObject, structure); 49 ptr->finishCreation(vm); 50 return ptr; 51 } 52 53 DECLARE_INFO; 54 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) 55 { 56 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); 57 } 58 59private: 60 JSTestEventConstructorPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) 61 : JSC::JSNonFinalObject(vm, structure) 62 { 63 } 64 65 void finishCreation(JSC::VM&); 66}; 67 68class JSTestEventConstructorConstructor : public DOMConstructorObject { 69private: 70 JSTestEventConstructorConstructor(JSC::Structure*, JSDOMGlobalObject*); 71 void finishCreation(JSC::VM&, JSDOMGlobalObject*); 72 73public: 74 typedef DOMConstructorObject Base; 75 static JSTestEventConstructorConstructor* create(JSC::VM& vm, JSC::Structure* structure, JSDOMGlobalObject* globalObject) 76 { 77 JSTestEventConstructorConstructor* ptr = new (NotNull, JSC::allocateCell<JSTestEventConstructorConstructor>(vm.heap)) JSTestEventConstructorConstructor(structure, globalObject); 78 ptr->finishCreation(vm, globalObject); 79 return ptr; 80 } 81 82 DECLARE_INFO; 83 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) 84 { 85 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); 86 } 87protected: 88 static JSC::EncodedJSValue JSC_HOST_CALL constructJSTestEventConstructor(JSC::ExecState*); 89 static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); 90}; 91 92EncodedJSValue JSC_HOST_CALL JSTestEventConstructorConstructor::constructJSTestEventConstructor(ExecState* exec) 93{ 94 JSTestEventConstructorConstructor* jsConstructor = jsCast<JSTestEventConstructorConstructor*>(exec->callee()); 95 96 ScriptExecutionContext* executionContext = jsConstructor->scriptExecutionContext(); 97 if (!executionContext) 98 return throwVMError(exec, createReferenceError(exec, "Constructor associated execution context is unavailable")); 99 100 AtomicString eventType = exec->argument(0).toString(exec)->value(exec); 101 if (UNLIKELY(exec->hadException())) 102 return JSValue::encode(jsUndefined()); 103 104 TestEventConstructorInit eventInit; 105 106 JSValue initializerValue = exec->argument(1); 107 if (!initializerValue.isUndefinedOrNull()) { 108 // Given the above test, this will always yield an object. 109 JSObject* initializerObject = initializerValue.toObject(exec); 110 111 // Create the dictionary wrapper from the initializer object. 112 JSDictionary dictionary(exec, initializerObject); 113 114 // Attempt to fill in the EventInit. 115 if (!fillTestEventConstructorInit(eventInit, dictionary)) 116 return JSValue::encode(jsUndefined()); 117 } 118 119 RefPtr<TestEventConstructor> event = TestEventConstructor::create(eventType, eventInit); 120 return JSValue::encode(toJS(exec, jsConstructor->globalObject(), event.get())); 121} 122 123bool fillTestEventConstructorInit(TestEventConstructorInit& eventInit, JSDictionary& dictionary) 124{ 125 if (!dictionary.tryGetProperty("attr2", eventInit.attr2)) 126 return false; 127 return true; 128} 129 130const ClassInfo JSTestEventConstructorConstructor::s_info = { "TestEventConstructorConstructor", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSTestEventConstructorConstructor) }; 131 132JSTestEventConstructorConstructor::JSTestEventConstructorConstructor(Structure* structure, JSDOMGlobalObject* globalObject) 133 : DOMConstructorObject(structure, globalObject) 134{ 135} 136 137void JSTestEventConstructorConstructor::finishCreation(VM& vm, JSDOMGlobalObject* globalObject) 138{ 139 Base::finishCreation(vm); 140 ASSERT(inherits(info())); 141 putDirect(vm, vm.propertyNames->prototype, JSTestEventConstructor::getPrototype(vm, globalObject), DontDelete | ReadOnly); 142 putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontDelete | DontEnum); 143} 144 145ConstructType JSTestEventConstructorConstructor::getConstructData(JSCell*, ConstructData& constructData) 146{ 147 constructData.native.function = constructJSTestEventConstructor; 148 return ConstructTypeHost; 149} 150 151/* Hash table for prototype */ 152 153static const HashTableValue JSTestEventConstructorPrototypeTableValues[] = 154{ 155 { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestEventConstructorConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) }, 156 { "attr1", DontDelete | ReadOnly | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestEventConstructorAttr1), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) }, 157 { "attr2", DontDelete | ReadOnly | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestEventConstructorAttr2), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) }, 158}; 159 160const ClassInfo JSTestEventConstructorPrototype::s_info = { "TestEventConstructorPrototype", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSTestEventConstructorPrototype) }; 161 162void JSTestEventConstructorPrototype::finishCreation(VM& vm) 163{ 164 Base::finishCreation(vm); 165 reifyStaticProperties(vm, JSTestEventConstructorPrototypeTableValues, *this); 166} 167 168const ClassInfo JSTestEventConstructor::s_info = { "TestEventConstructor", &Base::s_info, 0, 0 , CREATE_METHOD_TABLE(JSTestEventConstructor) }; 169 170JSTestEventConstructor::JSTestEventConstructor(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestEventConstructor> impl) 171 : JSDOMWrapper(structure, globalObject) 172 , m_impl(impl.leakRef()) 173{ 174} 175 176JSObject* JSTestEventConstructor::createPrototype(VM& vm, JSGlobalObject* globalObject) 177{ 178 return JSTestEventConstructorPrototype::create(vm, globalObject, JSTestEventConstructorPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); 179} 180 181JSObject* JSTestEventConstructor::getPrototype(VM& vm, JSGlobalObject* globalObject) 182{ 183 return getDOMPrototype<JSTestEventConstructor>(vm, globalObject); 184} 185 186void JSTestEventConstructor::destroy(JSC::JSCell* cell) 187{ 188 JSTestEventConstructor* thisObject = static_cast<JSTestEventConstructor*>(cell); 189 thisObject->JSTestEventConstructor::~JSTestEventConstructor(); 190} 191 192JSTestEventConstructor::~JSTestEventConstructor() 193{ 194 releaseImplIfNotNull(); 195} 196 197EncodedJSValue jsTestEventConstructorAttr1(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName) 198{ 199 UNUSED_PARAM(exec); 200 UNUSED_PARAM(slotBase); 201 UNUSED_PARAM(thisValue); 202 JSTestEventConstructor* castedThis = jsDynamicCast<JSTestEventConstructor*>(JSValue::decode(thisValue)); 203 if (UNLIKELY(!castedThis)) { 204 if (jsDynamicCast<JSTestEventConstructorPrototype*>(slotBase)) 205 return reportDeprecatedGetterError(*exec, "TestEventConstructor", "attr1"); 206 return throwGetterTypeError(*exec, "TestEventConstructor", "attr1"); 207 } 208 TestEventConstructor& impl = castedThis->impl(); 209 JSValue result = jsStringWithCache(exec, impl.attr1()); 210 return JSValue::encode(result); 211} 212 213 214EncodedJSValue jsTestEventConstructorAttr2(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName) 215{ 216 UNUSED_PARAM(exec); 217 UNUSED_PARAM(slotBase); 218 UNUSED_PARAM(thisValue); 219 JSTestEventConstructor* castedThis = jsDynamicCast<JSTestEventConstructor*>(JSValue::decode(thisValue)); 220 if (UNLIKELY(!castedThis)) { 221 if (jsDynamicCast<JSTestEventConstructorPrototype*>(slotBase)) 222 return reportDeprecatedGetterError(*exec, "TestEventConstructor", "attr2"); 223 return throwGetterTypeError(*exec, "TestEventConstructor", "attr2"); 224 } 225 TestEventConstructor& impl = castedThis->impl(); 226 JSValue result = jsStringWithCache(exec, impl.attr2()); 227 return JSValue::encode(result); 228} 229 230 231EncodedJSValue jsTestEventConstructorConstructor(ExecState* exec, JSObject* baseValue, EncodedJSValue, PropertyName) 232{ 233 JSTestEventConstructorPrototype* domObject = jsDynamicCast<JSTestEventConstructorPrototype*>(baseValue); 234 if (!domObject) 235 return throwVMTypeError(exec); 236 return JSValue::encode(JSTestEventConstructor::getConstructor(exec->vm(), domObject->globalObject())); 237} 238 239JSValue JSTestEventConstructor::getConstructor(VM& vm, JSGlobalObject* globalObject) 240{ 241 return getDOMConstructor<JSTestEventConstructorConstructor>(vm, jsCast<JSDOMGlobalObject*>(globalObject)); 242} 243 244bool JSTestEventConstructorOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) 245{ 246 UNUSED_PARAM(handle); 247 UNUSED_PARAM(visitor); 248 return false; 249} 250 251void JSTestEventConstructorOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) 252{ 253 JSTestEventConstructor* jsTestEventConstructor = jsCast<JSTestEventConstructor*>(handle.slot()->asCell()); 254 DOMWrapperWorld& world = *static_cast<DOMWrapperWorld*>(context); 255 uncacheWrapper(world, &jsTestEventConstructor->impl(), jsTestEventConstructor); 256 jsTestEventConstructor->releaseImpl(); 257} 258 259#if ENABLE(BINDING_INTEGRITY) 260#if PLATFORM(WIN) 261#pragma warning(disable: 4483) 262extern "C" { extern void (*const __identifier("??_7TestEventConstructor@WebCore@@6B@")[])(); } 263#else 264extern "C" { extern void* _ZTVN7WebCore20TestEventConstructorE[]; } 265#endif 266#endif 267JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestEventConstructor* impl) 268{ 269 if (!impl) 270 return jsNull(); 271 if (JSValue result = getExistingWrapper<JSTestEventConstructor>(globalObject, impl)) 272 return result; 273 274#if ENABLE(BINDING_INTEGRITY) 275 void* actualVTablePointer = *(reinterpret_cast<void**>(impl)); 276#if PLATFORM(WIN) 277 void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestEventConstructor@WebCore@@6B@")); 278#else 279 void* expectedVTablePointer = &_ZTVN7WebCore20TestEventConstructorE[2]; 280#if COMPILER(CLANG) 281 // If this fails TestEventConstructor does not have a vtable, so you need to add the 282 // ImplementationLacksVTable attribute to the interface definition 283 COMPILE_ASSERT(__is_polymorphic(TestEventConstructor), TestEventConstructor_is_not_polymorphic); 284#endif 285#endif 286 // If you hit this assertion you either have a use after free bug, or 287 // TestEventConstructor has subclasses. If TestEventConstructor has subclasses that get passed 288 // to toJS() we currently require TestEventConstructor you to opt out of binding hardening 289 // by adding the SkipVTableValidation attribute to the interface IDL definition 290 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); 291#endif 292 return createNewWrapper<JSTestEventConstructor>(globalObject, impl); 293} 294 295TestEventConstructor* toTestEventConstructor(JSC::JSValue value) 296{ 297 if (auto* wrapper = jsDynamicCast<JSTestEventConstructor*>(value)) 298 return &wrapper->impl(); 299 return nullptr; 300} 301 302} 303