1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* An enumeration of all possible element types in typed data. */
9 #ifndef js_ScalarType_h
10 #define js_ScalarType_h
12 #include "mozilla/Assertions.h" // MOZ_CRASH
14 #include <stddef.h> // size_t
20 // Scalar types that can appear in typed arrays.
21 // The enum values must be kept in sync with:
22 // * the TYPEDARRAY_KIND constants
23 // * the SCTAG_TYPED_ARRAY constants
24 // * JS_FOR_EACH_TYPEDARRAY
25 // * JS_FOR_PROTOTYPES_
26 // * JS_FOR_EACH_UNIQUE_SCALAR_TYPE_REPR_CTYPE
39 * Special type that is a uint8_t, but assignments are clamped to [0, 256).
40 * Treat the raw data type as a uint8_t.
48 * Types that don't have their own TypedArray equivalent, for now.
50 MaxTypedArrayViewType
,
56 static inline size_t byteSize(Type atype
) {
76 case MaxTypedArrayViewType
:
79 MOZ_CRASH("invalid scalar type");
82 static inline bool isSignedIntType(Type atype
) {
99 case MaxTypedArrayViewType
:
102 MOZ_CRASH("invalid scalar type");
105 static inline bool isBigIntType(Type atype
) {
122 case MaxTypedArrayViewType
:
125 MOZ_CRASH("invalid scalar type");
128 static inline const char* name(Type atype
) {
147 return "Uint8Clamped";
152 case MaxTypedArrayViewType
:
153 return "MaxTypedArrayViewType";
159 MOZ_CRASH("invalid scalar type");
162 static inline const char* byteSizeString(Type atype
) {
182 case MaxTypedArrayViewType
:
185 MOZ_CRASH("invalid scalar type");
188 } // namespace Scalar
192 #endif // js_ScalarType_h