Repository navigation
Conversation
… host interfaces Host code calls interface functions with the native signature, which uses Dynamic for type parameters. Script implementations with more specific types, such as a class implementing IMap<String, String>, read those values as the wrong types. Wrap such functions in an adapter that converts the arguments and the return value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Uh, that doesn't look great... |
Member
|
Is this not more of a cppia generator issue? How do other targets handle this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Host code calls interface functions with the native signature, which uses
Dynamicfor type parameters. A script class implementing a host interface with more specific types, e.g.IMap<String, String>, then reads the pushed values as the wrong types. This madegetreturn garbage/null or crash, both for calls from host code and for script calls (which go through the host's interface functions). This was found via HaxeFoundation/haxe#13118, where a test implementingIMapfails on cppia.When linking a script class's interface vtable slots, functions whose argument or return types differ from the native signature are now wrapped in an adapter. It reads the arguments using the native types, converts them via
pushArgsDynamic, calls the script function and converts the return value back. The adapter itself has the native signature, so script calls through the same slot still push matching values. Functions whose signature already matches are used directly as before.Adds
NativeInterfaceTypesto the cppia client tests, with script implementations ofIMap<String, String>andIMap<Int, Float>. Both tests fail without the fix, and pass with it, interpreted and with-jit.Unrelated, noticed while looking at this:
CppiaModule::getInterfaceSlotreturnsinterfaceSlots.size()+1for new names, but the host's names start at slot 2, so the first new script-only interface function name gets the same slot as the last host one.🤖 Generated with Claude Code