REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 4.09 KB
Close
/home/byroehnu/.trash/node_modules11/restructure/src/Pointer.js
Text
Base64
import * as utils from './utils.js'; import {Base} from './Base.js'; export class Pointer extends Base { constructor(offsetType, type, options = {}) { super(); this.offsetType = offsetType; this.type = type; this.options = options; if (this.type === 'void') { this.type = null; } if (this.options.type == null) { this.options.type = 'local'; } if (this.options.allowNull == null) { this.options.allowNull = true; } if (this.options.nullValue == null) { this.options.nullValue = 0; } if (this.options.lazy == null) { this.options.lazy = false; } if (this.options.relativeTo) { if (typeof this.options.relativeTo !== 'function') { throw new Error('relativeTo option must be a function'); } this.relativeToGetter = options.relativeTo; } } decode(stream, ctx) { const offset = this.offsetType.decode(stream, ctx); // handle NULL pointers if ((offset === this.options.nullValue) && this.options.allowNull) { return null; } let relative; switch (this.options.type) { case 'local': relative = ctx._startOffset; break; case 'immediate': relative = stream.pos - this.offsetType.size(); break; case 'parent': relative = ctx.parent._startOffset; break; default: var c = ctx; while (c.parent) { c = c.parent; } relative = c._startOffset || 0; } if (this.options.relativeTo) { relative += this.relativeToGetter(ctx); } const ptr = offset + relative; if (this.type != null) { let val = null; const decodeValue = () => { if (val != null) { return val; } const { pos } = stream; stream.pos = ptr; val = this.type.decode(stream, ctx); stream.pos = pos; return val; }; // If this is a lazy pointer, define a getter to decode only when needed. // This obviously only works when the pointer is contained by a Struct. if (this.options.lazy) { return new utils.PropertyDescriptor({ get: decodeValue}); } return decodeValue(); } else { return ptr; } } size(val, ctx) { const parent = ctx; switch (this.options.type) { case 'local': case 'immediate': break; case 'parent': ctx = ctx.parent; break; default: // global while (ctx.parent) { ctx = ctx.parent; } } let { type } = this; if (type == null) { if (!(val instanceof VoidPointer)) { throw new Error("Must be a VoidPointer"); } ({ type } = val); val = val.value; } if (val && ctx) { // Must be written as two separate lines rather than += in case `type.size` mutates ctx.pointerSize. let size = type.size(val, parent); ctx.pointerSize += size; } return this.offsetType.size(); } encode(stream, val, ctx) { let relative; const parent = ctx; if ((val == null)) { this.offsetType.encode(stream, this.options.nullValue); return; } switch (this.options.type) { case 'local': relative = ctx.startOffset; break; case 'immediate': relative = stream.pos + this.offsetType.size(val, parent); break; case 'parent': ctx = ctx.parent; relative = ctx.startOffset; break; default: // global relative = 0; while (ctx.parent) { ctx = ctx.parent; } } if (this.options.relativeTo) { relative += this.relativeToGetter(parent.val); } this.offsetType.encode(stream, ctx.pointerOffset - relative); let { type } = this; if (type == null) { if (!(val instanceof VoidPointer)) { throw new Error("Must be a VoidPointer"); } ({ type } = val); val = val.value; } ctx.pointers.push({ type, val, parent }); return ctx.pointerOffset += type.size(val, parent); } } // A pointer whose type is determined at decode time export class VoidPointer { constructor(type, value) { this.type = type; this.value = value; } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 17
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
Array.js
2.43 KB
lrw-r--r--
2026-02-14 19:19:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Base.js
412 B
lrw-r--r--
2026-02-14 19:19:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Bitfield.js
741 B
lrw-r--r--
2026-02-14 19:19:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Boolean.js
398 B
lrw-r--r--
2026-02-14 19:19:16
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Buffer.js
795 B
lrw-r--r--
2026-02-14 19:19:16
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DecodeStream.js
1.85 KB
lrw-r--r--
2026-02-14 19:19:16
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
EncodeStream.js
3.13 KB
lrw-r--r--
2026-02-14 19:19:16
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Enum.js
533 B
lrw-r--r--
2026-02-14 19:19:16
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
LazyArray.js
1.62 KB
lrw-r--r--
2026-02-14 19:19:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Number.js
2.23 KB
lrw-r--r--
2026-02-14 19:19:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Optional.js
920 B
lrw-r--r--
2026-02-14 19:19:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Pointer.js
4.09 KB
lrw-r--r--
2026-02-14 19:19:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Reserved.js
519 B
lrw-r--r--
2026-02-14 19:19:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
String.js
3.71 KB
lrw-r--r--
2026-02-14 19:19:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Struct.js
2.33 KB
lrw-r--r--
2026-02-14 19:19:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
utils.js
723 B
lrw-r--r--
2026-02-14 19:19:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
VersionedStruct.js
3.01 KB
lrw-r--r--
2026-02-14 19:19:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).