llde/xOBSE

Script Tokens and StringVars rewrite

Opened this issue · 0 comments

llde commented

Analisys for bug #229 revealed that the proper solution for the bug, correctly handling multibyte character inside the string, isn't currently feasible without a lot of change I'm not willing to do inside the 22.x branch.
First of all there is quite the technical debt inside the Script tokens and expression evaluators. Not only the script token pass around the char pointer of the stringVar std::string, with unclear lifetimes, when it may be better to pass the stringVar directly, but also the passed pointer is a raw pointer, that may either leak or be invalid if the referring stringVar is destoryed.
This overrealince of raw pointers make making changes to the string, in particular changes that require to reconstruct the char pointers, to be highly problematic.

Rewriting the Script Token system to handle the object lifetime, using either unique or shared pointers (when refcounting is useful) should be the first pass to properly implement multibyte aware strings