1
1
Fork 0
mirror of https://github.com/boxgaming/qbjs.git synced 2024-07-21 12:25:14 +00:00

Fixed issue with export causing collisions between muliple imported libraries

This commit is contained in:
boxgaming 2024-04-08 15:13:54 -05:00
parent 0187c6ce84
commit 37aa78a7c9
2 changed files with 18 additions and 10 deletions

View file

@ -769,7 +769,7 @@ if (QB.halted()) { return; };
var esize = 0; /* SINGLE */
esize = (QB.func_UBound( exportLines)) + 1;
QB.resizeArray(exportLines, [{l:0,u:esize}], '', true); /* STRING */
QB.arrayValue(exportLines, [ esize]).value = "this." + exportName + " = " + exportedItem + ";";
QB.arrayValue(exportLines, [ esize]).value = exportName + ": " + exportedItem + ",";
}
async function func_ConvertSub(m/*METHOD*/,args/*STRING*/,lineNumber/*INTEGER*/) {
if (QB.halted()) { return; };
@ -2157,10 +2157,14 @@ if (QB.halted()) { return; };
await sub_AddJSLine( lastLine, "}");
}
}
var ___v4048342 = 0; ___l3534726: for ( i= 1; i <= (QB.func_UBound( exportLines)); i= i + 1) { if (QB.halted()) { return; } ___v4048342++; if (___v4048342 % 100 == 0) { await QB.autoLimit(); }
await sub_AddJSLine( i, QB.arrayValue(exportLines, [ i]).value);
}
QB.resizeArray(exportLines, [{l:0,u:0}], '', false); /* STRING */
if ((QB.func_UBound( exportLines)) > 0) {
await sub_AddJSLine( 0, "return {");
var ___v4048342 = 0; ___l3534726: for ( i= 1; i <= (QB.func_UBound( exportLines)); i= i + 1) { if (QB.halted()) { return; } ___v4048342++; if (___v4048342 % 100 == 0) { await QB.autoLimit(); }
await sub_AddJSLine( i, QB.arrayValue(exportLines, [ i]).value);
}
await sub_AddJSLine( 0, "};");
QB.resizeArray(exportLines, [{l:0,u:0}], '', false); /* STRING */
}
}
async function sub_ReadLinesFromFile(filename/*STRING*/) {
if (QB.halted()) { return; };

View file

@ -876,7 +876,7 @@ Sub RegisterExport (exportName As String, exportedItem As String)
Dim esize
esize = UBound(exportLines) + 1
ReDim _Preserve exportLines(esize) As String
exportLines(esize) = "this." + exportName + " = " + exportedItem + ";"
exportLines(esize) = exportName + ": " + exportedItem + ","
End Sub
Function ConvertSub$ (m As Method, args As String, lineNumber As Integer)
@ -2300,10 +2300,14 @@ Sub ConvertMethods ()
Next i
' Add the export lines
For i = 1 To UBound(exportLines)
AddJSLine i, exportLines(i)
Next i
ReDim exportLines(0) As String
If UBound(exportLines) > 0 Then
AddJSLine 0, "return {"
For i = 1 To UBound(exportLines)
AddJSLine i, exportLines(i)
Next i
AddJSLine 0, "};"
ReDim exportLines(0) As String
End If
End Sub