@agoric/xsnap 0.14.3-dev-b047af2.0 → 0.14.3-dev-2a16ddd.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.
Files changed (125) hide show
  1. package/package.json +8 -15
  2. package/src/build.js +4 -61
  3. package/moddable/modules/data/base64/base64.js +0 -28
  4. package/moddable/modules/data/base64/manifest.json +0 -11
  5. package/moddable/modules/data/base64/modBase64.c +0 -188
  6. package/moddable/modules/data/binaryMessage/BinaryMessage.js +0 -106
  7. package/moddable/modules/data/crc/crc.c +0 -205
  8. package/moddable/modules/data/crc/crc.js +0 -36
  9. package/moddable/modules/data/crc/manifest.json +0 -8
  10. package/moddable/modules/data/hex/hex.js +0 -28
  11. package/moddable/modules/data/hex/manifest.json +0 -11
  12. package/moddable/modules/data/hex/modHex.c +0 -139
  13. package/moddable/modules/data/logical/logical.js +0 -32
  14. package/moddable/modules/data/logical/modLogical.c +0 -98
  15. package/moddable/modules/data/qrcode/manifest.json +0 -9
  16. package/moddable/modules/data/qrcode/qrcode.c +0 -93
  17. package/moddable/modules/data/qrcode/qrcode.js +0 -23
  18. package/moddable/modules/data/qrcode/qrcodegen.c +0 -1025
  19. package/moddable/modules/data/qrcode/qrcodegen.h +0 -267
  20. package/moddable/modules/data/text/decoder/manifest.json +0 -8
  21. package/moddable/modules/data/text/decoder/textdecoder.c +0 -480
  22. package/moddable/modules/data/text/decoder/textdecoder.js +0 -27
  23. package/moddable/modules/data/text/encoder/manifest.json +0 -8
  24. package/moddable/modules/data/text/encoder/textencoder.c +0 -232
  25. package/moddable/modules/data/text/encoder/textencoder.js +0 -24
  26. package/moddable/modules/data/tinyint/tinyint.c +0 -150
  27. package/moddable/modules/data/tinyint/tinyint.js +0 -53
  28. package/moddable/modules/data/url/manifest.json +0 -17
  29. package/moddable/modules/data/url/url.c +0 -1959
  30. package/moddable/modules/data/url/url.js +0 -210
  31. package/moddable/modules/data/wavreader/manifest.json +0 -8
  32. package/moddable/modules/data/wavreader/wavreader.js +0 -128
  33. package/moddable/modules/data/zlib/deflate.c +0 -161
  34. package/moddable/modules/data/zlib/deflate.js +0 -63
  35. package/moddable/modules/data/zlib/inflate.c +0 -145
  36. package/moddable/modules/data/zlib/inflate.js +0 -66
  37. package/moddable/modules/data/zlib/manifest_deflate.json +0 -9
  38. package/moddable/modules/data/zlib/manifest_inflate.json +0 -9
  39. package/moddable/modules/data/zlib/miniz.c +0 -4924
  40. package/moddable/xs/includes/xs.d.ts +0 -73
  41. package/moddable/xs/includes/xs.h +0 -1533
  42. package/moddable/xs/includes/xsmc.h +0 -206
  43. package/moddable/xs/makefiles/lin/makefile +0 -33
  44. package/moddable/xs/makefiles/lin/xsc.mk +0 -118
  45. package/moddable/xs/makefiles/lin/xsid.mk +0 -90
  46. package/moddable/xs/makefiles/lin/xsl.mk +0 -168
  47. package/moddable/xs/makefiles/lin/xst.mk +0 -201
  48. package/moddable/xs/makefiles/mac/makefile +0 -33
  49. package/moddable/xs/makefiles/mac/xsc.mk +0 -130
  50. package/moddable/xs/makefiles/mac/xsid.mk +0 -102
  51. package/moddable/xs/makefiles/mac/xsl.mk +0 -177
  52. package/moddable/xs/makefiles/mac/xst.mk +0 -203
  53. package/moddable/xs/makefiles/mac/xst_no_asan.txt +0 -52
  54. package/moddable/xs/makefiles/win/build.bat +0 -26
  55. package/moddable/xs/makefiles/win/xsc.mak +0 -142
  56. package/moddable/xs/makefiles/win/xsid.mak +0 -113
  57. package/moddable/xs/makefiles/win/xsl.mak +0 -186
  58. package/moddable/xs/makefiles/win/xst.mak +0 -195
  59. package/moddable/xs/platforms/lin_xs.h +0 -99
  60. package/moddable/xs/platforms/mac_xs.h +0 -97
  61. package/moddable/xs/platforms/wasm_xs.h +0 -79
  62. package/moddable/xs/platforms/win_xs.h +0 -104
  63. package/moddable/xs/platforms/xsHost.h +0 -63
  64. package/moddable/xs/platforms/xsPlatform.h +0 -618
  65. package/moddable/xs/sources/xsAPI.c +0 -2555
  66. package/moddable/xs/sources/xsAll.c +0 -294
  67. package/moddable/xs/sources/xsAll.h +0 -2741
  68. package/moddable/xs/sources/xsArguments.c +0 -222
  69. package/moddable/xs/sources/xsArray.c +0 -2657
  70. package/moddable/xs/sources/xsAtomics.c +0 -844
  71. package/moddable/xs/sources/xsBigInt.c +0 -1859
  72. package/moddable/xs/sources/xsBoolean.c +0 -109
  73. package/moddable/xs/sources/xsCode.c +0 -4493
  74. package/moddable/xs/sources/xsCommon.c +0 -1710
  75. package/moddable/xs/sources/xsCommon.h +0 -1142
  76. package/moddable/xs/sources/xsDataView.c +0 -2890
  77. package/moddable/xs/sources/xsDate.c +0 -1541
  78. package/moddable/xs/sources/xsDebug.c +0 -2710
  79. package/moddable/xs/sources/xsDefaults.c +0 -134
  80. package/moddable/xs/sources/xsError.c +0 -353
  81. package/moddable/xs/sources/xsFunction.c +0 -776
  82. package/moddable/xs/sources/xsGenerator.c +0 -865
  83. package/moddable/xs/sources/xsGlobal.c +0 -839
  84. package/moddable/xs/sources/xsJSON.c +0 -1091
  85. package/moddable/xs/sources/xsLexical.c +0 -1969
  86. package/moddable/xs/sources/xsLockdown.c +0 -933
  87. package/moddable/xs/sources/xsMapSet.c +0 -1649
  88. package/moddable/xs/sources/xsMarshall.c +0 -1020
  89. package/moddable/xs/sources/xsMath.c +0 -624
  90. package/moddable/xs/sources/xsMemory.c +0 -1941
  91. package/moddable/xs/sources/xsModule.c +0 -3101
  92. package/moddable/xs/sources/xsNumber.c +0 -560
  93. package/moddable/xs/sources/xsObject.c +0 -1102
  94. package/moddable/xs/sources/xsPlatforms.c +0 -480
  95. package/moddable/xs/sources/xsProfile.c +0 -577
  96. package/moddable/xs/sources/xsPromise.c +0 -1199
  97. package/moddable/xs/sources/xsProperty.c +0 -636
  98. package/moddable/xs/sources/xsProxy.c +0 -1014
  99. package/moddable/xs/sources/xsRegExp.c +0 -1168
  100. package/moddable/xs/sources/xsRun.c +0 -4889
  101. package/moddable/xs/sources/xsScope.c +0 -1293
  102. package/moddable/xs/sources/xsScript.c +0 -288
  103. package/moddable/xs/sources/xsScript.h +0 -1186
  104. package/moddable/xs/sources/xsSnapshot.c +0 -2161
  105. package/moddable/xs/sources/xsSnapshot.h +0 -51
  106. package/moddable/xs/sources/xsSourceMap.c +0 -218
  107. package/moddable/xs/sources/xsString.c +0 -3332
  108. package/moddable/xs/sources/xsSymbol.c +0 -503
  109. package/moddable/xs/sources/xsSyntaxical.c +0 -4193
  110. package/moddable/xs/sources/xsTree.c +0 -1893
  111. package/moddable/xs/sources/xsType.c +0 -1488
  112. package/moddable/xs/sources/xsdtoa.c +0 -6672
  113. package/moddable/xs/sources/xsmc.c +0 -340
  114. package/moddable/xs/sources/xsre.c +0 -7578
  115. package/xsnap-native/xsnap/makefiles/lin/makefile +0 -10
  116. package/xsnap-native/xsnap/makefiles/lin/xsnap-worker.mk +0 -153
  117. package/xsnap-native/xsnap/makefiles/lin/xsnap.mk +0 -144
  118. package/xsnap-native/xsnap/makefiles/mac/makefile +0 -10
  119. package/xsnap-native/xsnap/makefiles/mac/xsnap-worker.mk +0 -162
  120. package/xsnap-native/xsnap/makefiles/mac/xsnap.mk +0 -153
  121. package/xsnap-native/xsnap/sources/xsnap-worker.c +0 -996
  122. package/xsnap-native/xsnap/sources/xsnap.c +0 -716
  123. package/xsnap-native/xsnap/sources/xsnap.h +0 -142
  124. package/xsnap-native/xsnap/sources/xsnapPlatform.c +0 -1496
  125. package/xsnap-native/xsnap/sources/xsnapPlatform.h +0 -105
@@ -1,36 +0,0 @@
1
- /*
2
- * Copyright (c) 2021 Moddable Tech, Inc.
3
- *
4
- * This file is part of the Moddable SDK Runtime.
5
- *
6
- * The Moddable SDK Runtime is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU Lesser General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * The Moddable SDK Runtime is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU Lesser General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU Lesser General Public License
17
- * along with the Moddable SDK Runtime. If not, see <http://www.gnu.org/licenses/>.
18
- *
19
- */
20
-
21
-
22
- class CRC8 @ "xs_crc8_destructor" {
23
- constructor(polynomial, initial, reflectInput, reflectOutput, xorOutput) @ "xs_crc8";
24
- close() @ "xs_crc8_close";
25
- checksum(buffer) @ "xs_crc8_checksum";
26
- reset() @ "xs_crc8_reset";
27
- }
28
-
29
- class CRC16 @ "xs_crc16_destructor" {
30
- constructor(polynomial, initial, reflectInput, reflectOutput, xorOutput) @ "xs_crc16";
31
- close() @ "xs_crc16_close";
32
- checksum(buffer) @ "xs_crc16_checksum";
33
- reset() @ "xs_crc16_reset";
34
- }
35
-
36
- export { CRC8 as default, CRC8, CRC16 };
@@ -1,8 +0,0 @@
1
- {
2
- "modules": {
3
- "*": [
4
- "./crc"
5
- ]
6
- },
7
- "preload": "crc"
8
- }
@@ -1,28 +0,0 @@
1
- /*
2
- * Copyright (c) 2016-2017 Moddable Tech, Inc.
3
- *
4
- * This file is part of the Moddable SDK Runtime.
5
- *
6
- * The Moddable SDK Runtime is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU Lesser General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * The Moddable SDK Runtime is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU Lesser General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU Lesser General Public License
17
- * along with the Moddable SDK Runtime. If not, see <http://www.gnu.org/licenses/>.
18
- *
19
- */
20
-
21
- /*
22
- hex
23
- */
24
-
25
- export default class {
26
- static toString(buffer) @ "xs_hex_toString";
27
- static toBuffer(string) @ "xs_hex_toBuffer";
28
- }
@@ -1,11 +0,0 @@
1
- {
2
- "modules": {
3
- "*": [
4
- "./hex",
5
- "./modHex"
6
- ]
7
- },
8
- "preload": [
9
- "hex"
10
- ]
11
- }
@@ -1,139 +0,0 @@
1
- /*
2
- * Copyright (c) 2016-2022 Moddable Tech, Inc.
3
- *
4
- * This file is part of the Moddable SDK Runtime.
5
- *
6
- * The Moddable SDK Runtime is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU Lesser General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * The Moddable SDK Runtime is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU Lesser General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU Lesser General Public License
17
- * along with the Moddable SDK Runtime. If not, see <http://www.gnu.org/licenses/>.
18
- *
19
- */
20
-
21
- #include "xsPlatform.h"
22
- #include "xsmc.h"
23
-
24
- static const char *gHexUpper ICACHE_FLASH_ATTR = "0123456789ABCDEF";
25
-
26
- void xs_hex_toString(xsMachine *the)
27
- {
28
- int argc = xsmcArgc;
29
- const uint8_t *bytes;
30
- char *string;
31
- xsUnsignedValue length, i;
32
- char separator = 0;
33
- char *gHex = (char *)gHexUpper;
34
-
35
- xsmcGetBufferReadable(xsArg(0), (void **)&bytes, &length);
36
- if (0 == length)
37
- xsUnknownError("0 length buffer");
38
-
39
- if (argc > 1) {
40
- char *str = xsmcToString(xsArg(1));
41
- int len = c_strlen(str);
42
- if (len) {
43
- if (len > 1)
44
- xsUnknownError("invalid separator");
45
- separator = c_read8(str);
46
- if (!separator || (0x80 & separator))
47
- xsUnknownError("invalid separator");
48
- }
49
- if (argc > 2) {
50
- gHex = xsmcToString(xsArg(2));
51
- if (16 != c_strlen(gHex))
52
- xsUnknownError("bad string");
53
- for (i = 0; i < 16; i++) { // 7-bit ASCII, not UTF-8
54
- if (!gHex[i] || (0x80 & gHex[i]))
55
- xsUnknownError("bad string");
56
- }
57
- }
58
- }
59
-
60
- xsResult = xsStringBuffer(NULL, (length * 2) + (separator ? (length - 1) : 0));
61
- string = xsmcToString(xsResult);
62
- xsmcGetBufferReadable(xsArg(0), (void **)&bytes, &length);
63
- if (argc > 2)
64
- gHex = xsmcToString(xsArg(2));
65
-
66
- for (i = 0; i < length; i++) {
67
- uint8_t byte = c_read8(bytes++);
68
- if (separator && (0 != i))
69
- *string++ = separator;
70
- *string++ = c_read8(&gHex[byte >> 4]);
71
- *string++ = c_read8(&gHex[byte & 0x0F]);
72
- }
73
- }
74
-
75
- void xs_hex_toBuffer(xsMachine *the)
76
- {
77
- int argc = xsmcArgc;
78
- char separator = 0;
79
- const char *string;
80
- uint8_t *bytes;
81
- int length, i;
82
-
83
- if (argc > 1) {
84
- char *str = xsmcToString(xsArg(1));
85
- length = c_strlen(str);
86
- if (length) {
87
- if (length > 1)
88
- xsUnknownError("invalid separator");
89
- separator = c_read8(str);
90
- if (!separator || (0x80 & separator))
91
- xsUnknownError("invalid separator");
92
- }
93
- }
94
-
95
- string = xsmcToString(xsArg(0));
96
- length = c_strlen(string);
97
- if (length < 2)
98
- xsUnknownError("string too small");
99
-
100
- if ((separator && ((length + 1) % 3)) || (!separator && (length % 2)))
101
- xsUnknownError("bad string length");
102
-
103
- length = separator ? ((length + 1) / 3) : (length / 2);
104
- xsmcSetArrayBuffer(xsResult, NULL, length);
105
- bytes = xsmcToArrayBuffer(xsResult);
106
- string = xsmcToString(xsArg(0)); // refresh
107
- for (i = 0; i < length; i++) {
108
- uint8_t c;
109
- uint8_t byte;
110
-
111
- if (separator && (0 != i)) {
112
- if (c_read8(string++) != separator)
113
- xsUnknownError("expected separator");
114
- }
115
-
116
- c = c_read8(string++);
117
- if (('0' <= c) && (c <= '9'))
118
- byte = c - '0';
119
- else if (('A' <= c) && (c <= 'F'))
120
- byte = c - 'A' + 10;
121
- else if (('a' <= c) && (c <= 'f'))
122
- byte = c - 'a' + 10;
123
- else
124
- xsUnknownError("bad data");
125
- byte <<= 4;
126
-
127
- c = c_read8(string++);
128
- if (('0' <= c) && (c <= '9'))
129
- byte |= c - '0';
130
- else if (('A' <= c) && (c <= 'F'))
131
- byte |= c - 'A' + 10;
132
- else if (('a' <= c) && (c <= 'f'))
133
- byte |= c - 'a' + 10;
134
- else
135
- xsUnknownError("bad data");
136
-
137
- *bytes++ = byte;
138
- }
139
- }
@@ -1,32 +0,0 @@
1
- /*
2
- * Copyright (c) 2016-2017 Moddable Tech, Inc.
3
- *
4
- * This file is part of the Moddable SDK Runtime.
5
- *
6
- * The Moddable SDK Runtime is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU Lesser General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * The Moddable SDK Runtime is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU Lesser General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU Lesser General Public License
17
- * along with the Moddable SDK Runtime. If not, see <http://www.gnu.org/licenses/>.
18
- *
19
- */
20
-
21
- /*
22
- logical operations on buffers
23
- */
24
-
25
- export default class {
26
- static not(dst) {
27
- this.xor(dst, 0xff);
28
- }
29
- static xor(dst, src) @ "xs_logical_xor";
30
- static and(dst, src) @ "xs_logical_and";
31
- static or(dst, src) @ "xs_logical_or";
32
- }
@@ -1,98 +0,0 @@
1
- /*
2
- * Copyright (c) 2016-2022 Moddable Tech, Inc.
3
- *
4
- * This file is part of the Moddable SDK Runtime.
5
- *
6
- * The Moddable SDK Runtime is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU Lesser General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * The Moddable SDK Runtime is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU Lesser General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU Lesser General Public License
17
- * along with the Moddable SDK Runtime. If not, see <http://www.gnu.org/licenses/>.
18
- *
19
- */
20
-
21
- #include "xsPlatform.h"
22
- #include "xsmc.h"
23
-
24
- enum {
25
- kOpXor,
26
- kOpAnd,
27
- kOpOr
28
- };
29
-
30
- static void xs_logical_op(xsMachine *the, int operation)
31
- {
32
- int srcType = xsmcTypeOf(xsArg(1));
33
- uint8_t scratch;
34
- uint8_t *src, *dst;
35
- xsUnsignedValue srcLen, dstLen, i = 0;
36
-
37
- xsmcGetBufferWritable(xsArg(0), (void **)&dst, &dstLen);
38
-
39
- switch (srcType) {
40
- case xsIntegerType:
41
- case xsNumberType:
42
- scratch = (uint8_t)xsmcToInteger(xsArg(1));
43
- src = &scratch;
44
- srcLen = 1;
45
- break;
46
-
47
- case xsStringType:
48
- src = (uint8_t *)xsmcToString(xsArg(1));
49
- srcLen = c_strlen((char *)src);
50
- break;
51
-
52
- case xsReferenceType:
53
- xsmcGetBufferReadable(xsArg(1), (void **)&src, &srcLen);
54
- break;
55
-
56
- default:
57
- xsUnknownError("unsupported source");
58
- break;
59
- }
60
-
61
- if (kOpXor == operation) {
62
- while (dstLen--) {
63
- *dst++ ^= src[i++];
64
- if (i == srcLen)
65
- i = 0;
66
- }
67
- }
68
- else
69
- if (kOpOr == operation) {
70
- while (dstLen--) {
71
- *dst++ |= src[i++];
72
- if (i == srcLen)
73
- i = 0;
74
- }
75
- }
76
- else {
77
- while (dstLen--) {
78
- *dst++ &= src[i++];
79
- if (i == srcLen)
80
- i = 0;
81
- }
82
- }
83
- }
84
-
85
- void xs_logical_xor(xsMachine *the)
86
- {
87
- xs_logical_op(the, kOpXor);
88
- }
89
-
90
- void xs_logical_and(xsMachine *the)
91
- {
92
- xs_logical_op(the, kOpAnd);
93
- }
94
-
95
- void xs_logical_or(xsMachine *the)
96
- {
97
- xs_logical_op(the, kOpOr);
98
- }
@@ -1,9 +0,0 @@
1
- {
2
- "modules": {
3
- "*": [
4
- "./qrcode",
5
- "./qrcodegen"
6
- ]
7
- },
8
- "preload": "qrcode"
9
- }
@@ -1,93 +0,0 @@
1
- /*
2
- * Copyright (c) 2018-2022 Moddable Tech, Inc.
3
- *
4
- * This file is part of the Moddable SDK Runtime.
5
- *
6
- * The Moddable SDK Runtime is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU Lesser General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * The Moddable SDK Runtime is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU Lesser General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU Lesser General Public License
17
- * along with the Moddable SDK Runtime. If not, see <http://www.gnu.org/licenses/>.
18
- *
19
- */
20
- #include "xsmc.h"
21
- #include "mc.xs.h" // for xsID_ values
22
-
23
- #include "qrcodegen.h"
24
- #include "xsHost.h"
25
-
26
- void xs_qrcode(xsMachine *the)
27
- {
28
- size_t bufferSize;
29
- uint8_t *qr0 = NULL;
30
- void *data;
31
- xsType type;
32
- uint8_t ok;
33
- int x, y;
34
- uint8_t *module;
35
- int maxVersion = qrcodegen_VERSION_MAX;
36
-
37
- xsmcVars(3);
38
-
39
- if (xsmcHas(xsArg(0), xsID_maxVersion)) {
40
- xsmcGet(xsVar(0), xsArg(0), xsID_maxVersion);
41
- maxVersion = xsmcToInteger(xsVar(0));
42
- if ((maxVersion > qrcodegen_VERSION_MAX) || (maxVersion < qrcodegen_VERSION_MIN))
43
- xsRangeError("invalid");
44
- }
45
-
46
- bufferSize = qrcodegen_BUFFER_LEN_FOR_VERSION(maxVersion);
47
- qr0 = c_malloc(bufferSize << 1);
48
- if (!qr0)
49
- xsUnknownError("no memory");
50
-
51
- xsTry {
52
- xsmcGet(xsVar(0), xsArg(0), xsID_input);
53
- type = xsmcTypeOf(xsVar(0));
54
- if (xsStringType == type) {
55
- data = xsmcToString(xsVar(0));
56
- ok = qrcodegen_encodeText(data, qr0 + bufferSize, qr0,
57
- qrcodegen_Ecc_MEDIUM, qrcodegen_VERSION_MIN, maxVersion, qrcodegen_Mask_AUTO, true);
58
- }
59
- else {
60
- xsUnsignedValue dataSize;
61
-
62
- xsmcGetBufferReadable(xsVar(0), &data, &dataSize);
63
- if (dataSize > bufferSize)
64
- xsUnknownError("invalid");
65
- c_memcpy(qr0 + bufferSize, data, dataSize);
66
- ok = qrcodegen_encodeBinary(qr0 + bufferSize, dataSize, qr0,
67
- qrcodegen_Ecc_MEDIUM, qrcodegen_VERSION_MIN, maxVersion, qrcodegen_Mask_AUTO, true);
68
- }
69
-
70
- if (!ok)
71
- xsUnknownError("qrcode failed");
72
-
73
- int size = qrcodegen_getSize(qr0);
74
-
75
- xsmcSetArrayBuffer(xsResult, NULL, size * size);
76
-
77
- xsmcSetInteger(xsVar(0), size);
78
- xsmcSet(xsResult, xsID_size, xsVar(0));
79
-
80
- module = xsmcToArrayBuffer(xsResult);
81
- for (y = 0; y < size; y++) {
82
- for (x = 0; x < size; x++)
83
- *module++ = qrcodegen_getModule(qr0, x, y);
84
- }
85
-
86
- c_free(qr0);
87
- }
88
- xsCatch {
89
- c_free(qr0);
90
-
91
- xsThrow(xsException);
92
- }
93
- }
@@ -1,23 +0,0 @@
1
- /*
2
- * Copyright (c) 2018 Moddable Tech, Inc.
3
- *
4
- * This file is part of the Moddable SDK Runtime.
5
- *
6
- * The Moddable SDK Runtime is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU Lesser General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * The Moddable SDK Runtime is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU Lesser General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU Lesser General Public License
17
- * along with the Moddable SDK Runtime. If not, see <http://www.gnu.org/licenses/>.
18
- *
19
- */
20
-
21
- function QRCode(dictonary) @ "xs_qrcode";
22
-
23
- export default QRCode;