The definition of a field.
This type is used to define object records. A field defines a getter/setter pair of the record.
const SubRecord = bre.defineObjectRecord("SubRecord", [
{type: "uint8", name: "a"},
{type: "uint8", name: "b"},
])
const Record = bre.defineObjectRecord("Record", [
{type: "uint8[4]", name: "list"},
{type: SubRecord, name: "sub"},
{type: [SubRecord, 8], name: "subList"},
])
- Source:
Members
name :string
The name of this field.
- This requires a valid identifier of ECMAScript.
- The following names are forbidden:
__defineGetter__
__defineSetter__
__lookupGetter__
__lookupSetter__
__proto__
__noSuchMethod__
constructor
hasOwnProperty
isPrototypeOf
propertyIsEnumerable
toJSON
toLocaleString
toString
valueOf
Type:
- string
- Source:
type :string|class|Array
The type name of this field.
- Signed integer types:
"int8"
- 8 bits signed integer (-128..127
)."int16"
- 16 bits signed integer (-32768..32767
)."int32"
- 32 bits signed integer (-2147483648..2147483647
).
- Unsigned integer types:
"uint8"
- 8 bits unsigned integer (0..255
)."uint16"
- 16 bits unsigned integer (0..65535
)."uint32"
- 32 bits unsigned integer (0..4294967295
).
- Small unsigned integer types:
"bit1"
- 1 bits unsigned integer (0..1
)."bit2"
- 2 bits unsigned integer (0..3
)."bit3"
- 3 bits unsigned integer (0..7
)."bit4"
- 4 bits unsigned integer (0..15
)."bit5"
- 5 bits unsigned integer (0..31
)."bit6"
- 6 bits unsigned integer (0..63
)."bit7"
- 7 bits unsigned integer (0..127
).
- Floating point number types:
"float32"
- 32 bits floating point number (a.k.a.float
)."float64"
- 64 bits floating point number (a.k.a.double
).
- String types:
"string(N)"
- fixed length (N bytes) string (e.g."string(32)"
). The default encoding of this type isutf8
. It can use a specific encoding type instead of"string"
. For examples:"utf8(N)"
- fixed length (N bytes) string."utf16be(N)"
- fixed length (N bytes) string."shift_jis(N)"
- fixed length (N bytes) string.
- Note: It needs to set text encoder before use string types.
- Record types:
- Another record class (e.g.
ExampleRecord
).
- Another record class (e.g.
- Array types:
"T[N]"
- fixed length (count N) array. T is another type (e.g."uint8[8]"
). An array type can be T (e.g."uint8[2][3]"
).[T, N]
- fixed length (count N) array. T is another type (e.g.["uint8", 8]
, this is same as"uint8[8]"
). This notation is for record types (e.g.[ExampleRecord, 8]
).
Type:
- string | class | Array
- Source: