Code: Select all
type T extends wstring '' or zstring
'' data & overload declarations
end type
This is based off the work by Juergen Kuehlwein that is currently sitting as a pull request at https://github.com/freebasic/fbc/pull/118 and rebased on to current master at https://github.com/jayrm/fbc/tree/jklwn-ustring
JK has done a very good job of identifying the areas of the compiler that need to be looked at. As it stands though, the pull request can't be merged in without some major modifications and testing, so I've started working on the changes in a step-by-step manner at https://github.com/jayrm/fbc/tree/udt-wstring
JK's effort is based on some of the already very good string-type-UDT's made by José Roca in his WinFBX framework. However, some tricks and hacks are needed to make the UDT's work with fbc's current UDT+wstring handling, and this new UDT feature is to help with that. There is a very long discussion about it on José's site at http://www.jose.it-berater.org/smfforum ... topic=5253
Most notably are the quirk functions (like LCASE, INSTR, TRIM), that tend to prefer STRING casting when used with a UDT, even if the appropriate operator UDT.CAST exists.
While I have been reviewing JK's code, and writing tests for this new feature, I have noticed that there are wstring bugs in the compiler/rtlib that need to be dealt with as well:
#441 Operator Cast WString Ptr not recognised as pointer
#666 Cannot overload 'as string' with 'as zstring ptr'
#734 Passing String argument to Zstring Ptr parameter ignores Constness
#752 Cast(Zstring, u) is prohibited even if UDT from 'u' defines the member operator Cast() Byref As Zstring
#840 Constancy of certain wstring expressions changes when crosscompiling with differing sizeof(wstring)
#899 trim( wstring ) causes crash if string is single space
NEED HELP WITH:
If you know of any bugs either reported on this forum or sourceforge.net that I have missed, please post a link here, or even better, update the sourceforge.net ticket with the link as well. I don't know if I can fix all of them, but getting all the available information and test cases is the first step.
Or if you know of a wstring problem that's never been reported or you can't find if it has been reported, please post about it here, or create a new issue ticket.
Thanks, Jeff.