Skip to content

Commit 97cbcef

Browse files
committed
Fix last errors with container traits and std::tr1 when using gcc on linux
1 parent 39a147c commit 97cbcef

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

pygccxml/declarations/container_traits.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def erase_call(self, cls_name):
7777

7878
def no_std(self, cls_name):
7979
return self.decorated_call_prefix(
80-
cls_name, 'std::', self.erase_call)
80+
cls_name, 'std::' + utils.get_tr1(cls_name), self.erase_call)
8181

8282
def no_stdext(self, cls_name):
8383
return self.decorated_call_prefix(
@@ -403,32 +403,42 @@ def get_container_or_none(self, type_):
403403
cls_declaration = type_
404404
else:
405405
utils.loggers.queries_engine.debug(
406-
"Container traits: returning None, type not known")
406+
"Container traits: returning None, type not known\n")
407407
return
408408

409409
if not cls_declaration.name.startswith(self.name() + '<'):
410410
utils.loggers.queries_engine.debug(
411411
"Container traits: returning None, " +
412-
"declaration starts with " + self.name() + '<')
412+
"declaration starts with " + self.name() + '<\n')
413413
return
414414

415+
# When using libstd++, some container traits are defined in
416+
# std::tr1::. See remove_template_defaults_tester.py.
417+
# In this case the is_defined_in_xxx test needs to be done
418+
# on the parent
415419
decl = cls_declaration
416-
if isinstance(type_, cpptypes.declarated_t):
420+
if isinstance(type_, class_declaration.class_declaration_t):
421+
is_ns = isinstance(type_.parent, namespace.namespace_t)
422+
if is_ns and type_.parent.name == "tr1":
423+
decl = cls_declaration.parent
424+
elif isinstance(type_, cpptypes.declarated_t):
417425
is_ns = isinstance(type_.declaration.parent, namespace.namespace_t)
418426
if is_ns and type_.declaration.parent.name == "tr1":
419-
# When using libstd++, some container traits are defined in
420-
# std::tr1:: . See remove_template_defaults_tester.py.
421-
# In this case the is_defined_in_xxx test needs to be done
422-
# on the parent
423427
decl = cls_declaration.parent
424428

425429
for ns in std_namespaces:
426430
if type_traits.impl_details.is_defined_in_xxx(ns, decl):
431+
utils.loggers.queries_engine.debug(
432+
"Container traits: get_container_or_none() will return " +
433+
cls_declaration.name)
434+
# The is_defined_in_xxx check is done on decl, but we return
435+
# the original declation so that the rest of the algorithm
436+
# is able to work with it.
427437
return cls_declaration
428438

429439
# This should not happen
430440
utils.loggers.queries_engine.debug(
431-
"Container traits: get_container_or_none() will return None")
441+
"Container traits: get_container_or_none() will return None\n")
432442

433443
def is_my_case(self, type_):
434444
"""
@@ -689,6 +699,8 @@ def find_container_traits(cls_or_string):
689699
name = templates.name(cls_or_string)
690700
if name.startswith('std::'):
691701
name = name[len('std::'):]
702+
if name.startswith('std::tr1::'):
703+
name = name[len('std::tr1::'):]
692704
for cls_traits in container_traits:
693705
if cls_traits.name() == name:
694706
return cls_traits

unittests/remove_template_defaults_tester.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ def test_hash_multimap(self):
193193
name + '< const std::vector< int >, ' +
194194
'const __gnu_cxx::' + name + '< const std::wstring, double > >',
195195
name + '< const std::vector< int >, ' +
196-
'const std::' + name + '< const std::wstring, double > >',
196+
'const std::' + utils.get_tr1(hmm_traits_value) + name +
197+
'< const std::wstring, double > >',
197198
name + '< const std::vector< int >, ' +
198199
'const stdext::' + name + '< const std::wstring, double > >')
199200

0 commit comments

Comments
 (0)