Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Udt string offsets & bump to version 3.14.0 #527

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions source/global/version.bas
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
DIM SHARED Version AS STRING
DIM SHARED IsCiVersion AS _BYTE

Version$ = "3.13.1"
$VERSIONINFO:FILEVERSION#=3,13,1,0
$VERSIONINFO:PRODUCTVERSION#=3,13,1,0
Version$ = "3.14.0"
$VERSIONINFO:FILEVERSION#=3,14,0,0
$VERSIONINFO:PRODUCTVERSION#=3,14,0,0

' If ./internal/version.txt exist, then this is some kind of CI build with a label
IF _FILEEXISTS("internal/version.txt") THEN
Expand Down
20 changes: 10 additions & 10 deletions source/utilities/type.bas
Original file line number Diff line number Diff line change
Expand Up @@ -630,11 +630,11 @@ END SUB
SUB initialise_udt_varstrings (n$, udt, buf, base_offset)
IF NOT udtxvariable(udt) THEN EXIT SUB
element = udtxnext(udt)
offset = 0
offset = base_offset
DO WHILE element
IF udtetype(element) AND ISSTRING THEN
IF (udtetype(element) AND ISFIXEDLENGTH) = 0 THEN
WriteBufLine buf, "*(qbs**)(((char*)" + n$ + ")+" + STR$(base_offset + offset) + ") = qbs_new(0,0);"
WriteBufLine buf, "*(qbs**)(((char*)" + n$ + ")+" + STR$(offset) + ") = qbs_new(0,0);"
END IF
ELSEIF udtetype(element) AND ISUDT THEN
initialise_udt_varstrings n$, udtetype(element) AND 511, buf, offset
Expand All @@ -647,14 +647,14 @@ END SUB
SUB free_udt_varstrings (n$, udt, buf, base_offset)
IF NOT udtxvariable(udt) THEN EXIT SUB
element = udtxnext(udt)
offset = 0
offset = base_offset
DO WHILE element
IF udtetype(element) AND ISSTRING THEN
IF (udtetype(element) AND ISFIXEDLENGTH) = 0 THEN
WriteBufLine buf, "qbs_free(*((qbs**)(((char*)" + n$ + ")+" + STR$(base_offset + offset) + ")));"
WriteBufLine buf, "qbs_free(*((qbs**)(((char*)" + n$ + ")+" + STR$(offset) + ")));"
END IF
ELSEIF udtetype(element) AND ISUDT THEN
initialise_udt_varstrings n$, udtetype(element) AND 511, buf, offset
free_udt_varstrings n$, udtetype(element) AND 511, buf, offset
END IF
offset = offset + udtesize(element) \ 8
element = udtenext(element)
Expand All @@ -664,19 +664,19 @@ END SUB
SUB clear_udt_with_varstrings (n$, udt, buf, base_offset)
IF NOT udtxvariable(udt) THEN EXIT SUB
element = udtxnext(udt)
offset = 0
offset = base_offset
DO WHILE element
IF udtetype(element) AND ISSTRING THEN
IF (udtetype(element) AND ISFIXEDLENGTH) = 0 THEN
WriteBufLine buf, "(*(qbs**)(((char*)" + n$ + ")+" + STR$(base_offset + offset) + "))->len=0;"
WriteBufLine buf, "(*(qbs**)(((char*)" + n$ + ")+" + STR$(offset) + "))->len=0;"
ELSE
WriteBufLine buf, "memset((char*)" + n$ + "+" + STR$(base_offset + offset) + ",0," + STR$(udtesize(element) \ 8) + ");"
WriteBufLine buf, "memset((char*)" + n$ + "+" + STR$(offset) + ",0," + STR$(udtesize(element) \ 8) + ");"
END IF
ELSE
IF udtetype(element) AND ISUDT THEN
clear_udt_with_varstrings n$, udtetype(element) AND 511, buf, base_offset + offset
clear_udt_with_varstrings n$, udtetype(element) AND 511, buf, offset
ELSE
WriteBufLine buf, "memset((char*)" + n$ + "+" + STR$(base_offset + offset) + ",0," + STR$(udtesize(element) \ 8) + ");"
WriteBufLine buf, "memset((char*)" + n$ + "+" + STR$(offset) + ",0," + STR$(udtesize(element) \ 8) + ");"
END IF
END IF
offset = offset + udtesize(element) \ 8
Expand Down
31 changes: 31 additions & 0 deletions tests/compile_tests/types/nested_udt.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
$Console:Only

Type t1
a As String
End Type

Type t2
b As t1
s As String
End Type

Type t3
n As Long
c As t2
End Type

'Test nested variable length string in UDT variable
Dim test As t3
test.c.s = "Hello"
test.c.b.a = " world"
Print test.c.s; test.c.b.a


'Test nested variable length string in UDT array
Dim arr(3) as t3
For i = 0 to 3
arr(2).c.b.a = Str$(i)
Print arr(2).c.b.a;
Next i

System
2 changes: 2 additions & 0 deletions tests/compile_tests/types/nested_udt.output
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Hello world
0 1 2 3