@agoric/xsnap 0.14.3-u13.0 → 0.14.3-u16.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 +3 -3
- package/api.js +4 -2
- package/build.env +1 -1
- package/moddable/modules/data/base64/base64.js +28 -0
- package/moddable/modules/data/base64/manifest.json +11 -0
- package/moddable/modules/data/base64/modBase64.c +188 -0
- package/moddable/modules/data/binaryMessage/BinaryMessage.js +106 -0
- package/moddable/modules/data/crc/crc.c +205 -0
- package/moddable/modules/data/crc/crc.js +36 -0
- package/moddable/modules/data/crc/manifest.json +8 -0
- package/moddable/modules/data/hex/hex.js +28 -0
- package/moddable/modules/data/hex/manifest.json +11 -0
- package/moddable/modules/data/hex/modHex.c +139 -0
- package/moddable/modules/data/logical/logical.js +32 -0
- package/moddable/modules/data/logical/modLogical.c +98 -0
- package/moddable/modules/data/qrcode/manifest.json +9 -0
- package/moddable/modules/data/qrcode/qrcode.c +93 -0
- package/moddable/modules/data/qrcode/qrcode.js +23 -0
- package/moddable/modules/data/qrcode/qrcodegen.c +1025 -0
- package/moddable/modules/data/qrcode/qrcodegen.h +267 -0
- package/moddable/modules/data/text/decoder/manifest.json +8 -0
- package/moddable/modules/data/text/decoder/textdecoder.c +480 -0
- package/moddable/modules/data/text/decoder/textdecoder.js +27 -0
- package/moddable/modules/data/text/encoder/manifest.json +8 -0
- package/moddable/modules/data/text/encoder/textencoder.c +232 -0
- package/moddable/modules/data/text/encoder/textencoder.js +24 -0
- package/moddable/modules/data/tinyint/tinyint.c +150 -0
- package/moddable/modules/data/tinyint/tinyint.js +53 -0
- package/moddable/modules/data/url/manifest.json +17 -0
- package/moddable/modules/data/url/url.c +1959 -0
- package/moddable/modules/data/url/url.js +210 -0
- package/moddable/modules/data/wavreader/manifest.json +8 -0
- package/moddable/modules/data/wavreader/wavreader.js +128 -0
- package/moddable/modules/data/zlib/deflate.c +161 -0
- package/moddable/modules/data/zlib/deflate.js +63 -0
- package/moddable/modules/data/zlib/inflate.c +145 -0
- package/moddable/modules/data/zlib/inflate.js +66 -0
- package/moddable/modules/data/zlib/manifest_deflate.json +9 -0
- package/moddable/modules/data/zlib/manifest_inflate.json +9 -0
- package/moddable/modules/data/zlib/miniz.c +4924 -0
- package/moddable/xs/includes/xs.d.ts +73 -0
- package/moddable/xs/includes/xs.h +1533 -0
- package/moddable/xs/includes/xsmc.h +206 -0
- package/moddable/xs/makefiles/lin/makefile +33 -0
- package/moddable/xs/makefiles/lin/xsc.mk +118 -0
- package/moddable/xs/makefiles/lin/xsid.mk +90 -0
- package/moddable/xs/makefiles/lin/xsl.mk +168 -0
- package/moddable/xs/makefiles/lin/xst.mk +201 -0
- package/moddable/xs/makefiles/mac/makefile +33 -0
- package/moddable/xs/makefiles/mac/xsc.mk +130 -0
- package/moddable/xs/makefiles/mac/xsid.mk +102 -0
- package/moddable/xs/makefiles/mac/xsl.mk +177 -0
- package/moddable/xs/makefiles/mac/xst.mk +203 -0
- package/moddable/xs/makefiles/mac/xst_no_asan.txt +52 -0
- package/moddable/xs/makefiles/win/build.bat +26 -0
- package/moddable/xs/makefiles/win/xsc.mak +142 -0
- package/moddable/xs/makefiles/win/xsid.mak +113 -0
- package/moddable/xs/makefiles/win/xsl.mak +186 -0
- package/moddable/xs/makefiles/win/xst.mak +195 -0
- package/moddable/xs/platforms/lin_xs.h +99 -0
- package/moddable/xs/platforms/mac_xs.h +97 -0
- package/moddable/xs/platforms/wasm_xs.h +79 -0
- package/moddable/xs/platforms/win_xs.h +104 -0
- package/moddable/xs/platforms/xsHost.h +63 -0
- package/moddable/xs/platforms/xsPlatform.h +618 -0
- package/moddable/xs/sources/xsAPI.c +2555 -0
- package/moddable/xs/sources/xsAll.c +294 -0
- package/moddable/xs/sources/xsAll.h +2741 -0
- package/moddable/xs/sources/xsArguments.c +222 -0
- package/moddable/xs/sources/xsArray.c +2657 -0
- package/moddable/xs/sources/xsAtomics.c +844 -0
- package/moddable/xs/sources/xsBigInt.c +1859 -0
- package/moddable/xs/sources/xsBoolean.c +109 -0
- package/moddable/xs/sources/xsCode.c +4493 -0
- package/moddable/xs/sources/xsCommon.c +1710 -0
- package/moddable/xs/sources/xsCommon.h +1142 -0
- package/moddable/xs/sources/xsDataView.c +2890 -0
- package/moddable/xs/sources/xsDate.c +1541 -0
- package/moddable/xs/sources/xsDebug.c +2710 -0
- package/moddable/xs/sources/xsDefaults.c +134 -0
- package/moddable/xs/sources/xsError.c +353 -0
- package/moddable/xs/sources/xsFunction.c +776 -0
- package/moddable/xs/sources/xsGenerator.c +865 -0
- package/moddable/xs/sources/xsGlobal.c +839 -0
- package/moddable/xs/sources/xsJSON.c +1091 -0
- package/moddable/xs/sources/xsLexical.c +1969 -0
- package/moddable/xs/sources/xsLockdown.c +933 -0
- package/moddable/xs/sources/xsMapSet.c +1649 -0
- package/moddable/xs/sources/xsMarshall.c +1020 -0
- package/moddable/xs/sources/xsMath.c +624 -0
- package/moddable/xs/sources/xsMemory.c +1941 -0
- package/moddable/xs/sources/xsModule.c +3101 -0
- package/moddable/xs/sources/xsNumber.c +560 -0
- package/moddable/xs/sources/xsObject.c +1102 -0
- package/moddable/xs/sources/xsPlatforms.c +480 -0
- package/moddable/xs/sources/xsProfile.c +577 -0
- package/moddable/xs/sources/xsPromise.c +1199 -0
- package/moddable/xs/sources/xsProperty.c +636 -0
- package/moddable/xs/sources/xsProxy.c +1014 -0
- package/moddable/xs/sources/xsRegExp.c +1168 -0
- package/moddable/xs/sources/xsRun.c +4889 -0
- package/moddable/xs/sources/xsScope.c +1293 -0
- package/moddable/xs/sources/xsScript.c +288 -0
- package/moddable/xs/sources/xsScript.h +1186 -0
- package/moddable/xs/sources/xsSnapshot.c +2161 -0
- package/moddable/xs/sources/xsSnapshot.h +51 -0
- package/moddable/xs/sources/xsSourceMap.c +218 -0
- package/moddable/xs/sources/xsString.c +3332 -0
- package/moddable/xs/sources/xsSymbol.c +503 -0
- package/moddable/xs/sources/xsSyntaxical.c +4193 -0
- package/moddable/xs/sources/xsTree.c +1893 -0
- package/moddable/xs/sources/xsType.c +1488 -0
- package/moddable/xs/sources/xsdtoa.c +6672 -0
- package/moddable/xs/sources/xsmc.c +340 -0
- package/moddable/xs/sources/xsre.c +7578 -0
- package/package.json +39 -22
- package/scripts/get_xsnap_version.sh +14 -0
- package/scripts/test-package.sh +21 -0
- package/src/avaAssertXS.js +6 -2
- package/src/avaHandler.cjs +2 -5
- package/src/avaXS.js +7 -8
- package/src/build.js +161 -28
- package/src/replay.js +0 -3
- package/src/xsnap.js +105 -91
- package/src/xsrepl.js +2 -3
- package/xsnap-native/xsnap/makefiles/lin/makefile +10 -0
- package/xsnap-native/xsnap/makefiles/lin/xsnap-worker.mk +156 -0
- package/xsnap-native/xsnap/makefiles/lin/xsnap.mk +144 -0
- package/xsnap-native/xsnap/makefiles/mac/makefile +10 -0
- package/xsnap-native/xsnap/makefiles/mac/xsnap-worker.mk +165 -0
- package/xsnap-native/xsnap/makefiles/mac/xsnap.mk +153 -0
- package/xsnap-native/xsnap/sources/xsnap-worker.c +1008 -0
- package/xsnap-native/xsnap/sources/xsnap.c +717 -0
- package/xsnap-native/xsnap/sources/xsnap.h +142 -0
- package/xsnap-native/xsnap/sources/xsnapPlatform.c +1501 -0
- package/xsnap-native/xsnap/sources/xsnapPlatform.h +105 -0
- package/CHANGELOG.md +0 -646
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-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
|
+
* This file incorporates work covered by the following copyright and
|
|
20
|
+
* permission notice:
|
|
21
|
+
*
|
|
22
|
+
* Copyright (C) 2010-2016 Marvell International Ltd.
|
|
23
|
+
* Copyright (C) 2002-2010 Kinoma, Inc.
|
|
24
|
+
*
|
|
25
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
26
|
+
* you may not use this file except in compliance with the License.
|
|
27
|
+
* You may obtain a copy of the License at
|
|
28
|
+
*
|
|
29
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
30
|
+
*
|
|
31
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
32
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
33
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
34
|
+
* See the License for the specific language governing permissions and
|
|
35
|
+
* limitations under the License.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
#include "xsAll.h"
|
|
39
|
+
#include <stdio.h>
|
|
40
|
+
|
|
41
|
+
#ifndef ICACHE_XS6STRING_ATTR
|
|
42
|
+
#define ICACHE_XS6STRING_ATTR
|
|
43
|
+
#endif
|
|
44
|
+
|
|
45
|
+
#define fxPop() (*(the->stack++))
|
|
46
|
+
#define fxPush(_SLOT) (*(--the->stack) = (_SLOT))
|
|
47
|
+
|
|
48
|
+
void _xsNewArray(txMachine *the, txSlot *res, txInteger length)
|
|
49
|
+
{
|
|
50
|
+
fxNewArray(the, length);
|
|
51
|
+
*res = fxPop();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
void _xsNewObject(txMachine *the, txSlot *res)
|
|
55
|
+
{
|
|
56
|
+
fxNewObject(the);
|
|
57
|
+
*res = fxPop();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
void _xsNewHostInstance(txMachine *the, txSlot *res, txSlot *proto)
|
|
61
|
+
{
|
|
62
|
+
mxOverflow(-1);
|
|
63
|
+
fxPush(*proto);
|
|
64
|
+
fxNewHostInstance(the);
|
|
65
|
+
*res = fxPop();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
txBoolean _xsIsInstanceOf(txMachine *the, txSlot *v, txSlot *proto)
|
|
69
|
+
{
|
|
70
|
+
mxOverflow(-2);
|
|
71
|
+
fxPush(*proto);
|
|
72
|
+
fxPush(*v);
|
|
73
|
+
return fxIsInstanceOf(the);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
txBoolean _xsHas(txMachine *the, txSlot *self, txID id)
|
|
77
|
+
{
|
|
78
|
+
mxOverflow(-1);
|
|
79
|
+
fxPush(*self);
|
|
80
|
+
return mxHasID(id);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
txBoolean _xsHasIndex(txMachine *the, txSlot *self, txIndex index)
|
|
84
|
+
{
|
|
85
|
+
mxOverflow(-1);
|
|
86
|
+
fxPush(*self);
|
|
87
|
+
return fxHasIndex(the, index);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
void _xsGet(txMachine *the, txSlot *res, txSlot *self, txID id)
|
|
91
|
+
{
|
|
92
|
+
mxOverflow(-1);
|
|
93
|
+
fxPush(*self);
|
|
94
|
+
mxGetID(id);
|
|
95
|
+
*res = fxPop();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
void _xsGetAt(txMachine *the, txSlot *res, txSlot *self, txSlot *at)
|
|
99
|
+
{
|
|
100
|
+
mxOverflow(-2);
|
|
101
|
+
fxPush(*self);
|
|
102
|
+
fxPush(*at);
|
|
103
|
+
fxGetAt(the);
|
|
104
|
+
*res = fxPop();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
void _xsGetIndex(txMachine *the, txSlot *res, txSlot *self, txIndex index)
|
|
108
|
+
{
|
|
109
|
+
mxOverflow(-1);
|
|
110
|
+
fxPush(*self);
|
|
111
|
+
mxGetIndex(index);
|
|
112
|
+
*res = fxPop();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
void _xsSet(txMachine *the, txSlot *self, txID id, txSlot *v)
|
|
116
|
+
{
|
|
117
|
+
mxOverflow(-2);
|
|
118
|
+
fxPush(*v);
|
|
119
|
+
fxPush(*self);
|
|
120
|
+
mxSetID(id);
|
|
121
|
+
mxPop();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
void _xsSetAt(txMachine *the, txSlot *self, txSlot *at , txSlot *v)
|
|
125
|
+
{
|
|
126
|
+
mxOverflow(-3);
|
|
127
|
+
fxPush(*v);
|
|
128
|
+
fxPush(*self);
|
|
129
|
+
fxPush(*at);
|
|
130
|
+
fxSetAt(the);
|
|
131
|
+
mxPop();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
void _xsSetIndex(txMachine *the, txSlot *self, txIndex index, txSlot *v)
|
|
135
|
+
{
|
|
136
|
+
mxOverflow(-2);
|
|
137
|
+
fxPush(*v);
|
|
138
|
+
fxPush(*self);
|
|
139
|
+
mxSetIndex(index);
|
|
140
|
+
mxPop();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
void _xsDefine(txMachine *the, txSlot *self, txID id, txSlot *v, txFlag attributes)
|
|
144
|
+
{
|
|
145
|
+
mxOverflow(-2);
|
|
146
|
+
fxPush(*v);
|
|
147
|
+
fxPush(*self);
|
|
148
|
+
fxDefineID(the, id, attributes, attributes | XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG);
|
|
149
|
+
mxPop();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
void _xsDelete(txMachine *the, txSlot *self, txID id)
|
|
153
|
+
{
|
|
154
|
+
mxOverflow(-1);
|
|
155
|
+
fxPush(*self);
|
|
156
|
+
mxDeleteID(id);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
void _xsDeleteAt(txMachine *the, txSlot *self, txSlot *at)
|
|
160
|
+
{
|
|
161
|
+
mxOverflow(-2);
|
|
162
|
+
fxPush(*self);
|
|
163
|
+
fxPush(*at);
|
|
164
|
+
fxDeleteAt(the);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
void _xsCall(txMachine *the, txSlot *res, txSlot *self, txUnsigned id, ...)
|
|
168
|
+
{
|
|
169
|
+
va_list ap;
|
|
170
|
+
int n;
|
|
171
|
+
txSlot *v;
|
|
172
|
+
|
|
173
|
+
va_start(ap, id);
|
|
174
|
+
for (n = 0; va_arg(ap, txSlot *) != NULL; n++)
|
|
175
|
+
;
|
|
176
|
+
va_end(ap);
|
|
177
|
+
mxOverflow(-(n+6));
|
|
178
|
+
fxPush(*self);
|
|
179
|
+
fxCallID(the, (txID)id);
|
|
180
|
+
va_start(ap, id);
|
|
181
|
+
while ((v = va_arg(ap, txSlot *)) != NULL)
|
|
182
|
+
fxPush(*v);
|
|
183
|
+
va_end(ap);
|
|
184
|
+
fxRunCount(the, n);
|
|
185
|
+
if (res != NULL)
|
|
186
|
+
*res = fxPop();
|
|
187
|
+
else
|
|
188
|
+
mxPop();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
void _xsNew(txMachine *the, txSlot *res, txSlot *self, txUnsigned id, ...)
|
|
192
|
+
{
|
|
193
|
+
va_list ap;
|
|
194
|
+
int n;
|
|
195
|
+
txSlot *v;
|
|
196
|
+
|
|
197
|
+
va_start(ap, id);
|
|
198
|
+
for (n = 0; va_arg(ap, txSlot *) != NULL; n++)
|
|
199
|
+
;
|
|
200
|
+
va_end(ap);
|
|
201
|
+
mxOverflow(-(n+6));
|
|
202
|
+
fxPush(*self);
|
|
203
|
+
fxNewID(the, (txID)id);
|
|
204
|
+
va_start(ap, id);
|
|
205
|
+
while ((v = va_arg(ap, txSlot *)) != NULL)
|
|
206
|
+
fxPush(*v);
|
|
207
|
+
va_end(ap);
|
|
208
|
+
fxRunCount(the, n);
|
|
209
|
+
*res = fxPop();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
txBoolean _xsTest(txMachine *the, txSlot *v)
|
|
213
|
+
{
|
|
214
|
+
mxOverflow(-1);
|
|
215
|
+
fxPush(*v);
|
|
216
|
+
return fxRunTest(the);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
txInteger fxIncrementalVars(txMachine* the, txInteger theCount)
|
|
220
|
+
{
|
|
221
|
+
txSlot* aStack = the->scope;
|
|
222
|
+
txInteger aVar;
|
|
223
|
+
|
|
224
|
+
if (aStack - aStack->value.integer != the->stack) {
|
|
225
|
+
static const char msg[] ICACHE_XS6STRING_ATTR = "C: xsVars: too late";
|
|
226
|
+
mxSyntaxError((char *)msg);
|
|
227
|
+
}
|
|
228
|
+
mxOverflow(theCount);
|
|
229
|
+
aVar = aStack->value.integer;
|
|
230
|
+
aStack->value.integer += theCount;
|
|
231
|
+
if (theCount > 0) {
|
|
232
|
+
while (theCount) {
|
|
233
|
+
mxPushUndefined();
|
|
234
|
+
theCount--;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
else
|
|
238
|
+
the->stack -= theCount;
|
|
239
|
+
return aVar;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
txInteger _xsArgc(txMachine *the)
|
|
243
|
+
{
|
|
244
|
+
return mxArgc;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
#ifndef __XSMC_H__
|
|
248
|
+
enum {
|
|
249
|
+
xsBufferNonrelocatable,
|
|
250
|
+
xsBufferRelocatable
|
|
251
|
+
};
|
|
252
|
+
#endif
|
|
253
|
+
|
|
254
|
+
static txInteger _xsmcGetViewBuffer(txMachine *the, txSlot* view, txSlot* buffer, void **data, txUnsigned *count, txBoolean writable)
|
|
255
|
+
{
|
|
256
|
+
txInteger offset = view->value.dataView.offset;
|
|
257
|
+
txInteger size = view->value.dataView.size;
|
|
258
|
+
txSlot* arrayBuffer = buffer->value.reference->next;
|
|
259
|
+
txSlot* bufferInfo = arrayBuffer->next;
|
|
260
|
+
if (arrayBuffer->value.arrayBuffer.address == C_NULL)
|
|
261
|
+
mxTypeError("detached buffer");
|
|
262
|
+
if (writable && (arrayBuffer->flag & XS_DONT_SET_FLAG))
|
|
263
|
+
mxTypeError("read-only buffer");
|
|
264
|
+
if (bufferInfo->value.bufferInfo.maxLength >= 0) {
|
|
265
|
+
txInteger byteLength = bufferInfo->value.bufferInfo.length;
|
|
266
|
+
if (offset > byteLength)
|
|
267
|
+
mxTypeError("out of bounds view");
|
|
268
|
+
if (size < 0)
|
|
269
|
+
size = byteLength - offset;
|
|
270
|
+
else if (offset + size > byteLength)
|
|
271
|
+
mxTypeError("out of bounds view");
|
|
272
|
+
}
|
|
273
|
+
*data = arrayBuffer->value.arrayBuffer.address + offset;
|
|
274
|
+
*count = size;
|
|
275
|
+
|
|
276
|
+
return (XS_ARRAY_BUFFER_KIND == arrayBuffer->kind) ? xsBufferRelocatable : xsBufferNonrelocatable;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
txInteger _xsmcGetBuffer(txMachine *the, txSlot *slot, void **data, txUnsigned *count, txBoolean writable)
|
|
280
|
+
{
|
|
281
|
+
txSlot* instance;
|
|
282
|
+
|
|
283
|
+
if (slot->kind != XS_REFERENCE_KIND)
|
|
284
|
+
goto bail;
|
|
285
|
+
|
|
286
|
+
instance = slot->value.reference;
|
|
287
|
+
if (!(((slot = instance->next)) && (slot->flag & XS_INTERNAL_FLAG)))
|
|
288
|
+
goto bail;
|
|
289
|
+
|
|
290
|
+
if (slot->kind == XS_ARRAY_BUFFER_KIND) {
|
|
291
|
+
txSlot* bufferInfo = slot->next;
|
|
292
|
+
if (slot->value.arrayBuffer.address == C_NULL)
|
|
293
|
+
mxTypeError("detached buffer");
|
|
294
|
+
if (writable && (slot->flag & XS_DONT_SET_FLAG))
|
|
295
|
+
mxTypeError("read-only buffer");
|
|
296
|
+
*data = slot->value.arrayBuffer.address;
|
|
297
|
+
*count = bufferInfo->value.bufferInfo.length;
|
|
298
|
+
return xsBufferRelocatable;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (slot->kind == XS_TYPED_ARRAY_KIND) {
|
|
302
|
+
txSlot* view = slot->next;
|
|
303
|
+
txSlot* buffer = view->next;
|
|
304
|
+
if (1 != slot->value.typedArray.dispatch->size)
|
|
305
|
+
goto bail;
|
|
306
|
+
return _xsmcGetViewBuffer(the, view, buffer, data, count, writable);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (slot->kind == XS_HOST_KIND) {
|
|
310
|
+
txSlot* bufferInfo = slot->next;
|
|
311
|
+
if (slot->flag & XS_HOST_CHUNK_FLAG)
|
|
312
|
+
goto bail;
|
|
313
|
+
if (writable && (slot->flag & XS_DONT_SET_FLAG))
|
|
314
|
+
mxTypeError("read-only buffer");
|
|
315
|
+
if (bufferInfo && (bufferInfo->kind == XS_BUFFER_INFO_KIND)) {
|
|
316
|
+
*data = (uint8_t *)slot->value.host.data;
|
|
317
|
+
*count = bufferInfo->value.bufferInfo.length;
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
// for compatibility. should throw eventually.
|
|
321
|
+
txSlot tmp, ref;
|
|
322
|
+
fxReport(the, "# Use xsmcSetHostBuffer instead of xsmcSetHostData\n");
|
|
323
|
+
fxReference(the, &ref, instance);
|
|
324
|
+
_xsGet(the, &tmp, &ref, _byteLength);
|
|
325
|
+
*data = (uint8_t *)slot->value.host.data;
|
|
326
|
+
*count = (txUnsigned)fxToInteger(the, &tmp);
|
|
327
|
+
}
|
|
328
|
+
return xsBufferNonrelocatable;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
if (slot->kind == XS_DATA_VIEW_KIND) {
|
|
332
|
+
txSlot* view = slot;
|
|
333
|
+
txSlot* buffer = view->next;
|
|
334
|
+
return _xsmcGetViewBuffer(the, view, buffer, data, count, writable);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
bail:
|
|
338
|
+
mxTypeError("this is no buffer");
|
|
339
|
+
return xsBufferNonrelocatable;
|
|
340
|
+
}
|