Enable issue299_directc_nested_functions example#325
Merged
jameskermode merged 13 commits intoDec 18, 2025
Conversation
2 tasks
'quip_regression' left out as it has it's own workflow
…dles When compiling with -fdefault-integer-8, bare integer becomes 8 bytes. The handle arrays (e.g., this(4)) were declared as integer, meaning 4 x 8 = 32 bytes with -fdefault-integer-8, but sizeof_fortran_t was calculated assuming 4-byte integers (4 x 4 = 16 bytes). This mismatch caused segfaults when using transfer() to convert between pointer types and integer arrays. Fix by using integer(c_int) for all handle arrays, which remains 4 bytes regardless of -fdefault-integer-8. This ensures consistent size between wrapper generation time and runtime. Changes: - transform.py: Set wrapper_type to 'integer(c_int)' for derived type args - f90wrapgen.py: Use integer(c_int) for handle arrays in: - visit_Procedure (derived type arguments) - _write_sc_array_wrapper (this and dummy_this) - _write_array_getset_item (this and item handles) - _write_array_len (this handle) - _write_scalar_wrapper (this and derived type element handles) - Add 'use, intrinsic :: iso_c_binding, only: c_int' where needed Fixes the default_i8 example test.
The errorbinding example was added to the test suite in PR jameskermode#320 but was missing the required tests.py and tests_pkg.py files, causing CI to fail.
Remove f2py_string_input and issue299_directc_nested_functions from test suite until they are fixed: - f2py_string_input: undefined symbol string_in_array_ (linking issue) - issue299_directc_nested_functions: types.py shadows Python stdlib types module
During rebase, conflict resolution incorrectly re-added broken examples to the Makefile EXAMPLES list. These examples were intentionally excluded: - callback_print_function_issue93 (undefined symbol: pyfunc_print_) - f2py_string_input (undefined symbol: string_in_array_) - issue299_directc_nested_functions (types.py shadows stdlib) - issue41_abstract_classes (AttributeError on get_value) - recursive_type (Derived type not declared) The CMakeLists.txt was already correct; only Makefile needed fixing.
During rebase conflict resolution, an else clause was incorrectly added that declared dummy_this for module-level arrays. However, the subroutine signature for module-level arrays doesn't include any this argument (per issue jameskermode#306 fix), causing a mismatch: the variable was declared but not in the argument list, leading to compilation errors. Remove the erroneous else clause - module-level arrays should have no this argument in either the signature or declarations.
Generate Fortran wrappers and Python methods for deferred bindings on abstract types. This enables polymorphic dispatch through the base class. Changes: - transform.py: Resolve deferred binding prototypes to abstract interface procedures, marking them with 'deferred' and 'method' attributes - LinkBoundDType: Handle resolved deferred bindings (skip raw Prototypes) - Re-enable issue41_abstract_classes example in test suite When a factory function returns a polymorphic class(base_type) object, the Python wrapper now correctly has the deferred methods available, which dispatch through Fortran's polymorphic call mechanism.
Both examples now pass with the current codebase. The callback example had non-ASCII curly quotes in a comment that were breaking f2py on some systems - replaced with ASCII single quotes.
The test only verifies C compilation succeeds (the original issue jameskermode#299 fix). It does not import the generated Python module, so the types.py naming conflict with stdlib is not triggered.
Run python from parent directory to avoid the generated types.py shadowing Python's stdlib types module when getting numpy/python include paths.
645e290 to
71b3737
Compare
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.
Summary
Enable the issue299_directc_nested_functions example in CI.
The test only verifies C compilation succeeds (verifying the original issue #299 fix). It does not import the generated Python module, so the types.py naming conflict with stdlib is not triggered.
Test plan
Stacked on #324