diff --git a/pygccxml/declarations/smart_pointer_traits.py b/pygccxml/declarations/smart_pointer_traits.py index 28bfa844..bab111e2 100644 --- a/pygccxml/declarations/smart_pointer_traits.py +++ b/pygccxml/declarations/smart_pointer_traits.py @@ -18,7 +18,7 @@ class internal_type_traits(object): @staticmethod def get_by_name(type_, name): if class_traits.is_my_case(type_): - cls = class_traits.declaration_class(type_) + cls = class_traits.get_declaration(type_) return type_traits.remove_declarated( cls.typedef(name, recursive=False).decl_type) elif class_declaration_traits.is_my_case(type_): @@ -72,7 +72,7 @@ def value_type(type_): 'Type "%s" is not an instantiation of \ boost::shared_ptr or std::shared_ptr' % type_.decl_string) - return internal_type_traits.get_by_name(type_, "value_type") + return internal_type_traits.get_by_name(type_, "element_type") class auto_ptr_traits(object): diff --git a/unittests/test_smart_pointer.py b/unittests/test_smart_pointer.py index bcd4739c..1f5a3b34 100644 --- a/unittests/test_smart_pointer.py +++ b/unittests/test_smart_pointer.py @@ -76,6 +76,34 @@ def test_is_auto_pointer(self): self.assertFalse( declarations.auto_ptr_traits.is_smart_pointer(decls[0].decl_type)) + def test_smart_pointer_value_type(self): + """ + Test smart_pointer_traits.value_type method. + + """ + + if self.config.xml_generator == "gccxml": + return + + criteria = declarations.declaration_matcher(name="yes1") + decls = declarations.matcher.find(criteria, self.global_ns) + vt = declarations.smart_pointer_traits.value_type(decls[0].decl_type) + self.assertIsInstance(vt, declarations.int_t) + + def test_auto_pointer_value_type(self): + """ + Test auto_pointer_traits.value_type method. + + """ + + if self.config.xml_generator == "gccxml": + return + + criteria = declarations.declaration_matcher(name="yes2") + decls = declarations.matcher.find(criteria, self.global_ns) + vt = declarations.auto_ptr_traits.value_type(decls[0].decl_type) + self.assertIsInstance(vt, declarations.double_t) + def create_suite(): suite = unittest.TestSuite()