PageRenderTime 129ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/src/qt/qtwebkit/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp

https://gitlab.com/x33n/phantomjs
C++ | 286 lines | 218 code | 40 blank | 28 comment | 28 complexity | 20e09c26f8282c2c48d3653d0d1a1f8c MD5 | raw file
  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. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public License
  13. along with this library; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. #include "config.h"
  18. #include "JSTestOverloadedConstructors.h"
  19. #include "ExceptionCode.h"
  20. #include "JSArrayBuffer.h"
  21. #include "JSArrayBufferView.h"
  22. #include "JSBlob.h"
  23. #include "JSDOMBinding.h"
  24. #include "TestOverloadedConstructors.h"
  25. #include <runtime/Error.h>
  26. #include <wtf/GetPtr.h>
  27. using namespace JSC;
  28. namespace WebCore {
  29. /* Hash table for constructor */
  30. static const HashTableValue JSTestOverloadedConstructorsTableValues[] =
  31. {
  32. { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestOverloadedConstructorsConstructor), (intptr_t)0, NoIntrinsic },
  33. { 0, 0, 0, 0, NoIntrinsic }
  34. };
  35. static const HashTable JSTestOverloadedConstructorsTable = { 2, 1, JSTestOverloadedConstructorsTableValues, 0 };
  36. /* Hash table for constructor */
  37. static const HashTableValue JSTestOverloadedConstructorsConstructorTableValues[] =
  38. {
  39. { 0, 0, 0, 0, NoIntrinsic }
  40. };
  41. static const HashTable JSTestOverloadedConstructorsConstructorTable = { 1, 0, JSTestOverloadedConstructorsConstructorTableValues, 0 };
  42. EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors1(ExecState* exec)
  43. {
  44. JSTestOverloadedConstructorsConstructor* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(exec->callee());
  45. if (exec->argumentCount() < 1)
  46. return throwVMError(exec, createNotEnoughArgumentsError(exec));
  47. ArrayBuffer* arrayBuffer(toArrayBuffer(exec->argument(0)));
  48. if (exec->hadException())
  49. return JSValue::encode(jsUndefined());
  50. RefPtr<TestOverloadedConstructors> object = TestOverloadedConstructors::create(arrayBuffer);
  51. return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
  52. }
  53. EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors2(ExecState* exec)
  54. {
  55. JSTestOverloadedConstructorsConstructor* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(exec->callee());
  56. if (exec->argumentCount() < 1)
  57. return throwVMError(exec, createNotEnoughArgumentsError(exec));
  58. ArrayBufferView* arrayBufferView(toArrayBufferView(exec->argument(0)));
  59. if (exec->hadException())
  60. return JSValue::encode(jsUndefined());
  61. RefPtr<TestOverloadedConstructors> object = TestOverloadedConstructors::create(arrayBufferView);
  62. return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
  63. }
  64. EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors3(ExecState* exec)
  65. {
  66. JSTestOverloadedConstructorsConstructor* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(exec->callee());
  67. if (exec->argumentCount() < 1)
  68. return throwVMError(exec, createNotEnoughArgumentsError(exec));
  69. Blob* blob(toBlob(exec->argument(0)));
  70. if (exec->hadException())
  71. return JSValue::encode(jsUndefined());
  72. RefPtr<TestOverloadedConstructors> object = TestOverloadedConstructors::create(blob);
  73. return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
  74. }
  75. EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors4(ExecState* exec)
  76. {
  77. JSTestOverloadedConstructorsConstructor* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(exec->callee());
  78. if (exec->argumentCount() < 1)
  79. return throwVMError(exec, createNotEnoughArgumentsError(exec));
  80. const String& string(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec));
  81. if (exec->hadException())
  82. return JSValue::encode(jsUndefined());
  83. RefPtr<TestOverloadedConstructors> object = TestOverloadedConstructors::create(string);
  84. return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
  85. }
  86. EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors(ExecState* exec)
  87. {
  88. size_t argsCount = exec->argumentCount();
  89. JSValue arg0(exec->argument(0));
  90. if ((argsCount == 1 && (arg0.isObject() && asObject(arg0)->inherits(&JSArrayBuffer::s_info))))
  91. return JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors1(exec);
  92. if ((argsCount == 1 && (arg0.isObject() && asObject(arg0)->inherits(&JSArrayBufferView::s_info))))
  93. return JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors2(exec);
  94. if ((argsCount == 1 && (arg0.isObject() && asObject(arg0)->inherits(&JSBlob::s_info))))
  95. return JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors3(exec);
  96. if (argsCount == 1)
  97. return JSTestOverloadedConstructorsConstructor::constructJSTestOverloadedConstructors4(exec);
  98. if (argsCount < 1)
  99. return throwVMError(exec, createNotEnoughArgumentsError(exec));
  100. return throwVMTypeError(exec);
  101. }
  102. const ClassInfo JSTestOverloadedConstructorsConstructor::s_info = { "TestOverloadedConstructorsConstructor", &Base::s_info, &JSTestOverloadedConstructorsConstructorTable, 0, CREATE_METHOD_TABLE(JSTestOverloadedConstructorsConstructor) };
  103. JSTestOverloadedConstructorsConstructor::JSTestOverloadedConstructorsConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
  104. : DOMConstructorObject(structure, globalObject)
  105. {
  106. }
  107. void JSTestOverloadedConstructorsConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
  108. {
  109. Base::finishCreation(exec->vm());
  110. ASSERT(inherits(&s_info));
  111. putDirect(exec->vm(), exec->propertyNames().prototype, JSTestOverloadedConstructorsPrototype::self(exec, globalObject), DontDelete | ReadOnly);
  112. putDirect(exec->vm(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
  113. }
  114. bool JSTestOverloadedConstructorsConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
  115. {
  116. return getStaticValueSlot<JSTestOverloadedConstructorsConstructor, JSDOMWrapper>(exec, &JSTestOverloadedConstructorsConstructorTable, jsCast<JSTestOverloadedConstructorsConstructor*>(cell), propertyName, slot);
  117. }
  118. bool JSTestOverloadedConstructorsConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
  119. {
  120. return getStaticValueDescriptor<JSTestOverloadedConstructorsConstructor, JSDOMWrapper>(exec, &JSTestOverloadedConstructorsConstructorTable, jsCast<JSTestOverloadedConstructorsConstructor*>(object), propertyName, descriptor);
  121. }
  122. ConstructType JSTestOverloadedConstructorsConstructor::getConstructData(JSCell*, ConstructData& constructData)
  123. {
  124. constructData.native.function = constructJSTestOverloadedConstructors;
  125. return ConstructTypeHost;
  126. }
  127. /* Hash table for prototype */
  128. static const HashTableValue JSTestOverloadedConstructorsPrototypeTableValues[] =
  129. {
  130. { 0, 0, 0, 0, NoIntrinsic }
  131. };
  132. static const HashTable JSTestOverloadedConstructorsPrototypeTable = { 1, 0, JSTestOverloadedConstructorsPrototypeTableValues, 0 };
  133. const ClassInfo JSTestOverloadedConstructorsPrototype::s_info = { "TestOverloadedConstructorsPrototype", &Base::s_info, &JSTestOverloadedConstructorsPrototypeTable, 0, CREATE_METHOD_TABLE(JSTestOverloadedConstructorsPrototype) };
  134. JSObject* JSTestOverloadedConstructorsPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
  135. {
  136. return getDOMPrototype<JSTestOverloadedConstructors>(exec, globalObject);
  137. }
  138. const ClassInfo JSTestOverloadedConstructors::s_info = { "TestOverloadedConstructors", &Base::s_info, &JSTestOverloadedConstructorsTable, 0 , CREATE_METHOD_TABLE(JSTestOverloadedConstructors) };
  139. JSTestOverloadedConstructors::JSTestOverloadedConstructors(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestOverloadedConstructors> impl)
  140. : JSDOMWrapper(structure, globalObject)
  141. , m_impl(impl.leakRef())
  142. {
  143. }
  144. void JSTestOverloadedConstructors::finishCreation(VM& vm)
  145. {
  146. Base::finishCreation(vm);
  147. ASSERT(inherits(&s_info));
  148. }
  149. JSObject* JSTestOverloadedConstructors::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
  150. {
  151. return JSTestOverloadedConstructorsPrototype::create(exec->vm(), globalObject, JSTestOverloadedConstructorsPrototype::createStructure(globalObject->vm(), globalObject, globalObject->objectPrototype()));
  152. }
  153. void JSTestOverloadedConstructors::destroy(JSC::JSCell* cell)
  154. {
  155. JSTestOverloadedConstructors* thisObject = static_cast<JSTestOverloadedConstructors*>(cell);
  156. thisObject->JSTestOverloadedConstructors::~JSTestOverloadedConstructors();
  157. }
  158. JSTestOverloadedConstructors::~JSTestOverloadedConstructors()
  159. {
  160. releaseImplIfNotNull();
  161. }
  162. bool JSTestOverloadedConstructors::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
  163. {
  164. JSTestOverloadedConstructors* thisObject = jsCast<JSTestOverloadedConstructors*>(cell);
  165. ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
  166. return getStaticValueSlot<JSTestOverloadedConstructors, Base>(exec, &JSTestOverloadedConstructorsTable, thisObject, propertyName, slot);
  167. }
  168. bool JSTestOverloadedConstructors::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
  169. {
  170. JSTestOverloadedConstructors* thisObject = jsCast<JSTestOverloadedConstructors*>(object);
  171. ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
  172. return getStaticValueDescriptor<JSTestOverloadedConstructors, Base>(exec, &JSTestOverloadedConstructorsTable, thisObject, propertyName, descriptor);
  173. }
  174. JSValue jsTestOverloadedConstructorsConstructor(ExecState* exec, JSValue slotBase, PropertyName)
  175. {
  176. JSTestOverloadedConstructors* domObject = jsCast<JSTestOverloadedConstructors*>(asObject(slotBase));
  177. return JSTestOverloadedConstructors::getConstructor(exec, domObject->globalObject());
  178. }
  179. JSValue JSTestOverloadedConstructors::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
  180. {
  181. return getDOMConstructor<JSTestOverloadedConstructorsConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject));
  182. }
  183. static inline bool isObservable(JSTestOverloadedConstructors* jsTestOverloadedConstructors)
  184. {
  185. if (jsTestOverloadedConstructors->hasCustomProperties())
  186. return true;
  187. return false;
  188. }
  189. bool JSTestOverloadedConstructorsOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
  190. {
  191. JSTestOverloadedConstructors* jsTestOverloadedConstructors = jsCast<JSTestOverloadedConstructors*>(handle.get().asCell());
  192. if (!isObservable(jsTestOverloadedConstructors))
  193. return false;
  194. UNUSED_PARAM(visitor);
  195. return false;
  196. }
  197. void JSTestOverloadedConstructorsOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
  198. {
  199. JSTestOverloadedConstructors* jsTestOverloadedConstructors = jsCast<JSTestOverloadedConstructors*>(handle.get().asCell());
  200. DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
  201. uncacheWrapper(world, jsTestOverloadedConstructors->impl(), jsTestOverloadedConstructors);
  202. jsTestOverloadedConstructors->releaseImpl();
  203. }
  204. #if ENABLE(BINDING_INTEGRITY)
  205. #if PLATFORM(WIN)
  206. #pragma warning(disable: 4483)
  207. extern "C" { extern void (*const __identifier("??_7TestOverloadedConstructors@WebCore@@6B@")[])(); }
  208. #else
  209. extern "C" { extern void* _ZTVN7WebCore26TestOverloadedConstructorsE[]; }
  210. #endif
  211. #endif
  212. JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestOverloadedConstructors* impl)
  213. {
  214. if (!impl)
  215. return jsNull();
  216. if (JSValue result = getExistingWrapper<JSTestOverloadedConstructors>(exec, impl))
  217. return result;
  218. #if ENABLE(BINDING_INTEGRITY)
  219. void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
  220. #if PLATFORM(WIN)
  221. void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestOverloadedConstructors@WebCore@@6B@"));
  222. #else
  223. void* expectedVTablePointer = &_ZTVN7WebCore26TestOverloadedConstructorsE[2];
  224. #if COMPILER(CLANG)
  225. // If this fails TestOverloadedConstructors does not have a vtable, so you need to add the
  226. // ImplementationLacksVTable attribute to the interface definition
  227. COMPILE_ASSERT(__is_polymorphic(TestOverloadedConstructors), TestOverloadedConstructors_is_not_polymorphic);
  228. #endif
  229. #endif
  230. // If you hit this assertion you either have a use after free bug, or
  231. // TestOverloadedConstructors has subclasses. If TestOverloadedConstructors has subclasses that get passed
  232. // to toJS() we currently require TestOverloadedConstructors you to opt out of binding hardening
  233. // by adding the SkipVTableValidation attribute to the interface IDL definition
  234. RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
  235. #endif
  236. ReportMemoryCost<TestOverloadedConstructors>::reportMemoryCost(exec, impl);
  237. return createNewWrapper<JSTestOverloadedConstructors>(exec, globalObject, impl);
  238. }
  239. TestOverloadedConstructors* toTestOverloadedConstructors(JSC::JSValue value)
  240. {
  241. return value.inherits(&JSTestOverloadedConstructors::s_info) ? jsCast<JSTestOverloadedConstructors*>(asObject(value))->impl() : 0;
  242. }
  243. }