Skip to content

Commit cd1c87f

Browse files
committed
Merge branch 'hotfix/v1.7.3'
2 parents a7d0a2a + b7b5121 commit cd1c87f

30 files changed

+750
-105
lines changed

.travis.yml

Lines changed: 87 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,109 @@
11
language:
22
- python
33

4-
python:
5-
- "2.6"
6-
- "2.7"
7-
- "3.2"
8-
- "3.3"
9-
- "3.4"
10-
- "3.5"
4+
matrix:
5+
include:
6+
- os: linux
7+
python: 2.6
8+
env: XML_GENERATOR="gccxml"
9+
- os: linux
10+
python: 2.7
11+
env: XML_GENERATOR="gccxml"
12+
- os: linux
13+
python: 3.2
14+
env: XML_GENERATOR="gccxml"
15+
- os: linux
16+
python: 3.3
17+
env: XML_GENERATOR="gccxml"
18+
- os: linux
19+
python: 3.4
20+
env: XML_GENERATOR="gccxml"
21+
- os: linux
22+
python: 3.5
23+
env: XML_GENERATOR="gccxml"
24+
- os: linux
25+
python: 2.7
26+
env: XML_GENERATOR="castxml"
27+
- os: linux
28+
python: 3.5
29+
env: XML_GENERATOR="castxml"
30+
- os: osx
31+
osx_image: xcode7.2
32+
language: generic
33+
env:
34+
- XML_GENERATOR="castxml"
35+
- TRAVIS_PYTHON_VERSION="2"
36+
- os: osx
37+
osx_image: xcode7.2
38+
language: generic
39+
env:
40+
- XML_GENERATOR="castxml"
41+
- TRAVIS_PYTHON_VERSION="3"
42+
1143

1244
before_install:
13-
# Install gccxml
14-
- sudo apt-get update -qq
15-
- sudo apt-get install -qq gccxml
45+
# OS X
46+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then travis_retry brew update; fi
47+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ $TRAVIS_PYTHON_VERSION == 2 ]]; then brew install python; fi
48+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ $TRAVIS_PYTHON_VERSION == 3 ]]; then brew install python3; fi
49+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ $TRAVIS_PYTHON_VERSION == 3 ]]; then sudo ln -sf /usr/local/bin/pip3 /usr/local/bin/pip; fi
50+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ $TRAVIS_PYTHON_VERSION == 3 ]]; then sudo ln -sf /usr/local/bin/python3 /usr/local/bin/python; fi
51+
52+
# Download castxml binaries
53+
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then
54+
if [ ! -e ${HOME}/castxml ]; then
55+
curl https://midas3.kitware.com/midas/download/item/318762/castxml-macosx.tar.gz | tar zxf - -C ${HOME};
56+
fi;
57+
fi
58+
59+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ $XML_GENERATOR == "castxml" ]]; then
60+
if [ ! -e ${HOME}/castxml ]; then
61+
wget -O - https://midas3.kitware.com/midas/download/item/318227/castxml-linux.tar.gz | tar zxf - -C ${HOME};
62+
fi;
63+
fi
64+
65+
# Add the castxml binary to the path
66+
- if [[ $XML_GENERATOR == "castxml" ]]; then
67+
export PATH=$PATH:~/castxml/bin/;
68+
fi
69+
70+
# Setup gccxml for the gccxml builds on linux
71+
- if [[ "$XML_GENERATOR" == "gccxml" ]]; then sudo apt-get update -qq; fi
72+
- if [[ "$XML_GENERATOR" == "gccxml" ]]; then sudo apt-get install -qq gccxml; fi
73+
1674
# Install pep8, needed by the unit tests
1775
- pip install pep8
76+
1877
# Install coverage tools (On 3.2 the new coverage is broken, use an old one)
1978
# https://github.com/menegazzo/travispy/issues/20
20-
- if [ $TRAVIS_PYTHON_VERSION == 3.2 ];
21-
then pip install 'coverage<4.0'; else
22-
pip install coverage;
79+
- if [ $TRAVIS_PYTHON_VERSION == 3.2 ]; then
80+
pip install 'coverage<4.0';
81+
else
82+
pip install coverage;
2383
fi
2484
- pip install coveralls
2585

2686
install:
2787
- if [[ $TRAVIS_PYTHON_VERSION == 2.6 ]]; then pip install unittest2; fi
2888

2989
script:
90+
- echo $TRAVIS_OS_NAME
91+
3092
# Modify sitecustomize.py file for coverage. Allows to cover files run in a subprocess.
31-
- touch "/home/travis/virtualenv/python${TRAVIS_PYTHON_VERSION}/lib/python${TRAVIS_PYTHON_VERSION}/sitecustomize.py"
32-
- printf "import coverage\ncoverage.process_startup()\n" > "/home/travis/virtualenv/python${TRAVIS_PYTHON_VERSION}/lib/python${TRAVIS_PYTHON_VERSION}/sitecustomize.py"
93+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then touch "/home/travis/virtualenv/python${TRAVIS_PYTHON_VERSION}/lib/python${TRAVIS_PYTHON_VERSION}/sitecustomize.py"; fi
94+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ $TRAVIS_PYTHON_VERSION == 2 ]]; then touch "/usr/local/lib/python2.7/site-packages/sitecustomize.py"; fi
95+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ $TRAVIS_PYTHON_VERSION == 3 ]]; then touch "/usr/local/lib/python3.5/site-packages/sitecustomize.py"; fi
96+
97+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]];
98+
then printf "import coverage\ncoverage.process_startup()\n" > "/home/travis/virtualenv/python${TRAVIS_PYTHON_VERSION}/lib/python${TRAVIS_PYTHON_VERSION}/sitecustomize.py"; fi
99+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ $TRAVIS_PYTHON_VERSION == 2 ]];
100+
then printf "import coverage\ncoverage.process_startup()\n" > "/usr/local/lib/python2.7/site-packages/sitecustomize.py"; fi
101+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ $TRAVIS_PYTHON_VERSION == 3 ]];
102+
then printf "import coverage\ncoverage.process_startup()\n" > "/usr/local/lib/python3.5/site-packages/sitecustomize.py"; fi
103+
33104
# Install pygccxml
34105
- python setup.py install
106+
35107
# Run the tests with coverage
36108
- coverage run unittests/test_all.py
37109
# Combine multiple .coverage files (we have multiple files because some scripts were run in a subprocess).

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
# built documents.
5454
#
5555
# The short X.Y version.
56-
version = 'v1.7.2'
56+
version = 'v1.7.3'
5757
# The full version, including alpha/beta/rc tags.
58-
release = 'v1.7.2'
58+
release = 'v1.7.3'
5959

6060
# The language for content autogenerated by Sphinx. Refer to documentation
6161
# for a list of supported languages.

docs/examples/variables/example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
ns = global_namespace.namespace("ns")
2323

2424
# The variables() method will return a list of variables.
25-
# We know that he c variable is the third one in the list:
25+
# We know that the c variable is the third one in the list:
2626
c = ns.variables()[2]
2727
print("My name is: " + c.name)
2828
print("My type is: " + str(c.type))

docs/history.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,47 @@ to python 3 (keeping it compatible with python 2).
1111
In Mai 2014, Michka Popoff and the Insight Software Consortium revived pygccxml
1212
by setting up a git repositery on github, hosted along with gccxml.
1313

14+
Version 1.7.3
15+
-------------
16+
17+
1. Addition of an is_union() method in the type_traits module.
18+
19+
2. type_traits.smart_pointer_traits will now classify std::shared_ptr as a
20+
smart pointer (only boost::shared_ptr was recognized before)
21+
22+
3. Fix a regression in undname_creator_t.format_argtypes
23+
24+
4. C++xx flags are now correctly passed to CastXML. Allowed flags are:
25+
"-std=c++98", "-std=c++03", "-std=c++11", "-std=c++14", "-std=c++1z"
26+
Thanks to Mark Moll for the fix.
27+
28+
5. Add better support for "typedef (class|struct) {} foo;" syntax when using
29+
CastXML. GCCXML did not recognize the typedef. Fetching these
30+
declarations can now be done with: .typedef("foo") or .class_("foo").
31+
32+
6. Add support for the future llvm 3.9. As in release v1.7.1, new structs and
33+
typedefs are now exposed by llvm, which broke pyplusplus.
34+
In this case these are ```__NSConstantString_tag``` and ```__NSConstantString```.
35+
The two declarations are now hidden from the declarations tree, but can still
36+
be generated by using the ``config.flags = ["f1"]`` option.
37+
38+
7. Multiple fixes to adapt default arguments in functions for py++. Using the
39+
latest version of CastXML is recommended. This makes sure default arguments
40+
for function parameters are correctly defined, so that py++ can process them.
41+
42+
8. Fix for exception when using castxml + gcc5 + std=c++11 and maps.
43+
44+
9. Removed unittest2 dependency for testing with python 2.6
45+
46+
10. Testing: test with std::tr1 unordered containers for gcc >= 4.4.7 and castxml
47+
48+
11. Cosmetic fix for generator name printed to stdout when launching unit tests
49+
50+
12. Fix simple typo in example.py comment
51+
52+
Thanks to the following people for their contribution to this release:
53+
Mark Moll, Ashish Sadanandan, Mark Oates
54+
1455
Version 1.7.2
1556
-------------
1657

pygccxml/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@
4040
# TODO:
4141
# 1. Add "explicit" property for constructors
4242

43-
__version__ = 'v1.7.2'
43+
__version__ = 'v1.7.3'

pygccxml/binary_parsers/undname.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,9 @@ def format_argtypes(self, argtypes, hint):
187187
# ugly hack, later, I will replace ', ' with ',', so single
188188
# space will still exist
189189
argsep = ', '
190-
return argsep.join(map(self.__format_type_as_undecorated(
191-
type_, True, hint), argtypes))
190+
return argsep.join(
191+
map(lambda type_: self.__format_type_as_undecorated(
192+
type_, True, hint), argtypes))
192193

193194
def format_calldef(self, calldef, hint):
194195
calldef_type = calldef.function_type()

pygccxml/declarations/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from .scopedef import scopedef_t
1919
from .enumeration import enumeration_t
2020
from .namespace import namespace_t
21+
from .typedef import typedef_t
2122

2223
from .class_declaration import class_t
2324
from .class_declaration import CLASS_TYPES
@@ -26,8 +27,6 @@
2627
from .class_declaration import class_declaration_t
2728
from .class_declaration import class_types
2829

29-
from .typedef import typedef_t
30-
3130
from .cpptypes import type_t
3231
from .cpptypes import dummy_type_t
3332
from .cpptypes import unknown_t

pygccxml/declarations/type_traits.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,15 @@ def is_fundamental(type):
365365
(cpptypes.volatile_t, cpptypes.const_t))
366366

367367

368-
class declaration_xxx_traits(object):
368+
def is_union(type_):
369+
"""returns True if type represents a C++ union"""
370+
if not is_class(type_):
371+
return False
372+
decl = class_traits.get_declaration(type_)
373+
return decl.class_type == class_declaration.CLASS_TYPES.UNION
374+
369375

376+
class declaration_xxx_traits(object):
370377
"""this class implements the functionality needed for convenient work with
371378
declaration classes
372379
@@ -1166,24 +1173,28 @@ class smart_pointer_traits(object):
11661173
@staticmethod
11671174
def is_smart_pointer(type_):
11681175
"""returns True, if type represents instantiation of
1169-
`boost::shared_ptr`, False otherwise"""
1176+
`boost::shared_ptr` or `std::shared_ptr`, False otherwise"""
11701177
type_ = remove_alias(type_)
11711178
type_ = remove_cv(type_)
11721179
type_ = remove_declarated(type_)
11731180
if not isinstance(type_,
11741181
(class_declaration.class_declaration_t,
11751182
class_declaration.class_t)):
11761183
return False
1177-
if not impl_details.is_defined_in_xxx('boost', type_):
1184+
if not (impl_details.is_defined_in_xxx('boost', type_) or
1185+
impl_details.is_defined_in_xxx('std', type_)):
11781186
return False
1179-
return type_.decl_string.startswith('::boost::shared_ptr<')
1187+
return type_.decl_string.startswith('::boost::shared_ptr<') or \
1188+
type_.decl_string.startswith('::std::shared_ptr<')
11801189

11811190
@staticmethod
11821191
def value_type(type_):
1183-
"""returns reference to `boost::shared_ptr` value type"""
1192+
"""returns reference to `boost::shared_ptr` \
1193+
or `std::shared_ptr` value type"""
11841194
if not smart_pointer_traits.is_smart_pointer(type_):
11851195
raise TypeError(
1186-
'Type "%s" is not instantiation of boost::shared_ptr' %
1196+
'Type "%s" is not an instantiation of \
1197+
boost::shared_ptr or std::shared_ptr' %
11871198
type_.decl_string)
11881199
return internal_type_traits.get_by_name(type_, "value_type")
11891200

pygccxml/parser/patcher.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Distributed under the Boost Software License, Version 1.0.
44
# See http://www.boost.org/LICENSE_1_0.txt
55

6+
import re
67
from pygccxml import utils
78
from pygccxml import declarations
89

@@ -44,14 +45,18 @@ def __is_unqualified_enum(self, func, arg):
4445
if not declarations.is_enum(type_):
4546
return False
4647
enum_type = declarations.enum_declaration(type_)
47-
return enum_type.has_value_name(arg.default_value)
48+
# GCCXML does not qualify an enum value in the default argument
49+
# but CastXML does. Split the default value and use only the
50+
# enum value for fixing it.
51+
return enum_type.has_value_name(
52+
arg.default_value.split('::')[-1])
4853

4954
def __fix_unqualified_enum(self, func, arg):
5055
type_ = declarations.remove_reference(declarations.remove_cv(arg.type))
5156
enum_type = declarations.enum_declaration(type_)
5257
return self.__join_names(
5358
enum_type.parent.decl_string,
54-
arg.default_value)
59+
arg.default_value.split('::')[-1])
5560

5661
def __is_invalid_integral(self, func, arg):
5762
type_ = declarations.remove_reference(declarations.remove_cv(arg.type))
@@ -102,6 +107,27 @@ def __fix_invalid_integral(self, func, arg):
102107
arg.default_value))
103108
else:
104109
parent = parent.parent
110+
111+
# check if we have an unqualified integral constant
112+
# only do patching in cases where we have a bare variable name
113+
c_var = re.compile("[a-z_][a-z0-9_]*", re.IGNORECASE)
114+
m = c_var.match(arg.default_value)
115+
if m:
116+
parent = func.parent
117+
while parent:
118+
try:
119+
found = parent.variable(arg.default_value,
120+
recursive=False)
121+
except declarations.matcher.declaration_not_found_t:
122+
# ignore exceptions if a match is not found
123+
found = None
124+
if found:
125+
if declarations.is_fundamental(arg.type):
126+
return "%s" % self.__join_names(
127+
found.parent.decl_string,
128+
arg.default_value)
129+
parent = parent.parent
130+
105131
return arg.default_value
106132

107133
def __find_enum(self, scope, default_value):

pygccxml/parser/project_reader.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,10 @@ def _relink_declarated_types(self, leaved_classes, declarated_types):
521521
else:
522522

523523
name = decl_wrapper_type.declaration._name
524+
if name == "":
525+
# Happens with gcc5, castxml + std=c++11
526+
# See issue #45
527+
continue
524528
if name.startswith("__vmi_class_type_info_pseudo"):
525529
continue
526530
if name == "rebind<std::__tree_node" + \

0 commit comments

Comments
 (0)