Skip to content

Commit df343d9

Browse files
author
roman_yakovenko
committed
fix bug related to merging free functions
1 parent d3a8650 commit df343d9

File tree

5 files changed

+61
-15
lines changed

5 files changed

+61
-15
lines changed

pygccxml/declarations/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@
262262
from mdecl_wrapper import mdecl_wrapper_t
263263

264264
from decl_printer import decl_printer_t
265+
from decl_printer import dump_declarations
265266
from decl_printer import print_declarations
266267

267268

@@ -334,10 +335,3 @@
334335
__impl_matchers[ namespace_t.free_operator ] = operator_matcher_t
335336
__impl_decl_types[ namespace_t.free_operator ] = free_operator_t
336337

337-
338-
339-
340-
341-
342-
343-

pygccxml/declarations/calldef.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ def _get__cmp__items( self ):
177177
, self.return_type
178178
, self.has_extern
179179
, self.does_throw
180-
, self._sorted_list( self.exceptions ) ]
180+
, self._sorted_list( self.exceptions )
181+
, self.demangled_name ]
181182
items.extend( self._get__cmp__call_items() )
182183
return items
183184

@@ -188,8 +189,8 @@ def __eq__(self, other):
188189
and self.arguments == other.arguments \
189190
and self.has_extern == other.has_extern \
190191
and self.does_throw == other.does_throw \
191-
and self._sorted_list( self.exceptions ) \
192-
== other._sorted_list( other.exceptions )
192+
and self._sorted_list( self.exceptions ) == other._sorted_list( other.exceptions ) \
193+
and self.demangled_name == other.demangled_name
193194

194195
def _get_arguments(self):
195196
return self._arguments

pygccxml/declarations/decl_printer.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,14 @@ def print_declarations( decls
285285
prn.level = 0
286286
prn.instance = d
287287
algorithm.apply_visitor(prn, d)
288+
289+
def dump_declarations( decls, fpath ):
290+
"""
291+
dump declarations tree rooted at each of the included nodes to the file
292+
293+
:param decls: either a single :class:declaration_t object or list of :class:declaration_t objects
294+
:param fpath: file name
295+
"""
296+
fobj = file( fpath, 'w+' )
297+
print_declarations( decls, writer=fobj.write )
298+
fobj.close()
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2004-2008 Roman Yakovenko.
2+
// Distributed under the Boost Software License, Version 1.0. (See
3+
// accompanying file LICENSE_1_0.txt or copy at
4+
// http://www.boost.org/LICENSE_1_0.txt)
5+
6+
#ifndef __merge_free_functions_hpp__
7+
#define __merge_free_functions_hpp__
8+
9+
#include <iostream>
10+
11+
/*
12+
namespace n1{
13+
14+
struct s1{};
15+
struct s2{};
16+
17+
template<typename _Facet>
18+
bool has_facet(int i) throw(){
19+
return false;
20+
}
21+
22+
void do_smth(){
23+
has_facet<s1>( 12 );
24+
has_facet<s2>( 12 );
25+
}
26+
27+
}
28+
*/
29+
30+
31+
#endif//__merge_free_functions_hpp__
32+

unittests/xmlfile_reader_tester.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# accompanying file LICENSE_1_0.txt or copy at
44
# http://www.boost.org/LICENSE_1_0.txt)
55

6+
import os
67
import unittest
78
import autoconfig
89
import parser_test_case
@@ -14,13 +15,15 @@
1415
class tester_t( parser_test_case.parser_test_case_t ):
1516
def __init__(self, *args):
1617
parser_test_case.parser_test_case_t.__init__(self, *args)
17-
self.__fname = 'core_types.hpp'
18+
#self.__fname = 'core_types.hpp'
19+
self.__fname = 'merge_free_functions.hpp'
1820

1921
def test(self):
2022
src_reader = parser.source_reader_t( self.config )
2123
src_decls = src_reader.read_file( self.__fname )
2224

2325
xmlfile = src_reader.create_xml_file( self.__fname )
26+
print xmlfile
2427
try:
2528
fconfig = parser.file_configuration_t( data=xmlfile
2629
, start_with_declarations=None
@@ -29,11 +32,16 @@ def test(self):
2932
prj_reader = parser.project_reader_t( self.config )
3033
prj_decls = prj_reader.read_files( [fconfig]
3134
, compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE )
32-
33-
self.failUnless( src_decls == prj_decls
34-
, "There is a difference between declarations in file %s." % self.__fname )
35+
36+
declarations.dump_declarations( src_decls
37+
, os.path.join( autoconfig.build_directory, 'xmlfile_reader.src.txt' ) )
38+
declarations.dump_declarations( prj_decls
39+
, os.path.join( autoconfig.build_directory, 'xmlfile_reader.prj.txt' ) )
40+
41+
if src_decls != prj_decls:
42+
self.fail( "There is a difference between declarations in file %s." % self.__fname )
3543
finally:
36-
utils.remove_file_no_raise( xmlfile )
44+
pass #utils.remove_file_no_raise( xmlfile )
3745

3846
def create_suite():
3947
suite = unittest.TestSuite()

0 commit comments

Comments
 (0)