mirror of
https://github.com/nasa/trick.git
synced 2024-12-18 20:57:55 +00:00
Updated not to always pass disown flag for swig pointer conversion instead base on "own" value of the input object. (#1690)
This commit is contained in:
parent
d997759a6d
commit
a1d151c4c3
@ -51,7 +51,15 @@
|
||||
// TYPE *
|
||||
void * temp_ptr ;
|
||||
|
||||
if ( SWIG_IsOK(SWIG_ConvertPtr($input, &temp_ptr,$1_descriptor, SWIG_POINTER_DISOWN)) ) {
|
||||
SwigPyObject *sobj = SWIG_Python_GetSwigThis($input) ;
|
||||
// isDisown is set to SWIG_POINTER_DISOWN by default
|
||||
int isDisown = SWIG_POINTER_DISOWN ;
|
||||
if (sobj) {
|
||||
// isDisown is re-set based on whether the Python processor owns the input object
|
||||
isDisown = !sobj->own ;
|
||||
}
|
||||
|
||||
if ( SWIG_IsOK(SWIG_ConvertPtr($input, &temp_ptr,$1_descriptor, isDisown)) ) {
|
||||
$1 = reinterpret_cast< $1_ltype >(temp_ptr) ;
|
||||
} else if ( SWIG_IsOK(SWIG_ConvertPtr($input, &temp_ptr,SWIG_TypeQuery("_p_swig_ref"), 0)) ) {
|
||||
// Array to pointer assignment
|
||||
|
@ -2781,12 +2781,16 @@ def main():
|
||||
# Polymorphic assignments and access
|
||||
test_suite = "polymorphism"
|
||||
|
||||
test_so.a = trick.Cat()
|
||||
#test_so.a = trick.Cat()
|
||||
# use MM to allocate memory for a pointer declared in S_define
|
||||
test_so.a = trick.TMM_declare_var_s("Cat")
|
||||
TRICK_EXPECT_EQ( test_so.a.id , 1, test_suite , "single abstract ptr" )
|
||||
trick.trick_test_add_parent( test_suite , "single abstract ptr" , "1770735610")
|
||||
#test_so.a.speak()
|
||||
#test_so.a[0].speak()
|
||||
test_so.a = trick.Dog()
|
||||
#test_so.a = trick.Dog()
|
||||
# use MM to allocate memory for a pointer declared in S_define
|
||||
test_so.a = trick.TMM_declare_var_s("Dog")
|
||||
TRICK_EXPECT_EQ( test_so.a.id , 2, test_suite , "single abstract ptr" )
|
||||
|
||||
test_so.aarray[0] = trick.Cat()
|
||||
|
Loading…
Reference in New Issue
Block a user