Skip to content

Commit e0e3857

Browse files
committed
Merge branch 'hotfix/v1.6.1'
2 parents 741c035 + 427ef73 commit e0e3857

File tree

7 files changed

+138
-14
lines changed

7 files changed

+138
-14
lines changed

docs/history/history.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ Thanks to all the people that have contributed patches, bug reports and suggesti
4343
* Alejandro Dubrovsky
4444
* Aron Xu
4545

46+
Version 1.6.1
47+
-------------
48+
49+
1. Fix a regression introduced by previous changes. Syntax errors were introduced
50+
in the part were you can check if a class is copyable or not (see #13). These
51+
have been fixed now.
52+
4653
Version 1.6
4754
-----------
4855

pygccxml/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
# TODO:
3434
# 1. Add "explicit" property for constructors
3535

36-
__version__ = 'v1.5.2'
36+
__version__ = 'v1.6.1'

pygccxml/declarations/class_declaration.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -572,40 +572,51 @@ def _get_partial_name_impl(self):
572572

573573
def find_noncopyable_vars(self):
574574
"""returns list of all `noncopyable` variables"""
575+
575576
from . import type_traits as tt # prevent cyclic dependencies
577+
576578
logger = utils.loggers.cxx_parser
577579
mvars = self.vars(
578580
lambda v: not v.type_qualifiers.has_static,
579581
recursive=False,
580582
allow_empty=True)
581583
noncopyable_vars = []
584+
585+
message = (
586+
"__contains_noncopyable_mem_var - %s - TRUE - " +
587+
"containes const member variable")
588+
582589
for mvar in mvars:
590+
583591
type_ = tt.remove_reference(mvar.type)
592+
584593
if tt.is_const(type_):
585594
no_const = tt.remove_const(type_)
586-
message = (
587-
"__contains_noncopyable_mem_var - %s - TRUE - " +
588-
"containes const member variable")
589595
if tt.is_fundamental(no_const) or tt.is_enum(no_const):
590-
logger.debug(
591-
message + "- fundamental or enum" % self.decl_string)
596+
logger.debug((
597+
message + "- fundamental or enum")
598+
% self.decl_string)
592599
noncopyable_vars.append(mvar)
593600
if tt.is_class(no_const):
594-
logger.debug(message + " - class" % self.decl_string)
601+
logger.debug((message + " - class") % self.decl_string)
595602
noncopyable_vars.append(mvar)
596603
if tt.is_array(no_const):
597-
logger.debug(message + " - array" % self.decl_string)
604+
logger.debug((message + " - array") % self.decl_string)
598605
noncopyable_vars.append(mvar)
606+
599607
if tt.class_traits.is_my_case(type_):
608+
600609
cls = tt.class_traits.get_declaration(type_)
601610
if tt.is_noncopyable(cls):
602-
logger.debug(
603-
message +
604-
" - class that is not copyable" % self.decl_string)
611+
logger.debug((
612+
message + " - class that is not copyable")
613+
% self.decl_string)
605614
noncopyable_vars.append(mvar)
615+
606616
logger.debug((
607-
"__contains_noncopyable_mem_var - %s - false - doesn't " +
608-
"contains noncopyable members") % self.decl_string)
617+
"__contains_noncopyable_mem_var - %s - FALSE - doesn't " +
618+
"contain noncopyable members") % self.decl_string)
619+
609620
return noncopyable_vars
610621

611622
@property

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from distutils.core import setup
88

99
setup(name="pygccxml",
10-
version="v1.6.0",
10+
version="v1.6.1",
1111
description="GCC-XML generated file reader",
1212
author="Insight Software Consortium.",
1313
author_email="[email protected]",
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright 2014 Insight Software Consortium.
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// See http://www.boost.org/LICENSE_1_0.txt
4+
5+
// A non copyable class, see:
6+
// http://stackoverflow.com/questions/2173746/how-do-i-make-this-c-object-non-copyable
7+
8+
9+
#ifndef __non_copyable_classes_hpp__
10+
#define __non_copyable_classes_hpp__
11+
12+
namespace non_copyable{
13+
14+
// A first base class, which can not be copied
15+
class Foo1 {
16+
private:
17+
Foo1();
18+
Foo1( const Foo1& other ); // non construction-copyable
19+
Foo1& operator=( const Foo1& ); // non copyable
20+
protected:
21+
int var;
22+
public:
23+
void set_values (int a)
24+
{ var=a; }
25+
};
26+
27+
// A second base class, with a non copiable const
28+
class Foo2 {
29+
private:
30+
Foo2();
31+
protected:
32+
const int var;
33+
};
34+
35+
class MainFoo1: public Foo1 {
36+
public:
37+
int get_var()
38+
{ return var; }
39+
};
40+
41+
class MainFoo2: public Foo2 {
42+
public:
43+
int get_var()
44+
{ return var; }
45+
};
46+
47+
}
48+
49+
#endif//__non_copyable_classes_hpp__
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Copyright 2014 Insight Software Consortium.
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# See http://www.boost.org/LICENSE_1_0.txt
4+
5+
import unittest
6+
import parser_test_case
7+
8+
from pygccxml import parser
9+
from pygccxml import declarations
10+
11+
12+
class tester_t(parser_test_case.parser_test_case_t):
13+
14+
def __init__(self, *args):
15+
parser_test_case.parser_test_case_t.__init__(self, *args)
16+
self.header = 'non_copyable_classes.hpp'
17+
self.global_ns = None
18+
19+
def setUp(self):
20+
if not self.global_ns:
21+
decls = parser.parse([self.header], self.config)
22+
self.global_ns = declarations.get_global_namespace(decls)
23+
self.global_ns.init_optimizer()
24+
25+
def test(self):
26+
27+
"""
28+
Search for two classes which can not be copied.
29+
30+
See bug #13
31+
32+
Covers two cases for the moment
33+
1) non copyable class
34+
2) non copyable class due to a non copyable const
35+
36+
"""
37+
38+
MainFoo1 = self.global_ns.class_('MainFoo1')
39+
self.assertTrue(declarations.is_noncopyable(MainFoo1))
40+
41+
MainFoo2 = self.global_ns.class_('MainFoo2')
42+
self.assertTrue(declarations.is_noncopyable(MainFoo2))
43+
44+
45+
def create_suite():
46+
suite = unittest.TestSuite()
47+
suite.addTest(unittest.makeSuite(tester_t))
48+
return suite
49+
50+
51+
def run_suite():
52+
unittest.TextTestRunner(verbosity=2).run(create_suite())
53+
54+
if __name__ == "__main__":
55+
run_suite()

unittests/test_all.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import cache_enums_tester
3535
import decl_printer_tester
3636
import typedefs_tester
37+
import non_copyable_classes_tester
3738
# import demangled_tester
3839
import unnamed_enums_bug_tester
3940
import vector_traits_tester
@@ -93,6 +94,7 @@
9394
cache_enums_tester,
9495
decl_printer_tester,
9596
typedefs_tester,
97+
non_copyable_classes_tester,
9698
unnamed_enums_bug_tester,
9799
vector_traits_tester,
98100
string_traits_tester,

0 commit comments

Comments
 (0)