KHtml

kjs_arraytyped.h
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 #ifndef KJS_ARRAYTYPES_H
21 #define KJS_ARRAYTYPES_H
22 
23 #include "kjs_arraybufferview.h"
24 
25 namespace KJS
26 {
27 
28 // Declare a TypedArray Class, type == the type, for example int8_t
29 // and TypeName is a readable name for the Type, for example Int8.
30 // Use this Macro to declare all typed arrays types.
31 
32 #define KJS_TYPEDARRAY_DECLARE(type,TypeName) \
33  class ArrayBufferViewProto##TypeName; \
34  class ArrayBufferView##TypeName : public ArrayBufferView<type, ArrayBufferViewProto##TypeName> { \
35  public: \
36  explicit ArrayBufferView##TypeName(ExecState* exec, ArrayBuffer* buffer, size_t byteOffset, size_t byteLength); \
37  virtual ~ArrayBufferView##TypeName() {}; \
38  \
39  static const ClassInfo info; \
40  virtual const ClassInfo* classInfo() const { return &info; } \
41  }; \
42  \
43  class ArrayBufferConstructorImp##TypeName : public ArrayBufferViewConstructorImp<type, ArrayBufferView##TypeName> \
44  { \
45  public: \
46  ArrayBufferConstructorImp##TypeName(ExecState *exec, DOM::DocumentImpl* d) \
47  : ArrayBufferViewConstructorImp<type, ArrayBufferView##TypeName>(exec, d) \
48  { } \
49  using KJS::JSObject::construct; \
50  virtual JSObject* construct(ExecState *exec, const List &args); \
51  }; \
52  \
53  class ArrayBufferViewProto##TypeName : public ArrayBufferViewProto<type, ArrayBufferView##TypeName> \
54  { \
55  friend KJS::JSObject* KJS_CACHEGLOBALOBJECT_NS cacheGlobalObject<ArrayBufferViewProto##TypeName>(KJS::ExecState *exec, const KJS::Identifier &propertyName); \
56  public: \
57  virtual const KJS::ClassInfo *classInfo() const { return &info; } \
58  static const KJS::ClassInfo info; \
59  static KJS::JSObject *self(KJS::ExecState *exec); \
60  protected: \
61  ArrayBufferViewProto##TypeName(KJS::ExecState *exec); \
62  static KJS::Identifier* s_name; \
63  static KJS::Identifier* name(); \
64  };
65 
66 KJS_TYPEDARRAY_DECLARE(int8_t, Int8)
67 KJS_TYPEDARRAY_DECLARE(uint8_t, Uint8)
68 KJS_TYPEDARRAY_DECLARE(int16_t, Int16)
69 KJS_TYPEDARRAY_DECLARE(uint16_t, Uint16)
70 KJS_TYPEDARRAY_DECLARE(int32_t, Int32)
71 KJS_TYPEDARRAY_DECLARE(uint32_t, Uint32)
72 
73 KJS_TYPEDARRAY_DECLARE(float, Float32)
74 KJS_TYPEDARRAY_DECLARE(double, Float64)
75 
76 #undef KJS_TYPEDARRAY_DECLARE
77 
78 }
79 
80 #endif //KJS_ARRAYTYPES_H
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.