From 1fa14f74a77df4d49bfd06b41a2ac17b0331d1d9 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Wed, 26 Oct 2005 07:08:18 +0000 Subject: [PATCH] add disown.i and li_attribute.i git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7726 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 2 + Examples/test-suite/disown.i | 47 ++++++++++++++++++++++ Examples/test-suite/li_attribute.i | 1 + Examples/test-suite/perl5/Makefile.in | 3 +- Examples/test-suite/perl5/disown_runme.pl | 10 +++++ Examples/test-suite/python/Makefile.in | 1 - Examples/test-suite/python/disown_runme.py | 6 +++ Examples/test-suite/ruby/Makefile.in | 3 +- Examples/test-suite/ruby/disown_runme.rb | 9 +++++ Examples/test-suite/ruby/track_objects.i | 2 +- Examples/test-suite/tcl/Makefile.in | 3 +- Examples/test-suite/tcl/disown_runme.tcl | 16 ++++++++ 12 files changed, 98 insertions(+), 5 deletions(-) create mode 100644 Examples/test-suite/disown.i create mode 100644 Examples/test-suite/perl5/disown_runme.pl create mode 100644 Examples/test-suite/python/disown_runme.py create mode 100644 Examples/test-suite/ruby/disown_runme.rb create mode 100644 Examples/test-suite/tcl/disown_runme.tcl diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index fe20cc691..ce185da0d 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -125,6 +125,7 @@ CPP_TEST_CASES += \ director_string \ director_unroll \ director_wombat \ + disown \ dynamic_cast \ empty \ enum_plus \ @@ -156,6 +157,7 @@ CPP_TEST_CASES += \ inline_initializer \ kind \ langobj \ + li_attribute \ li_carrays \ li_cdata \ li_cpointer \ diff --git a/Examples/test-suite/disown.i b/Examples/test-suite/disown.i new file mode 100644 index 000000000..b7fbb67bc --- /dev/null +++ b/Examples/test-suite/disown.i @@ -0,0 +1,47 @@ +%module disown + +%{ +#include +%} + +#pragma SWIG nowarn=453 + +%apply SWIGTYPE *DISOWN { A *disown }; + +%inline { + struct A + { + ~A() + { + // std::cout <<"delete A" << std::endl; + } + + + }; + + class B + { + A *_a; + public: + B() : _a(0) + { + } + + ~B() + { + if (_a) { + // std::cout <<"delete A from B" << std::endl; + delete _a; + } + // std::cout <<"delete B" << std::endl; + } + + int acquire(A *disown) + { + // std::cout <<"acquire A" << std::endl; + _a = disown; + return 5; + } + + }; +} diff --git a/Examples/test-suite/li_attribute.i b/Examples/test-suite/li_attribute.i index c5b0eed43..322f56312 100644 --- a/Examples/test-suite/li_attribute.i +++ b/Examples/test-suite/li_attribute.i @@ -1,5 +1,6 @@ %module li_attribute +%include exception.i %include attribute.i %attribute(A, int, a, get_a, set_a); diff --git a/Examples/test-suite/perl5/Makefile.in b/Examples/test-suite/perl5/Makefile.in index e2a5ef455..c910864e1 100644 --- a/Examples/test-suite/perl5/Makefile.in +++ b/Examples/test-suite/perl5/Makefile.in @@ -13,10 +13,11 @@ top_builddir = @top_builddir@ CPP_TEST_CASES += \ primitive_types \ - li_attribute \ + li_cdata \ li_cstring \ C_TEST_CASES += \ + li_cdata \ li_cstring \ diff --git a/Examples/test-suite/perl5/disown_runme.pl b/Examples/test-suite/perl5/disown_runme.pl new file mode 100644 index 000000000..0e8f8cb6b --- /dev/null +++ b/Examples/test-suite/perl5/disown_runme.pl @@ -0,0 +1,10 @@ +use disown; + +if (1) { + $a = new disown::A(); + $b = new disown::B(); + $c = $b->acquire($a); +} + + + diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index dcc9da2e8..500556fa7 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -24,7 +24,6 @@ CPP_TEST_CASES += \ input \ inplaceadd \ kwargs \ - li_attribute \ li_cstring \ li_cwstring \ li_implicit \ diff --git a/Examples/test-suite/python/disown_runme.py b/Examples/test-suite/python/disown_runme.py new file mode 100644 index 000000000..bc9583408 --- /dev/null +++ b/Examples/test-suite/python/disown_runme.py @@ -0,0 +1,6 @@ +from disown import * + +a = A() +b = B() + +b.acquire(a) diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index 578131de3..089606e07 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -15,10 +15,11 @@ CPP_TEST_CASES = \ track_objects \ track_objects_directors \ primitive_types \ - li_attribute \ + li_cdata \ li_cstring C_TEST_CASES += \ + li_cdata \ li_cstring include $(srcdir)/../common.mk diff --git a/Examples/test-suite/ruby/disown_runme.rb b/Examples/test-suite/ruby/disown_runme.rb new file mode 100644 index 000000000..afbaf7037 --- /dev/null +++ b/Examples/test-suite/ruby/disown_runme.rb @@ -0,0 +1,9 @@ +require 'disown' + +include Disown + + +a = A.new +b = B.new +b.acquire(a) + diff --git a/Examples/test-suite/ruby/track_objects.i b/Examples/test-suite/ruby/track_objects.i index d82e94a04..b6aef73d0 100644 --- a/Examples/test-suite/ruby/track_objects.i +++ b/Examples/test-suite/ruby/track_objects.i @@ -13,7 +13,7 @@ %typemap(argout) Foo** foo { /* %typemap(argout) Foo** foo */ - $result = SWIG_NewPointerObj((void *) *$1, $*1_descriptor, 0); + $result = SWIG_NewPointerObj((void *) *$1, $*1_descriptor, $track); } %apply SWIGTYPE *DISOWN {Foo* ownedFoo}; diff --git a/Examples/test-suite/tcl/Makefile.in b/Examples/test-suite/tcl/Makefile.in index 2eca05818..ed258b7af 100644 --- a/Examples/test-suite/tcl/Makefile.in +++ b/Examples/test-suite/tcl/Makefile.in @@ -13,12 +13,13 @@ top_builddir = @top_builddir@ CPP_TEST_CASES += \ primitive_types \ - li_attribute \ + li_cdata \ li_cstring \ li_cwstring \ li_std_wstring C_TEST_CASES += \ + li_cdata \ li_cstring \ li_cwstring diff --git a/Examples/test-suite/tcl/disown_runme.tcl b/Examples/test-suite/tcl/disown_runme.tcl new file mode 100644 index 000000000..d6647c037 --- /dev/null +++ b/Examples/test-suite/tcl/disown_runme.tcl @@ -0,0 +1,16 @@ + +# This is the union runtime testcase. It ensures that values within a +# union embedded within a struct can be set and read correctly. + +if [ catch { load ./disown[info sharedlibextension] disown} err_msg ] { + puts stderr "Could not load shared object:\n$err_msg" +} + +set x 0 +while {$x<100} { + set a [new_A] + B b + b acquire $a + incr x +} +