@dusted/anqst 1.0.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/src/app.js +1 -0
- package/dist/src/base93.js +124 -0
- package/dist/src/codecgenerators/basecodecemitters/bigint-qint64/decoder.js +35 -0
- package/dist/src/codecgenerators/basecodecemitters/bigint-qint64/encoder.js +36 -0
- package/dist/src/codecgenerators/basecodecemitters/bigint-quint64/decoder.js +26 -0
- package/dist/src/codecgenerators/basecodecemitters/bigint-quint64/encoder.js +38 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-blob/decoder.js +28 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-blob/encoder.js +34 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-buffer/decoder.js +29 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-buffer/encoder.js +36 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-float32Array/decoder.js +46 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-float32Array/encoder.js +49 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-float64Array/decoder.js +46 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-float64Array/encoder.js +47 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-int16Array/decoder.js +46 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-int16Array/encoder.js +49 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-int32Array/decoder.js +50 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-int32Array/encoder.js +52 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-int8Array/decoder.js +38 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-int8Array/encoder.js +44 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-typedArray/decoder.js +33 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-typedArray/encoder.js +34 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-uint16Array/decoder.js +46 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-uint16Array/encoder.js +49 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-uint32Array/decoder.js +46 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-uint32Array/encoder.js +49 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-uint8Array/decoder.js +28 -0
- package/dist/src/codecgenerators/basecodecemitters/binary-uint8Array/encoder.js +34 -0
- package/dist/src/codecgenerators/basecodecemitters/boolean/decoder.js +34 -0
- package/dist/src/codecgenerators/basecodecemitters/boolean/encoder.js +40 -0
- package/dist/src/codecgenerators/basecodecemitters/dynamic-json/decoder.js +43 -0
- package/dist/src/codecgenerators/basecodecemitters/dynamic-json/encoder.js +45 -0
- package/dist/src/codecgenerators/basecodecemitters/dynamic-object/decoder.js +44 -0
- package/dist/src/codecgenerators/basecodecemitters/dynamic-object/encoder.js +46 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-int16/decoder.js +32 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-int16/encoder.js +43 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-int32/decoder.js +26 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-int32/encoder.js +37 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-int8/decoder.js +26 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-int8/encoder.js +37 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-qint16/decoder.js +36 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-qint16/encoder.js +36 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-qint32/decoder.js +25 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-qint32/encoder.js +36 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-qint8/decoder.js +36 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-qint8/encoder.js +36 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-quint16/decoder.js +26 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-quint16/encoder.js +38 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-quint32/decoder.js +27 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-quint32/encoder.js +39 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-quint8/decoder.js +26 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-quint8/encoder.js +38 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-uint16/decoder.js +30 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-uint16/encoder.js +42 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-uint32/decoder.js +31 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-uint32/encoder.js +43 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-uint8/decoder.js +30 -0
- package/dist/src/codecgenerators/basecodecemitters/integer-uint8/encoder.js +40 -0
- package/dist/src/codecgenerators/basecodecemitters/number/decoder.js +26 -0
- package/dist/src/codecgenerators/basecodecemitters/number/encoder.js +38 -0
- package/dist/src/codecgenerators/basecodecemitters/shared/comments.js +13 -0
- package/dist/src/codecgenerators/basecodecemitters/shared/contracts.js +2 -0
- package/dist/src/codecgenerators/basecodecemitters/shared/fixedwidth.js +53 -0
- package/dist/src/codecgenerators/basecodecemitters/shared/index.js +21 -0
- package/dist/src/codecgenerators/basecodecemitters/shared/positionalBase93.js +48 -0
- package/dist/src/codecgenerators/basecodecemitters/shared/rawbytes.js +30 -0
- package/dist/src/codecgenerators/basecodecemitters/string/decoder.js +43 -0
- package/dist/src/codecgenerators/basecodecemitters/string/encoder.js +43 -0
- package/dist/src/codecgenerators/basecodecemitters/stringArray/decoder.js +80 -0
- package/dist/src/codecgenerators/basecodecemitters/stringArray/encoder.js +57 -0
- package/dist/src/emit.js +752 -118
- package/dist/src/structured-top-level-codecs.js +1305 -0
- package/package.json +1 -1
- package/spec/AnQst-Spec-DSL.d.ts +12 -6
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter (decode): base93 blob → TypeScript `number`, C++ `quint16`.
|
|
4
|
+
* Reconstructs the platform-native 2-byte unsigned scalar from a 3-character base93 payload.
|
|
5
|
+
* See RefinedSpecs/Codecs/Integer_quint16_Codec.md.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.decoderEmitter = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
const fixedwidth_1 = require("../shared/fixedwidth");
|
|
11
|
+
const encoder_1 = require("./encoder");
|
|
12
|
+
Object.defineProperty(exports, "descriptor", { enumerable: true, get: function () { return encoder_1.descriptor; } });
|
|
13
|
+
const strategyComment = (0, comments_1.emitStrategyComment)("Base codec emitter (decode): AnQst.Type.quint16 / quint16", [
|
|
14
|
+
"Decodes base93 to exactly 2 bytes, then reads Uint16Array[0] in TypeScript or quint16 in C++.",
|
|
15
|
+
"Standalone payloads are fixed-width and therefore always 3 base93 characters for valid quint16 values.",
|
|
16
|
+
"Portable interoperability is byte-exact because both sides reinterpret the same 2 decoded bytes as quint16."
|
|
17
|
+
]);
|
|
18
|
+
exports.decoderEmitter = {
|
|
19
|
+
descriptor: encoder_1.descriptor,
|
|
20
|
+
emitTsDecoder() {
|
|
21
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitTsFixedWidthStandaloneDecoder)("decodeQuint16Standalone", encoder_1.descriptor.fixedWidth)}`;
|
|
22
|
+
},
|
|
23
|
+
emitCppDecoder() {
|
|
24
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitCppFixedWidthStandaloneDecoder)("decodeQuint16Standalone", encoder_1.descriptor.fixedWidth)}`;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter (encode): AnQst.Type.quint16 ↔ TypeScript `number`, C++ `quint16`.
|
|
4
|
+
* Standalone wire shape is one 3-character base93 string carrying exactly 2 raw bytes.
|
|
5
|
+
* See RefinedSpecs/Codecs/Integer_quint16_Codec.md.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.encoderEmitter = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
const fixedwidth_1 = require("../shared/fixedwidth");
|
|
11
|
+
const FIXED_WIDTH = {
|
|
12
|
+
byteWidth: 2,
|
|
13
|
+
tsViewCtor: "Uint16Array",
|
|
14
|
+
cppType: "quint16"
|
|
15
|
+
};
|
|
16
|
+
exports.descriptor = {
|
|
17
|
+
codecId: "integer-quint16",
|
|
18
|
+
specPath: "RefinedSpecs/Codecs/Integer_quint16_Codec.md",
|
|
19
|
+
tsType: "number",
|
|
20
|
+
cppType: "quint16",
|
|
21
|
+
wireCategory: "fixed-width-scalar",
|
|
22
|
+
strategySummary: "Unsigned 16-bit scalar: write the platform-native 2-byte Uint16Array/quint16 representation, then base93-encode it to a 3-character standalone string.",
|
|
23
|
+
fixedWidth: FIXED_WIDTH
|
|
24
|
+
};
|
|
25
|
+
const strategyComment = (0, comments_1.emitStrategyComment)("Base codec emitter (encode): AnQst.Type.quint16 / quint16", [
|
|
26
|
+
"Uses Uint16Array[0] so TypeScript follows the quint16 prose for the host-native 2-byte unsigned representation.",
|
|
27
|
+
"Emits exactly 3 base93 characters for the standalone wire payload because 2 raw bytes are encoded directly.",
|
|
28
|
+
"C++ encoder memcpy-copies the same 2 bytes from quint16, preserving portable interop at the byte level."
|
|
29
|
+
]);
|
|
30
|
+
exports.encoderEmitter = {
|
|
31
|
+
descriptor: exports.descriptor,
|
|
32
|
+
emitTsEncoder() {
|
|
33
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitTsFixedWidthStandaloneEncoder)("encodeQuint16Standalone", FIXED_WIDTH)}`;
|
|
34
|
+
},
|
|
35
|
+
emitCppEncoder() {
|
|
36
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitCppFixedWidthStandaloneEncoder)("encodeQuint16Standalone", FIXED_WIDTH)}`;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter (decode): base93 blob → TypeScript `number`, C++ `quint32`.
|
|
4
|
+
* Reconstructs the 4-byte unsigned payload from a 5-character base93 string and
|
|
5
|
+
* reads it back through Uint32Array / quint32 in host-native byte order.
|
|
6
|
+
* See RefinedSpecs/Codecs/Integer_quint32_Codec.md.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.decoderEmitter = exports.descriptor = void 0;
|
|
10
|
+
const comments_1 = require("../shared/comments");
|
|
11
|
+
const fixedwidth_1 = require("../shared/fixedwidth");
|
|
12
|
+
const encoder_1 = require("./encoder");
|
|
13
|
+
Object.defineProperty(exports, "descriptor", { enumerable: true, get: function () { return encoder_1.descriptor; } });
|
|
14
|
+
const strategyComment = (0, comments_1.emitStrategyComment)("Base codec emitter (decode): AnQst.Type.quint32 / quint32", [
|
|
15
|
+
"Decodes base93 to 4 bytes, then reads Uint32Array[0] in TypeScript or quint32 in C++.",
|
|
16
|
+
"Standalone payloads are fixed-width and therefore always 5 base93 characters for valid quint32 values.",
|
|
17
|
+
"Portable interoperability is direct because both sides reinterpret the same 4 decoded bytes."
|
|
18
|
+
]);
|
|
19
|
+
exports.decoderEmitter = {
|
|
20
|
+
descriptor: encoder_1.descriptor,
|
|
21
|
+
emitTsDecoder() {
|
|
22
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitTsFixedWidthStandaloneDecoder)("decodeQuint32Standalone", encoder_1.descriptor.fixedWidth)}`;
|
|
23
|
+
},
|
|
24
|
+
emitCppDecoder() {
|
|
25
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitCppFixedWidthStandaloneDecoder)("decodeQuint32Standalone", encoder_1.descriptor.fixedWidth)}`;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter (encode): AnQst.Type.quint32 ↔ TypeScript `number`, C++ `quint32`.
|
|
4
|
+
* Standalone wire shape is one 5-character base93 string carrying exactly 4 bytes
|
|
5
|
+
* from a Uint32Array host-native unsigned 32-bit representation.
|
|
6
|
+
* See RefinedSpecs/Codecs/Integer_quint32_Codec.md.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.encoderEmitter = exports.descriptor = void 0;
|
|
10
|
+
const comments_1 = require("../shared/comments");
|
|
11
|
+
const fixedwidth_1 = require("../shared/fixedwidth");
|
|
12
|
+
const FIXED_WIDTH = {
|
|
13
|
+
byteWidth: 4,
|
|
14
|
+
tsViewCtor: "Uint32Array",
|
|
15
|
+
cppType: "quint32"
|
|
16
|
+
};
|
|
17
|
+
exports.descriptor = {
|
|
18
|
+
codecId: "integer-quint32",
|
|
19
|
+
specPath: "RefinedSpecs/Codecs/Integer_quint32_Codec.md",
|
|
20
|
+
tsType: "number",
|
|
21
|
+
cppType: "quint32",
|
|
22
|
+
wireCategory: "fixed-width-scalar",
|
|
23
|
+
strategySummary: "Unsigned 32-bit scalar: materialize 4 host-native bytes via Uint32Array/quint32, then base93-encode them to a standalone 5-character string.",
|
|
24
|
+
fixedWidth: FIXED_WIDTH
|
|
25
|
+
};
|
|
26
|
+
const strategyComment = (0, comments_1.emitStrategyComment)("Base codec emitter (encode): AnQst.Type.quint32 / quint32", [
|
|
27
|
+
"Uses Uint32Array[0] so TypeScript follows the quint32 prose for 4-byte unsigned materialization.",
|
|
28
|
+
"Emits exactly 5 base93 characters for the standalone wire payload.",
|
|
29
|
+
"C++ encoder memcpy-copies the quint32 bytes, matching the TypeScript wire byte-for-byte on the same host."
|
|
30
|
+
]);
|
|
31
|
+
exports.encoderEmitter = {
|
|
32
|
+
descriptor: exports.descriptor,
|
|
33
|
+
emitTsEncoder() {
|
|
34
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitTsFixedWidthStandaloneEncoder)("encodeQuint32Standalone", FIXED_WIDTH)}`;
|
|
35
|
+
},
|
|
36
|
+
emitCppEncoder() {
|
|
37
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitCppFixedWidthStandaloneEncoder)("encodeQuint32Standalone", FIXED_WIDTH)}`;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter (decode): base93 blob → TypeScript `number`, C++ `quint8`.
|
|
4
|
+
* Reconstructs the single unsigned byte from a 2-character base93 payload.
|
|
5
|
+
* See RefinedSpecs/Codecs/Integer_quint8_Codec.md.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.decoderEmitter = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
const fixedwidth_1 = require("../shared/fixedwidth");
|
|
11
|
+
const encoder_1 = require("./encoder");
|
|
12
|
+
Object.defineProperty(exports, "descriptor", { enumerable: true, get: function () { return encoder_1.descriptor; } });
|
|
13
|
+
const strategyComment = (0, comments_1.emitStrategyComment)("Base codec emitter (decode): AnQst.Type.quint8 / quint8", [
|
|
14
|
+
"Decodes base93 to one byte, then reads Uint8Array[0] in TypeScript or quint8 in C++.",
|
|
15
|
+
"Standalone payloads are fixed-width and therefore always 2 base93 characters for valid quint8 values.",
|
|
16
|
+
"Portable interoperability is direct because the byte itself is already the decoded unsigned 8-bit value."
|
|
17
|
+
]);
|
|
18
|
+
exports.decoderEmitter = {
|
|
19
|
+
descriptor: encoder_1.descriptor,
|
|
20
|
+
emitTsDecoder() {
|
|
21
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitTsFixedWidthStandaloneDecoder)("decodeQuint8Standalone", encoder_1.descriptor.fixedWidth)}`;
|
|
22
|
+
},
|
|
23
|
+
emitCppDecoder() {
|
|
24
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitCppFixedWidthStandaloneDecoder)("decodeQuint8Standalone", encoder_1.descriptor.fixedWidth)}`;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter (encode): AnQst.Type.quint8 ↔ TypeScript `number`, C++ `quint8`.
|
|
4
|
+
* Standalone wire shape is one 2-character base93 string carrying exactly 1 byte.
|
|
5
|
+
* See RefinedSpecs/Codecs/Integer_quint8_Codec.md.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.encoderEmitter = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
const fixedwidth_1 = require("../shared/fixedwidth");
|
|
11
|
+
const FIXED_WIDTH = {
|
|
12
|
+
byteWidth: 1,
|
|
13
|
+
tsViewCtor: "Uint8Array",
|
|
14
|
+
cppType: "quint8"
|
|
15
|
+
};
|
|
16
|
+
exports.descriptor = {
|
|
17
|
+
codecId: "integer-quint8",
|
|
18
|
+
specPath: "RefinedSpecs/Codecs/Integer_quint8_Codec.md",
|
|
19
|
+
tsType: "number",
|
|
20
|
+
cppType: "quint8",
|
|
21
|
+
wireCategory: "fixed-width-scalar",
|
|
22
|
+
strategySummary: "Unsigned 8-bit scalar: write the low 8 bits via Uint8Array/quint8, then base93-encode the single byte to a 2-character standalone string.",
|
|
23
|
+
fixedWidth: FIXED_WIDTH
|
|
24
|
+
};
|
|
25
|
+
const strategyComment = (0, comments_1.emitStrategyComment)("Base codec emitter (encode): AnQst.Type.quint8 / quint8", [
|
|
26
|
+
"Uses Uint8Array[0] so TypeScript follows the quint8 prose for 1-byte unsigned truncation/wrapping.",
|
|
27
|
+
"Emits exactly 2 base93 characters for the standalone wire payload.",
|
|
28
|
+
"C++ encoder memcpy-copies the single quint8 byte, matching the TypeScript wire byte-for-byte."
|
|
29
|
+
]);
|
|
30
|
+
exports.encoderEmitter = {
|
|
31
|
+
descriptor: exports.descriptor,
|
|
32
|
+
emitTsEncoder() {
|
|
33
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitTsFixedWidthStandaloneEncoder)("encodeQuint8Standalone", FIXED_WIDTH)}`;
|
|
34
|
+
},
|
|
35
|
+
emitCppEncoder() {
|
|
36
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitCppFixedWidthStandaloneEncoder)("encodeQuint8Standalone", FIXED_WIDTH)}`;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter (decode): base93 blob -> TypeScript `number`, C++ `uint16_t`.
|
|
4
|
+
*
|
|
5
|
+
* This reverses the standalone `uint16` encoder by decoding 3 base93 characters
|
|
6
|
+
* to 2 bytes and reading them through `Uint16Array` / `uint16_t`. The wire
|
|
7
|
+
* contract is intentionally identical to `quint16`, while descriptor identity
|
|
8
|
+
* remains distinct for downstream code generation and C++ type selection.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.decoderEmitter = exports.descriptor = void 0;
|
|
12
|
+
const comments_1 = require("../shared/comments");
|
|
13
|
+
const fixedwidth_1 = require("../shared/fixedwidth");
|
|
14
|
+
const encoder_1 = require("./encoder");
|
|
15
|
+
Object.defineProperty(exports, "descriptor", { enumerable: true, get: function () { return encoder_1.descriptor; } });
|
|
16
|
+
const fixedWidth = encoder_1.descriptor.fixedWidth;
|
|
17
|
+
const strategyComment = (0, comments_1.emitStrategyComment)("Base codec emitter (decode): AnQst.Type.uint16 / uint16_t", [
|
|
18
|
+
"Base93-decodes the standalone payload to 2 bytes, then reads them through Uint16Array or uint16_t.",
|
|
19
|
+
"Returns the JavaScript number represented by the unsigned 16-bit host-endian byte pair.",
|
|
20
|
+
"Accepts the same 3-character wires as quint16 because the byte-level wire format is deliberately identical."
|
|
21
|
+
]);
|
|
22
|
+
exports.decoderEmitter = {
|
|
23
|
+
descriptor: encoder_1.descriptor,
|
|
24
|
+
emitTsDecoder() {
|
|
25
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitTsFixedWidthStandaloneDecoder)("decodeUint16Standalone", fixedWidth)}`;
|
|
26
|
+
},
|
|
27
|
+
emitCppDecoder() {
|
|
28
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitCppFixedWidthStandaloneDecoder)("decodeUint16Standalone", fixedWidth)}`;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter (encode): `AnQst.Type.uint16` -> TypeScript `number`, C++ `uint16_t`.
|
|
4
|
+
*
|
|
5
|
+
* This codec is wire-identical to `AnQst.Type.quint16`: a fixed-width unsigned
|
|
6
|
+
* 16-bit scalar written through `Uint16Array`, preserving the platform-native
|
|
7
|
+
* 2-byte layout before base93-encoding it to a 3-character standalone string.
|
|
8
|
+
* The distinction is preserved only in descriptor metadata and emitted C++
|
|
9
|
+
* mapping (`uint16_t` instead of `quint16`).
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.encoderEmitter = exports.descriptor = void 0;
|
|
13
|
+
const comments_1 = require("../shared/comments");
|
|
14
|
+
const fixedwidth_1 = require("../shared/fixedwidth");
|
|
15
|
+
const fixedWidth = {
|
|
16
|
+
byteWidth: 2,
|
|
17
|
+
tsViewCtor: "Uint16Array",
|
|
18
|
+
cppType: "uint16_t"
|
|
19
|
+
};
|
|
20
|
+
exports.descriptor = {
|
|
21
|
+
codecId: "AnQst.Type.uint16",
|
|
22
|
+
specPath: "RefinedSpecs/Codecs/Integer_uint16_Codec.md",
|
|
23
|
+
tsType: "number",
|
|
24
|
+
cppType: "uint16_t",
|
|
25
|
+
wireCategory: "fixed-width-scalar",
|
|
26
|
+
strategySummary: "Wire-identical to quint16: 2-byte unsigned scalar via Uint16Array / memcpy into uint16_t, base93-encoded as a 3-character standalone string.",
|
|
27
|
+
fixedWidth
|
|
28
|
+
};
|
|
29
|
+
const strategyComment = (0, comments_1.emitStrategyComment)("Base codec emitter (encode): AnQst.Type.uint16 / uint16_t", [
|
|
30
|
+
"Uses Uint16Array so TypeScript follows the uint16/quint16 prose for unsigned 16-bit host-endian bytes.",
|
|
31
|
+
"Emits exactly 3 base93 characters because the standalone payload is always 2 bytes wide.",
|
|
32
|
+
"C++ encoder memcpy-copies uint16_t into the same 2-byte payload, keeping the wire identical to quint16."
|
|
33
|
+
]);
|
|
34
|
+
exports.encoderEmitter = {
|
|
35
|
+
descriptor: exports.descriptor,
|
|
36
|
+
emitTsEncoder() {
|
|
37
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitTsFixedWidthStandaloneEncoder)("encodeUint16Standalone", fixedWidth)}`;
|
|
38
|
+
},
|
|
39
|
+
emitCppEncoder() {
|
|
40
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitCppFixedWidthStandaloneEncoder)("encodeUint16Standalone", fixedWidth)}`;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter (decode): base93 blob -> TypeScript `number`, C++ `uint32_t`.
|
|
4
|
+
*
|
|
5
|
+
* This reverses the standalone `uint32` encoder by decoding 5 base93 characters
|
|
6
|
+
* to 4 bytes and reading them through `Uint32Array` / `uint32_t`. The wire
|
|
7
|
+
* contract is intentionally identical to `quint32`, while descriptor identity
|
|
8
|
+
* remains distinct for downstream code generation and C++ type selection.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.decoder = exports.decoderEmitter = exports.descriptor = void 0;
|
|
12
|
+
const comments_1 = require("../shared/comments");
|
|
13
|
+
const fixedwidth_1 = require("../shared/fixedwidth");
|
|
14
|
+
const encoder_1 = require("./encoder");
|
|
15
|
+
Object.defineProperty(exports, "descriptor", { enumerable: true, get: function () { return encoder_1.descriptor; } });
|
|
16
|
+
const fixedWidth = encoder_1.descriptor.fixedWidth;
|
|
17
|
+
const strategyComment = (0, comments_1.emitStrategyComment)("Base codec emitter (decode): AnQst.Type.uint32 / uint32_t", [
|
|
18
|
+
"Base93-decodes the standalone payload to 4 bytes, then reads them through Uint32Array or uint32_t.",
|
|
19
|
+
"Returns the JavaScript number represented by the unsigned 32-bit host-endian byte sequence.",
|
|
20
|
+
"Accepts the same 5-character wires as quint32 because the byte-level wire format is deliberately identical."
|
|
21
|
+
]);
|
|
22
|
+
exports.decoderEmitter = {
|
|
23
|
+
descriptor: encoder_1.descriptor,
|
|
24
|
+
emitTsDecoder() {
|
|
25
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitTsFixedWidthStandaloneDecoder)("decodeUint32Standalone", fixedWidth)}`;
|
|
26
|
+
},
|
|
27
|
+
emitCppDecoder() {
|
|
28
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitCppFixedWidthStandaloneDecoder)("decodeUint32Standalone", fixedWidth)}`;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.decoder = exports.decoderEmitter;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter (encode): `AnQst.Type.uint32` -> TypeScript `number`, C++ `uint32_t`.
|
|
4
|
+
*
|
|
5
|
+
* This codec is wire-identical to `AnQst.Type.quint32`: a fixed-width unsigned
|
|
6
|
+
* 32-bit scalar written through `Uint32Array`, preserving the platform-native
|
|
7
|
+
* 4-byte layout before base93-encoding it to a 5-character standalone string.
|
|
8
|
+
* The distinction is preserved only in descriptor metadata and emitted C++
|
|
9
|
+
* mapping (`uint32_t` instead of `quint32`).
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.encoder = exports.encoderEmitter = exports.descriptor = void 0;
|
|
13
|
+
const comments_1 = require("../shared/comments");
|
|
14
|
+
const fixedwidth_1 = require("../shared/fixedwidth");
|
|
15
|
+
const fixedWidth = {
|
|
16
|
+
byteWidth: 4,
|
|
17
|
+
tsViewCtor: "Uint32Array",
|
|
18
|
+
cppType: "uint32_t"
|
|
19
|
+
};
|
|
20
|
+
exports.descriptor = {
|
|
21
|
+
codecId: "AnQst.Type.uint32",
|
|
22
|
+
specPath: "RefinedSpecs/Codecs/Integer_uint32_Codec.md",
|
|
23
|
+
tsType: "number",
|
|
24
|
+
cppType: "uint32_t",
|
|
25
|
+
wireCategory: "fixed-width-scalar",
|
|
26
|
+
strategySummary: "Wire-identical to quint32: 4-byte unsigned scalar via Uint32Array / memcpy into uint32_t, base93-encoded as a 5-character standalone string.",
|
|
27
|
+
fixedWidth
|
|
28
|
+
};
|
|
29
|
+
const strategyComment = (0, comments_1.emitStrategyComment)("Base codec emitter (encode): AnQst.Type.uint32 / uint32_t", [
|
|
30
|
+
"Uses Uint32Array so TypeScript follows the uint32/quint32 prose for unsigned 32-bit host-endian bytes.",
|
|
31
|
+
"Emits exactly 5 base93 characters because the standalone payload is always 4 bytes wide.",
|
|
32
|
+
"C++ encoder memcpy-copies uint32_t into the same 4-byte payload, keeping the wire identical to quint32."
|
|
33
|
+
]);
|
|
34
|
+
exports.encoderEmitter = {
|
|
35
|
+
descriptor: exports.descriptor,
|
|
36
|
+
emitTsEncoder() {
|
|
37
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitTsFixedWidthStandaloneEncoder)("encodeUint32Standalone", fixedWidth)}`;
|
|
38
|
+
},
|
|
39
|
+
emitCppEncoder() {
|
|
40
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitCppFixedWidthStandaloneEncoder)("encodeUint32Standalone", fixedWidth)}`;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.encoder = exports.encoderEmitter;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter (decode): base93 blob -> TypeScript `number`, C++ `uint8_t`.
|
|
4
|
+
*
|
|
5
|
+
* This reverses the standalone `uint8` encoder by decoding 2 base93 characters
|
|
6
|
+
* to one byte and reading that byte through `Uint8Array` / `uint8_t`. The wire
|
|
7
|
+
* contract is identical to `quint8`, while the descriptor keeps the `uint8_t`
|
|
8
|
+
* identity for downstream code generation.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.decoder = exports.descriptor = void 0;
|
|
12
|
+
const comments_1 = require("../shared/comments");
|
|
13
|
+
const fixedwidth_1 = require("../shared/fixedwidth");
|
|
14
|
+
const encoder_1 = require("./encoder");
|
|
15
|
+
Object.defineProperty(exports, "descriptor", { enumerable: true, get: function () { return encoder_1.descriptor; } });
|
|
16
|
+
const fixedWidth = encoder_1.descriptor.fixedWidth;
|
|
17
|
+
const strategyComment = (0, comments_1.emitStrategyComment)("Base codec emitter (decode): AnQst.Type.uint8 / uint8_t", [
|
|
18
|
+
"Base93-decodes the standalone payload to one byte, then reads it through Uint8Array or uint8_t.",
|
|
19
|
+
"Returns a JS number in the unsigned 0-255 domain described by the uint8 spec.",
|
|
20
|
+
"Accepts the same 2-character wire strings as quint8 because the wire format is intentionally identical."
|
|
21
|
+
]);
|
|
22
|
+
exports.decoder = {
|
|
23
|
+
descriptor: encoder_1.descriptor,
|
|
24
|
+
emitTsDecoder() {
|
|
25
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitTsFixedWidthStandaloneDecoder)("decodeUint8Standalone", fixedWidth)}`;
|
|
26
|
+
},
|
|
27
|
+
emitCppDecoder() {
|
|
28
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitCppFixedWidthStandaloneDecoder)("decodeUint8Standalone", fixedWidth)}`;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter (encode): `AnQst.Type.uint8` -> TypeScript `number`, C++ `uint8_t`.
|
|
4
|
+
*
|
|
5
|
+
* This codec is wire-identical to `AnQst.Type.quint8`: a single unsigned byte
|
|
6
|
+
* encoded as a 2-character base93 string. The distinction is preserved only in
|
|
7
|
+
* descriptor metadata and the emitted C++ type mapping (`uint8_t` vs `quint8`).
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.encoder = exports.descriptor = void 0;
|
|
11
|
+
const comments_1 = require("../shared/comments");
|
|
12
|
+
const fixedwidth_1 = require("../shared/fixedwidth");
|
|
13
|
+
const fixedWidth = {
|
|
14
|
+
byteWidth: 1,
|
|
15
|
+
tsViewCtor: "Uint8Array",
|
|
16
|
+
cppType: "uint8_t"
|
|
17
|
+
};
|
|
18
|
+
exports.descriptor = {
|
|
19
|
+
codecId: "AnQst.Type.uint8",
|
|
20
|
+
specPath: "RefinedSpecs/Codecs/Integer_uint8_Codec.md",
|
|
21
|
+
tsType: "number",
|
|
22
|
+
cppType: "uint8_t",
|
|
23
|
+
wireCategory: "fixed-width-scalar",
|
|
24
|
+
strategySummary: "Single unsigned byte via Uint8Array / memcpy into uint8_t, base93 standalone string (2 chars); wire-identical to quint8 but descriptor/C++ mapping remain distinct.",
|
|
25
|
+
fixedWidth
|
|
26
|
+
};
|
|
27
|
+
const strategyComment = (0, comments_1.emitStrategyComment)("Base codec emitter (encode): AnQst.Type.uint8 / uint8_t", [
|
|
28
|
+
"Uses Uint8Array for the 1-byte unsigned representation on the TS side.",
|
|
29
|
+
"Uses std::memcpy into uint8_t on the C++ side for the same single-byte payload.",
|
|
30
|
+
"Produces the same 2-character base93 wire form as quint8; only descriptor and C++ typedef mapping differ."
|
|
31
|
+
]);
|
|
32
|
+
exports.encoder = {
|
|
33
|
+
descriptor: exports.descriptor,
|
|
34
|
+
emitTsEncoder() {
|
|
35
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitTsFixedWidthStandaloneEncoder)("encodeUint8Standalone", fixedWidth)}`;
|
|
36
|
+
},
|
|
37
|
+
emitCppEncoder() {
|
|
38
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitCppFixedWidthStandaloneEncoder)("encodeUint8Standalone", fixedWidth)}`;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter (decode): base93 blob → TypeScript `number`, C++ `double`.
|
|
4
|
+
* Reconstructs IEEE 754 binary64 from eight decoded bytes (platform-native order).
|
|
5
|
+
* See RefinedSpecs/Codecs/Number_number_Codec.md and AnQst-Opaque-Wire-Contract.md §6.4.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.numberDecoderEmitter = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
const fixedwidth_1 = require("../shared/fixedwidth");
|
|
11
|
+
const encoder_1 = require("./encoder");
|
|
12
|
+
Object.defineProperty(exports, "descriptor", { enumerable: true, get: function () { return encoder_1.descriptor; } });
|
|
13
|
+
const strategyComment = (0, comments_1.emitStrategyComment)("Base codec emitter (decode): AnQst.Type.number / double", [
|
|
14
|
+
"Decodes base93 to bytes, then Float64Array (TS) or std::memcpy (C++).",
|
|
15
|
+
"Expects base93Decode in scope; standalone payloads are exactly 10 characters.",
|
|
16
|
+
"Round-trips all IEEE special values and distinct NaN payloads when produced by the encoder."
|
|
17
|
+
]);
|
|
18
|
+
exports.numberDecoderEmitter = {
|
|
19
|
+
descriptor: encoder_1.descriptor,
|
|
20
|
+
emitTsDecoder() {
|
|
21
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitTsFixedWidthStandaloneDecoder)("decodeAnQstNumber", encoder_1.descriptor.fixedWidth)}`;
|
|
22
|
+
},
|
|
23
|
+
emitCppDecoder() {
|
|
24
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitCppFixedWidthStandaloneDecoder)("decodeAnQstNumber", encoder_1.descriptor.fixedWidth)}`;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter (encode): AnQst.Type.number ↔ TypeScript `number`, C++ `double`.
|
|
4
|
+
* Standalone wire shape is one base93 string of length 10 (8 IEEE 754 binary64 bytes).
|
|
5
|
+
* See RefinedSpecs/Codecs/Number_number_Codec.md and AnQst-Codec-Design-Principles.md §4.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.numberEncoderEmitter = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
const fixedwidth_1 = require("../shared/fixedwidth");
|
|
11
|
+
const fixedWidth = {
|
|
12
|
+
byteWidth: 8,
|
|
13
|
+
tsViewCtor: "Float64Array",
|
|
14
|
+
cppType: "double"
|
|
15
|
+
};
|
|
16
|
+
exports.descriptor = {
|
|
17
|
+
codecId: "AnQst.Type.number",
|
|
18
|
+
specPath: "RefinedSpecs/Codecs/Number_number_Codec.md",
|
|
19
|
+
tsType: "number",
|
|
20
|
+
cppType: "double",
|
|
21
|
+
wireCategory: "fixed-width-scalar",
|
|
22
|
+
strategySummary: "IEEE 754 binary64: 8 platform-native bytes packed via base93 (10 characters standalone).",
|
|
23
|
+
fixedWidth
|
|
24
|
+
};
|
|
25
|
+
const strategyComment = (0, comments_1.emitStrategyComment)("Base codec emitter (encode): AnQst.Type.number / double", [
|
|
26
|
+
"Uses Float64Array (TS) or std::memcpy (C++) for platform-native IEEE 754 bytes.",
|
|
27
|
+
"Emits base93 via shared fixed-width standalone helper (expects base93Encode in scope).",
|
|
28
|
+
"Preserves all bit patterns including ±0, NaN, ±Infinity, subnormals."
|
|
29
|
+
]);
|
|
30
|
+
exports.numberEncoderEmitter = {
|
|
31
|
+
descriptor: exports.descriptor,
|
|
32
|
+
emitTsEncoder() {
|
|
33
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitTsFixedWidthStandaloneEncoder)("encodeAnQstNumber", fixedWidth)}`;
|
|
34
|
+
},
|
|
35
|
+
emitCppEncoder() {
|
|
36
|
+
return `${strategyComment}\n\n${(0, fixedwidth_1.emitCppFixedWidthStandaloneEncoder)("encodeAnQstNumber", fixedWidth)}`;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitStrategyComment = emitStrategyComment;
|
|
4
|
+
function emitStrategyComment(title, bullets) {
|
|
5
|
+
const lines = [
|
|
6
|
+
"/**",
|
|
7
|
+
` * ${title}`,
|
|
8
|
+
" *",
|
|
9
|
+
...bullets.map((bullet) => ` * - ${bullet}`),
|
|
10
|
+
" */"
|
|
11
|
+
];
|
|
12
|
+
return lines.join("\n");
|
|
13
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitTsFixedWidthStandaloneEncoder = emitTsFixedWidthStandaloneEncoder;
|
|
4
|
+
exports.emitTsFixedWidthStandaloneDecoder = emitTsFixedWidthStandaloneDecoder;
|
|
5
|
+
exports.emitCppFixedWidthStandaloneEncoder = emitCppFixedWidthStandaloneEncoder;
|
|
6
|
+
exports.emitCppFixedWidthStandaloneDecoder = emitCppFixedWidthStandaloneDecoder;
|
|
7
|
+
function tsScalarBufferInit(descriptor, valueExpr) {
|
|
8
|
+
return [
|
|
9
|
+
`const buf = new ArrayBuffer(${descriptor.byteWidth});`,
|
|
10
|
+
`new ${descriptor.tsViewCtor}(buf)[0] = ${valueExpr};`,
|
|
11
|
+
"const bytes = new Uint8Array(buf);"
|
|
12
|
+
];
|
|
13
|
+
}
|
|
14
|
+
function tsScalarBufferRead(descriptor, bytesExpr) {
|
|
15
|
+
return [
|
|
16
|
+
`const buf = new ArrayBuffer(${descriptor.byteWidth});`,
|
|
17
|
+
`new Uint8Array(buf).set(${bytesExpr});`,
|
|
18
|
+
`return new ${descriptor.tsViewCtor}(buf)[0];`
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
function emitTsFixedWidthStandaloneEncoder(functionName, descriptor, valueExpr = "value") {
|
|
22
|
+
const lines = [
|
|
23
|
+
`function ${functionName}(value) {`,
|
|
24
|
+
...tsScalarBufferInit(descriptor, valueExpr).map((line) => ` ${line}`),
|
|
25
|
+
" return base93Encode(bytes);",
|
|
26
|
+
"}"
|
|
27
|
+
];
|
|
28
|
+
return lines.join("\n");
|
|
29
|
+
}
|
|
30
|
+
function emitTsFixedWidthStandaloneDecoder(functionName, descriptor) {
|
|
31
|
+
const lines = [
|
|
32
|
+
`function ${functionName}(encoded) {`,
|
|
33
|
+
" const bytes = base93Decode(encoded);",
|
|
34
|
+
...tsScalarBufferRead(descriptor, "bytes").map((line) => ` ${line}`),
|
|
35
|
+
"}"
|
|
36
|
+
];
|
|
37
|
+
return lines.join("\n");
|
|
38
|
+
}
|
|
39
|
+
function emitCppFixedWidthStandaloneEncoder(functionName, descriptor) {
|
|
40
|
+
return `inline std::string ${functionName}(const ${descriptor.cppType}& value) {
|
|
41
|
+
std::array<std::uint8_t, ${descriptor.byteWidth}> bytes{};
|
|
42
|
+
std::memcpy(bytes.data(), &value, ${descriptor.byteWidth});
|
|
43
|
+
return base93Encode(std::vector<std::uint8_t>(bytes.begin(), bytes.end()));
|
|
44
|
+
}`;
|
|
45
|
+
}
|
|
46
|
+
function emitCppFixedWidthStandaloneDecoder(functionName, descriptor) {
|
|
47
|
+
return `inline ${descriptor.cppType} ${functionName}(const std::string& encoded) {
|
|
48
|
+
const std::vector<std::uint8_t> bytes = base93Decode(encoded);
|
|
49
|
+
${descriptor.cppType} value{};
|
|
50
|
+
std::memcpy(&value, bytes.data(), ${descriptor.byteWidth});
|
|
51
|
+
return value;
|
|
52
|
+
}`;
|
|
53
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./comments"), exports);
|
|
18
|
+
__exportStar(require("./contracts"), exports);
|
|
19
|
+
__exportStar(require("./fixedwidth"), exports);
|
|
20
|
+
__exportStar(require("./positionalBase93"), exports);
|
|
21
|
+
__exportStar(require("./rawbytes"), exports);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitPositionalBase93CountEncoder = emitPositionalBase93CountEncoder;
|
|
4
|
+
exports.emitPositionalBase93CountDecoder = emitPositionalBase93CountDecoder;
|
|
5
|
+
exports.emitPositionalBase93CountCppFunctions = emitPositionalBase93CountCppFunctions;
|
|
6
|
+
const base93_1 = require("../../../base93");
|
|
7
|
+
function emitPositionalBase93CountEncoder(functionName = "encodeBase93Count") {
|
|
8
|
+
return `function ${functionName}(value) {
|
|
9
|
+
var A = "${base93_1.BASE93_ALPHABET}", v = value >>> 0, out = "";
|
|
10
|
+
if (v === 0) return A[0];
|
|
11
|
+
while (v > 0) {
|
|
12
|
+
out = A[v % 93] + out;
|
|
13
|
+
v = (v / 93) | 0;
|
|
14
|
+
}
|
|
15
|
+
return out;
|
|
16
|
+
}`;
|
|
17
|
+
}
|
|
18
|
+
function emitPositionalBase93CountDecoder(functionName = "decodeBase93Count") {
|
|
19
|
+
return `function ${functionName}(value) {
|
|
20
|
+
var n = value.length, acc = 0, i, c;
|
|
21
|
+
for (i = 0; i < n; i++) {
|
|
22
|
+
c = value.charCodeAt(i);
|
|
23
|
+
acc = acc * 93 + c - 32 - (c > 34) - (c > 92);
|
|
24
|
+
}
|
|
25
|
+
return acc >>> 0;
|
|
26
|
+
}`;
|
|
27
|
+
}
|
|
28
|
+
function emitPositionalBase93CountCppFunctions() {
|
|
29
|
+
return `inline std::string encodeBase93Count(std::uint32_t value) {
|
|
30
|
+
static constexpr char A[] = "${base93_1.BASE93_ALPHABET}";
|
|
31
|
+
if (value == 0u) return std::string(1, A[0]);
|
|
32
|
+
std::string out;
|
|
33
|
+
while (value > 0u) {
|
|
34
|
+
out.insert(out.begin(), A[value % 93u]);
|
|
35
|
+
value /= 93u;
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
inline std::uint32_t decodeBase93Count(const std::string& value) {
|
|
41
|
+
std::uint32_t acc = 0;
|
|
42
|
+
for (char c : value) {
|
|
43
|
+
const unsigned char uc = static_cast<unsigned char>(c);
|
|
44
|
+
acc = acc * 93u + static_cast<std::uint32_t>(uc - 32 - (uc > 34) - (uc > 92));
|
|
45
|
+
}
|
|
46
|
+
return acc;
|
|
47
|
+
}`;
|
|
48
|
+
}
|