Hi Juergen, I have been reviewing your code last few weekends.
Your original code rebased on to current master I pushed here:
https://github.com/jayrm/fbc/tree/jklwn-ustringOverall, it's a big change to the compiler, though looks like you have made changes in the right places. However, the logic in some places ignores cases that might be present.
I've been working on adding the changes step-by-step here:
https://github.com/jayrm/fbc/tree/udt-wstringI'm using this new syntax to indicate that a UDT should behave like a wstring (or a zstring):
type T extends wstring '' or zstring
'' ...
end type
For testing, I am using a minimal implementation. As far as the compiler changes go, I'm not really interested in how well the UDT works as a dynamic wstring, just that it works as wstring:
type UWSTRING_FIXED extends wstring
private:
_data as wstring * 256
public:
declare constructor()
declare constructor( byval rhs as const wstring const ptr )
declare constructor( byval rhs as const zstring const ptr )
declare operator cast() byref as wstring
declare const function length() as integer
end type
constructor UWSTRING_FIXED()
_data = ""
end constructor
constructor UWSTRING_FIXED( byval s as const wstring const ptr )
_data = *s
end constructor
constructor UWSTRING_FIXED( byval s as const zstring const ptr )
_data = wstr( *s )
end constructor
operator UWSTRING_FIXED.Cast() byref as wstring
operator = *cast(wstring ptr, @_data)
end operator
const function UWSTRING_FIXED.length() as integer
function = len( _data )
end function
operator Len( byref s as const UWSTRING_FIXED ) as integer
return s.Length()
end operator
I'm going step-by-step to determine what changes are needed, why they are needed, and fully test. For example, test-suite for my branch not passing on Travis-CI due memory leaks I didn't notice (double free). That could be due my changes, or due missing overloads the minimal implementation.
Also I have been investigating some of the long standing WSTRING bugs posted on sf.net while working on review of your code.
A requirement that the m_pBuffer element be first element should not be required. Instead, fbc should be calling an operator overload to get the data's address if the user has defined one. Or maybe it needs to be a requirement of the UDT that the user writes.