-
Notifications
You must be signed in to change notification settings - Fork 155
user defined types can extend zstring or wstring #150
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
Conversation
- intent is that a UDT can extend the built in zstring and wstring types - add tests/udt-wstring directory - add tests/udt-zstring directory - add astTryConvertUdtToWstring() to cast UDT to z|wstring if the UDT has a cast to z|wstring operator - add symbGetIsUdtZstring() and symbGetIsUdtWstring() to detect if UDT extends z|wstring
- Cxxx() conversion functions will accept UDT as Z|WSTRING
- SADD/STRPTR will accept UDT as Z|WSTRING to return Z|WSTRING ptr - SADD/STRPTR(wstring) returns WSTRING PTR
- type can extend Z|WSTRING and another user defined type (pseudo multiple inheritance for z|wstring only) - extended types inherit Z|WSTRING if the base type also extended Z|WSTRING
|
Force push to rebase on current fbc/master |
|
This pull request now also includes additions for Existing user code is not affected by this pull request, and I plan to continue support for the feature in future. On this basis I believe it acceptable to merge in to master without a review. |
|
Sounds good. |
Allow a user defined type (UDT) to inherit properties and behaviours of a zstring or wstring by extending existing syntax. Purpose is to allow users to create custom string types (i.e. dynamic memory management) that can integrate well in to existing fbc compiler built ins.
New Syntax:
In places where fbc compiler would have normally rejected a UDT, this declaration of a UDT will instruct compiler to convert the UDT to a
z|wstringthrough a suitableCASToperator.zstring|wstringbehaviour can be inherited directly fromzstring|wstring, or indirectly and singly from the base type:Or
zstring|wstringbehaviours can also be inherited in a UDT with a kind of pseudo multiple-inheritance:Changed:
Added:
The only change to existing behaviour is
SADD/STRPTR(wstring)now returnsWSTRING PTR. This will break any user code whereSTRPTR(wstring)is expected to return aZSTRING PTRNew implicit conversions and behaviours are activated only if a UDT extends
zstringorwstring.In future expect separate pull requests for:
LEFT,RIGHTto accept UDT extendsz|wstringwithout having to explicitly overloadLEFT,RIGHT. This involves fixing, in my opinion multiple string related bugs on sf.netIIFto allow handling UDT's that inheritzstring|wstringSELECT CASEto allow handling UDT's that inheritzstring|wstringSWAPwhich maybe would be handled best with an overloaded member function rather than implicit conversion tozstring|wstringThis pull request introduces the initial feature and handles nearly all the quirk keywords. I'd like to merge this change in before working on the remaining features in separate pull requests.
Forum discussion at Extending Wstring and Zstring with UDTs