Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add directorin typemap for Python and Ruby shared_ptr.
- Loading branch information
Showing
5 changed files
with
282 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
Examples/test-suite/python/li_boost_shared_ptr_director_runme.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.