Skip to content

Commit e178aeb

Browse files
committed
Merge branch 'develop'
2 parents b67b261 + 5f6f235 commit e178aeb

File tree

266 files changed

+6354
-8244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

266 files changed

+6354
-8244
lines changed

.github/workflows/tests.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
on: [push, pull_request]
1+
on:
2+
push:
3+
branches:
4+
- main
5+
- develop
6+
pull_request:
7+
28
jobs:
39
tests:
410
name: ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.version }}-python-${{ matrix.python-version }}-${{ matrix.castxml-epic }}
@@ -93,12 +99,7 @@ jobs:
9399
if: matrix.os == 'macos-12'
94100
run: |
95101
wget -q -O - https://data.kitware.com/api/v1/file/hashsum/sha512/5d937e938f7b882a3a3e7941e68f8312d0898aaf2082e00003dd362b1ba70b98b0a08706a1be28e71652a6a0f1e66f89768b5eaa20e5a100592d5b3deefec3f0/download | tar zxf - -C ~/
96-
- name: Setup castxml config
97-
if: matrix.compiler == 'gcc' && matrix.version == '9'
98-
run: mv unittests/configs/gcc9.cfg unittests/xml_generator.cfg;
99102
- name: Run tests
100103
run: |
101104
export PATH=~/castxml/bin:$PATH
102-
coverage run -m unittests.test_all
103-
coverage combine
104-
coverage xml
105+
pytest tests

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
*.pyo
33
*~
44
docs/_build
5+
tests/temp
6+
tests/data/pygccxml.cache
7+
tests/data/directory_cache_test
8+
tests/data/ogre.1.7.xml
59
unittests/temp
610
unittests/data/pygccxml.cache
711
unittests/data/directory_cache_test

CHANGELOG.md

Lines changed: 13 additions & 0 deletions

docs/install.rst

Lines changed: 4 additions & 4 deletions

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ keywords = [
1818
"CastXML",
1919
"gccxml",
2020
]
21-
version = "2.5.0"
21+
version = "2.6.0"
2222

2323
classifiers = [
2424
"Development Status :: 5 - Production/Stable",
@@ -55,6 +55,7 @@ test = [
5555
"coverage",
5656
"coveralls",
5757
"pycodestyle",
58+
"pytest",
5859
]
5960
docs = [
6061
"sphinx",

src/pygccxml/declarations/container_traits.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,14 +647,14 @@ def remove_defaults(self, type_or_string):
647647

648648
unordered_set_traits = container_traits_impl_t(
649649
'unordered_set',
650-
1,
650+
0,
651651
'value_type',
652652
'erase_hash_allocator',
653653
unordered_maps_and_sets=True)
654654

655655
unordered_multiset_traits = container_traits_impl_t(
656656
'unordered_multiset',
657-
1,
657+
0,
658658
'value_type',
659659
'erase_hash_allocator',
660660
unordered_maps_and_sets=True)

src/pygccxml/declarations/cpptypes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from . import algorithms_cache
1111
from . import byte_info
12+
from . import elaborated_info
1213

1314

1415
class type_t(byte_info.byte_info):
@@ -593,10 +594,10 @@ def __init__(self, base):
593594
compound_t.__init__(self, base)
594595

595596
def build_decl_string(self, with_defaults=True):
596-
if hasattr(self.base.declaration, "elaborated_type_specifier"):
597+
prefix = ""
598+
if isinstance(self.base, type(declarated_t)) and \
599+
isinstance(self.base.declaration, type(elaborated_info)):
597600
prefix = self.base.declaration.elaborated_type_specifier + " "
598-
else:
599-
prefix = ""
600601
return prefix + self.base.build_decl_string(with_defaults)
601602

602603
def _clone_impl(self):

src/pygccxml/parser/config.py

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import os
1212
import copy
1313
import platform
14+
import shutil
1415
import subprocess
1516
import warnings
1617
# In py3, ConfigParser was renamed to the more-standard configparser.
@@ -129,16 +130,12 @@ def compiler(self, compiler):
129130

130131
@property
131132
def xml_generator(self):
132-
"""get xml_generator (gccxml or castxml)"""
133+
"""get xml_generator"""
133134
return self.__xml_generator
134135

135136
@xml_generator.setter
136137
def xml_generator(self, xml_generator):
137-
"""set xml_generator (gccxml or castxml)"""
138-
if "real" in xml_generator:
139-
# Support for gccxml.real from newer gccxml package
140-
# Can be removed once gccxml support is dropped.
141-
xml_generator = "gccxml"
138+
"""set xml_generator"""
142139
self.__xml_generator = xml_generator
143140

144141
@property
@@ -241,9 +238,8 @@ def raise_on_wrong_settings(self):
241238
self.__ensure_dir_exists(self.working_directory, 'working directory')
242239
for idir in self.include_paths:
243240
self.__ensure_dir_exists(idir, 'include directory')
244-
if self.__xml_generator not in ["castxml", "gccxml"]:
245-
msg = ('xml_generator("%s") should either be ' +
246-
'"castxml" or "gccxml".') % self.xml_generator
241+
if self.__xml_generator != "castxml":
242+
msg = f"xml_generator ({self.xml_generator}) can only be 'castxml'"
247243
raise RuntimeError(msg)
248244

249245

@@ -456,35 +452,20 @@ def create_compiler_path(xml_generator, compiler_path):
456452
if xml_generator == 'castxml' and compiler_path is None:
457453
if platform.system() == 'Windows':
458454
# Look for msvc
459-
compiler_path = __get_first_compiler_in_path('where', 'cl')
455+
compiler_path = shutil.which('cl')
460456
# No msvc found; look for mingw
461-
if compiler_path == '':
462-
compiler_path = __get_first_compiler_in_path('where', 'mingw')
457+
if compiler_path is None:
458+
compiler_path = shutil.which('mingw')
463459
else:
464460
# OS X or Linux
465461
# Look for clang first, then gcc
466-
compiler_path = __get_first_compiler_in_path('which', 'clang++')
462+
compiler_path = shutil.which('clang++')
467463
# No clang found; use gcc
468-
if compiler_path == '':
469-
compiler_path = __get_first_compiler_in_path('which', 'c++')
470-
471-
if compiler_path == "":
472-
compiler_path = None
464+
if compiler_path is None:
465+
compiler_path = shutil.which('c++')
473466

474467
return compiler_path
475468

476469

477-
def __get_first_compiler_in_path(command, compiler_name):
478-
p = subprocess.Popen(
479-
[command, compiler_name],
480-
stdout=subprocess.PIPE,
481-
stderr=subprocess.PIPE)
482-
path = p.stdout.read().decode("utf-8").rstrip().split("\r\n")[0].rstrip()
483-
p.wait()
484-
p.stdout.close()
485-
p.stderr.close()
486-
return path
487-
488-
489470
if __name__ == '__main__':
490471
print(load_xml_generator_configuration('xml_generator.cfg').__dict__)

src/pygccxml/parser/scanner.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
XML_AN_STATIC = "static"
5757
XML_AN_THROW = "throw"
5858
XML_AN_TYPE = "type"
59+
XML_AN_ORIGINAL_TYPE = "original_type"
5960
XML_AN_VIRTUAL = "virtual"
6061
XML_AN_VOLATILE = "volatile"
6162
XML_NN_ARGUMENT = "Argument"
@@ -558,7 +559,10 @@ def __read_argument(self, attrs):
558559
XML_AN_NAME,
559560
'arg%d' % len(
560561
self.__inst.arguments))
561-
argument.decl_type = attrs[XML_AN_TYPE]
562+
argument.decl_type = attrs.get(
563+
XML_AN_ORIGINAL_TYPE,
564+
attrs.get(XML_AN_TYPE)
565+
)
562566
argument.default_value = attrs.get(XML_AN_DEFAULT)
563567
self.__read_attributes(argument, attrs)
564568
self.__inst.arguments.append(argument)
@@ -576,8 +580,8 @@ def __read_calldef(self, calldef, attrs, is_declaration):
576580
if is_declaration:
577581
self.__calldefs.append(calldef)
578582
calldef.name = attrs.get(XML_AN_NAME, '')
579-
calldef.has_extern = attrs.get(XML_AN_EXTERN, False)
580-
calldef.has_inline = bool(attrs.get(XML_AN_INLINE, "") == "1")
583+
calldef.has_extern = bool(attrs.get(XML_AN_EXTERN, False))
584+
calldef.has_inline = bool(attrs.get(XML_AN_INLINE, False))
581585
throw_stmt = attrs.get(XML_AN_THROW)
582586
if None is throw_stmt:
583587
calldef.does_throw = True
@@ -593,9 +597,9 @@ def __read_calldef(self, calldef, attrs, is_declaration):
593597

594598
def __read_member_function(self, calldef, attrs, is_declaration):
595599
self.__read_calldef(calldef, attrs, is_declaration)
596-
calldef.has_const = attrs.get(XML_AN_CONST, False)
600+
calldef.has_const = bool(attrs.get(XML_AN_CONST, False))
597601
if is_declaration:
598-
calldef.has_static = attrs.get(XML_AN_STATIC, False)
602+
calldef.has_static = bool(attrs.get(XML_AN_STATIC, False))
599603
if XML_AN_PURE_VIRTUAL in attrs:
600604
calldef.virtuality = declarations.VIRTUALITY_TYPES.PURE_VIRTUAL
601605
elif XML_AN_VIRTUAL in attrs:
@@ -626,9 +630,9 @@ def __read_typedef(self, attrs):
626630

627631
def __read_variable(self, attrs):
628632
type_qualifiers = declarations.type_qualifiers_t()
629-
type_qualifiers.has_mutable = attrs.get(XML_AN_MUTABLE, False)
630-
type_qualifiers.has_static = attrs.get(XML_AN_STATIC, False)
631-
type_qualifiers.has_extern = attrs.get(XML_AN_EXTERN, False)
633+
type_qualifiers.has_mutable = bool(attrs.get(XML_AN_MUTABLE, False))
634+
type_qualifiers.has_static = bool(attrs.get(XML_AN_STATIC, False))
635+
type_qualifiers.has_extern = bool(attrs.get(XML_AN_EXTERN, False))
632636
bits = attrs.get(XML_AN_BITS)
633637
if bits:
634638
bits = int(bits)

src/pygccxml/utils/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
99
"""
1010

11-
from .utils import is_str
1211
from .utils import get_architecture
1312
from .utils import loggers
1413
from .utils import create_temp_file_name

0 commit comments

Comments
 (0)