File indexing completed on 2023-10-03 03:17:37
0001 /* 0002 * This file is part of the KDE libraries 0003 * Copyright (C) 2013 Bernd Buschinski <b.buschinski@googlemail.com> 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Lesser General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Lesser General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Lesser General Public 0016 * License along with this library; if not, write to the Free Software 0017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 0018 */ 0019 0020 #include "kjs_arraytyped.h" 0021 0022 namespace KJS 0023 { 0024 0025 // Define TypedArrayTypes 0026 // type == the type, like int8_t 0027 // TypeName == the readable Type, like Int8 0028 // this will define 0029 // ArrayBufferConstructorImpInt8 0030 // ArrayBufferViewProtoInt8 0031 // ArrayBufferViewInt8 0032 0033 #define KJS_TYPEDARRAY_DEFINE(type,TypeName) \ 0034 JSObject* ArrayBufferConstructorImp##TypeName::construct(ExecState *exec, const List &args) \ 0035 { \ 0036 return ArrayBufferViewConstructorImp<type, ArrayBufferView##TypeName>::construct(exec, args); \ 0037 } \ 0038 \ 0039 Identifier* ArrayBufferViewProto##TypeName::name() \ 0040 { \ 0041 if (!s_name) \ 0042 s_name = new KJS::Identifier("[[" "ArrayBuffer"#TypeName ".prototype]]"); \ 0043 return s_name; \ 0044 } \ 0045 \ 0046 KJS::Identifier* ArrayBufferViewProto##TypeName::s_name = nullptr; \ 0047 const KJS::ClassInfo ArrayBufferViewProto##TypeName::info = { "ArrayBuffer"#TypeName , nullptr, &ArrayBufferViewProtoTable, nullptr }; \ 0048 \ 0049 KJS::JSObject *ArrayBufferViewProto##TypeName::self(KJS::ExecState *exec) { \ 0050 return KJS_CACHEGLOBALOBJECT_NS cacheGlobalObject<ArrayBufferViewProto##TypeName >(exec, *name()); \ 0051 } \ 0052 ArrayBufferViewProto##TypeName::ArrayBufferViewProto##TypeName(KJS::ExecState *exec) \ 0053 : ArrayBufferViewProto<type, ArrayBufferView##TypeName>(exec) \ 0054 {} \ 0055 \ 0056 const KJS::ClassInfo ArrayBufferView##TypeName::info = { "ArrayBuffer"#TypeName , nullptr, &ArrayBufferViewProtoTable, nullptr }; \ 0057 \ 0058 ArrayBufferView##TypeName::ArrayBufferView##TypeName(ExecState* exec, ArrayBuffer* buffer, size_t byteOffset, size_t byteLength) \ 0059 : ArrayBufferView<type, ArrayBufferViewProto##TypeName>(exec,buffer, byteOffset, byteLength) \ 0060 {} 0061 0062 KJS_TYPEDARRAY_DEFINE(int8_t, Int8) 0063 KJS_TYPEDARRAY_DEFINE(uint8_t, Uint8) 0064 KJS_TYPEDARRAY_DEFINE(int16_t, Int16) 0065 KJS_TYPEDARRAY_DEFINE(uint16_t, Uint16) 0066 KJS_TYPEDARRAY_DEFINE(int32_t, Int32) 0067 KJS_TYPEDARRAY_DEFINE(uint32_t, Uint32) 0068 0069 KJS_TYPEDARRAY_DEFINE(float, Float32) 0070 KJS_TYPEDARRAY_DEFINE(double, Float64) 0071 0072 }