aboutsummaryrefslogtreecommitdiff
path: root/Examples/test-suite/python/li_boost_shared_ptr_director_runme.py
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2019-10-08 15:48:26 -0700
committerHaibo Huang <hhb@google.com>2019-11-14 22:14:23 +0000
commit80b4251e302efb18c145a4786249d695397ed42a (patch)
tree12b9dec2513f7caa92e7835bc17ab16ae5635df6 /Examples/test-suite/python/li_boost_shared_ptr_director_runme.py
parent189852d8cdfd5863c52ec7aa73affd926c5a3f43 (diff)
parent1e36f51346d95f8b9848e682c2eb986e9cb9b4f4 (diff)
downloadswig-80b4251e302efb18c145a4786249d695397ed42a.tar.gz
Upgrade swig to 'rel-4.0.1'llvm-r383902b
Also run autogen.sh to generate configure files. Exempt-From-Owner-Approval: add myself to owners Change-Id: I391aa20428836ae74dab8c8427627ca4dbc8ecf4
Diffstat (limited to 'Examples/test-suite/python/li_boost_shared_ptr_director_runme.py')
-rw-r--r--Examples/test-suite/python/li_boost_shared_ptr_director_runme.py80
1 files changed, 80 insertions, 0 deletions
diff --git a/Examples/test-suite/python/li_boost_shared_ptr_director_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_director_runme.py
new file mode 100644
index 000000000..52868eacc
--- /dev/null
+++ b/Examples/test-suite/python/li_boost_shared_ptr_director_runme.py
@@ -0,0 +1,80 @@
+from li_boost_shared_ptr_director import *
+
+class Derived(Base):
+ def __init__(self, flag):
+ self.return_none = flag
+ Base.__init__(self)
+
+ def ret_c_shared_ptr(self):
+ if self.return_none:
+ return None
+ else:
+ return C()
+
+ def ret_c_by_value(self):
+ return C()
+
+ def take_c_by_value(self,c):
+ return c.get_m()
+
+ def take_c_by_ref(self,c):
+ return c.get_m()
+
+ def take_c_by_pointer(self,c):
+ if c:
+ return c.get_m()
+ else:
+ return -2
+
+ def take_c_by_pointer_ref(self,c):
+ if c:
+ return c.get_m()
+ else:
+ return -3
+
+ def take_c_shared_ptr_by_value(self,c):
+ if c:
+ return c.get_m()
+ else:
+ return -4
+
+ def take_c_shared_ptr_by_ref(self,c):
+ if c:
+ return c.get_m()
+ else:
+ return -5
+
+ def take_c_shared_ptr_by_pointer(self,c):
+ if c:
+ return c.get_m()
+ else:
+ return -6
+
+ def take_c_shared_ptr_by_pointer_ref(self,c):
+ if c:
+ return c.get_m()
+ else:
+ return -7
+
+a = Derived(False)
+b = Derived(True)
+
+assert call_ret_c_shared_ptr(a) == 1
+assert call_ret_c_shared_ptr(b) == -1
+assert call_ret_c_by_value(a) == 1
+
+assert call_take_c_by_value(a) == 5
+assert call_take_c_by_ref(a) == 6
+assert call_take_c_by_pointer(a) == 7
+assert call_take_c_by_pointer_ref(a) == 8
+assert call_take_c_shared_ptr_by_value(a) == 9
+assert call_take_c_shared_ptr_by_ref(a) == 10
+assert call_take_c_shared_ptr_by_pointer(a) == 11
+assert call_take_c_shared_ptr_by_pointer_ref(a) == 12
+
+assert call_take_c_by_pointer_with_null(a) == -2
+assert call_take_c_by_pointer_ref_with_null(a) == -3
+assert call_take_c_shared_ptr_by_value_with_null(a) == -4
+assert call_take_c_shared_ptr_by_ref_with_null(a) == -5
+assert call_take_c_shared_ptr_by_pointer_with_null(a) == -6
+assert call_take_c_shared_ptr_by_pointer_ref_with_null(a) == -7