@microtronics/studio-cli 0.58.0 → 0.59.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/CHANGELOG.md +20 -18
- package/dist/main.js +26 -26
- package/out/dde/fileGenerators/dloLocalData.js +30 -11
- package/package.json +1 -1
|
@@ -9,23 +9,28 @@ const PAWN_SZTEMP_DECL = '\tnew szTemp{64};';
|
|
|
9
9
|
const PAWN_STRCAT_RETURN = '\treturn strcat(aData, szTemp, sizeof(szTemp));';
|
|
10
10
|
/**
|
|
11
11
|
* Determines if a field type can use a format helper function, and which one.
|
|
12
|
-
* Returns null if the field type needs inline code (packed types,
|
|
12
|
+
* Returns null if the field type needs inline code (packed types, wstring, etc.)
|
|
13
13
|
*/
|
|
14
14
|
function getHelperFormatType(tdefPwn) {
|
|
15
|
+
// Binary (memtostr) fields - check before printf since printf is null for binary
|
|
16
|
+
if (!tdefPwn.printf && tdefPwn.printfFormat === 'memtostr') {
|
|
17
|
+
return 'bin';
|
|
18
|
+
}
|
|
15
19
|
if (!tdefPwn.printf) {
|
|
16
20
|
return null;
|
|
17
21
|
}
|
|
18
22
|
const rwp = tdefPwn.rwp || '%n';
|
|
19
23
|
const hasCellArray = rwp.includes('[');
|
|
20
24
|
const hasPackedArray = rwp.includes('{');
|
|
25
|
+
const isComplex = hasPackedArray || hasCellArray;
|
|
21
26
|
if (tdefPwn.printfFormat === 'stampToISOString') {
|
|
22
|
-
return
|
|
27
|
+
return isComplex ? null : 'stamp';
|
|
23
28
|
}
|
|
24
29
|
switch (tdefPwn.printf) {
|
|
25
30
|
case '%d':
|
|
26
|
-
return
|
|
31
|
+
return isComplex ? null : 'd';
|
|
27
32
|
case '%f':
|
|
28
|
-
return
|
|
33
|
+
return isComplex ? null : 'f';
|
|
29
34
|
case '%s':
|
|
30
35
|
return hasCellArray ? null : 's';
|
|
31
36
|
default:
|
|
@@ -212,6 +217,14 @@ function buildHelperFunctions(pawnSource, usedFormats) {
|
|
|
212
217
|
pawnSource(PAWN_STRCAT_RETURN);
|
|
213
218
|
pawnSource('}');
|
|
214
219
|
}
|
|
220
|
+
if (usedFormats.has('bin')) {
|
|
221
|
+
pawnSource('');
|
|
222
|
+
pawnSource('stock _DDE_fmt_bin(aData{}, mem{}, dim) {');
|
|
223
|
+
pawnSource(PAWN_SZTEMP_DECL);
|
|
224
|
+
pawnSource('\tmemtostr(szTemp, mem, 0, dim);');
|
|
225
|
+
pawnSource('\treturn dim;');
|
|
226
|
+
pawnSource('}');
|
|
227
|
+
}
|
|
215
228
|
}
|
|
216
229
|
/**
|
|
217
230
|
* Builds the Pawn index expression for accessing an array element by byte offset.
|
|
@@ -241,7 +254,13 @@ function buildArrayGroupBlock(pawnSource, group) {
|
|
|
241
254
|
const indexExpr = buildIndexExpression(startOffset, step);
|
|
242
255
|
const condition = buildConditionExpression(startOffset, endOffset, step);
|
|
243
256
|
pawnSource(`\tif (${condition}) {`);
|
|
244
|
-
|
|
257
|
+
if (formatType === 'bin') {
|
|
258
|
+
const fieldAccess = `${pawnVarBase}[${indexExpr}]${subField}`;
|
|
259
|
+
pawnSource(`\t\treturn _DDE_fmt_bin(aData, ${fieldAccess}, ${fieldAccess}_dim);`);
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
pawnSource(`\t\treturn _DDE_fmt_${formatType}(aData, ${pawnVarBase}[${indexExpr}]${subField});`);
|
|
263
|
+
}
|
|
245
264
|
pawnSource(`\t}`);
|
|
246
265
|
}
|
|
247
266
|
/**
|
|
@@ -260,12 +279,16 @@ function buildOptimizedCaseForField(pawnSource, containerTitle, field) {
|
|
|
260
279
|
const fieldNamePrefix = field.library ? `_${helper_1.Helper.generateHashForLibraryName(field.library)}` : 'DDE_';
|
|
261
280
|
const ddeFieldName = `${fieldNamePrefix}${containerTitle}_${field.name}`;
|
|
262
281
|
const formatType = getHelperFormatType(tdefPwn);
|
|
263
|
-
if (formatType) {
|
|
282
|
+
if (formatType === 'bin') {
|
|
283
|
+
// Compact single-line case using binary helper function
|
|
284
|
+
pawnSource(`\t\tcase ${field.byteOffset}: return _DDE_fmt_bin(aData, ${ddeFieldName}, ${ddeFieldName}_dim);`);
|
|
285
|
+
}
|
|
286
|
+
else if (formatType) {
|
|
264
287
|
// Compact single-line case using helper function
|
|
265
288
|
pawnSource(`\t\tcase ${field.byteOffset}: return _DDE_fmt_${formatType}(aData, ${ddeFieldName});`);
|
|
266
289
|
}
|
|
267
290
|
else {
|
|
268
|
-
// Fall back to inline code (
|
|
291
|
+
// Fall back to inline code (packed types, wstring, etc.)
|
|
269
292
|
pawnSource(`\t\tcase ${field.byteOffset}: {`);
|
|
270
293
|
if (tdefPwn.printf) {
|
|
271
294
|
let printfInsert = ddeFieldName;
|
|
@@ -275,10 +298,6 @@ function buildOptimizedCaseForField(pawnSource, containerTitle, field) {
|
|
|
275
298
|
pawnSource(`\t\t\tsprintf(szTemp, _, "${tdefPwn.printf}", ${printfInsert});`);
|
|
276
299
|
pawnSource(`\t\t\treturn (strcat(aData, szTemp, sizeof(szTemp)));`);
|
|
277
300
|
}
|
|
278
|
-
else if (tdefPwn.printfFormat === 'memtostr') {
|
|
279
|
-
pawnSource(`\t\t\tmemtostr(szTemp, ${ddeFieldName}, 0, ${ddeFieldName}_dim);`);
|
|
280
|
-
pawnSource(`\t\t\treturn ${ddeFieldName}_dim;`);
|
|
281
|
-
}
|
|
282
301
|
pawnSource(`\t\t}`);
|
|
283
302
|
}
|
|
284
303
|
}
|