Skip to content

Commit 6a0bf82

Browse files
committed
Fix smart_pointer_traits.value_type method
and add tests for smart_pointer_traits.value_type and auto_pointer_traits.value_type
1 parent 3e73d65 commit 6a0bf82

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

pygccxml/declarations/smart_pointer_traits.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class internal_type_traits(object):
1818
@staticmethod
1919
def get_by_name(type_, name):
2020
if class_traits.is_my_case(type_):
21-
cls = class_traits.declaration_class(type_)
21+
cls = class_traits.get_declaration(type_)
2222
return type_traits.remove_declarated(
2323
cls.typedef(name, recursive=False).decl_type)
2424
elif class_declaration_traits.is_my_case(type_):
@@ -72,7 +72,7 @@ def value_type(type_):
7272
'Type "%s" is not an instantiation of \
7373
boost::shared_ptr or std::shared_ptr' %
7474
type_.decl_string)
75-
return internal_type_traits.get_by_name(type_, "value_type")
75+
return internal_type_traits.get_by_name(type_, "element_type")
7676

7777

7878
class auto_ptr_traits(object):

unittests/test_smart_pointer.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,34 @@ def test_is_auto_pointer(self):
7676
self.assertFalse(
7777
declarations.auto_ptr_traits.is_smart_pointer(decls[0].decl_type))
7878

79+
def test_smart_pointer_value_type(self):
80+
"""
81+
Test smart_pointer_traits.value_type method.
82+
83+
"""
84+
85+
if self.config.xml_generator == "gccxml":
86+
return
87+
88+
criteria = declarations.declaration_matcher(name="yes1")
89+
decls = declarations.matcher.find(criteria, self.global_ns)
90+
vt = declarations.smart_pointer_traits.value_type(decls[0].decl_type)
91+
self.assertIsInstance(vt, declarations.int_t)
92+
93+
def test_auto_pointer_value_type(self):
94+
"""
95+
Test auto_pointer_traits.value_type method.
96+
97+
"""
98+
99+
if self.config.xml_generator == "gccxml":
100+
return
101+
102+
criteria = declarations.declaration_matcher(name="yes2")
103+
decls = declarations.matcher.find(criteria, self.global_ns)
104+
vt = declarations.auto_ptr_traits.value_type(decls[0].decl_type)
105+
self.assertIsInstance(vt, declarations.double_t)
106+
79107

80108
def create_suite():
81109
suite = unittest.TestSuite()

0 commit comments

Comments
 (0)