• Home
  • Raw
  • Download

Lines Matching full:offset

3 import { Offset, Table, IGeneratedObject } from "./types.js";
54 readInt8(offset: number): number {
55 return this.readUint8(offset) << 24 >> 24;
58 readUint8(offset: number): number {
59 return this.bytes_[offset];
62 readInt16(offset: number): number {
63 return this.readUint16(offset) << 16 >> 16;
66 readUint16(offset: number): number {
67 return this.bytes_[offset] | this.bytes_[offset + 1] << 8;
70 readInt32(offset: number): number {
71 …return this.bytes_[offset] | this.bytes_[offset + 1] << 8 | this.bytes_[offset + 2] << 16 | this.b…
74 readUint32(offset: number): number {
75 return this.readInt32(offset) >>> 0;
78 readInt64(offset: number): bigint {
79 …return BigInt.asIntN(64, BigInt(this.readUint32(offset)) + (BigInt(this.readUint32(offset + 4)) <<…
82 readUint64(offset: number): bigint {
83 …return BigInt.asUintN(64, BigInt(this.readUint32(offset)) + (BigInt(this.readUint32(offset + 4)) <…
86 readFloat32(offset: number): number {
87 int32[0] = this.readInt32(offset);
91 readFloat64(offset: number): number {
92 int32[isLittleEndian ? 0 : 1] = this.readInt32(offset);
93 int32[isLittleEndian ? 1 : 0] = this.readInt32(offset + 4);
97 writeInt8(offset: number, value: number): void {
98 this.bytes_[offset] = value;
101 writeUint8(offset: number, value: number): void {
102 this.bytes_[offset] = value;
105 writeInt16(offset: number, value: number): void {
106 this.bytes_[offset] = value;
107 this.bytes_[offset + 1] = value >> 8;
110 writeUint16(offset: number, value: number): void {
111 this.bytes_[offset] = value;
112 this.bytes_[offset + 1] = value >> 8;
115 writeInt32(offset: number, value: number): void {
116 this.bytes_[offset] = value;
117 this.bytes_[offset + 1] = value >> 8;
118 this.bytes_[offset + 2] = value >> 16;
119 this.bytes_[offset + 3] = value >> 24;
122 writeUint32(offset: number, value: number): void {
123 this.bytes_[offset] = value;
124 this.bytes_[offset + 1] = value >> 8;
125 this.bytes_[offset + 2] = value >> 16;
126 this.bytes_[offset + 3] = value >> 24;
129 writeInt64(offset: number, value: bigint): void {
130 this.writeInt32(offset, Number(BigInt.asIntN(32, value)));
131 this.writeInt32(offset + 4, Number(BigInt.asIntN(32, value >> BigInt(32))));
134 writeUint64(offset: number, value: bigint): void {
135 this.writeUint32(offset, Number(BigInt.asUintN(32, value)));
136 this.writeUint32(offset + 4, Number(BigInt.asUintN(32, value >> BigInt(32))));
139 writeFloat32(offset: number, value: number): void {
141 this.writeInt32(offset, int32[0]);
144 writeFloat64(offset: number, value: number): void {
146 this.writeInt32(offset, int32[isLittleEndian ? 0 : 1]);
147 this.writeInt32(offset + 4, int32[isLittleEndian ? 1 : 0]);
170 * Look up a field in the vtable, return an offset into the object, or 0 if the
173 __offset(bb_pos: number, vtable_offset: number): Offset {
179 * Initialize any Table-derived type to point to the union at the given offset.
181 __union(t: Table, offset: number): Table {
182 t.bb_pos = offset + this.readInt32(offset);
195 * @param offset
198 __string(offset: number, opt_encoding?: Encoding): string | Uint8Array {
199 offset += this.readInt32(offset);
200 const length = this.readInt32(offset);
201 offset += SIZEOF_INT;
202 const utf8bytes = this.bytes_.subarray(offset, offset + length);
216 __union_with_string(o: Table | string, offset: number) : Table | string {
218 return this.__string(offset) as string;
220 return this.__union(o, offset);
224 * Retrieve the relative offset stored at "offset"
226 __indirect(offset: Offset): Offset {
227 return offset + this.readInt32(offset);
231 * Get the start of data of a vector whose offset is stored at "offset" in this object.
233 __vector(offset: Offset): Offset {
234 return offset + this.readInt32(offset) + SIZEOF_INT; // data starts after the length
238 * Get the length of a vector whose offset is stored at "offset" in this object.
240 __vector_len(offset: Offset): Offset {
241 return this.readInt32(offset + this.readInt32(offset));