@microtronics/studio-cli 0.58.0 → 0.60.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 +23 -15
- package/dist/main.js +23 -23
- package/out/dde/fileGenerators/dloLocalData.js +29 -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,13 @@ 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('\tmemtostr(aData, mem, 0, dim);');
|
|
224
|
+
pawnSource('\treturn dim;');
|
|
225
|
+
pawnSource('}');
|
|
226
|
+
}
|
|
215
227
|
}
|
|
216
228
|
/**
|
|
217
229
|
* Builds the Pawn index expression for accessing an array element by byte offset.
|
|
@@ -241,7 +253,13 @@ function buildArrayGroupBlock(pawnSource, group) {
|
|
|
241
253
|
const indexExpr = buildIndexExpression(startOffset, step);
|
|
242
254
|
const condition = buildConditionExpression(startOffset, endOffset, step);
|
|
243
255
|
pawnSource(`\tif (${condition}) {`);
|
|
244
|
-
|
|
256
|
+
if (formatType === 'bin') {
|
|
257
|
+
const fieldAccess = `${pawnVarBase}[${indexExpr}]${subField}`;
|
|
258
|
+
pawnSource(`\t\treturn _DDE_fmt_bin(aData, ${fieldAccess}, ${fieldAccess}_dim);`);
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
pawnSource(`\t\treturn _DDE_fmt_${formatType}(aData, ${pawnVarBase}[${indexExpr}]${subField});`);
|
|
262
|
+
}
|
|
245
263
|
pawnSource(`\t}`);
|
|
246
264
|
}
|
|
247
265
|
/**
|
|
@@ -260,12 +278,16 @@ function buildOptimizedCaseForField(pawnSource, containerTitle, field) {
|
|
|
260
278
|
const fieldNamePrefix = field.library ? `_${helper_1.Helper.generateHashForLibraryName(field.library)}` : 'DDE_';
|
|
261
279
|
const ddeFieldName = `${fieldNamePrefix}${containerTitle}_${field.name}`;
|
|
262
280
|
const formatType = getHelperFormatType(tdefPwn);
|
|
263
|
-
if (formatType) {
|
|
281
|
+
if (formatType === 'bin') {
|
|
282
|
+
// Compact single-line case using binary helper function
|
|
283
|
+
pawnSource(`\t\tcase ${field.byteOffset}: return _DDE_fmt_bin(aData, ${ddeFieldName}, ${ddeFieldName}_dim);`);
|
|
284
|
+
}
|
|
285
|
+
else if (formatType) {
|
|
264
286
|
// Compact single-line case using helper function
|
|
265
287
|
pawnSource(`\t\tcase ${field.byteOffset}: return _DDE_fmt_${formatType}(aData, ${ddeFieldName});`);
|
|
266
288
|
}
|
|
267
289
|
else {
|
|
268
|
-
// Fall back to inline code (
|
|
290
|
+
// Fall back to inline code (packed types, wstring, etc.)
|
|
269
291
|
pawnSource(`\t\tcase ${field.byteOffset}: {`);
|
|
270
292
|
if (tdefPwn.printf) {
|
|
271
293
|
let printfInsert = ddeFieldName;
|
|
@@ -275,10 +297,6 @@ function buildOptimizedCaseForField(pawnSource, containerTitle, field) {
|
|
|
275
297
|
pawnSource(`\t\t\tsprintf(szTemp, _, "${tdefPwn.printf}", ${printfInsert});`);
|
|
276
298
|
pawnSource(`\t\t\treturn (strcat(aData, szTemp, sizeof(szTemp)));`);
|
|
277
299
|
}
|
|
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
300
|
pawnSource(`\t\t}`);
|
|
283
301
|
}
|
|
284
302
|
}
|