Repository navigation
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 |
|
This change still doesn't make sense, there is a rogue I think the Could you clarify what the compiler error actually is? Is it that |
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. HaxeFoundation/hxcpp#1403 Fixes #32
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. HaxeFoundation/hxcpp#1403 Fixes #32
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. HaxeFoundation/hxcpp#1403 Fixes #32
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. HaxeFoundation/hxcpp#1403 Fixes #32
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. HaxeFoundation/hxcpp#1403 Fixes #32
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. HaxeFoundation/hxcpp#1403 Fixes #32
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. HaxeFoundation/hxcpp#1403 Fixes #32
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. HaxeFoundation/hxcpp#1403 Fixes #32
|
Yes, that's it. With current Haxe development and hxcpp master, a host built with class OptionalToString {
public function new() {}
public function toString(indent:Int = 0):String return "indent" + indent;
}
class OptionalToStringChild extends OptionalToString {}fails with:
The I agree the generator is the better place, so I opened HaxeFoundation/haxe#13066: it walks up the hierarchy past the nearest funky |
Thanks for the explanation, that makes more sense. Though it seems a bit hacky and it would be nice to avoid the dummy parameter. If it's just a gap in what Haxe's generator is already doing then it does make sense to handle it there. It should also be possible to backport that fix to haxe 4.3.x so we can decide whether to add this workaround in hxcpp or to just rely on the haxe side patch. |
ScriptableHasToString says whether `T::toString()` compiles, and the wrapper dispatches on it with std::true_type / std::false_type, as Boxed and Invoker already do, instead of ranking an `int` overload over a `...` one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I replaced the dummy parameter in 4e1b2b7: a About relying on the Haxe side: 4.3.7 came out in May 2025, |
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.