diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3c68ef7a..a3b5f842 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -70,7 +70,7 @@ jobs: castxml-epic: 1 cppstd: "-std=c++11" - - os: macos-12 + - os: macos-13 compiler: xcode version: "default" python-version: "3.8" @@ -96,7 +96,7 @@ jobs: run: | wget -q -O - https://data.kitware.com/api/v1/file/hashsum/sha512/bdbb67a10c5f8d1b738cd19cb074f409d4803e8077cb8c1072ef4eaf738fa871a73643f9c8282d58cae28d188df842c82ad6620b6d590b0396a0172a27438dce/download | tar zxf - -C ~/ - name: Setup castxml for Mac - if: matrix.os == 'macos-12' + if: matrix.os == 'macos-13' run: | wget -q -O - https://data.kitware.com/api/v1/file/hashsum/sha512/5d937e938f7b882a3a3e7941e68f8312d0898aaf2082e00003dd362b1ba70b98b0a08706a1be28e71652a6a0f1e66f89768b5eaa20e5a100592d5b3deefec3f0/download | tar zxf - -C ~/ - name: Run tests diff --git a/CHANGELOG.md b/CHANGELOG.md index ec5e3902..959b5290 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ Changes ======= +Version 2.6.1 +------------- + +1. Fix test_remove_template_defaults when tested on macos 13 + +2. Fix some test compilation with c++14/17 + Version 2.6.0 ------------- @@ -14,6 +21,8 @@ Version 2.6.0 5. Fix a bug in build_decl_string with elaborated type specifiers +6. Fix a bug where the declared widht of arrays args where lost (by using the original type xml tag) + Version 2.5.0 ------------- diff --git a/pyproject.toml b/pyproject.toml index 3dbe90f2..8abdfac0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ keywords = [ "CastXML", "gccxml", ] -version = "2.6.0" +version = "2.6.1" classifiers = [ "Development Status :: 5 - Production/Stable", diff --git a/src/pygccxml/declarations/container_traits.py b/src/pygccxml/declarations/container_traits.py index e5035782..0f8d1d61 100644 --- a/src/pygccxml/declarations/container_traits.py +++ b/src/pygccxml/declarations/container_traits.py @@ -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): @@ -29,20 +39,10 @@ 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. 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(): diff --git a/src/pygccxml/declarations/type_traits.py b/src/pygccxml/declarations/type_traits.py index bc9be8de..ba129259 100644 --- a/src/pygccxml/declarations/type_traits.py +++ b/src/pygccxml/declarations/type_traits.py @@ -480,25 +480,57 @@ def is_fundamental(type_): (cpptypes.volatile_t, cpptypes.const_t)) +def _normalize(string): + return string.replace(' ', '').replace("::std", "std") + + +def _normalize_equivalences(equivalences): + return [_normalize(eq) for eq in equivalences] + + string_equivalences = [ ( - '::std::basic_string,' - 'std::allocator>'), - '::std::basic_string', '::std::string'] + 'std::basic_string, ' + 'std::allocator>' + ), + 'std::basic_string', + 'std::string' + ] wstring_equivalences = [ ( - '::std::basic_string,' + - 'std::allocator>'), - '::std::basic_string', '::std::wstring'] + 'std::basic_string, ' + 'std::allocator>' + ), + 'std::basic_string', + 'std::wstring' + ] ostream_equivalences = [ - '::std::basic_ostream>', - '::std::basic_ostream', '::std::ostream'] + 'std::basic_ostream>', + 'std::basic_ostream', + 'std::ostream' + ] wostream_equivalences = [ - '::std::basic_ostream>', - '::std::basic_ostream', '::std::wostream'] + 'std::basic_ostream>', + 'std::basic_ostream', + 'std::wostream' + ] + + +normalized_string_equivalences = _normalize_equivalences( + string_equivalences + ) +normalized_wstring_equivalences = _normalize_equivalences( + wstring_equivalences + ) +normalized_ostream_equivalences = _normalize_equivalences( + ostream_equivalences + ) +normalized_wostream_equivalences = _normalize_equivalences( + wostream_equivalences + ) def is_std_string(type_): @@ -508,12 +540,12 @@ def is_std_string(type_): """ if isinstance(type_, str): - return type_ in string_equivalences + return _normalize(type_) in normalized_string_equivalences type_ = remove_alias(type_) type_ = remove_reference(type_) type_ = remove_cv(type_) - return type_.decl_string.replace(' ', '') in string_equivalences + return _normalize(type_.decl_string) in normalized_string_equivalences def is_std_wstring(type_): @@ -523,12 +555,12 @@ def is_std_wstring(type_): """ if isinstance(type_, str): - return type_ in wstring_equivalences + return _normalize(type_) in normalized_wstring_equivalences type_ = remove_alias(type_) type_ = remove_reference(type_) type_ = remove_cv(type_) - return type_.decl_string.replace(' ', '') in wstring_equivalences + return _normalize(type_.decl_string) in normalized_wstring_equivalences def is_std_ostream(type_): @@ -538,12 +570,12 @@ def is_std_ostream(type_): """ if isinstance(type_, str): - return type_ in ostream_equivalences + return _normalize(type_) in normalized_ostream_equivalences type_ = remove_alias(type_) type_ = remove_reference(type_) type_ = remove_cv(type_) - return type_.decl_string.replace(' ', '') in ostream_equivalences + return _normalize(type_.decl_string) in normalized_ostream_equivalences def is_std_wostream(type_): @@ -553,9 +585,9 @@ def is_std_wostream(type_): """ if isinstance(type_, str): - return type_ in wostream_equivalences + return _normalize(type_) in normalized_wostream_equivalences type_ = remove_alias(type_) type_ = remove_reference(type_) type_ = remove_cv(type_) - return type_.decl_string.replace(' ', '') in wostream_equivalences + return _normalize(type_.decl_string) in normalized_wostream_equivalences diff --git a/tests/data/core_types.hpp b/tests/data/core_types.hpp index 41dc655d..4038865e 100644 --- a/tests/data/core_types.hpp +++ b/tests/data/core_types.hpp @@ -48,13 +48,11 @@ typedef EFavoriteDrinks typedef_EFavoriteDrinks; typedef int (*function_ptr)(int, double); -struct exception{}; - struct members_pointers_t{ int some_function( double hi, int i ){ return 0; } - int some_function( double hi) const throw( exception ){ + int some_function( double hi) const { return 0; }; int m_some_const_member; diff --git a/tests/test_remove_template_defaults.py b/tests/test_remove_template_defaults.py index b1706c4c..5f5024a4 100644 --- a/tests/test_remove_template_defaults.py +++ b/tests/test_remove_template_defaults.py @@ -3,6 +3,8 @@ # Distributed under the Boost Software License, Version 1.0. # See http://www.boost.org/LICENSE_1_0.txt +import platform + import pytest from . import autoconfig @@ -20,7 +22,12 @@ def global_ns(): COMPILATION_MODE = parser.COMPILATION_MODE.ALL_AT_ONCE config = autoconfig.cxx_parsers_cfg.config.clone() - config.cflags = "-std=c++11" + if platform.system() == "Darwin": + config.cflags = "-std=c++11 -Dat_quick_exit=atexit -Dquick_exit=exit" + # https://fr.mathworks.com/matlabcentral/answers/2013982-clibgen-generatelibrarydefinition-error-the-global-scope-has-no-quick_exit-on-mac-m2#answer_1439856 + # https://github.com/jetbrains/kotlin/commit/d50f585911dedec5723213da8835707ac95e1c01 + else: + config.cflags = "-std=c++11" decls = parser.parse(TEST_FILES, config, COMPILATION_MODE) global_ns = declarations.get_global_namespace(decls) global_ns.init_optimizer() diff --git a/tests/test_source_reader.py b/tests/test_source_reader.py index 355e225e..20e403a6 100644 --- a/tests/test_source_reader.py +++ b/tests/test_source_reader.py @@ -3,6 +3,8 @@ # Distributed under the Boost Software License, Version 1.0. # See http://www.boost.org/LICENSE_1_0.txt +import platform + import pytest from . import autoconfig @@ -19,6 +21,10 @@ def global_ns(): COMPILATION_MODE = parser.COMPILATION_MODE.ALL_AT_ONCE config = autoconfig.cxx_parsers_cfg.config.clone() + if platform.system() == "Darwin": + config.cflags = "-Dat_quick_exit=atexit -Dquick_exit=exit" + # https://fr.mathworks.com/matlabcentral/answers/2013982-clibgen-generatelibrarydefinition-error-the-global-scope-has-no-quick_exit-on-mac-m2#answer_1439856 + # https://github.com/jetbrains/kotlin/commit/d50f585911dedec5723213da8835707ac95e1c01 decls = parser.parse(TEST_FILES, config, COMPILATION_MODE) global_ns = declarations.get_global_namespace(decls) global_ns.init_optimizer()