KHtml

kjs_arraytyped.cpp
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 2013 Bernd Buschinski <[email protected]>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser 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  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #include "kjs_arraytyped.h"
21 
22 namespace KJS
23 {
24 
25 // Define TypedArrayTypes
26 // type == the type, like int8_t
27 // TypeName == the readable Type, like Int8
28 // this will define
29 // ArrayBufferConstructorImpInt8
30 // ArrayBufferViewProtoInt8
31 // ArrayBufferViewInt8
32 
33 #define KJS_TYPEDARRAY_DEFINE(type,TypeName) \
34  JSObject* ArrayBufferConstructorImp##TypeName::construct(ExecState *exec, const List &args) \
35  { \
36  return ArrayBufferViewConstructorImp<type, ArrayBufferView##TypeName>::construct(exec, args); \
37  } \
38  \
39  Identifier* ArrayBufferViewProto##TypeName::name() \
40  { \
41  if (!s_name) \
42  s_name = new KJS::Identifier("[[" "ArrayBuffer"#TypeName ".prototype]]"); \
43  return s_name; \
44  } \
45  \
46  KJS::Identifier* ArrayBufferViewProto##TypeName::s_name = nullptr; \
47  const KJS::ClassInfo ArrayBufferViewProto##TypeName::info = { "ArrayBuffer"#TypeName , nullptr, &ArrayBufferViewProtoTable, nullptr }; \
48  \
49  KJS::JSObject *ArrayBufferViewProto##TypeName::self(KJS::ExecState *exec) { \
50  return KJS_CACHEGLOBALOBJECT_NS cacheGlobalObject<ArrayBufferViewProto##TypeName >(exec, *name()); \
51  } \
52  ArrayBufferViewProto##TypeName::ArrayBufferViewProto##TypeName(KJS::ExecState *exec) \
53  : ArrayBufferViewProto<type, ArrayBufferView##TypeName>(exec) \
54  {} \
55  \
56  const KJS::ClassInfo ArrayBufferView##TypeName::info = { "ArrayBuffer"#TypeName , nullptr, &ArrayBufferViewProtoTable, nullptr }; \
57  \
58  ArrayBufferView##TypeName::ArrayBufferView##TypeName(ExecState* exec, ArrayBuffer* buffer, size_t byteOffset, size_t byteLength) \
59  : ArrayBufferView<type, ArrayBufferViewProto##TypeName>(exec,buffer, byteOffset, byteLength) \
60  {}
61 
62 KJS_TYPEDARRAY_DEFINE(int8_t, Int8)
63 KJS_TYPEDARRAY_DEFINE(uint8_t, Uint8)
64 KJS_TYPEDARRAY_DEFINE(int16_t, Int16)
65 KJS_TYPEDARRAY_DEFINE(uint16_t, Uint16)
66 KJS_TYPEDARRAY_DEFINE(int32_t, Int32)
67 KJS_TYPEDARRAY_DEFINE(uint32_t, Uint32)
68 
69 KJS_TYPEDARRAY_DEFINE(float, Float32)
70 KJS_TYPEDARRAY_DEFINE(double, Float64)
71 
72 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:04 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.