Repository navigation
Conversation
CFFIAPI.h declares hxs_encoding, hxs_utf16, alloc_hxs_utf8 and the other Prime string functions only under HXCPP_PRIME, which CFFIPrime.h defines before it includes CFFI.h. An extension that includes CFFI.h first, as SteamWrap does, gets the API without them, and CFFIPrime.h's own inclusion of CFFI.h then does nothing. Since 1e6417d, the ordinary wrapper of a DEFINE_PRIME function uses three of them, so such an extension no longer compiled. CFFIAPI.h now marks that it declared them, and with HX_CFFI_PRIME_ONLY declares them alone. CFFIPrime.h includes it that way when they are missing, so the wrapper keeps Unicode strings whatever the order. An ndll resolves each function the first time it is called, so declaring them later changes nothing else. Under neko, CFFI.h included first leaves out the defaults of alloc_hxs_utf8 and hxs_utf16, but hxs_encoding's default answers UTF-8, so neither is called. Tests: test/regression/CffiPrimeAfterCffi builds an ndll that includes CFFI.h before CFFIPrime.h and passes strings that are not ASCII through the wrapper. Before, the ndll failed to compile. The other Cffi* cases pass, and both include orders compile with IMPLEMENT_API, STATIC_LINK and neither. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Since 1e6417d (#323), a native extension that includes
hx/CFFI.hbeforehx/CFFIPrime.hno longer compiles:SteamWrap is one of them:
CFFIAPI.hdeclares the Prime string functions only underHXCPP_PRIME, whichCFFIPrime.hdefines before it includesCFFI.h. Included first,CFFI.hdeclares the API without them, and the inclusion fromCFFIPrime.hthen does nothing. The ordinary wrapper of aDEFINE_PRIMEfunction now uses three of them. The tests only includeCFFIPrime.h, so CI did not see it.CFFIAPI.hnow definesHX_CFFI_PRIME_DECLAREDwhen it declares them, and declares only them underHX_CFFI_PRIME_ONLY. When they are missing,CFFIPrime.hincludes it that way, so the wrapper keeps Unicode strings whatever the include order. An ndll resolves each function the first time it is called, so declaring them later changes nothing else. Under neko, withCFFI.hfirst,CFFILoader.hhas no defaults foralloc_hxs_utf8andhxs_utf16, buthxs_encoding's default answers UTF-8, so neither is called.Tests:
test/regression/CffiPrimeAfterCffibuilds an ndll that includesCFFI.hbeforeCFFIPrime.hand passes strings that are not ASCII through the wrapper, both ways. Before, its ndll failed to compile. It is skipped on Emscripten, asCffiPrimeUnicodeFallbackis. The otherCffi*cases pass, and both include orders compile withIMPLEMENT_API, withSTATIC_LINKand with neither.