Skip to content

Commit

Permalink
Merge pull request #177 from CastXML/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
iMichka authored Apr 14, 2024
2 parents ce011e1 + 6d4544c commit b67b261
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 250 deletions.
13 changes: 2 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
castxml-epic: 1
cppstd: "-std=c++11"

- os: macos-latest
- os: macos-12
compiler: xcode
version: "default"
python-version: "3.8"
Expand All @@ -90,7 +90,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-latest'
if: matrix.os == 'macos-12'
run: |
wget -q -O - https://data.kitware.com/api/v1/file/hashsum/sha512/5d937e938f7b882a3a3e7941e68f8312d0898aaf2082e00003dd362b1ba70b98b0a08706a1be28e71652a6a0f1e66f89768b5eaa20e5a100592d5b3deefec3f0/download | tar zxf - -C ~/
- name: Setup castxml config
Expand All @@ -102,12 +102,3 @@ jobs:
coverage run -m unittests.test_all
coverage combine
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage.xml
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: true
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changes
=======

Version 2.5.0
-------------

1. Add support for new cxx versions in cxx_standard class

2. Deprecate utils.is_str

3. pyproject.toml improvements


Version 2.4.0
-------------

Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[build-system]
requires = ["setuptools", "wheel"]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "pygccxml"
Expand All @@ -17,7 +18,7 @@ keywords = [
"CastXML",
"gccxml",
]
version = "2.4.0"
version = "2.5.0"

classifiers = [
"Development Status :: 5 - Production/Stable",
Expand Down
4 changes: 2 additions & 2 deletions src/pygccxml/declarations/container_traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def remove_defaults(self, type_or_string):
"""

name = type_or_string
if not utils.is_str(type_or_string):
if not isinstance(type_or_string, str):
name = self.class_declaration(type_or_string).name
if not self.remove_defaults_impl:
return name
Expand Down Expand Up @@ -705,7 +705,7 @@ def find_container_traits(cls_or_string):
declarations.container_traits: a container traits
"""

if utils.is_str(cls_or_string):
if isinstance(cls_or_string, str):
if not templates.is_instantiation(cls_or_string):
return None
name = templates.name(cls_or_string)
Expand Down
8 changes: 4 additions & 4 deletions src/pygccxml/declarations/type_traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def is_std_string(type_):
"""

if utils.is_str(type_):
if isinstance(type_, str):
return type_ in string_equivalences

type_ = remove_alias(type_)
Expand All @@ -522,7 +522,7 @@ def is_std_wstring(type_):
"""

if utils.is_str(type_):
if isinstance(type_, str):
return type_ in wstring_equivalences

type_ = remove_alias(type_)
Expand All @@ -537,7 +537,7 @@ def is_std_ostream(type_):
"""

if utils.is_str(type_):
if isinstance(type_, str):
return type_ in ostream_equivalences

type_ = remove_alias(type_)
Expand All @@ -552,7 +552,7 @@ def is_std_wostream(type_):
"""

if utils.is_str(type_):
if isinstance(type_, str):
return type_ in wostream_equivalences

type_ = remove_alias(type_)
Expand Down
3 changes: 1 addition & 2 deletions src/pygccxml/parser/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from ConfigParser import SafeConfigParser as ConfigParser
except ImportError:
from configparser import ConfigParser
from .. import utils


class parser_configuration_t(object):
Expand Down Expand Up @@ -383,7 +382,7 @@ def load_xml_generator_configuration(configuration, **defaults):
"""
parser = configuration
if utils.is_str(configuration):
if isinstance(configuration, str):
parser = ConfigParser()
parser.read(configuration)

Expand Down
3 changes: 1 addition & 2 deletions src/pygccxml/parser/linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# See http://www.boost.org/LICENSE_1_0.txt

from pygccxml import declarations
from .. import utils


class linker_t(
Expand Down Expand Up @@ -304,7 +303,7 @@ def visit_member_variable_type(self):
self.__link_compound_type()

def visit_declarated(self):
if utils.is_str(self.__inst.declaration):
if isinstance(self.__inst.declaration, str):
self.__inst.declaration = self.__decls[self.__inst.declaration]

def visit_restrict(self):
Expand Down
4 changes: 2 additions & 2 deletions src/pygccxml/parser/project_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def __init__(self, config, cache=None, decl_factory=None):
self.__dcache = None
if isinstance(cache, declarations_cache.cache_base_t):
self.__dcache = cache
elif utils.is_str(cache):
elif isinstance(cache, str):
self.__dcache = declarations_cache.file_cache_t(cache)
else:
self.__dcache = declarations_cache.dummy_cache_t()
Expand Down Expand Up @@ -221,7 +221,7 @@ def get_os_file_names(files):

fnames = []
for f in files:
if utils.is_str(f):
if isinstance(f, str):
fnames.append(f)
elif isinstance(f, file_configuration_t):
if f.content_type in (
Expand Down
2 changes: 1 addition & 1 deletion src/pygccxml/parser/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def startElement(self, name, attrs):
self.__update_membership(attrs)
self.__read_attributes(obj, attrs)

elif utils.is_str(obj):
elif isinstance(obj, str):

self.__files[element_id] = os.path.normpath(obj)

Expand Down
38 changes: 12 additions & 26 deletions src/pygccxml/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def is_str(string):
bool: True or False
"""
warnings.warn(
"The is_str function is deprecated. \
Use isinstance(string, str) instead.",
DeprecationWarning)

if sys.version_info[:2] >= (3, 0):
return isinstance(string, str)

Expand All @@ -50,35 +55,12 @@ def find_xml_generator(name="castxml", search_path=None):
"""

if sys.version_info[:2] >= (3, 3):
path = _find_xml_generator_for_python_greater_equals_33(
name, search_path=search_path)
else:
path = _find_xml_generator_for_legacy_python(name)

path = shutil.which(name, path=search_path)
if path == "" or path is None:
raise Exception("No c++ parser found. Please install castxml.")
return path.rstrip(), name


def _find_xml_generator_for_python_greater_equals_33(name, search_path=None):
return shutil.which(name, path=search_path)


def _find_xml_generator_for_legacy_python(name):
if platform.system() == "Windows":
command = "where"
else:
command = "which"
p = subprocess.Popen([command, name], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
path = p.stdout.read().decode("utf-8")
p.wait()
p.stdout.close()
p.stderr.close()
return path.rstrip()


def _create_logger_(name):
"""Implementation detail, creates a logger."""
logger = logging.getLogger(name)
Expand Down Expand Up @@ -295,8 +277,12 @@ class cxx_standard(object):
'-std=c++17': 201703,
'-std=gnu++1z': 201703,
'-std=gnu++17': 201703,
'-std=c++2a': float('inf'),
'-std=gnu++2a': float('inf'),
'-std=c++2a': 202002,
'-std=gnu++2a': 202002,
'-std=c++20': 202002,
'-std=gnu++20': 202002,
'-std=c++23': float('inf'),
'-std=gnu++23': float('inf'),
}

def __init__(self, cflags):
Expand Down
3 changes: 1 addition & 2 deletions unittests/find_container_traits_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from pygccxml import parser
from pygccxml import declarations
from pygccxml import utils


class Test(parser_test_case.parser_test_case_t):
Expand All @@ -30,7 +29,7 @@ def setUp(self):
self.global_ns = Test.global_ns

def __cmp_traits(self, typedef, expected, partial_name, key_type=None):
if utils.is_str(typedef):
if isinstance(typedef, str):
typedef = self.global_ns.typedef(typedef)
traits = declarations.find_container_traits(typedef)
self.assertTrue(
Expand Down
21 changes: 0 additions & 21 deletions unittests/misc/profile_parser.py

This file was deleted.

Loading

0 comments on commit b67b261

Please sign in to comment.