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(Condition1) || ENABLE(Condition2) 24 25#include "JSTestSerializedScriptValueInterface.h" 26 27#include "JSDOMBinding.h" 28#include "JSMessagePort.h" 29#include "MessagePort.h" 30#include "ScriptExecutionContext.h" 31#include "SerializedScriptValue.h" 32#include "TestSerializedScriptValueInterface.h" 33#include <runtime/JSArray.h> 34#include <wtf/GetPtr.h> 35 36using namespace JSC; 37 38namespace WebCore { 39 40// Attributes 41 42JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceValue(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName); 43void setJSTestSerializedScriptValueInterfaceValue(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::EncodedJSValue); 44JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceReadonlyValue(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName); 45JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceCachedValue(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName); 46void setJSTestSerializedScriptValueInterfaceCachedValue(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::EncodedJSValue); 47JSC::EncodedJSValue jsTestSerializedScriptValueInterfacePorts(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName); 48JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceCachedReadonlyValue(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName); 49JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceConstructor(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName); 50 51class JSTestSerializedScriptValueInterfacePrototype : public JSC::JSNonFinalObject { 52public: 53 typedef JSC::JSNonFinalObject Base; 54 static JSTestSerializedScriptValueInterfacePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) 55 { 56 JSTestSerializedScriptValueInterfacePrototype* ptr = new (NotNull, JSC::allocateCell<JSTestSerializedScriptValueInterfacePrototype>(vm.heap)) JSTestSerializedScriptValueInterfacePrototype(vm, globalObject, structure); 57 ptr->finishCreation(vm); 58 return ptr; 59 } 60 61 DECLARE_INFO; 62 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) 63 { 64 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); 65 } 66 67private: 68 JSTestSerializedScriptValueInterfacePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) 69 : JSC::JSNonFinalObject(vm, structure) 70 { 71 } 72 73 void finishCreation(JSC::VM&); 74}; 75 76class JSTestSerializedScriptValueInterfaceConstructor : public DOMConstructorObject { 77private: 78 JSTestSerializedScriptValueInterfaceConstructor(JSC::Structure*, JSDOMGlobalObject*); 79 void finishCreation(JSC::VM&, JSDOMGlobalObject*); 80 81public: 82 typedef DOMConstructorObject Base; 83 static JSTestSerializedScriptValueInterfaceConstructor* create(JSC::VM& vm, JSC::Structure* structure, JSDOMGlobalObject* globalObject) 84 { 85 JSTestSerializedScriptValueInterfaceConstructor* ptr = new (NotNull, JSC::allocateCell<JSTestSerializedScriptValueInterfaceConstructor>(vm.heap)) JSTestSerializedScriptValueInterfaceConstructor(structure, globalObject); 86 ptr->finishCreation(vm, globalObject); 87 return ptr; 88 } 89 90 DECLARE_INFO; 91 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) 92 { 93 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); 94 } 95}; 96 97const ClassInfo JSTestSerializedScriptValueInterfaceConstructor::s_info = { "TestSerializedScriptValueInterfaceConstructor", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterfaceConstructor) }; 98 99JSTestSerializedScriptValueInterfaceConstructor::JSTestSerializedScriptValueInterfaceConstructor(Structure* structure, JSDOMGlobalObject* globalObject) 100 : DOMConstructorObject(structure, globalObject) 101{ 102} 103 104void JSTestSerializedScriptValueInterfaceConstructor::finishCreation(VM& vm, JSDOMGlobalObject* globalObject) 105{ 106 Base::finishCreation(vm); 107 ASSERT(inherits(info())); 108 putDirect(vm, vm.propertyNames->prototype, JSTestSerializedScriptValueInterface::getPrototype(vm, globalObject), DontDelete | ReadOnly); 109 putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum); 110} 111 112/* Hash table for prototype */ 113 114static const HashTableValue JSTestSerializedScriptValueInterfacePrototypeTableValues[] = 115{ 116 { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) }, 117 { "value", DontDelete | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializedScriptValueInterfaceValue) }, 118 { "readonlyValue", DontDelete | ReadOnly | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceReadonlyValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) }, 119 { "cachedValue", DontDelete | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceCachedValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializedScriptValueInterfaceCachedValue) }, 120 { "ports", DontDelete | ReadOnly | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfacePorts), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) }, 121 { "cachedReadonlyValue", DontDelete | ReadOnly | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceCachedReadonlyValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) }, 122}; 123 124const ClassInfo JSTestSerializedScriptValueInterfacePrototype::s_info = { "TestSerializedScriptValueInterfacePrototype", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterfacePrototype) }; 125 126void JSTestSerializedScriptValueInterfacePrototype::finishCreation(VM& vm) 127{ 128 Base::finishCreation(vm); 129 reifyStaticProperties(vm, JSTestSerializedScriptValueInterfacePrototypeTableValues, *this); 130} 131 132const ClassInfo JSTestSerializedScriptValueInterface::s_info = { "TestSerializedScriptValueInterface", &Base::s_info, 0, 0 , CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterface) }; 133 134JSTestSerializedScriptValueInterface::JSTestSerializedScriptValueInterface(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestSerializedScriptValueInterface> impl) 135 : JSDOMWrapper(structure, globalObject) 136 , m_impl(impl.leakRef()) 137{ 138} 139 140JSObject* JSTestSerializedScriptValueInterface::createPrototype(VM& vm, JSGlobalObject* globalObject) 141{ 142 return JSTestSerializedScriptValueInterfacePrototype::create(vm, globalObject, JSTestSerializedScriptValueInterfacePrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); 143} 144 145JSObject* JSTestSerializedScriptValueInterface::getPrototype(VM& vm, JSGlobalObject* globalObject) 146{ 147 return getDOMPrototype<JSTestSerializedScriptValueInterface>(vm, globalObject); 148} 149 150void JSTestSerializedScriptValueInterface::destroy(JSC::JSCell* cell) 151{ 152 JSTestSerializedScriptValueInterface* thisObject = static_cast<JSTestSerializedScriptValueInterface*>(cell); 153 thisObject->JSTestSerializedScriptValueInterface::~JSTestSerializedScriptValueInterface(); 154} 155 156JSTestSerializedScriptValueInterface::~JSTestSerializedScriptValueInterface() 157{ 158 releaseImplIfNotNull(); 159} 160 161EncodedJSValue jsTestSerializedScriptValueInterfaceValue(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName) 162{ 163 UNUSED_PARAM(exec); 164 UNUSED_PARAM(slotBase); 165 UNUSED_PARAM(thisValue); 166 JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue)); 167 if (UNLIKELY(!castedThis)) { 168 if (jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(slotBase)) 169 return reportDeprecatedGetterError(*exec, "TestSerializedScriptValueInterface", "value"); 170 return throwGetterTypeError(*exec, "TestSerializedScriptValueInterface", "value"); 171 } 172 TestSerializedScriptValueInterface& impl = castedThis->impl(); 173 JSValue result = impl.value() ? impl.value()->deserialize(exec, castedThis->globalObject(), 0) : jsNull(); 174 return JSValue::encode(result); 175} 176 177 178EncodedJSValue jsTestSerializedScriptValueInterfaceReadonlyValue(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName) 179{ 180 UNUSED_PARAM(exec); 181 UNUSED_PARAM(slotBase); 182 UNUSED_PARAM(thisValue); 183 JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue)); 184 if (UNLIKELY(!castedThis)) { 185 if (jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(slotBase)) 186 return reportDeprecatedGetterError(*exec, "TestSerializedScriptValueInterface", "readonlyValue"); 187 return throwGetterTypeError(*exec, "TestSerializedScriptValueInterface", "readonlyValue"); 188 } 189 TestSerializedScriptValueInterface& impl = castedThis->impl(); 190 JSValue result = impl.readonlyValue() ? impl.readonlyValue()->deserialize(exec, castedThis->globalObject(), 0) : jsNull(); 191 return JSValue::encode(result); 192} 193 194 195EncodedJSValue jsTestSerializedScriptValueInterfaceCachedValue(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName) 196{ 197 UNUSED_PARAM(exec); 198 UNUSED_PARAM(slotBase); 199 UNUSED_PARAM(thisValue); 200 JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue)); 201 if (UNLIKELY(!castedThis)) { 202 if (jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(slotBase)) 203 return reportDeprecatedGetterError(*exec, "TestSerializedScriptValueInterface", "cachedValue"); 204 return throwGetterTypeError(*exec, "TestSerializedScriptValueInterface", "cachedValue"); 205 } 206 if (JSValue cachedValue = castedThis->m_cachedValue.get()) 207 return JSValue::encode(cachedValue); 208 TestSerializedScriptValueInterface& impl = castedThis->impl(); 209 JSValue result = impl.cachedValue() ? impl.cachedValue()->deserialize(exec, castedThis->globalObject(), 0) : jsNull(); 210 castedThis->m_cachedValue.set(exec->vm(), castedThis, result); 211 return JSValue::encode(result); 212} 213 214 215EncodedJSValue jsTestSerializedScriptValueInterfacePorts(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName) 216{ 217 UNUSED_PARAM(exec); 218 UNUSED_PARAM(slotBase); 219 UNUSED_PARAM(thisValue); 220 JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue)); 221 if (UNLIKELY(!castedThis)) { 222 if (jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(slotBase)) 223 return reportDeprecatedGetterError(*exec, "TestSerializedScriptValueInterface", "ports"); 224 return throwGetterTypeError(*exec, "TestSerializedScriptValueInterface", "ports"); 225 } 226 TestSerializedScriptValueInterface& impl = castedThis->impl(); 227 JSValue result = jsArray(exec, castedThis->globalObject(), impl.ports()); 228 return JSValue::encode(result); 229} 230 231 232EncodedJSValue jsTestSerializedScriptValueInterfaceCachedReadonlyValue(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName) 233{ 234 UNUSED_PARAM(exec); 235 UNUSED_PARAM(slotBase); 236 UNUSED_PARAM(thisValue); 237 JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue)); 238 if (UNLIKELY(!castedThis)) { 239 if (jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(slotBase)) 240 return reportDeprecatedGetterError(*exec, "TestSerializedScriptValueInterface", "cachedReadonlyValue"); 241 return throwGetterTypeError(*exec, "TestSerializedScriptValueInterface", "cachedReadonlyValue"); 242 } 243 if (JSValue cachedValue = castedThis->m_cachedReadonlyValue.get()) 244 return JSValue::encode(cachedValue); 245 TestSerializedScriptValueInterface& impl = castedThis->impl(); 246 JSValue result = impl.cachedReadonlyValue() ? impl.cachedReadonlyValue()->deserialize(exec, castedThis->globalObject(), 0) : jsNull(); 247 castedThis->m_cachedReadonlyValue.set(exec->vm(), castedThis, result); 248 return JSValue::encode(result); 249} 250 251 252EncodedJSValue jsTestSerializedScriptValueInterfaceConstructor(ExecState* exec, JSObject* baseValue, EncodedJSValue, PropertyName) 253{ 254 JSTestSerializedScriptValueInterfacePrototype* domObject = jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(baseValue); 255 if (!domObject) 256 return throwVMTypeError(exec); 257 return JSValue::encode(JSTestSerializedScriptValueInterface::getConstructor(exec->vm(), domObject->globalObject())); 258} 259 260void setJSTestSerializedScriptValueInterfaceValue(ExecState* exec, JSObject* baseObject, EncodedJSValue thisValue, EncodedJSValue encodedValue) 261{ 262 JSValue value = JSValue::decode(encodedValue); 263 UNUSED_PARAM(baseObject); 264 JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue)); 265 if (UNLIKELY(!castedThis)) { 266 if (jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(JSValue::decode(thisValue))) 267 reportDeprecatedSetterError(*exec, "TestSerializedScriptValueInterface", "value"); 268 else 269 throwSetterTypeError(*exec, "TestSerializedScriptValueInterface", "value"); 270 return; 271 } 272 TestSerializedScriptValueInterface& impl = castedThis->impl(); 273 RefPtr<SerializedScriptValue> nativeValue(SerializedScriptValue::create(exec, value, 0, 0)); 274 if (UNLIKELY(exec->hadException())) 275 return; 276 impl.setValue(nativeValue); 277} 278 279 280void setJSTestSerializedScriptValueInterfaceCachedValue(ExecState* exec, JSObject* baseObject, EncodedJSValue thisValue, EncodedJSValue encodedValue) 281{ 282 JSValue value = JSValue::decode(encodedValue); 283 UNUSED_PARAM(baseObject); 284 JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue)); 285 if (UNLIKELY(!castedThis)) { 286 if (jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(JSValue::decode(thisValue))) 287 reportDeprecatedSetterError(*exec, "TestSerializedScriptValueInterface", "cachedValue"); 288 else 289 throwSetterTypeError(*exec, "TestSerializedScriptValueInterface", "cachedValue"); 290 return; 291 } 292 TestSerializedScriptValueInterface& impl = castedThis->impl(); 293 RefPtr<SerializedScriptValue> nativeValue(SerializedScriptValue::create(exec, value, 0, 0)); 294 if (UNLIKELY(exec->hadException())) 295 return; 296 impl.setCachedValue(nativeValue); 297} 298 299 300JSValue JSTestSerializedScriptValueInterface::getConstructor(VM& vm, JSGlobalObject* globalObject) 301{ 302 return getDOMConstructor<JSTestSerializedScriptValueInterfaceConstructor>(vm, jsCast<JSDOMGlobalObject*>(globalObject)); 303} 304 305void JSTestSerializedScriptValueInterface::visitChildren(JSCell* cell, SlotVisitor& visitor) 306{ 307 JSTestSerializedScriptValueInterface* thisObject = jsCast<JSTestSerializedScriptValueInterface*>(cell); 308 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 309 COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag); 310 ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren()); 311 Base::visitChildren(thisObject, visitor); 312 visitor.append(&thisObject->m_cachedValue); 313 visitor.append(&thisObject->m_cachedReadonlyValue); 314} 315 316bool JSTestSerializedScriptValueInterfaceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) 317{ 318 UNUSED_PARAM(handle); 319 UNUSED_PARAM(visitor); 320 return false; 321} 322 323void JSTestSerializedScriptValueInterfaceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) 324{ 325 JSTestSerializedScriptValueInterface* jsTestSerializedScriptValueInterface = jsCast<JSTestSerializedScriptValueInterface*>(handle.slot()->asCell()); 326 DOMWrapperWorld& world = *static_cast<DOMWrapperWorld*>(context); 327 uncacheWrapper(world, &jsTestSerializedScriptValueInterface->impl(), jsTestSerializedScriptValueInterface); 328 jsTestSerializedScriptValueInterface->releaseImpl(); 329} 330 331#if ENABLE(BINDING_INTEGRITY) 332#if PLATFORM(WIN) 333#pragma warning(disable: 4483) 334extern "C" { extern void (*const __identifier("??_7TestSerializedScriptValueInterface@WebCore@@6B@")[])(); } 335#else 336extern "C" { extern void* _ZTVN7WebCore34TestSerializedScriptValueInterfaceE[]; } 337#endif 338#endif 339JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestSerializedScriptValueInterface* impl) 340{ 341 if (!impl) 342 return jsNull(); 343 if (JSValue result = getExistingWrapper<JSTestSerializedScriptValueInterface>(globalObject, impl)) 344 return result; 345 346#if ENABLE(BINDING_INTEGRITY) 347 void* actualVTablePointer = *(reinterpret_cast<void**>(impl)); 348#if PLATFORM(WIN) 349 void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestSerializedScriptValueInterface@WebCore@@6B@")); 350#else 351 void* expectedVTablePointer = &_ZTVN7WebCore34TestSerializedScriptValueInterfaceE[2]; 352#if COMPILER(CLANG) 353 // If this fails TestSerializedScriptValueInterface does not have a vtable, so you need to add the 354 // ImplementationLacksVTable attribute to the interface definition 355 COMPILE_ASSERT(__is_polymorphic(TestSerializedScriptValueInterface), TestSerializedScriptValueInterface_is_not_polymorphic); 356#endif 357#endif 358 // If you hit this assertion you either have a use after free bug, or 359 // TestSerializedScriptValueInterface has subclasses. If TestSerializedScriptValueInterface has subclasses that get passed 360 // to toJS() we currently require TestSerializedScriptValueInterface you to opt out of binding hardening 361 // by adding the SkipVTableValidation attribute to the interface IDL definition 362 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); 363#endif 364 return createNewWrapper<JSTestSerializedScriptValueInterface>(globalObject, impl); 365} 366 367TestSerializedScriptValueInterface* toTestSerializedScriptValueInterface(JSC::JSValue value) 368{ 369 if (auto* wrapper = jsDynamicCast<JSTestSerializedScriptValueInterface*>(value)) 370 return &wrapper->impl(); 371 return nullptr; 372} 373 374} 375 376#endif // ENABLE(Condition1) || ENABLE(Condition2) 377