Pygccxml update, use --castxml-output=1 modern xml format from castxml#5695
Merged
hjmjohnson merged 14 commits intoInsightSoftwareConsortium:mainfrom Jan 29, 2026
Merged
Conversation
dzenanz
reviewed
Dec 17, 2025
Member
dzenanz
left a comment
There was a problem hiding this comment.
Update looks good on a glance, but there are CI failures.
Member
Author
I think we need an updated version of CastXML to complement this. |
Member
Author
|
Related to
See #5540 (comment) for an explanation of the failure. |
a08445c to
092e3df
Compare
dzenanz
approved these changes
Jan 28, 2026
Member
Author
|
NOTE: # for constructors like
# vnl_matrix(unsigned r, unsigned c, unsigned n, const T values[]);
# ====
# pygccxml v2.4.0 and `castxml --castxml-gccxml `
# wrote the following to the vnl_matrix.i file
# vnl_matrixD(unsigned int r, unsigned int c, unsigned int n,
# double const * values);
# ====
# pygccxml v3.0.4 and `castxml --castxml-output=1`
# wrote the following to the vnl_matrix.i file
# vnl_matrixD(unsigned int r, unsigned int c, unsigned int n,
# double const [0] values);
# ^^^ <- Invalid for swig wrapping
#
# In function parameter lists, C and C++ apply array-to-pointer adjustment:
#
# Any parameter of type T[] or T[N] is adjusted to T*. |
This corresponds to commit hash 62f600c98ec6a25fd3d264774c6fc811ec3c46e4 from upstream repository https://github.com/CastXML/pygccxml
Remove reliance on the "--castxml-gccxml" that does not support newer compilers. For example: LLVM PR 114788 switched libc++'s <cstddef> to use decltype() to define size_t. Any build using libc++ 21 or later will have this problem, not just those that get it via the macOS SDK.
pygccxml does not support rvalue types (i.e. move constructors
with &&).
Previously move-constructors became duplicate no-argument
constructors declarations in .i files
```c++
class test
{
public:
test() {};
test(test &&) {};
}
```
```c++
test();
test(); # <-- Generated because the invalid first argument is dropped
# due to ?unknown? result from pygccxml when
# castxml xml file has RValueReferenceType argument
```
This includes variable name refactoring and return path simplification to remove syntactic noise It is part of the support needed to move castxml from "--castxml-gccxml" to "--castxml-output=1" to support newer compilers.
New versions of castxml and pygccxml > 3 have explicit support for presenting arguments as array, but swig only supports pointers. ```c++ \# below are functionally equivalent void func(int a [],size_t n); # <- new pygccxml and castxml void func(int * a, size_t n); # <- only supported format for swig ```
New versions of castxml with --castxml-output=1 and new version of pygccxml have syntax formatting differences that were not captured in the previous simple string replacments. ```diff - std::basic_string< char > # --castxml-gccxml ; pygccxml < 3 + std::basic_string<char> # --castxml-output=1 ; pygccxml > 3 ``` The re.sub mechansism works with both variants.
Update `igenerator.py` to use raw strings for regex patterns, enhancing readability and consistency. Allow for spaces before or after optional white space (mostly in template<> parameters) to support both old and new castxml format results.
Ensure proper module import order and improve compliance with linting standards. Silence PEP 8 Warning: E402 module level import not at top of file
Consolidate redundant code as a helper function
Add method to reduce redundancy in kwargs processing
ruff: fix F541
092e3df to
d329665
Compare
dzenanz
approved these changes
Jan 28, 2026
Member
dzenanz
left a comment
There was a problem hiding this comment.
Thank you for pushing this forward.
thewtex
approved these changes
Jan 29, 2026
Member
thewtex
left a comment
There was a problem hiding this comment.
Tremendous!!!~ 🥇 Thank you, Hans!
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.
First step towards resolving issues related to wrapping on newer compilers.
#5540 (comment)
Related to issues identified in: #5636
PR Checklist