Skip to content

Commit 5420eb7

Browse files
committed
Merge branch 'hotfix/v1.7.6'
2 parents 54201e5 + b1f6423 commit 5420eb7

File tree

9 files changed

+120
-13
lines changed

9 files changed

+120
-13
lines changed

docs/conf.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@
4646

4747
# General information about the project.
4848
project = u'pygccxml'
49-
copyright = u'2014-2015, Insight Software Consortium'
49+
copyright = u'2014-2016, Insight Software Consortium'
5050

5151
# The version info for the project you're documenting, acts as replacement for
5252
# |version| and |release|, also used in various other places throughout the
5353
# built documents.
5454
#
5555
# The short X.Y version.
56-
version = '1.7.5'
56+
version = '1.7.6'
5757
# The full version, including alpha/beta/rc tags.
58-
release = '1.7.5'
58+
release = '1.7.6'
5959

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

docs/history.rst

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ 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.6
15+
-------------
16+
17+
1. Fix problem with argument without names when building declaration string (#55)
18+
1419
Version 1.7.5
1520
-------------
1621

pygccxml/__init__.py

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

43-
__version__ = '1.7.5'
43+
__version__ = '1.7.6'

pygccxml/declarations/algorithm.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,24 @@ def full_name(decl, with_defaults=True):
124124
raise RuntimeError("Unable to generate full name for None object!")
125125
if with_defaults:
126126
if not decl.cache.full_name:
127-
decl.cache.full_name = full_name_from_declaration_path(
128-
declaration_path(decl))
127+
path = declaration_path(decl)
128+
if path == [""]:
129+
# Declarations without names are allowed (for examples class
130+
# or struct instances). In this case set an empty name..
131+
decl.cache.full_name = ""
132+
else:
133+
decl.cache.full_name = full_name_from_declaration_path(path)
129134
return decl.cache.full_name
130135
else:
131136
if not decl.cache.full_partial_name:
132-
decl.cache.full_partial_name = full_name_from_declaration_path(
133-
partial_declaration_path(decl))
137+
path = partial_declaration_path(decl)
138+
if path == [""]:
139+
# Declarations without names are allowed (for examples class
140+
# or struct instances). In this case set an empty name.
141+
decl.cache.full_partial_name = ""
142+
else:
143+
decl.cache.full_partial_name = \
144+
full_name_from_declaration_path(path)
134145
return decl.cache.full_partial_name
135146

136147

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
from setuptools import setup
88

99
setup(name="pygccxml",
10-
version="1.7.5",
10+
version="1.7.6",
1111
author="Roman Yakovenko",
1212
author_email="roman yakovenko at gmail com",
1313
maintainer="Michka Popoff and the Insight Software Consortium",
1414
maintainer_email="[email protected]",
1515
description="Python package for easy C++ declarations navigation.",
1616
url="https://github.com/gccxml/pygccxml",
17-
download_url="https://github.com/gccxml/pygccxml/archive/v1.7.5.tar.gz",
17+
download_url="https://github.com/gccxml/pygccxml/archive/v1.7.6.tar.gz",
1818
license="Boost",
1919
keywords="C++, declaration parser, CastXML, gccxml",
2020
packages=["pygccxml",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2014-2016 Insight Software Consortium.
2+
// Copyright 2004-2009 Roman Yakovenko.
3+
// Distributed under the Boost Software License, Version 1.0.
4+
// See http://www.boost.org/LICENSE_1_0.txt
5+
6+
// Demonstrate some code where a struct without name is passed to a
7+
// templated function. See bug #55
8+
9+
template <typename type>
10+
void
11+
function(type &var) {};
12+
13+
int main()
14+
{
15+
// Create foo, a struct with no name
16+
struct { } foo;
17+
function(foo);
18+
}

unittests/test_all.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
import test_cpp_standards
7272
import unnamed_classes_tester
7373
import test_map_gcc5
74+
import test_argument_without_name
7475

7576
testers = [
7677
# , demangled_tester # failing right now
@@ -134,7 +135,8 @@
134135
test_copy_constructor,
135136
test_cpp_standards,
136137
unnamed_classes_tester,
137-
test_map_gcc5
138+
test_map_gcc5,
139+
test_argument_without_name
138140
]
139141

140142
if 'posix' in os.name:
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright 2014-2016 Insight Software Consortium.
2+
# Copyright 2004-2009 Roman Yakovenko.
3+
# Distributed under the Boost Software License, Version 1.0.
4+
# See http://www.boost.org/LICENSE_1_0.txt
5+
6+
import unittest
7+
import parser_test_case
8+
9+
from pygccxml import parser
10+
from pygccxml import declarations
11+
12+
13+
class tester_t(parser_test_case.parser_test_case_t):
14+
15+
def __init__(self, *args):
16+
parser_test_case.parser_test_case_t.__init__(self, *args)
17+
self.header = "test_argument_without_name.hpp"
18+
self.config.cflags = "-std=c++11"
19+
20+
def test_argument_without_name(self):
21+
22+
"""
23+
Test passing an object without name to a templated function.
24+
25+
The test was failing when building the declaration string.
26+
The declaration string will be 'void (*)( & )'. If the passed
27+
object had a name the result would then be 'void (*)(Name & )'.
28+
29+
See bug #55
30+
31+
"""
32+
33+
if self.config.xml_generator == "gccxml":
34+
return
35+
36+
decls = parser.parse([self.header], self.config)
37+
global_ns = declarations.get_global_namespace(decls)
38+
39+
criteria = declarations.calldef_matcher(name="function")
40+
free_funcs = declarations.matcher.find(criteria, global_ns)
41+
for free_func in free_funcs:
42+
decl_string = free_func.create_decl_string(with_defaults=False)
43+
self.assertEqual(decl_string, "void (*)( & )")
44+
45+
46+
def create_suite():
47+
suite = unittest.TestSuite()
48+
suite.addTest(unittest.makeSuite(tester_t))
49+
return suite
50+
51+
52+
def run_suite():
53+
unittest.TextTestRunner(verbosity=2).run(create_suite())
54+
55+
if __name__ == "__main__":
56+
run_suite()

unittests/test_map_gcc5.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright 2014-2016 Insight Software Consortium.
2+
# Copyright 2004-2009 Roman Yakovenko.
23
# Distributed under the Boost Software License, Version 1.0.
34
# See http://www.boost.org/LICENSE_1_0.txt
45

@@ -21,15 +22,29 @@ def test_map_gcc5(self):
2122
"""
2223
The code in test_map_gcc5.hpp was breaking pygccxml.
2324
24-
Test that case (gcc5 + castxml + c++11). See issue #45
25+
Test that case (gcc5 + castxml + c++11).
26+
27+
See issue #45 and #55
2528
2629
"""
2730

2831
if self.config.xml_generator == "gccxml":
2932
return
3033

3134
decls = parser.parse([self.header], self.config)
32-
self.global_ns = declarations.get_global_namespace(decls)
35+
global_ns = declarations.get_global_namespace(decls)
36+
37+
# This calldef is defined with gcc > 4.9 (maybe earlier, not tested)
38+
# and -std=c++11. Calling create_decl_string is failing with gcc.
39+
# With clang the calldef does not exist so the matcher
40+
# will just return an empty list, letting the test pass.
41+
# See the test_argument_without_name.py for an equivalent test,
42+
# which is not depending on the presence of the _M_clone_node
43+
# method in the stl_tree.h file.
44+
criteria = declarations.calldef_matcher(name="_M_clone_node")
45+
free_funcs = declarations.matcher.find(criteria, global_ns)
46+
for free_funcs in free_funcs:
47+
free_funcs.create_decl_string(with_defaults=False)
3348

3449

3550
def create_suite():

0 commit comments

Comments
 (0)