js/src/builtin/TypedObjectConstants.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/builtin/TypedObjectConstants.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,112 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99:
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +// Specialized .h file to be used by both JS and C++ code.
    1.11 +
    1.12 +#ifndef builtin_TypedObjectConstants_h
    1.13 +#define builtin_TypedObjectConstants_h
    1.14 +
    1.15 +///////////////////////////////////////////////////////////////////////////
    1.16 +// Slots for typed prototypes
    1.17 +
    1.18 +#define JS_TYPROTO_SLOT_DESCR            0
    1.19 +#define JS_TYPROTO_SLOTS                 1
    1.20 +
    1.21 +///////////////////////////////////////////////////////////////////////////
    1.22 +// Slots for type objects
    1.23 +//
    1.24 +// Some slots apply to all type objects and some are specific to
    1.25 +// particular kinds of type objects. For simplicity we use the same
    1.26 +// number of slots no matter what kind of type descriptor we are
    1.27 +// working with, even though this is mildly wasteful.
    1.28 +
    1.29 +// Slots on all type objects
    1.30 +#define JS_DESCR_SLOT_KIND               0  // Atomized string representation
    1.31 +#define JS_DESCR_SLOT_STRING_REPR        1  // Atomized string representation
    1.32 +#define JS_DESCR_SLOT_ALIGNMENT          2  // Alignment in bytes
    1.33 +#define JS_DESCR_SLOT_SIZE               3  // Size in bytes, if sized, else 0
    1.34 +#define JS_DESCR_SLOT_OPAQUE             4  // Atomized string representation
    1.35 +#define JS_DESCR_SLOT_TYPROTO            5  // Prototype for instances, if any
    1.36 +
    1.37 +// Slots on scalars, references, and x4s
    1.38 +#define JS_DESCR_SLOT_TYPE               6  // Type code
    1.39 +
    1.40 +// Slots on all array descriptors
    1.41 +#define JS_DESCR_SLOT_ARRAY_ELEM_TYPE    6
    1.42 +
    1.43 +// Slots on sized array descriptors
    1.44 +#define JS_DESCR_SLOT_SIZED_ARRAY_LENGTH 7
    1.45 +
    1.46 +// Slots on struct type objects
    1.47 +#define JS_DESCR_SLOT_STRUCT_FIELD_NAMES 6
    1.48 +#define JS_DESCR_SLOT_STRUCT_FIELD_TYPES 7
    1.49 +#define JS_DESCR_SLOT_STRUCT_FIELD_OFFSETS 8
    1.50 +
    1.51 +// Maximum number of slots for any descriptor
    1.52 +#define JS_DESCR_SLOTS                   9
    1.53 +
    1.54 +// These constants are for use exclusively in JS code. In C++ code,
    1.55 +// prefer TypeRepresentation::Scalar etc, which allows you to
    1.56 +// write a switch which will receive a warning if you omit a case.
    1.57 +#define JS_TYPEREPR_UNSIZED_ARRAY_KIND  0
    1.58 +#define JS_TYPEREPR_MAX_UNSIZED_KIND    0    // Unsized kinds go above here
    1.59 +#define JS_TYPEREPR_SCALAR_KIND         1
    1.60 +#define JS_TYPEREPR_REFERENCE_KIND      2
    1.61 +#define JS_TYPEREPR_STRUCT_KIND         3
    1.62 +#define JS_TYPEREPR_SIZED_ARRAY_KIND    4
    1.63 +#define JS_TYPEREPR_X4_KIND             5
    1.64 +
    1.65 +// These constants are for use exclusively in JS code. In C++ code,
    1.66 +// prefer ScalarTypeRepresentation::TYPE_INT8 etc, which allows
    1.67 +// you to write a switch which will receive a warning if you omit a
    1.68 +// case.
    1.69 +#define JS_SCALARTYPEREPR_INT8          0
    1.70 +#define JS_SCALARTYPEREPR_UINT8         1
    1.71 +#define JS_SCALARTYPEREPR_INT16         2
    1.72 +#define JS_SCALARTYPEREPR_UINT16        3
    1.73 +#define JS_SCALARTYPEREPR_INT32         4
    1.74 +#define JS_SCALARTYPEREPR_UINT32        5
    1.75 +#define JS_SCALARTYPEREPR_FLOAT32       6
    1.76 +#define JS_SCALARTYPEREPR_FLOAT64       7
    1.77 +#define JS_SCALARTYPEREPR_UINT8_CLAMPED 8
    1.78 +
    1.79 +// These constants are for use exclusively in JS code. In C++ code,
    1.80 +// prefer ReferenceTypeRepresentation::TYPE_ANY etc, which allows
    1.81 +// you to write a switch which will receive a warning if you omit a
    1.82 +// case.
    1.83 +#define JS_REFERENCETYPEREPR_ANY        0
    1.84 +#define JS_REFERENCETYPEREPR_OBJECT     1
    1.85 +#define JS_REFERENCETYPEREPR_STRING     2
    1.86 +
    1.87 +// These constants are for use exclusively in JS code.  In C++ code,
    1.88 +// prefer X4TypeRepresentation::TYPE_INT32 etc, since that allows
    1.89 +// you to write a switch which will receive a warning if you omit a
    1.90 +// case.
    1.91 +#define JS_X4TYPEREPR_INT32         0
    1.92 +#define JS_X4TYPEREPR_FLOAT32       1
    1.93 +
    1.94 +///////////////////////////////////////////////////////////////////////////
    1.95 +// Slots for typed objects
    1.96 +
    1.97 +#define JS_TYPEDOBJ_SLOT_BYTEOFFSET       0
    1.98 +#define JS_TYPEDOBJ_SLOT_BYTELENGTH       1
    1.99 +#define JS_TYPEDOBJ_SLOT_OWNER            2
   1.100 +#define JS_TYPEDOBJ_SLOT_NEXT_VIEW        3
   1.101 +
   1.102 +#define JS_DATAVIEW_SLOTS              4 // Number of slots for data views
   1.103 +
   1.104 +#define JS_TYPEDOBJ_SLOT_LENGTH           4 // Length of array (see (*) below)
   1.105 +#define JS_TYPEDOBJ_SLOT_TYPE_DESCR       5 // For typed objects, type descr
   1.106 +
   1.107 +#define JS_TYPEDOBJ_SLOT_DATA             7 // private slot, based on alloc kind
   1.108 +#define JS_TYPEDOBJ_SLOTS                 6 // Number of slots for typed objs
   1.109 +
   1.110 +// (*) The JS_TYPEDOBJ_SLOT_LENGTH slot stores the length for typed objects of
   1.111 +// sized and unsized array type. The slot contains 0 for non-arrays.
   1.112 +// The slot also contains 0 for *unattached* typed objects, no matter what
   1.113 +// type they have.
   1.114 +
   1.115 +#endif

mercurial