Skip to content

Commit

Permalink
scanner: debug spaces in templates
Browse files Browse the repository at this point in the history
  • Loading branch information
iMichka committed Dec 20, 2024
1 parent ea300f6 commit d68418c
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 148 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ jobs:
- name: Run tests
run: |
export PATH=~/castxml/bin:$PATH
pytest tests
pytest tests/test_remove_template_defaults.py
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ docs = [
examples = [
"notebook",
]
[tool.pytest.ini_options]
pythonpath = ["src"]
10 changes: 8 additions & 2 deletions src/pygccxml/declarations/container_traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def erase_recursive(self, cls_name):
def erase_allocator(self, cls_name, default_allocator='std::allocator'):
cls_name = self.replace_basic_string(cls_name)
c_name, c_args = templates.split(cls_name)
print("erase_allocator c_name, c_args", c_name, c_args)
if len(c_args) != 2:
return
value_type = c_args[0]
Expand All @@ -112,8 +113,10 @@ def erase_allocator(self, cls_name, default_allocator='std::allocator'):
allocator=default_allocator)
if self.normalize(cls_name) == \
self.normalize(tmpl):
return templates.join(
x = templates.join(
c_name, [self.erase_recursive(value_type)])
print("erase_allocator x", x)
return x

def erase_container(self, cls_name, default_container_name='std::deque'):
cls_name = self.replace_basic_string(cls_name)
Expand Down Expand Up @@ -378,7 +381,9 @@ def get_container_or_none(self, type_):
"""

print("get_container_or_none", type_)
type_ = type_traits.remove_alias(type_)
print("get_container_or_none", type_)
type_ = type_traits.remove_cv(type_)

utils.loggers.queries_engine.debug(
Expand Down Expand Up @@ -520,13 +525,14 @@ def remove_defaults(self, type_or_string):
std::vector< int >
"""

print("xxxx", type_or_string)
name = type_or_string
if not isinstance(type_or_string, str):
name = self.class_declaration(type_or_string).name
if not self.remove_defaults_impl:
return name
no_defaults = self.remove_defaults_impl(name)
print("xxxx name, no_defaults", name, no_defaults)
if not no_defaults:
return name
return no_defaults
Expand Down
2 changes: 2 additions & 0 deletions src/pygccxml/declarations/type_traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ def remove_alias(type_):
Returns:
type_t: the type associated to the inputted declaration
"""
print("remove_alias", type_)
if isinstance(type_, cpptypes.type_t):
type_ref = type_
elif isinstance(type_, typedef.typedef_t):
type_ref = type_.decl_type
else:
# Not a valid input, just return it
return type_
print("remove_alias type_ref", type_ref)
if type_ref.cache.remove_alias:
return type_ref.cache.remove_alias
no_alias = __remove_alias(type_ref.clone())
Expand Down
3 changes: 3 additions & 0 deletions src/pygccxml/parser/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ def members(self):

def startElement(self, name, attrs):

# print(attrs)

try:
if name not in self.__readers:
return
Expand Down Expand Up @@ -654,6 +656,7 @@ def __read_variable(self, attrs):

def __read_class_impl(self, class_type, attrs):
name = attrs.get(XML_AN_NAME, '')
# name = name.replace(">", " >").replace("<", "< ")
if '$' in name or '.' in name:
name = ''
if XML_AN_INCOMPLETE in attrs:
Expand Down
Loading

0 comments on commit d68418c

Please sign in to comment.