js/src/builtin/TypedObjectConstants.h

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:11b8262957f5
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=8 sts=4 et sw=4 tw=99:
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/. */
6
7 // Specialized .h file to be used by both JS and C++ code.
8
9 #ifndef builtin_TypedObjectConstants_h
10 #define builtin_TypedObjectConstants_h
11
12 ///////////////////////////////////////////////////////////////////////////
13 // Slots for typed prototypes
14
15 #define JS_TYPROTO_SLOT_DESCR 0
16 #define JS_TYPROTO_SLOTS 1
17
18 ///////////////////////////////////////////////////////////////////////////
19 // Slots for type objects
20 //
21 // Some slots apply to all type objects and some are specific to
22 // particular kinds of type objects. For simplicity we use the same
23 // number of slots no matter what kind of type descriptor we are
24 // working with, even though this is mildly wasteful.
25
26 // Slots on all type objects
27 #define JS_DESCR_SLOT_KIND 0 // Atomized string representation
28 #define JS_DESCR_SLOT_STRING_REPR 1 // Atomized string representation
29 #define JS_DESCR_SLOT_ALIGNMENT 2 // Alignment in bytes
30 #define JS_DESCR_SLOT_SIZE 3 // Size in bytes, if sized, else 0
31 #define JS_DESCR_SLOT_OPAQUE 4 // Atomized string representation
32 #define JS_DESCR_SLOT_TYPROTO 5 // Prototype for instances, if any
33
34 // Slots on scalars, references, and x4s
35 #define JS_DESCR_SLOT_TYPE 6 // Type code
36
37 // Slots on all array descriptors
38 #define JS_DESCR_SLOT_ARRAY_ELEM_TYPE 6
39
40 // Slots on sized array descriptors
41 #define JS_DESCR_SLOT_SIZED_ARRAY_LENGTH 7
42
43 // Slots on struct type objects
44 #define JS_DESCR_SLOT_STRUCT_FIELD_NAMES 6
45 #define JS_DESCR_SLOT_STRUCT_FIELD_TYPES 7
46 #define JS_DESCR_SLOT_STRUCT_FIELD_OFFSETS 8
47
48 // Maximum number of slots for any descriptor
49 #define JS_DESCR_SLOTS 9
50
51 // These constants are for use exclusively in JS code. In C++ code,
52 // prefer TypeRepresentation::Scalar etc, which allows you to
53 // write a switch which will receive a warning if you omit a case.
54 #define JS_TYPEREPR_UNSIZED_ARRAY_KIND 0
55 #define JS_TYPEREPR_MAX_UNSIZED_KIND 0 // Unsized kinds go above here
56 #define JS_TYPEREPR_SCALAR_KIND 1
57 #define JS_TYPEREPR_REFERENCE_KIND 2
58 #define JS_TYPEREPR_STRUCT_KIND 3
59 #define JS_TYPEREPR_SIZED_ARRAY_KIND 4
60 #define JS_TYPEREPR_X4_KIND 5
61
62 // These constants are for use exclusively in JS code. In C++ code,
63 // prefer ScalarTypeRepresentation::TYPE_INT8 etc, which allows
64 // you to write a switch which will receive a warning if you omit a
65 // case.
66 #define JS_SCALARTYPEREPR_INT8 0
67 #define JS_SCALARTYPEREPR_UINT8 1
68 #define JS_SCALARTYPEREPR_INT16 2
69 #define JS_SCALARTYPEREPR_UINT16 3
70 #define JS_SCALARTYPEREPR_INT32 4
71 #define JS_SCALARTYPEREPR_UINT32 5
72 #define JS_SCALARTYPEREPR_FLOAT32 6
73 #define JS_SCALARTYPEREPR_FLOAT64 7
74 #define JS_SCALARTYPEREPR_UINT8_CLAMPED 8
75
76 // These constants are for use exclusively in JS code. In C++ code,
77 // prefer ReferenceTypeRepresentation::TYPE_ANY etc, which allows
78 // you to write a switch which will receive a warning if you omit a
79 // case.
80 #define JS_REFERENCETYPEREPR_ANY 0
81 #define JS_REFERENCETYPEREPR_OBJECT 1
82 #define JS_REFERENCETYPEREPR_STRING 2
83
84 // These constants are for use exclusively in JS code. In C++ code,
85 // prefer X4TypeRepresentation::TYPE_INT32 etc, since that allows
86 // you to write a switch which will receive a warning if you omit a
87 // case.
88 #define JS_X4TYPEREPR_INT32 0
89 #define JS_X4TYPEREPR_FLOAT32 1
90
91 ///////////////////////////////////////////////////////////////////////////
92 // Slots for typed objects
93
94 #define JS_TYPEDOBJ_SLOT_BYTEOFFSET 0
95 #define JS_TYPEDOBJ_SLOT_BYTELENGTH 1
96 #define JS_TYPEDOBJ_SLOT_OWNER 2
97 #define JS_TYPEDOBJ_SLOT_NEXT_VIEW 3
98
99 #define JS_DATAVIEW_SLOTS 4 // Number of slots for data views
100
101 #define JS_TYPEDOBJ_SLOT_LENGTH 4 // Length of array (see (*) below)
102 #define JS_TYPEDOBJ_SLOT_TYPE_DESCR 5 // For typed objects, type descr
103
104 #define JS_TYPEDOBJ_SLOT_DATA 7 // private slot, based on alloc kind
105 #define JS_TYPEDOBJ_SLOTS 6 // Number of slots for typed objs
106
107 // (*) The JS_TYPEDOBJ_SLOT_LENGTH slot stores the length for typed objects of
108 // sized and unsized array type. The slot contains 0 for non-arrays.
109 // The slot also contains 0 for *unattached* typed objects, no matter what
110 // type they have.
111
112 #endif

mercurial