Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Modules/ThirdParty/pygccxml/src/UpdatepygccxmlFromUpstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ fi

# Update the git tag for the version you are merging
git_url="https://github.com/CastXML/pygccxml"
git_tag="v2.4.0"
upstream_sha="ce011e1bc57248d205cfda60dd51b3182acbe106"
git_tag="v3.0.2"
upstream_sha="62f600c98ec6a25fd3d264774c6fc811ec3c46e4"

#
# Once the merge has been done
# EDIT THIS SCRIPT to change the hash tag at which to begin the
# next update...
#
# This merge was done on: April 9th, 2024
git branch pygccxml-upstream b39a0bbb81bf02fc6541131b331f36254b3971d4
# This merge was done with respect to pygccxml v3.0.2 as of : March 16th, 2025
git branch pygccxml-upstream de4804643f66c89d38725a3ae1742071cd354efc

#
# Make a temp directory to handle the import of the upstream source
Expand Down Expand Up @@ -81,8 +81,8 @@ cd ..
rm -fr pygccxml-Tmp

#
# checkout a new update branch off master
git checkout -b pygccxml-update master
# checkout a new update branch off main
git checkout -b pygccxml-update main
#
# use subtree merge to bring in upstream changes
git merge -s recursive -X subtree=Modules/ThirdParty/pygccxml/src/pygccxml pygccxml-upstream
Expand Down
2 changes: 1 addition & 1 deletion Modules/ThirdParty/pygccxml/src/pygccxml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@
from importlib import metadata

# Begin ITK edit
__version__ = "2.4.0"
__version__ = "3.0.2"
# __version__ = metadata.version("pygccxml")
16 changes: 14 additions & 2 deletions Modules/ThirdParty/pygccxml/src/pygccxml/declarations/calldef.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,24 @@ def does_throw(self, does_throw):

@property
def exceptions(self):
"""The list of exceptions.
@type: list of :class:`declaration_t`"""
"""
The list of exceptions.

Useless with c++17 and above as dynamich exceptions
are not allowed anymore:
https://developers.redhat.com/articles/2021/08/06/porting-your-code-c17-gcc-11#exception_specification_changes # noqa

@type: list of :class:`declaration_t`
"""
return self._exceptions

@exceptions.setter
def exceptions(self, exceptions):
"""
Useless with c++17 and above as dynamich exceptions
are not allowed anymore:
https://developers.redhat.com/articles/2021/08/06/porting-your-code-c17-gcc-11#exception_specification_changes # noqa
"""
self._exceptions = exceptions

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@

std_namespaces = ('std', 'stdext', '__gnu_cxx')

# Take into account different equivalences (with or without spaces)
string_equivalences = type_traits.string_equivalences + \
type_traits.normalized_string_equivalences
string_equivalences = [
v for v in string_equivalences if not v == "std::string"]
wstring_equivalences = type_traits.wstring_equivalences + \
type_traits.normalized_wstring_equivalences
wstring_equivalences = [
v for v in wstring_equivalences if not v == "std::wstring"]


class defaults_eraser(object):

Expand All @@ -28,27 +38,17 @@ def __init__(self, unordered_maps_and_sets):
def normalize(self, type_str):
return type_str.replace(' ', '')

def replace_basic_string(self, cls_name):

# Take the lists of all possible string variations
# and clean them up by replacing ::std by std.
str_eq = [
v.replace("::std", "std") for v in
type_traits.string_equivalences]
wstr_eq = [
v.replace("::std", "std") for v in
type_traits.wstring_equivalences]

# Replace all the variations of strings by the smallest one.
@staticmethod
def replace_basic_string(cls_name):
strings = {
"std::string": [v for v in str_eq if not v == "std::string"],
"std::wstring": [v for v in wstr_eq if not v == "std::wstring"]}
"std::string": string_equivalences,
"std::wstring": wstring_equivalences
}

new_name = cls_name
for short_name, long_names in strings.items():
for lname in long_names:
new_name = new_name.replace(lname, short_name)

return new_name

def decorated_call_prefix(self, cls_name, text, doit):
Expand Down Expand Up @@ -99,13 +99,12 @@ def erase_recursive(self, cls_name):
return self.no_end_const(cls_name)

def erase_allocator(self, cls_name, default_allocator='std::allocator'):
cls_name = self.replace_basic_string(cls_name)
c_name, c_args = templates.split(cls_name)
if len(c_args) != 2:
return
value_type = c_args[0]
tmpl = string.Template(
"$container< $value_type, $allocator<$value_type> >")
"$container<$value_type, $allocator<$value_type>>")
tmpl = tmpl.substitute(
container=c_name,
value_type=value_type,
Expand All @@ -116,24 +115,21 @@ def erase_allocator(self, cls_name, default_allocator='std::allocator'):
c_name, [self.erase_recursive(value_type)])

def erase_container(self, cls_name, default_container_name='std::deque'):
cls_name = self.replace_basic_string(cls_name)
c_name, c_args = templates.split(cls_name)
if len(c_args) != 2:
return
value_type = c_args[0]
dc_no_defaults = self.erase_recursive(c_args[1])
if self.normalize(dc_no_defaults) != self.normalize(
if self.normalize(dc_no_defaults) == self.normalize(
templates.join(default_container_name, [value_type])):
return
return templates.join(
c_name, [self.erase_recursive(value_type)])
return templates.join(
c_name, [self.erase_recursive(value_type)])

def erase_container_compare(
self,
cls_name,
default_container_name='std::vector',
default_compare='std::less'):
cls_name = self.replace_basic_string(cls_name)
c_name, c_args = templates.split(cls_name)
if len(c_args) != 3:
return
Expand All @@ -153,14 +149,13 @@ def erase_compare_allocator(
cls_name,
default_compare='std::less',
default_allocator='std::allocator'):
cls_name = self.replace_basic_string(cls_name)
c_name, c_args = templates.split(cls_name)
if len(c_args) != 3:
return
value_type = c_args[0]
tmpl = string.Template(
"$container< $value_type, $compare<$value_type>, " +
"$allocator<$value_type> >")
"$container<$value_type, $compare<$value_type>, " +
"$allocator<$value_type>>")
tmpl = tmpl.substitute(
container=c_name,
value_type=value_type,
Expand All @@ -176,22 +171,21 @@ def erase_map_compare_allocator(
cls_name,
default_compare='std::less',
default_allocator='std::allocator'):
cls_name = self.replace_basic_string(cls_name)
c_name, c_args = templates.split(cls_name)
if len(c_args) != 4:
return
key_type = c_args[0]
mapped_type = c_args[1]
tmpls = [
string.Template(
"$container< $key_type, $mapped_type, $compare<$key_type>, " +
"$allocator< std::pair< const $key_type, $mapped_type> > >"),
"$container<$key_type, $mapped_type, $compare<$key_type>, " +
"$allocator<std::pair<const $key_type, $mapped_type>>>"),
string.Template(
"$container< $key_type, $mapped_type, $compare<$key_type>, " +
"$allocator< std::pair< $key_type const, $mapped_type> > >"),
"$container<$key_type, $mapped_type, $compare<$key_type>, " +
"$allocator<std::pair< $key_type const, $mapped_type>>>"),
string.Template(
"$container< $key_type, $mapped_type, $compare<$key_type>, " +
"$allocator< std::pair< $key_type, $mapped_type> > >")]
"$container<$key_type, $mapped_type, $compare<$key_type>, " +
"$allocator<std::pair<$key_type, $mapped_type>>>")]
for tmpl in tmpls:
tmpl = tmpl.substitute(
container=c_name,
Expand All @@ -206,7 +200,6 @@ def erase_map_compare_allocator(
self.erase_recursive(mapped_type)])

def erase_hash_allocator(self, cls_name):
cls_name = self.replace_basic_string(cls_name)
c_name, c_args = templates.split(cls_name)
if len(c_args) < 3:
return
Expand All @@ -218,13 +211,13 @@ def erase_hash_allocator(self, cls_name):
if len(c_args) == 3:
default_hash = 'hash_compare'
tmpl = (
"$container< $value_type, $hash<$value_type, " +
"$less<$value_type> >, $allocator<$value_type> >")
"$container<$value_type, $hash<$value_type, " +
"$less<$value_type>>, $allocator<$value_type>>")
elif len(c_args) == 4:
default_hash = 'hash'
tmpl = (
"$container< $value_type, $hash<$value_type >, " +
"$equal_to<$value_type >, $allocator<$value_type> >")
"$container<$value_type, $hash<$value_type>, " +
"$equal_to<$value_type>, $allocator<$value_type>>")
else:
return

Expand All @@ -244,7 +237,6 @@ def erase_hash_allocator(self, cls_name):
c_name, [self.erase_recursive(value_type)])

def erase_hashmap_compare_allocator(self, cls_name):
cls_name = self.replace_basic_string(cls_name)
c_name, c_args = templates.split(cls_name)

if self.unordered_maps_and_sets:
Expand All @@ -263,14 +255,14 @@ def erase_hashmap_compare_allocator(self, cls_name):
if len(c_args) == 4:
default_hash = 'hash_compare'
tmpl = string.Template(
"$container< $key_type, $mapped_type, " +
"$hash<$key_type, $less<$key_type> >, " +
"$allocator< std::pair< const $key_type, $mapped_type> > >")
"$container<$key_type, $mapped_type, " +
"$hash<$key_type, $less<$key_type>>, " +
"$allocator<std::pair<const $key_type, $mapped_type>>>")
if key_type.startswith('const ') or key_type.endswith(' const'):
tmpl = string.Template(
"$container< $key_type, $mapped_type, $hash<$key_type, " +
"$less<$key_type> >, $allocator< std::pair< $key_type, " +
"$mapped_type> > >")
"$container<$key_type, $mapped_type, $hash<$key_type, " +
"$less<$key_type>>, $allocator<std::pair<$key_type, " +
"$mapped_type>>>")
elif len(c_args) == 5:
default_hash = 'hash'
if self.unordered_maps_and_sets:
Expand All @@ -279,31 +271,31 @@ def erase_hashmap_compare_allocator(self, cls_name):
"$hash<$key_type>, " +
"$equal_to<$key_type>, " +
"$allocator<std::pair<const$key_type, " +
"$mapped_type> > >")
"$mapped_type>>>")
if key_type.startswith('const ') or \
key_type.endswith(' const'):
tmpl = string.Template(
"$container<$key_type, $mapped_type, " +
"$hash<$key_type >, " +
"$equal_to<$key_type >, " +
"$hash<$key_type>, " +
"$equal_to<$key_type>, " +
"$allocator<std::pair<$key_type, " +
"$mapped_type> > >")
"$mapped_type>>>")
else:
tmpl = string.Template(
"$container< $key_type, $mapped_type, "
"$container<$key_type, $mapped_type, "
"$hash<$key_type >, " +
"$equal_to<$key_type>, "
"$allocator< $mapped_type> >")
"$allocator<$mapped_type>>")
if key_type.startswith('const ') or \
key_type.endswith(' const'):
# TODO: this template is the same than above.
# Make sure why this was needed and if this is
# tested. There may be a const missing somewhere.
tmpl = string.Template(
"$container< $key_type, $mapped_type, " +
"$hash<$key_type >, " +
"$container<$key_type, $mapped_type, " +
"$hash<$key_type>, " +
"$equal_to<$key_type>, " +
"$allocator< $mapped_type > >")
"$allocator<$mapped_type>>")
else:
return

Expand Down Expand Up @@ -524,6 +516,7 @@ def remove_defaults(self, type_or_string):
name = type_or_string
if not isinstance(type_or_string, str):
name = self.class_declaration(type_or_string).name
name = defaults_eraser.replace_basic_string(name)
if not self.remove_defaults_impl:
return name
no_defaults = self.remove_defaults_impl(name)
Expand Down Expand Up @@ -647,14 +640,14 @@ def remove_defaults(self, type_or_string):

unordered_set_traits = container_traits_impl_t(
'unordered_set',
1,
0,
'value_type',
'erase_hash_allocator',
unordered_maps_and_sets=True)

unordered_multiset_traits = container_traits_impl_t(
'unordered_multiset',
1,
0,
'value_type',
'erase_hash_allocator',
unordered_maps_and_sets=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from . import algorithms_cache
from . import byte_info
from . import elaborated_info


class type_t(byte_info.byte_info):
Expand Down Expand Up @@ -593,10 +594,10 @@ def __init__(self, base):
compound_t.__init__(self, base)

def build_decl_string(self, with_defaults=True):
if hasattr(self.base.declaration, "elaborated_type_specifier"):
prefix = ""
if isinstance(self.base, type(declarated_t)) and \
isinstance(self.base.declaration, type(elaborated_info)):
prefix = self.base.declaration.elaborated_type_specifier + " "
else:
prefix = ""
return prefix + self.base.build_decl_string(with_defaults)

def _clone_impl(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ def join(self, name, args, arg_separator=None):
args = [_f for _f in args if _f]

if not args:
args_str = ' '
args_str = ''
elif len(args) == 1:
args_str = ' ' + args[0] + ' '
args_str = args[0]
else:
args_str = ' ' + arg_separator.join(args) + ' '
args_str = arg_separator.join(args)

return ''.join([name, self.__begin, args_str, self.__end])

Expand Down
Loading
Loading