Skip to content

Commit 617729f

Browse files
committed
test
1 parent de5c0e4 commit 617729f

File tree

9 files changed

+204
-169
lines changed

9 files changed

+204
-169
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ jobs:
102102
- name: Run tests
103103
run: |
104104
export PATH=~/castxml/bin:$PATH
105-
pytest tests
105+
pytest tests/test_remove_template_defaults.py

src/pygccxml/declarations/container_traits.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def normalize(self, type_str):
3030

3131
def replace_basic_string(self, cls_name):
3232

33+
print("replace_basic_string START", cls_name)
34+
3335
# Take the lists of all possible string variations
3436
# and clean them up by replacing ::std by std.
3537
str_eq = [
@@ -49,6 +51,8 @@ def replace_basic_string(self, cls_name):
4951
for lname in long_names:
5052
new_name = new_name.replace(lname, short_name)
5153

54+
print("replace_basic_string DONE", new_name)
55+
5256
return new_name
5357

5458
def decorated_call_prefix(self, cls_name, text, doit):
@@ -99,13 +103,14 @@ def erase_recursive(self, cls_name):
99103
return self.no_end_const(cls_name)
100104

101105
def erase_allocator(self, cls_name, default_allocator='std::allocator'):
106+
print("erase_allocator START", cls_name)
102107
cls_name = self.replace_basic_string(cls_name)
103108
c_name, c_args = templates.split(cls_name)
104109
if len(c_args) != 2:
105110
return
106111
value_type = c_args[0]
107112
tmpl = string.Template(
108-
"$container<$value_type, $allocator<$value_type>>")
113+
"$container<$value_type,$allocator<$value_type>>")
109114
tmpl = tmpl.substitute(
110115
container=c_name,
111116
value_type=value_type,
@@ -525,6 +530,7 @@ def remove_defaults(self, type_or_string):
525530
name = self.class_declaration(type_or_string).name
526531
if not self.remove_defaults_impl:
527532
return name
533+
print("remove_defaults", name)
528534
no_defaults = self.remove_defaults_impl(name)
529535
if not no_defaults:
530536
return name

src/pygccxml/declarations/pattern_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,11 @@ def join(self, name, args, arg_separator=None):
192192
args = [_f for _f in args if _f]
193193

194194
if not args:
195-
args_str = ' '
195+
args_str = ''
196196
elif len(args) == 1:
197-
args_str = ' ' + args[0] + ' '
197+
args_str = '' + args[0] + ''
198198
else:
199-
args_str = ' ' + arg_separator.join(args) + ' '
199+
args_str = '' + arg_separator.join(args) + ''
200200

201201
return ''.join([name, self.__begin, args_str, self.__end])
202202

src/pygccxml/declarations/type_traits.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,10 @@ def is_fundamental(type_):
481481

482482

483483
string_equivalences = [
484-
(
485-
'::std::basic_string<char,std::char_traits<char>,'
486-
'std::allocator<char>>'),
484+
'::std::basic_string<char,std::char_traits<char>,std::allocator<char>>,\
485+
std::allocator<std::basic_string<char,std::char_traits<char>,\
486+
std::allocator<char>>'
487+
'::std::basic_string<char,std::char_traits<char>,std::allocator<char>>',
487488
'::std::basic_string<char>', '::std::string']
488489

489490
wstring_equivalences = [

src/pygccxml/parser/patcher.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,32 @@ def remove_spaces_from_template_names(decls):
314314
after hash<std::vector<int>>
315315
"""
316316
for decl in decls:
317+
# if "v_int" in decl.name:
318+
# print("------")
319+
# print(
320+
# decl.decl_type,
321+
# type(decl.decl_type),
322+
# decl.decl_type.declaration.name)
323+
# if "vector" in decl.name:
324+
# print("------")
325+
# print("vvvvvvv", decl, decl.name)
317326
decl.name = decl.name.replace(" >", ">").replace("< ", "<")
318327
decl.partial_name = \
319328
decl.partial_name.replace(" >", ">").replace("< ", "<")
329+
if isinstance(decl, declarations.typedef_t) and \
330+
isinstance(decl.decl_type, declarations.declarated_t):
331+
decl.decl_type.declaration.name = fix_spaces(
332+
decl.decl_type.declaration.name)
333+
decl.decl_type.declaration.partial_name = fix_spaces(
334+
decl.decl_type.declaration.partial_name)
335+
# if "v_int" in decl.name:
336+
# print(
337+
# decl.decl_type,
338+
# type(decl.decl_type),
339+
# decl.decl_type.declaration.name)
340+
# if "vector" in decl.name:
341+
# print("vvvvvvv", decl, decl.name)
342+
343+
344+
def fix_spaces(val):
345+
return val.replace(" >", ">").replace("< ", "<")

tests/test_pattern_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ def test_split():
6666
6767
"""
6868

69-
p1 = "std::vector<char, std::allocator<char> >"
70-
p2 = "std::vector<int, std::allocator<int> >"
69+
p1 = "std::vector<char, std::allocator<char>>"
70+
p2 = "std::vector<int, std::allocator<int>>"
7171
args_list = [
7272
"const std::basic_string<char> &", "const int &", "const double &"]
7373

0 commit comments

Comments
 (0)