@dusted/anqst 1.0.0 → 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 +103 -77
- package/dist/src/base93.js +124 -0
- package/dist/src/build-stamp.js +1 -1
- 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 +760 -120
- package/dist/src/structured-top-level-codecs.js +1305 -0
- package/package.json +2 -3
- package/spec/AnQst-Spec-DSL.d.ts +15 -8
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AnQstGen base-type codec emitter for `binary-float32Array`.
|
|
4
|
+
* Decoder consumes one base93 string of raw bytes and reconstructs a concrete `Float32Array`.
|
|
5
|
+
* Multi-byte element byte order and all IEEE 754 bit patterns are preserved exactly as transmitted.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.decoder = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
const encoder_1 = require("./encoder");
|
|
11
|
+
Object.defineProperty(exports, "descriptor", { enumerable: true, get: function () { return encoder_1.descriptor; } });
|
|
12
|
+
const TS_FN = "decodeBinaryFloat32ArrayStandalone";
|
|
13
|
+
const CPP_FN = "decodeBinaryFloat32ArrayStandalone";
|
|
14
|
+
exports.decoder = {
|
|
15
|
+
descriptor: encoder_1.descriptor,
|
|
16
|
+
emitTsDecoder() {
|
|
17
|
+
return [
|
|
18
|
+
(0, comments_1.emitStrategyComment)("AnQst Float32Array decoder (raw-byte base93)", [
|
|
19
|
+
"Decodes base93 to bytes, then constructs a concrete Float32Array view over the decoded buffer.",
|
|
20
|
+
"Rejected decoded byte counts not divisible by 4 indicate corrupted wire data because Float32Array elements require 4 bytes each."
|
|
21
|
+
]),
|
|
22
|
+
`function ${TS_FN}(encoded) {`,
|
|
23
|
+
" const bytes = base93Decode(encoded);",
|
|
24
|
+
" if ((bytes.byteLength & 3) !== 0) {",
|
|
25
|
+
" throw new RangeError(\"Decoded Float32Array byte length must be divisible by 4.\");",
|
|
26
|
+
" }",
|
|
27
|
+
" return new Float32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);",
|
|
28
|
+
"}"
|
|
29
|
+
].join("\n");
|
|
30
|
+
},
|
|
31
|
+
emitCppDecoder() {
|
|
32
|
+
return [
|
|
33
|
+
(0, comments_1.emitStrategyComment)("AnQst Float32Array decoder (QByteArray raw bytes)", [
|
|
34
|
+
"C++ receives the raw bytes as QByteArray; float interpretation stays outside the byte-transport codec.",
|
|
35
|
+
"Portable tests may supply a lightweight QByteArray shim with a (const char*, int) constructor."
|
|
36
|
+
]),
|
|
37
|
+
`inline QByteArray ${CPP_FN}(const std::string& encoded) {`,
|
|
38
|
+
" const std::vector<std::uint8_t> bytes = base93Decode(encoded);",
|
|
39
|
+
" return QByteArray(",
|
|
40
|
+
" reinterpret_cast<const char*>(bytes.data()),",
|
|
41
|
+
" static_cast<int>(bytes.size())",
|
|
42
|
+
" );",
|
|
43
|
+
"}"
|
|
44
|
+
].join("\n");
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AnQstGen base-type codec emitter for `binary-float32Array`.
|
|
4
|
+
* Wire form is one base93 string carrying the raw bytes of a `Float32Array` view.
|
|
5
|
+
* The TypeScript path must respect `byteOffset`/`byteLength`; the C++ path keeps the spec-facing `QByteArray` signature.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.encoder = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
exports.descriptor = {
|
|
11
|
+
codecId: "binary-float32Array",
|
|
12
|
+
specPath: "RefinedSpecs/Codecs/Binary_float32Array_Codec.md",
|
|
13
|
+
tsType: "Float32Array",
|
|
14
|
+
cppType: "QByteArray",
|
|
15
|
+
wireCategory: "binary",
|
|
16
|
+
strategySummary: "Base93-encode the raw bytes of the Float32Array view (respecting byteOffset/byteLength); C++ receives the same raw bytes in QByteArray."
|
|
17
|
+
};
|
|
18
|
+
const TS_FN = "encodeBinaryFloat32ArrayStandalone";
|
|
19
|
+
const CPP_FN = "encodeBinaryFloat32ArrayStandalone";
|
|
20
|
+
exports.encoder = {
|
|
21
|
+
descriptor: exports.descriptor,
|
|
22
|
+
emitTsEncoder() {
|
|
23
|
+
return [
|
|
24
|
+
(0, comments_1.emitStrategyComment)("AnQst Float32Array encoder (raw-byte base93)", [
|
|
25
|
+
"Reads only the concrete view window via byteOffset/byteLength, so subviews do not leak adjacent buffer bytes.",
|
|
26
|
+
"Preserves the stored IEEE 754 binary32 bit patterns exactly, including NaN payloads, infinities, and signed zero."
|
|
27
|
+
]),
|
|
28
|
+
`function ${TS_FN}(value) {`,
|
|
29
|
+
" const bytes = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);",
|
|
30
|
+
" return base93Encode(bytes);",
|
|
31
|
+
"}"
|
|
32
|
+
].join("\n");
|
|
33
|
+
},
|
|
34
|
+
emitCppEncoder() {
|
|
35
|
+
return [
|
|
36
|
+
(0, comments_1.emitStrategyComment)("AnQst Float32Array encoder (QByteArray raw bytes)", [
|
|
37
|
+
"Host-side integration passes the raw float32 bytes as QByteArray; portable tests can provide a minimal QByteArray shim.",
|
|
38
|
+
"No byte swapping or float normalization is performed; the QByteArray contents are forwarded as-is into base93."
|
|
39
|
+
]),
|
|
40
|
+
`inline std::string ${CPP_FN}(const QByteArray& value) {`,
|
|
41
|
+
" std::vector<std::uint8_t> bytes(static_cast<std::size_t>(value.size()));",
|
|
42
|
+
" if (!bytes.empty()) {",
|
|
43
|
+
" std::memcpy(bytes.data(), value.constData(), bytes.size());",
|
|
44
|
+
" }",
|
|
45
|
+
" return base93Encode(bytes);",
|
|
46
|
+
"}"
|
|
47
|
+
].join("\n");
|
|
48
|
+
}
|
|
49
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AnQstGen base-type codec emitter for `binary-float64Array`.
|
|
4
|
+
* Decoder consumes one base93 string of raw bytes and reconstructs a concrete `Float64Array`.
|
|
5
|
+
* Multi-byte element byte order is preserved exactly as transmitted; no byte swapping is introduced.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.decoder = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
const encoder_1 = require("./encoder");
|
|
11
|
+
Object.defineProperty(exports, "descriptor", { enumerable: true, get: function () { return encoder_1.descriptor; } });
|
|
12
|
+
const TS_FN = "decodeBinaryFloat64ArrayStandalone";
|
|
13
|
+
const CPP_FN = "decodeBinaryFloat64ArrayStandalone";
|
|
14
|
+
exports.decoder = {
|
|
15
|
+
descriptor: encoder_1.descriptor,
|
|
16
|
+
emitTsDecoder() {
|
|
17
|
+
return [
|
|
18
|
+
(0, comments_1.emitStrategyComment)("AnQst Float64Array decoder (raw-byte base93)", [
|
|
19
|
+
"Decodes base93 to bytes, then constructs a concrete Float64Array over the decoded buffer.",
|
|
20
|
+
"Rejected decoded byte counts that are not divisible by 8 indicate corrupted wire data because Float64Array elements require 8 bytes each."
|
|
21
|
+
]),
|
|
22
|
+
`function ${TS_FN}(encoded) {`,
|
|
23
|
+
" const bytes = base93Decode(encoded);",
|
|
24
|
+
" if ((bytes.byteLength & 7) !== 0) {",
|
|
25
|
+
' throw new RangeError("Decoded Float64Array byte length must be divisible by 8.");',
|
|
26
|
+
" }",
|
|
27
|
+
" return new Float64Array(bytes.buffer);",
|
|
28
|
+
"}"
|
|
29
|
+
].join("\n");
|
|
30
|
+
},
|
|
31
|
+
emitCppDecoder() {
|
|
32
|
+
return [
|
|
33
|
+
(0, comments_1.emitStrategyComment)("AnQst Float64Array decoder (QByteArray raw bytes)", [
|
|
34
|
+
"C++ receives the raw bytes as QByteArray; element interpretation stays outside the byte-transport codec.",
|
|
35
|
+
"Portable tests may supply a lightweight QByteArray shim with a (const char*, int) constructor."
|
|
36
|
+
]),
|
|
37
|
+
`inline QByteArray ${CPP_FN}(const std::string& encoded) {`,
|
|
38
|
+
" const std::vector<std::uint8_t> bytes = base93Decode(encoded);",
|
|
39
|
+
" return QByteArray(",
|
|
40
|
+
" reinterpret_cast<const char*>(bytes.data()),",
|
|
41
|
+
" static_cast<int>(bytes.size())",
|
|
42
|
+
" );",
|
|
43
|
+
"}"
|
|
44
|
+
].join("\n");
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AnQstGen base-type codec emitter for `binary-float64Array`.
|
|
4
|
+
* Wire form is one base93 string carrying the raw bytes of a `Float64Array` view.
|
|
5
|
+
* The TypeScript path must respect `byteOffset`/`byteLength`; the C++ path keeps the spec-facing `QByteArray` signature.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.encoder = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
const rawbytes_1 = require("../shared/rawbytes");
|
|
11
|
+
exports.descriptor = {
|
|
12
|
+
codecId: "binary-float64Array",
|
|
13
|
+
specPath: "RefinedSpecs/Codecs/Binary_float64Array_Codec.md",
|
|
14
|
+
tsType: "Float64Array",
|
|
15
|
+
cppType: "QByteArray",
|
|
16
|
+
wireCategory: "binary",
|
|
17
|
+
strategySummary: "Base93-encode the raw bytes of the Float64Array view (respecting byteOffset/byteLength); C++ receives the same raw bytes in QByteArray."
|
|
18
|
+
};
|
|
19
|
+
const TS_FN = "encodeBinaryFloat64ArrayStandalone";
|
|
20
|
+
const CPP_FN = "encodeBinaryFloat64ArrayStandalone";
|
|
21
|
+
exports.encoder = {
|
|
22
|
+
descriptor: exports.descriptor,
|
|
23
|
+
emitTsEncoder() {
|
|
24
|
+
return [
|
|
25
|
+
(0, comments_1.emitStrategyComment)("AnQst Float64Array encoder (raw-byte base93)", [
|
|
26
|
+
"Reads only the active Float64Array view window via byteOffset/byteLength, so subviews do not leak adjacent buffer bytes.",
|
|
27
|
+
"Preserves the stored IEEE 754 binary64 bytes exactly, including NaN payloads, infinities, signed zero, and subnormals."
|
|
28
|
+
]),
|
|
29
|
+
(0, rawbytes_1.emitTsRawByteStandaloneEncoder)(TS_FN, "new Uint8Array(value.buffer, value.byteOffset, value.byteLength)")
|
|
30
|
+
].join("\n\n");
|
|
31
|
+
},
|
|
32
|
+
emitCppEncoder() {
|
|
33
|
+
return [
|
|
34
|
+
(0, comments_1.emitStrategyComment)("AnQst Float64Array encoder (QByteArray raw bytes)", [
|
|
35
|
+
"Host-side integration passes the Float64Array payload as QByteArray because the backend mapping is raw bytes, not a numeric container.",
|
|
36
|
+
"No byte swapping or normalization is performed; the QByteArray contents are forwarded as-is into base93."
|
|
37
|
+
]),
|
|
38
|
+
`inline std::string ${CPP_FN}(const QByteArray& value) {`,
|
|
39
|
+
" std::vector<std::uint8_t> bytes(static_cast<std::size_t>(value.size()));",
|
|
40
|
+
" if (!bytes.empty()) {",
|
|
41
|
+
" std::memcpy(bytes.data(), value.constData(), bytes.size());",
|
|
42
|
+
" }",
|
|
43
|
+
" return base93Encode(bytes);",
|
|
44
|
+
"}"
|
|
45
|
+
].join("\n");
|
|
46
|
+
}
|
|
47
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AnQstGen base-type codec emitter for `binary-int16Array`.
|
|
4
|
+
* Decoder consumes one base93 string of raw bytes and reconstructs a concrete `Int16Array`.
|
|
5
|
+
* Multi-byte element byte order is preserved exactly as transmitted; no byte swapping is introduced.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.decoder = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
const encoder_1 = require("./encoder");
|
|
11
|
+
Object.defineProperty(exports, "descriptor", { enumerable: true, get: function () { return encoder_1.descriptor; } });
|
|
12
|
+
const TS_FN = "decodeBinaryInt16ArrayStandalone";
|
|
13
|
+
const CPP_FN = "decodeBinaryInt16ArrayStandalone";
|
|
14
|
+
exports.decoder = {
|
|
15
|
+
descriptor: encoder_1.descriptor,
|
|
16
|
+
emitTsDecoder() {
|
|
17
|
+
return [
|
|
18
|
+
(0, comments_1.emitStrategyComment)("AnQst Int16Array decoder (raw-byte base93)", [
|
|
19
|
+
"Decodes base93 to bytes, then reconstructs a concrete Int16Array over the decoded buffer.",
|
|
20
|
+
"Rejected odd decoded byte counts indicate corrupted wire data because Int16Array elements require 2 bytes each."
|
|
21
|
+
]),
|
|
22
|
+
`function ${TS_FN}(encoded) {`,
|
|
23
|
+
" const bytes = base93Decode(encoded);",
|
|
24
|
+
" if ((bytes.byteLength & 1) !== 0) {",
|
|
25
|
+
" throw new RangeError(\"Decoded Int16Array byte length must be divisible by 2.\");",
|
|
26
|
+
" }",
|
|
27
|
+
" return new Int16Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 2);",
|
|
28
|
+
"}"
|
|
29
|
+
].join("\n");
|
|
30
|
+
},
|
|
31
|
+
emitCppDecoder() {
|
|
32
|
+
return [
|
|
33
|
+
(0, comments_1.emitStrategyComment)("AnQst Int16Array decoder (QByteArray raw bytes)", [
|
|
34
|
+
"C++ receives the raw bytes as QByteArray; signed 16-bit interpretation stays outside the byte-transport codec.",
|
|
35
|
+
"Portable tests may supply a lightweight QByteArray shim with a (const char*, int) constructor."
|
|
36
|
+
]),
|
|
37
|
+
`inline QByteArray ${CPP_FN}(const std::string& encoded) {`,
|
|
38
|
+
" const std::vector<std::uint8_t> bytes = base93Decode(encoded);",
|
|
39
|
+
" return QByteArray(",
|
|
40
|
+
" reinterpret_cast<const char*>(bytes.data()),",
|
|
41
|
+
" static_cast<int>(bytes.size())",
|
|
42
|
+
" );",
|
|
43
|
+
"}"
|
|
44
|
+
].join("\n");
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AnQstGen base-type codec emitter for `binary-int16Array`.
|
|
4
|
+
* Wire form is one base93 string carrying the raw bytes of an `Int16Array` view.
|
|
5
|
+
* The TypeScript path must respect `byteOffset`/`byteLength`; the C++ path keeps the spec-facing `QByteArray` signature.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.encoder = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
exports.descriptor = {
|
|
11
|
+
codecId: "binary-int16Array",
|
|
12
|
+
specPath: "RefinedSpecs/Codecs/Binary_int16Array_Codec.md",
|
|
13
|
+
tsType: "Int16Array",
|
|
14
|
+
cppType: "QByteArray",
|
|
15
|
+
wireCategory: "binary",
|
|
16
|
+
strategySummary: "Base93-encode the raw bytes of the Int16Array view (respecting byteOffset/byteLength); C++ receives the same raw bytes in QByteArray."
|
|
17
|
+
};
|
|
18
|
+
const TS_FN = "encodeBinaryInt16ArrayStandalone";
|
|
19
|
+
const CPP_FN = "encodeBinaryInt16ArrayStandalone";
|
|
20
|
+
exports.encoder = {
|
|
21
|
+
descriptor: exports.descriptor,
|
|
22
|
+
emitTsEncoder() {
|
|
23
|
+
return [
|
|
24
|
+
(0, comments_1.emitStrategyComment)("AnQst Int16Array encoder (raw-byte base93)", [
|
|
25
|
+
"Reads only the concrete view window via byteOffset/byteLength, so subviews do not leak adjacent buffer bytes.",
|
|
26
|
+
"Preserves platform-native two-byte element layout by forwarding the stored raw bytes unchanged into base93."
|
|
27
|
+
]),
|
|
28
|
+
`function ${TS_FN}(value) {`,
|
|
29
|
+
" const bytes = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);",
|
|
30
|
+
" return base93Encode(bytes);",
|
|
31
|
+
"}"
|
|
32
|
+
].join("\n");
|
|
33
|
+
},
|
|
34
|
+
emitCppEncoder() {
|
|
35
|
+
return [
|
|
36
|
+
(0, comments_1.emitStrategyComment)("AnQst Int16Array encoder (QByteArray raw bytes)", [
|
|
37
|
+
"Host-side integration passes the raw typed-array bytes as QByteArray; portable tests can provide a minimal QByteArray shim.",
|
|
38
|
+
"No byte swapping is performed; the QByteArray contents are forwarded as-is into base93."
|
|
39
|
+
]),
|
|
40
|
+
`inline std::string ${CPP_FN}(const QByteArray& value) {`,
|
|
41
|
+
" std::vector<std::uint8_t> bytes(static_cast<std::size_t>(value.size()));",
|
|
42
|
+
" if (!bytes.empty()) {",
|
|
43
|
+
" std::memcpy(bytes.data(), value.constData(), bytes.size());",
|
|
44
|
+
" }",
|
|
45
|
+
" return base93Encode(bytes);",
|
|
46
|
+
"}"
|
|
47
|
+
].join("\n");
|
|
48
|
+
}
|
|
49
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter: `AnQst.Type.int32Array` decoder.
|
|
4
|
+
* Decodes one raw-byte base93 string back into a concrete `Int32Array`, preserving
|
|
5
|
+
* the exact transmitted byte sequence and rejecting byte counts that cannot form 32-bit elements.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.decoder = exports.decoderEmitter = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
const encoder_1 = require("./encoder");
|
|
11
|
+
Object.defineProperty(exports, "descriptor", { enumerable: true, get: function () { return encoder_1.descriptor; } });
|
|
12
|
+
const TS_FN = "decodeBinaryInt32ArrayStandalone";
|
|
13
|
+
const CPP_FN = "decodeBinaryInt32ArrayStandalone";
|
|
14
|
+
exports.decoderEmitter = {
|
|
15
|
+
descriptor: encoder_1.descriptor,
|
|
16
|
+
emitTsDecoder() {
|
|
17
|
+
return [
|
|
18
|
+
(0, comments_1.emitStrategyComment)("AnQst Int32Array decoder (raw-byte base93)", [
|
|
19
|
+
"Base93-decodes the standalone wire payload back to raw bytes and reconstructs a concrete Int32Array.",
|
|
20
|
+
"Decoded byte counts must be divisible by 4 because each Int32Array element occupies exactly 4 bytes.",
|
|
21
|
+
"Slices the decoded byte window before constructing Int32Array so reconstruction is robust even if the decoded Uint8Array is not offset-zero."
|
|
22
|
+
]),
|
|
23
|
+
`function ${TS_FN}(encoded) {`,
|
|
24
|
+
" const bytes = base93Decode(encoded);",
|
|
25
|
+
" if ((bytes.byteLength & 3) !== 0) {",
|
|
26
|
+
" throw new RangeError(\"Decoded Int32Array byte length must be divisible by 4.\");",
|
|
27
|
+
" }",
|
|
28
|
+
" const buffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);",
|
|
29
|
+
" return new Int32Array(buffer);",
|
|
30
|
+
"}"
|
|
31
|
+
].join("\n");
|
|
32
|
+
},
|
|
33
|
+
emitCppDecoder() {
|
|
34
|
+
return [
|
|
35
|
+
(0, comments_1.emitStrategyComment)("AnQst Int32Array decoder (QByteArray raw bytes)", [
|
|
36
|
+
"C++ receives the same raw 32-bit element storage bytes as QByteArray; typed interpretation remains outside this byte-transport helper.",
|
|
37
|
+
"Portable interop tests can use a lightweight QByteArray shim with a (const char*, int) constructor.",
|
|
38
|
+
"No sign conversion or byte swapping occurs during wire decode; the original raw bytes are restored exactly."
|
|
39
|
+
]),
|
|
40
|
+
`inline QByteArray ${CPP_FN}(const std::string& encoded) {`,
|
|
41
|
+
" const std::vector<std::uint8_t> bytes = base93Decode(encoded);",
|
|
42
|
+
" return QByteArray(",
|
|
43
|
+
" reinterpret_cast<const char*>(bytes.data()),",
|
|
44
|
+
" static_cast<int>(bytes.size())",
|
|
45
|
+
" );",
|
|
46
|
+
"}"
|
|
47
|
+
].join("\n");
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
exports.decoder = exports.decoderEmitter;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter: `AnQst.Type.int32Array` encoder.
|
|
4
|
+
* Emits the visible `Int32Array` view window as standalone raw-byte base93 while
|
|
5
|
+
* preserving signed bit patterns and portable `QByteArray` interop on the C++ side.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.encoder = exports.encoderEmitter = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
exports.descriptor = {
|
|
11
|
+
codecId: "binary-int32Array",
|
|
12
|
+
specPath: "RefinedSpecs/Codecs/Binary_int32Array_Codec.md",
|
|
13
|
+
tsType: "Int32Array",
|
|
14
|
+
cppType: "QByteArray",
|
|
15
|
+
wireCategory: "binary",
|
|
16
|
+
strategySummary: "Base93-encode the raw bytes of the visible Int32Array view; decode reconstructs a concrete Int32Array, while C++ interoperates through the same QByteArray raw-byte payload."
|
|
17
|
+
};
|
|
18
|
+
const TS_FN = "encodeBinaryInt32ArrayStandalone";
|
|
19
|
+
const CPP_FN = "encodeBinaryInt32ArrayStandalone";
|
|
20
|
+
exports.encoderEmitter = {
|
|
21
|
+
descriptor: exports.descriptor,
|
|
22
|
+
emitTsEncoder() {
|
|
23
|
+
return [
|
|
24
|
+
(0, comments_1.emitStrategyComment)("AnQst Int32Array encoder (raw-byte base93)", [
|
|
25
|
+
"Encodes only the active Int32Array view window via byteOffset/byteLength so subviews do not leak adjacent backing-buffer bytes.",
|
|
26
|
+
"Signed values are transported as their raw stored bytes with no reinterpretation, normalization, or byte swapping.",
|
|
27
|
+
"Wire bytes remain portable because the C++ side consumes and emits the same QByteArray byte sequence."
|
|
28
|
+
]),
|
|
29
|
+
`function ${TS_FN}(value) {`,
|
|
30
|
+
" const bytes = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);",
|
|
31
|
+
" return base93Encode(bytes);",
|
|
32
|
+
"}"
|
|
33
|
+
].join("\n");
|
|
34
|
+
},
|
|
35
|
+
emitCppEncoder() {
|
|
36
|
+
return [
|
|
37
|
+
(0, comments_1.emitStrategyComment)("AnQst Int32Array encoder (QByteArray raw bytes)", [
|
|
38
|
+
"Host-side integration passes Int32Array storage as QByteArray so the byte transport stays identical across TypeScript and C++.",
|
|
39
|
+
"No sign conversion or endianness adjustment is applied; the stored bytes are forwarded unchanged into base93.",
|
|
40
|
+
"Uses an explicit copy so portable test shims only need QByteArray::constData() and QByteArray::size()."
|
|
41
|
+
]),
|
|
42
|
+
`inline std::string ${CPP_FN}(const QByteArray& value) {`,
|
|
43
|
+
" std::vector<std::uint8_t> bytes(static_cast<std::size_t>(value.size()));",
|
|
44
|
+
" if (!bytes.empty()) {",
|
|
45
|
+
" std::memcpy(bytes.data(), value.constData(), bytes.size());",
|
|
46
|
+
" }",
|
|
47
|
+
" return base93Encode(bytes);",
|
|
48
|
+
"}"
|
|
49
|
+
].join("\n");
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
exports.encoder = exports.encoderEmitter;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter (decode): base93 blob → TypeScript `Int8Array`, C++ `QByteArray`.
|
|
4
|
+
* Reconstructs raw bytes with base93Decode, then reinterprets the backing buffer as Int8Array.
|
|
5
|
+
* The wire format is identical to the buffer and typedArray binary codecs.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.binaryInt8ArrayDecoderEmitter = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
const encoder_1 = require("./encoder");
|
|
11
|
+
Object.defineProperty(exports, "descriptor", { enumerable: true, get: function () { return encoder_1.descriptor; } });
|
|
12
|
+
const strategyComment = (0, comments_1.emitStrategyComment)("Base codec emitter (decode): AnQst.Type.int8Array / QByteArray", [
|
|
13
|
+
"Decodes base93 into raw bytes, then reconstructs Int8Array with new Int8Array(bytes.buffer).",
|
|
14
|
+
"Preserves signed byte patterns because the underlying bytes are transported unchanged.",
|
|
15
|
+
"C++ side rebuilds a QByteArray from the decoded byte vector using the same wire contract."
|
|
16
|
+
]);
|
|
17
|
+
exports.binaryInt8ArrayDecoderEmitter = {
|
|
18
|
+
descriptor: encoder_1.descriptor,
|
|
19
|
+
emitTsDecoder() {
|
|
20
|
+
return `${strategyComment}
|
|
21
|
+
|
|
22
|
+
function decodeAnQstBinaryInt8Array(encoded) {
|
|
23
|
+
const bytes = base93Decode(encoded);
|
|
24
|
+
return new Int8Array(bytes.buffer);
|
|
25
|
+
}`;
|
|
26
|
+
},
|
|
27
|
+
emitCppDecoder() {
|
|
28
|
+
return `${strategyComment}
|
|
29
|
+
|
|
30
|
+
inline QByteArray decodeAnQstBinaryInt8Array(const std::string& encoded) {
|
|
31
|
+
const std::vector<std::uint8_t> bytes = base93Decode(encoded);
|
|
32
|
+
return QByteArray(
|
|
33
|
+
reinterpret_cast<const char*>(bytes.data()),
|
|
34
|
+
static_cast<int>(bytes.size())
|
|
35
|
+
);
|
|
36
|
+
}`;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter (encode): AnQst.Type.int8Array ↔ TypeScript `Int8Array`, C++ `QByteArray`.
|
|
4
|
+
* Serializes the raw bytes of the Int8Array view with base93, preserving byteOffset/byteLength.
|
|
5
|
+
* Wire format matches the buffer and typedArray binary codecs; only the TS view type differs.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.binaryInt8ArrayEncoderEmitter = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
exports.descriptor = {
|
|
11
|
+
codecId: "AnQst.Type.int8Array",
|
|
12
|
+
specPath: "RefinedSpecs/Codecs/Binary_int8Array_Codec.md",
|
|
13
|
+
tsType: "Int8Array",
|
|
14
|
+
cppType: "QByteArray",
|
|
15
|
+
wireCategory: "binary",
|
|
16
|
+
strategySummary: "Serialize the raw bytes of the Int8Array view as base93, respecting byteOffset/byteLength and preserving signed byte bit patterns."
|
|
17
|
+
};
|
|
18
|
+
const strategyComment = (0, comments_1.emitStrategyComment)("Base codec emitter (encode): AnQst.Type.int8Array / QByteArray", [
|
|
19
|
+
"Views Int8Array as Uint8Array over the same buffer slice so only the active view bytes are emitted.",
|
|
20
|
+
"Uses the shared base93 binary transport contract; signed byte interpretation is irrelevant on the wire.",
|
|
21
|
+
"C++ side mirrors this as raw QByteArray bytes encoded with the same base93 algorithm."
|
|
22
|
+
]);
|
|
23
|
+
exports.binaryInt8ArrayEncoderEmitter = {
|
|
24
|
+
descriptor: exports.descriptor,
|
|
25
|
+
emitTsEncoder() {
|
|
26
|
+
return `${strategyComment}
|
|
27
|
+
|
|
28
|
+
function encodeAnQstBinaryInt8Array(value) {
|
|
29
|
+
const bytes = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
30
|
+
return base93Encode(bytes);
|
|
31
|
+
}`;
|
|
32
|
+
},
|
|
33
|
+
emitCppEncoder() {
|
|
34
|
+
return `${strategyComment}
|
|
35
|
+
|
|
36
|
+
inline std::string encodeAnQstBinaryInt8Array(const QByteArray& value) {
|
|
37
|
+
const auto* begin = reinterpret_cast<const std::uint8_t*>(value.constData());
|
|
38
|
+
return base93Encode(std::vector<std::uint8_t>(
|
|
39
|
+
begin,
|
|
40
|
+
begin + static_cast<std::size_t>(value.size())
|
|
41
|
+
));
|
|
42
|
+
}`;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter: `AnQst.Type.typedArray` decoder.
|
|
4
|
+
* Decoding requires a concrete TypedArray constructor because abstract `TypedArray`
|
|
5
|
+
* alone does not identify element width or the runtime view type to reconstruct.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.decoderEmitter = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
const rawbytes_1 = require("../shared/rawbytes");
|
|
11
|
+
const encoder_1 = require("./encoder");
|
|
12
|
+
Object.defineProperty(exports, "descriptor", { enumerable: true, get: function () { return encoder_1.descriptor; } });
|
|
13
|
+
const TS_FN = "decodeBinaryTypedArrayStandalone";
|
|
14
|
+
const CPP_FN = "decodeBinaryTypedArrayStandalone";
|
|
15
|
+
const strategyComment = (0, comments_1.emitStrategyComment)("Base codec emitter (decode): AnQst.Type.typedArray / QByteArray", [
|
|
16
|
+
"Base93-decodes the standalone raw-byte payload back to a Uint8Array of bytes.",
|
|
17
|
+
"The emitted TypeScript API requires a concrete typed-array constructor because abstract TypedArray is insufficient to reconstruct element width and view type.",
|
|
18
|
+
"C++ rebuilds QByteArray directly because the backend mapping remains raw bytes."
|
|
19
|
+
]);
|
|
20
|
+
exports.decoderEmitter = {
|
|
21
|
+
descriptor: encoder_1.descriptor,
|
|
22
|
+
emitTsDecoder() {
|
|
23
|
+
return `${strategyComment}
|
|
24
|
+
|
|
25
|
+
function ${TS_FN}(encoded, typedArrayCtor) {
|
|
26
|
+
const bytes = base93Decode(encoded);
|
|
27
|
+
return new typedArrayCtor(bytes.buffer);
|
|
28
|
+
}`;
|
|
29
|
+
},
|
|
30
|
+
emitCppDecoder() {
|
|
31
|
+
return `${strategyComment}\n\n${(0, rawbytes_1.emitCppRawByteStandaloneDecoder)(CPP_FN, "QByteArray(reinterpret_cast<const char*>(bytes.data()), static_cast<int>(bytes.size()))")}`;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base codec emitter: `AnQst.Type.typedArray` encoder.
|
|
4
|
+
* Emits the active TypedArray view window as standalone base93 raw bytes.
|
|
5
|
+
* The wire bytes match `buffer`; only the TypeScript domain type is a typed-array view.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.encoderEmitter = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
const rawbytes_1 = require("../shared/rawbytes");
|
|
11
|
+
exports.descriptor = {
|
|
12
|
+
codecId: "binary-typedArray",
|
|
13
|
+
specPath: "RefinedSpecs/Codecs/Binary_typedArray_Codec.md",
|
|
14
|
+
tsType: "TypedArray",
|
|
15
|
+
cppType: "QByteArray",
|
|
16
|
+
wireCategory: "binary",
|
|
17
|
+
strategySummary: "Encode the raw bytes of the active TypedArray view as standalone base93, preserving byteOffset/byteLength; decode requires a concrete typed-array constructor."
|
|
18
|
+
};
|
|
19
|
+
const TS_FN = "encodeBinaryTypedArrayStandalone";
|
|
20
|
+
const CPP_FN = "encodeBinaryTypedArrayStandalone";
|
|
21
|
+
const strategyComment = (0, comments_1.emitStrategyComment)("Base codec emitter (encode): AnQst.Type.typedArray / QByteArray", [
|
|
22
|
+
"Wraps the incoming TypedArray view as Uint8Array(value.buffer, value.byteOffset, value.byteLength) so only the visible bytes are emitted.",
|
|
23
|
+
"Wire format is identical to the buffer codec: one standalone base93 string carrying raw bytes.",
|
|
24
|
+
"C++ treats QByteArray as an opaque byte buffer and copies its bytes into the shared base93 encoder."
|
|
25
|
+
]);
|
|
26
|
+
exports.encoderEmitter = {
|
|
27
|
+
descriptor: exports.descriptor,
|
|
28
|
+
emitTsEncoder() {
|
|
29
|
+
return `${strategyComment}\n\n${(0, rawbytes_1.emitTsRawByteStandaloneEncoder)(TS_FN, "new Uint8Array(value.buffer, value.byteOffset, value.byteLength)")}`;
|
|
30
|
+
},
|
|
31
|
+
emitCppEncoder() {
|
|
32
|
+
return `${strategyComment}\n\n${(0, rawbytes_1.emitCppRawByteStandaloneEncoder)(CPP_FN, "std::vector<std::uint8_t>(reinterpret_cast<const std::uint8_t*>(value.constData()), reinterpret_cast<const std::uint8_t*>(value.constData()) + static_cast<std::size_t>(value.size()))")}`;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AnQstGen base-type codec emitter for `binary-uint16Array`.
|
|
4
|
+
* Decoder consumes one base93 string of raw bytes and reconstructs a concrete `Uint16Array`.
|
|
5
|
+
* Multi-byte element byte order is preserved exactly as transmitted; no byte swapping is introduced.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.decoder = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
const encoder_1 = require("./encoder");
|
|
11
|
+
Object.defineProperty(exports, "descriptor", { enumerable: true, get: function () { return encoder_1.descriptor; } });
|
|
12
|
+
const TS_FN = "decodeBinaryUint16ArrayStandalone";
|
|
13
|
+
const CPP_FN = "decodeBinaryUint16ArrayStandalone";
|
|
14
|
+
exports.decoder = {
|
|
15
|
+
descriptor: encoder_1.descriptor,
|
|
16
|
+
emitTsDecoder() {
|
|
17
|
+
return [
|
|
18
|
+
(0, comments_1.emitStrategyComment)("AnQst Uint16Array decoder (raw-byte base93)", [
|
|
19
|
+
"Decodes base93 to bytes, then constructs a concrete Uint16Array over the decoded buffer.",
|
|
20
|
+
"Rejected odd decoded byte counts indicate corrupted wire data because Uint16Array elements require 2 bytes each."
|
|
21
|
+
]),
|
|
22
|
+
`function ${TS_FN}(encoded) {`,
|
|
23
|
+
" const bytes = base93Decode(encoded);",
|
|
24
|
+
" if ((bytes.byteLength & 1) !== 0) {",
|
|
25
|
+
" throw new RangeError(\"Decoded Uint16Array byte length must be divisible by 2.\");",
|
|
26
|
+
" }",
|
|
27
|
+
" return new Uint16Array(bytes.buffer);",
|
|
28
|
+
"}"
|
|
29
|
+
].join("\n");
|
|
30
|
+
},
|
|
31
|
+
emitCppDecoder() {
|
|
32
|
+
return [
|
|
33
|
+
(0, comments_1.emitStrategyComment)("AnQst Uint16Array decoder (QByteArray raw bytes)", [
|
|
34
|
+
"C++ receives the raw bytes as QByteArray; element interpretation stays outside the byte-transport codec.",
|
|
35
|
+
"Portable tests may supply a lightweight QByteArray shim with a (const char*, int) constructor."
|
|
36
|
+
]),
|
|
37
|
+
`inline QByteArray ${CPP_FN}(const std::string& encoded) {`,
|
|
38
|
+
" const std::vector<std::uint8_t> bytes = base93Decode(encoded);",
|
|
39
|
+
" return QByteArray(",
|
|
40
|
+
" reinterpret_cast<const char*>(bytes.data()),",
|
|
41
|
+
" static_cast<int>(bytes.size())",
|
|
42
|
+
" );",
|
|
43
|
+
"}"
|
|
44
|
+
].join("\n");
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AnQstGen base-type codec emitter for `binary-uint16Array`.
|
|
4
|
+
* Wire form is one base93 string carrying the raw bytes of a `Uint16Array` view.
|
|
5
|
+
* The TypeScript path must respect `byteOffset`/`byteLength`; the C++ path keeps the spec-facing `QByteArray` signature.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.encoder = exports.descriptor = void 0;
|
|
9
|
+
const comments_1 = require("../shared/comments");
|
|
10
|
+
exports.descriptor = {
|
|
11
|
+
codecId: "binary-uint16Array",
|
|
12
|
+
specPath: "RefinedSpecs/Codecs/Binary_uint16Array_Codec.md",
|
|
13
|
+
tsType: "Uint16Array",
|
|
14
|
+
cppType: "QByteArray",
|
|
15
|
+
wireCategory: "binary",
|
|
16
|
+
strategySummary: "Base93-encode the raw bytes of the Uint16Array view (respecting byteOffset/byteLength); C++ receives the same raw bytes in QByteArray."
|
|
17
|
+
};
|
|
18
|
+
const TS_FN = "encodeBinaryUint16ArrayStandalone";
|
|
19
|
+
const CPP_FN = "encodeBinaryUint16ArrayStandalone";
|
|
20
|
+
exports.encoder = {
|
|
21
|
+
descriptor: exports.descriptor,
|
|
22
|
+
emitTsEncoder() {
|
|
23
|
+
return [
|
|
24
|
+
(0, comments_1.emitStrategyComment)("AnQst Uint16Array encoder (raw-byte base93)", [
|
|
25
|
+
"Reads only the concrete view window via byteOffset/byteLength, so subviews do not leak adjacent buffer bytes.",
|
|
26
|
+
"Preserves platform-native endianness by forwarding the raw stored bytes unchanged into base93."
|
|
27
|
+
]),
|
|
28
|
+
`function ${TS_FN}(value) {`,
|
|
29
|
+
" const bytes = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);",
|
|
30
|
+
" return base93Encode(bytes);",
|
|
31
|
+
"}"
|
|
32
|
+
].join("\n");
|
|
33
|
+
},
|
|
34
|
+
emitCppEncoder() {
|
|
35
|
+
return [
|
|
36
|
+
(0, comments_1.emitStrategyComment)("AnQst Uint16Array encoder (QByteArray raw bytes)", [
|
|
37
|
+
"Host-side integration passes the raw typed-array bytes as QByteArray; portable tests can provide a minimal QByteArray shim.",
|
|
38
|
+
"No byte swapping is performed; the QByteArray contents are forwarded as-is into base93."
|
|
39
|
+
]),
|
|
40
|
+
`inline std::string ${CPP_FN}(const QByteArray& value) {`,
|
|
41
|
+
" std::vector<std::uint8_t> bytes(static_cast<std::size_t>(value.size()));",
|
|
42
|
+
" if (!bytes.empty()) {",
|
|
43
|
+
" std::memcpy(bytes.data(), value.constData(), bytes.size());",
|
|
44
|
+
" }",
|
|
45
|
+
" return base93Encode(bytes);",
|
|
46
|
+
"}"
|
|
47
|
+
].join("\n");
|
|
48
|
+
}
|
|
49
|
+
};
|