Skip to content

Commit 4dda1ea

Browse files
authored
Merge pull request #332 from jayrm/strings
Allow overloads for [z|w]string [ptr] types and conversions for UDT's casting [z|w]string [ptr] types
2 parents 8539e1d + 3437197 commit 4dda1ea

File tree

8 files changed

+323
-94
lines changed

8 files changed

+323
-94
lines changed

changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Version 1.09.0
1313
- fbc: gen gcc: allow compiling with GCC 4.5 and older, by avoiding -Wno-unused-but-set-variable (TeeEmCee)
1414
- fbc: internal function fbcQueryGcc() to ask gcc for the correct as & ld to use (TeeEmCee)
1515
- rtlib: freebsd: minimum thread stacksize 8192 KiB
16+
- sf.net #666: allow overload 'as string' with 'as zstring ptr' parameters
1617

1718
[added]
1819
- fbc: add '-z fbrt' command line option to link against libfbrt*.a instead of libfb*.a
@@ -23,6 +24,7 @@ Version 1.09.0
2324
- fbc: add '-entry name' command line option to set program entry point (TeeEmCee)
2425
- added objinfo support for ELF files on freebsd
2526
- PROCPTR( identifier, type ) syntax to allow getting procedure pointer for based on sub/function type
27+
- sf.net #666: overload matching for UDT's with CAST() operators as [w|z]string type and implicit conversions
2628

2729
[fixed]
2830
- github #315: set parameters when calling SCREENCONTROL (was broken in fbc 1.08.0 due to new LONG/LONGINT SCREENCONTROL API's)
@@ -38,6 +40,7 @@ Version 1.09.0
3840
- darwin: a variety of improvements to allow compiling and linking (TeeEmCee)
3941
- gfxlib2: fix d2d scaling issues for high dpi (adeyblue)
4042
- fbc: improve error message on statement between SELECT and first CASE inside a subroutine and don't allow CONST/ENUM between any SELECT & first CASE.
43+
- sf.net #843: Implicit casting of argument to string works for Instr() and Mid() but not for Left() and Right()
4144

4245

4346
Version 1.08.0

src/compiler/dstr.bas

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ declare sub hRealloc _
4949
#endmacro
5050

5151
'':::::
52-
#define CALC_LEN( p ) iif( p <> NULL, len( *src ), 0 )
52+
#define CALC_LEN( p ) iif( p <> NULL, len( *p ), 0 )
5353

5454
''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
5555
'' dynamic zstrings
@@ -61,9 +61,9 @@ sub DZstrZero _
6161
byref dst as DZSTRING _
6262
)
6363

64-
dst.data = NULL
65-
dst.len = 0
66-
dst.size = 0
64+
dst.data = NULL
65+
dst.len = 0
66+
dst.size = 0
6767

6868
end sub
6969

@@ -209,9 +209,9 @@ sub DWstrZero _
209209
byref dst as DWSTRING _
210210
)
211211

212-
dst.data = NULL
213-
dst.len = 0
214-
dst.size = 0
212+
dst.data = NULL
213+
dst.len = 0
214+
dst.size = 0
215215

216216
end sub
217217

src/compiler/symb-data.bas

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ sub symbDataInit( )
134134
'' populate symb_dtypeMatchTB() with ranking numbers
135135
for i = 0 to NUMTYPES - 1
136136
dtype2 = rank(i)
137-
symb_dtypeMatchTB( dtype1, dtype2 ) = i
137+
symb_dtypeMatchTB( dtype1, dtype2 ) = OvlMatchScore( i, 0 )
138138
next
139139

140140
next
@@ -525,14 +525,21 @@ end function
525525
'' result:
526526
''
527527
'' FB_OVLPROC_FULLMATCH => compatible, exact match
528+
'' FB_OVLPROC_FULLMATCH - stringrank => compatible, distance between string types (no w<->z conversion)
528529
'' FB_OVLPROC_FULLMATCH - baselevel => compatible, derived types
529530
'' FB_OVLPROC_TYPEMATCH + consts => same type, different consts
530531
'' FB_OVLPROC_HALFMATCH => compatible, same data type class
531532
'' FB_OVLPROC_HALFMATCH - rank => compatible, distance between numeric types
532-
'' FB_OVLPROC_HALFMATCH - struct => compatible, UDT ctor/cast
533+
'' FB_OVLPROC_HALFMATCH - stringrank => compatible, distance between string types (w<->z conversion)
534+
'' FB_OVLPROC_CONVMATCH - struct => compatible, UDT ctor
535+
'' FB_OVLPROC_CASTMATCH => compatible, implicit cast required (udt and string casts)
536+
'' FB_OVLPROC_CONVMATCH => compatible, implicit conversion required (udt and string conversions)
537+
'' FB_OVLPROC_CONVMATCH - struct => compatible, lowest UDT conv/cast
533538
'' FB_OVLPROC_LOWEST_MATCH => compatible, lowest scoring parameter
534539
'' FB_OVLPROC_NO_MATCH => incompatible
535540

541+
'' FB_OVLPROC_MAJORSCALE => granularity of the matching score
542+
536543
''
537544
function typeCalcMatch _
538545
( _
@@ -558,7 +565,7 @@ function typeCalcMatch _
558565
end if
559566

560567
if( (typeGetDtAndPtrOnly( ldtype ) = typeGetDtAndPtrOnly( rdtype )) and (lsubtype = rsubtype) ) then
561-
return FB_OVLPROC_TYPEMATCH + const_matches
568+
return FB_OVLPROC_TYPEMATCH + OvlMatchScore( const_matches, 0 )
562569
end if
563570

564571
'' We know that they're different (in terms of dtype or subtype or both),

0 commit comments

Comments
 (0)