/src/3rdparty/webkit/Source/WebCore/generated/JSInt32Array.cpp

https://bitbucket.org/ultra_iter/qt-vtl · C++ · 282 lines · 211 code · 48 blank · 23 comment · 12 complexity · b102e8bbad96104e177b7d92f366a5a2 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 "JSInt32Array.h"
  19. #include "ExceptionCode.h"
  20. #include "Int32Array.h"
  21. #include "JSDOMBinding.h"
  22. #include "JSInt32Array.h"
  23. #include <runtime/Error.h>
  24. #include <runtime/PropertyNameArray.h>
  25. #include <wtf/GetPtr.h>
  26. using namespace JSC;
  27. namespace WebCore {
  28. ASSERT_CLASS_FITS_IN_CELL(JSInt32Array);
  29. /* Hash table */
  30. #if ENABLE(JIT)
  31. #define THUNK_GENERATOR(generator) , generator
  32. #else
  33. #define THUNK_GENERATOR(generator)
  34. #endif
  35. static const HashTableValue JSInt32ArrayTableValues[3] =
  36. {
  37. { "length", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsInt32ArrayLength), (intptr_t)0 THUNK_GENERATOR(0) },
  38. { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsInt32ArrayConstructor), (intptr_t)0 THUNK_GENERATOR(0) },
  39. { 0, 0, 0, 0 THUNK_GENERATOR(0) }
  40. };
  41. #undef THUNK_GENERATOR
  42. static JSC_CONST_HASHTABLE HashTable JSInt32ArrayTable = { 5, 3, JSInt32ArrayTableValues, 0 };
  43. /* Hash table for constructor */
  44. #if ENABLE(JIT)
  45. #define THUNK_GENERATOR(generator) , generator
  46. #else
  47. #define THUNK_GENERATOR(generator)
  48. #endif
  49. static const HashTableValue JSInt32ArrayConstructorTableValues[2] =
  50. {
  51. { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsInt32ArrayBYTES_PER_ELEMENT), (intptr_t)0 THUNK_GENERATOR(0) },
  52. { 0, 0, 0, 0 THUNK_GENERATOR(0) }
  53. };
  54. #undef THUNK_GENERATOR
  55. static JSC_CONST_HASHTABLE HashTable JSInt32ArrayConstructorTable = { 2, 1, JSInt32ArrayConstructorTableValues, 0 };
  56. const ClassInfo JSInt32ArrayConstructor::s_info = { "Int32ArrayConstructor", &DOMConstructorObject::s_info, &JSInt32ArrayConstructorTable, 0 };
  57. JSInt32ArrayConstructor::JSInt32ArrayConstructor(ExecState* exec, Structure* structure, JSDOMGlobalObject* globalObject)
  58. : DOMConstructorObject(structure, globalObject)
  59. {
  60. ASSERT(inherits(&s_info));
  61. putDirect(exec->globalData(), exec->propertyNames().prototype, JSInt32ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly);
  62. }
  63. bool JSInt32ArrayConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
  64. {
  65. return getStaticValueSlot<JSInt32ArrayConstructor, JSDOMWrapper>(exec, &JSInt32ArrayConstructorTable, this, propertyName, slot);
  66. }
  67. bool JSInt32ArrayConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
  68. {
  69. return getStaticValueDescriptor<JSInt32ArrayConstructor, JSDOMWrapper>(exec, &JSInt32ArrayConstructorTable, this, propertyName, descriptor);
  70. }
  71. ConstructType JSInt32ArrayConstructor::getConstructData(ConstructData& constructData)
  72. {
  73. constructData.native.function = constructJSInt32Array;
  74. return ConstructTypeHost;
  75. }
  76. /* Hash table for prototype */
  77. #if ENABLE(JIT)
  78. #define THUNK_GENERATOR(generator) , generator
  79. #else
  80. #define THUNK_GENERATOR(generator)
  81. #endif
  82. static const HashTableValue JSInt32ArrayPrototypeTableValues[4] =
  83. {
  84. { "BYTES_PER_ELEMENT", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsInt32ArrayBYTES_PER_ELEMENT), (intptr_t)0 THUNK_GENERATOR(0) },
  85. { "subarray", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsInt32ArrayPrototypeFunctionSubarray), (intptr_t)2 THUNK_GENERATOR(0) },
  86. { "set", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsInt32ArrayPrototypeFunctionSet), (intptr_t)0 THUNK_GENERATOR(0) },
  87. { 0, 0, 0, 0 THUNK_GENERATOR(0) }
  88. };
  89. #undef THUNK_GENERATOR
  90. static JSC_CONST_HASHTABLE HashTable JSInt32ArrayPrototypeTable = { 8, 7, JSInt32ArrayPrototypeTableValues, 0 };
  91. static const HashTable* getJSInt32ArrayPrototypeTable(ExecState* exec)
  92. {
  93. return getHashTableForGlobalData(exec->globalData(), &JSInt32ArrayPrototypeTable);
  94. }
  95. const ClassInfo JSInt32ArrayPrototype::s_info = { "Int32ArrayPrototype", &JSC::JSObjectWithGlobalObject::s_info, 0, getJSInt32ArrayPrototypeTable };
  96. JSObject* JSInt32ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
  97. {
  98. return getDOMPrototype<JSInt32Array>(exec, globalObject);
  99. }
  100. bool JSInt32ArrayPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
  101. {
  102. return getStaticPropertySlot<JSInt32ArrayPrototype, JSObject>(exec, getJSInt32ArrayPrototypeTable(exec), this, propertyName, slot);
  103. }
  104. bool JSInt32ArrayPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
  105. {
  106. return getStaticPropertyDescriptor<JSInt32ArrayPrototype, JSObject>(exec, getJSInt32ArrayPrototypeTable(exec), this, propertyName, descriptor);
  107. }
  108. static const HashTable* getJSInt32ArrayTable(ExecState* exec)
  109. {
  110. return getHashTableForGlobalData(exec->globalData(), &JSInt32ArrayTable);
  111. }
  112. const ClassInfo JSInt32Array::s_info = { "Int32Array", &JSArrayBufferView::s_info, 0, getJSInt32ArrayTable };
  113. JSInt32Array::JSInt32Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<Int32Array> impl)
  114. : JSArrayBufferView(structure, globalObject, impl)
  115. {
  116. ASSERT(inherits(&s_info));
  117. }
  118. JSObject* JSInt32Array::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
  119. {
  120. return new (exec) JSInt32ArrayPrototype(exec->globalData(), globalObject, JSInt32ArrayPrototype::createStructure(exec->globalData(), JSArrayBufferViewPrototype::self(exec, globalObject)));
  121. }
  122. bool JSInt32Array::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
  123. {
  124. bool ok;
  125. unsigned index = propertyName.toUInt32(ok);
  126. if (ok && index < static_cast<Int32Array*>(impl())->length()) {
  127. slot.setValue(getByIndex(exec, index));
  128. return true;
  129. }
  130. return getStaticValueSlot<JSInt32Array, Base>(exec, getJSInt32ArrayTable(exec), this, propertyName, slot);
  131. }
  132. bool JSInt32Array::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
  133. {
  134. bool ok;
  135. unsigned index = propertyName.toUInt32(ok);
  136. if (ok && index < static_cast<Int32Array*>(impl())->length()) {
  137. descriptor.setDescriptor(getByIndex(exec, index), DontDelete);
  138. return true;
  139. }
  140. return getStaticValueDescriptor<JSInt32Array, Base>(exec, getJSInt32ArrayTable(exec), this, propertyName, descriptor);
  141. }
  142. bool JSInt32Array::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
  143. {
  144. if (propertyName < static_cast<Int32Array*>(impl())->length()) {
  145. slot.setValue(getByIndex(exec, propertyName));
  146. return true;
  147. }
  148. return getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);
  149. }
  150. JSValue jsInt32ArrayLength(ExecState* exec, JSValue slotBase, const Identifier&)
  151. {
  152. JSInt32Array* castedThis = static_cast<JSInt32Array*>(asObject(slotBase));
  153. UNUSED_PARAM(exec);
  154. Int32Array* imp = static_cast<Int32Array*>(castedThis->impl());
  155. JSValue result = jsNumber(imp->length());
  156. return result;
  157. }
  158. JSValue jsInt32ArrayConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
  159. {
  160. JSInt32Array* domObject = static_cast<JSInt32Array*>(asObject(slotBase));
  161. return JSInt32Array::getConstructor(exec, domObject->globalObject());
  162. }
  163. void JSInt32Array::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
  164. {
  165. bool ok;
  166. unsigned index = propertyName.toUInt32(ok);
  167. if (ok) {
  168. indexSetter(exec, index, value);
  169. return;
  170. }
  171. Base::put(exec, propertyName, value, slot);
  172. }
  173. void JSInt32Array::put(ExecState* exec, unsigned propertyName, JSValue value)
  174. {
  175. indexSetter(exec, propertyName, value);
  176. return;
  177. }
  178. void JSInt32Array::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
  179. {
  180. for (unsigned i = 0; i < static_cast<Int32Array*>(impl())->length(); ++i)
  181. propertyNames.add(Identifier::from(exec, i));
  182. Base::getOwnPropertyNames(exec, propertyNames, mode);
  183. }
  184. JSValue JSInt32Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
  185. {
  186. return getDOMConstructor<JSInt32ArrayConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
  187. }
  188. EncodedJSValue JSC_HOST_CALL jsInt32ArrayPrototypeFunctionSubarray(ExecState* exec)
  189. {
  190. JSValue thisValue = exec->hostThisValue();
  191. if (!thisValue.inherits(&JSInt32Array::s_info))
  192. return throwVMTypeError(exec);
  193. JSInt32Array* castedThis = static_cast<JSInt32Array*>(asObject(thisValue));
  194. Int32Array* imp = static_cast<Int32Array*>(castedThis->impl());
  195. int start(exec->argument(0).toInt32(exec));
  196. if (exec->hadException())
  197. return JSValue::encode(jsUndefined());
  198. int argsCount = exec->argumentCount();
  199. if (argsCount <= 1) {
  200. JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->subarray(start)));
  201. return JSValue::encode(result);
  202. }
  203. int end(exec->argument(1).toInt32(exec));
  204. if (exec->hadException())
  205. return JSValue::encode(jsUndefined());
  206. JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->subarray(start, end)));
  207. return JSValue::encode(result);
  208. }
  209. EncodedJSValue JSC_HOST_CALL jsInt32ArrayPrototypeFunctionSet(ExecState* exec)
  210. {
  211. JSValue thisValue = exec->hostThisValue();
  212. if (!thisValue.inherits(&JSInt32Array::s_info))
  213. return throwVMTypeError(exec);
  214. JSInt32Array* castedThis = static_cast<JSInt32Array*>(asObject(thisValue));
  215. return JSValue::encode(castedThis->set(exec));
  216. }
  217. // Constant getters
  218. JSValue jsInt32ArrayBYTES_PER_ELEMENT(ExecState* exec, JSValue, const Identifier&)
  219. {
  220. UNUSED_PARAM(exec);
  221. return jsNumber(static_cast<int>(4));
  222. }
  223. JSValue JSInt32Array::getByIndex(ExecState*, unsigned index)
  224. {
  225. return jsNumber(static_cast<Int32Array*>(impl())->item(index));
  226. }
  227. Int32Array* toInt32Array(JSC::JSValue value)
  228. {
  229. return value.inherits(&JSInt32Array::s_info) ? static_cast<JSInt32Array*>(asObject(value))->impl() : 0;
  230. }
  231. }