Skip to content

Conversation

@tobil4sk
Copy link
Member

This enables an alternate solution for these bugs:
HaxeFoundation/haxe#12374
HaxeFoundation/haxe#12376

With this PR, haxe is able to mark methods as overrides so that they don't add an additional slot to the vtable. This way, haxe can still include them in __scriptableFunctions so that they can be resolved correctly in super.method calls, avoiding #1150.

Alternatively, if the haxe version is old and does not mark them, then fallback logic is used to infer overrides from matching method names. This has a runtime cost but avoids incorrect behaviour for current haxe. This only really affects 4.3.7 as older versions suffered from #1150.

This allows overridden methods to be marked so that they do not add an
addtional slot to the vtable, which has previously caused bugs due to
incorrect vtable indices.
For haxe versions that do not tag overridden methods in
__scriptableFunctions tables, we can infer overrides at runtime by
comparing method names.
This way is a bit more backwards compatible. An overridden method will
always have a super version provided.
@tobil4sk tobil4sk force-pushed the fix/haxe-overridden-scriptable-methods branch from 0a60050 to e378ab7 Compare December 15, 2025 11:37
@Simn Simn merged commit 596badd into HaxeFoundation:master Dec 27, 2025
120 checks passed
@Simn
Copy link
Member

Simn commented Dec 27, 2025

Out of curiosity, where does the data functions points to actually come from? I went looking for that because these for-loops clearly assume zero-termination, but the only thing I found is the static __scriptableFunctions which is used in HX_SCRIPTABLE_REGISTER_CLASS.

@tobil4sk
Copy link
Member Author

tobil4sk commented Dec 27, 2025

__scriptableFunctions is generated by gencpp (e.g. here) for each class/interface, and is passed in via HX_SCRIPTABLE_REGISTER_CLASS into:

HaxeNativeClass *registered = new HaxeNativeClass(inName.utf8_str(),inDataOffset, inFunctions,inFactory, inConstruct);

So gencpp makes sure these are 0 terminated.

@tobil4sk tobil4sk deleted the fix/haxe-overridden-scriptable-methods branch December 27, 2025 09:07
@Simn
Copy link
Member

Simn commented Dec 27, 2025

__scriptableFunctions is generated by gencpp (e.g. here) for each class/interface

Aah, that's the piece I was missing, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants