Conversation
HX_DEFINE_SCRIPTABLE always calls __superString::toString() with no arguments. A Haxe toString(indent = 0) is one C++ parameter, so that call does not compile. The zero-argument form is used when it exists. Otherwise null is passed for the default. Co-authored-by: Cursor <cursoragent@cursor.com>
The cppia host build is what failed: toString(indent = 0) is one C++ parameter, and the scriptable wrapper called it with none. A zero-argument toString is compiled in the same file so that form stays valid. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Seems like this is more of a specific hack to fix a program with that toString signature, but not a good general solution if the toString signature is different |
A Haxe toString with parameters compiles to a C++ overload that hides hx::Object::toString() without overriding it, whatever the parameters. Passing null for them only worked for a single optional one. Native code calling toString() on such an object reaches hx::Object::toString(), so the scriptable wrapper now calls that one too. The cppia tests now build host classes that inherit a toString with one optional parameter and with two required ones, and check at run time that script classes extending them print like native ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
You're right. Passing |
HX_DEFINE_SCRIPTABLEalways calls__superString::toString()with no arguments. A HaxetoString(indent = 0)is one C++ parameter, so that call does not compile.The zero-argument form is used when it exists. Otherwise
nullis passed for the default.The cppia host build compiles
OptionalToString, whosetoStringtakes an optional argument, andZeroArgToString, whosetoStringdoes not. Without this change that host build does not compile.