Skip to content

Commit e0fec34

Browse files
committed
scanner: debug spaces in templates
1 parent ea300f6 commit e0fec34

File tree

7 files changed

+171
-153
lines changed

7 files changed

+171
-153
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

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ docs = [
6464
examples = [
6565
"notebook",
6666
]
67+
[tool.pytest.ini_options]
68+
pythonpath = ["src"]

src/pygccxml/declarations/container_traits.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,22 @@ def erase_recursive(self, cls_name):
101101
def erase_allocator(self, cls_name, default_allocator='std::allocator'):
102102
cls_name = self.replace_basic_string(cls_name)
103103
c_name, c_args = templates.split(cls_name)
104+
print("erase_allocator c_name, c_args", c_name, c_args)
104105
if len(c_args) != 2:
105106
return
106107
value_type = c_args[0]
107108
tmpl = string.Template(
108-
"$container< $value_type, $allocator<$value_type> >")
109+
"$container<$value_type, $allocator<$value_type>>")
109110
tmpl = tmpl.substitute(
110111
container=c_name,
111112
value_type=value_type,
112113
allocator=default_allocator)
113114
if self.normalize(cls_name) == \
114115
self.normalize(tmpl):
115-
return templates.join(
116+
x = templates.join(
116117
c_name, [self.erase_recursive(value_type)])
118+
print("erase_allocator x", x)
119+
return x
117120

118121
def erase_container(self, cls_name, default_container_name='std::deque'):
119122
cls_name = self.replace_basic_string(cls_name)
@@ -378,7 +381,9 @@ def get_container_or_none(self, type_):
378381
379382
"""
380383

384+
print("get_container_or_none", type_)
381385
type_ = type_traits.remove_alias(type_)
386+
print("get_container_or_none", type_)
382387
type_ = type_traits.remove_cv(type_)
383388

384389
utils.loggers.queries_engine.debug(
@@ -520,13 +525,14 @@ def remove_defaults(self, type_or_string):
520525
std::vector< int >
521526
522527
"""
523-
528+
print("xxxx", type_or_string)
524529
name = type_or_string
525530
if not isinstance(type_or_string, str):
526531
name = self.class_declaration(type_or_string).name
527532
if not self.remove_defaults_impl:
528533
return name
529534
no_defaults = self.remove_defaults_impl(name)
535+
print("xxxx name, no_defaults", name, no_defaults)
530536
if not no_defaults:
531537
return name
532538
return no_defaults

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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ def remove_alias(type_):
5252
Returns:
5353
type_t: the type associated to the inputted declaration
5454
"""
55+
print("remove_alias", type_)
5556
if isinstance(type_, cpptypes.type_t):
5657
type_ref = type_
5758
elif isinstance(type_, typedef.typedef_t):
5859
type_ref = type_.decl_type
5960
else:
6061
# Not a valid input, just return it
6162
return type_
63+
print("remove_alias type_ref", type_ref)
6264
if type_ref.cache.remove_alias:
6365
return type_ref.cache.remove_alias
6466
no_alias = __remove_alias(type_ref.clone())

src/pygccxml/parser/scanner.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ def members(self):
286286

287287
def startElement(self, name, attrs):
288288

289+
# print(attrs)
290+
289291
try:
290292
if name not in self.__readers:
291293
return
@@ -654,6 +656,7 @@ def __read_variable(self, attrs):
654656

655657
def __read_class_impl(self, class_type, attrs):
656658
name = attrs.get(XML_AN_NAME, '')
659+
# name = name.replace(">", " >").replace("<", "< ")
657660
if '$' in name or '.' in name:
658661
name = ''
659662
if XML_AN_INCOMPLETE in attrs:

0 commit comments

Comments
 (0)