add disown.i and li_attribute.i
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7726 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
85f9345667
commit
3ebece429c
12 changed files with 98 additions and 5 deletions
|
|
@ -125,6 +125,7 @@ CPP_TEST_CASES += \
|
||||||
director_string \
|
director_string \
|
||||||
director_unroll \
|
director_unroll \
|
||||||
director_wombat \
|
director_wombat \
|
||||||
|
disown \
|
||||||
dynamic_cast \
|
dynamic_cast \
|
||||||
empty \
|
empty \
|
||||||
enum_plus \
|
enum_plus \
|
||||||
|
|
@ -156,6 +157,7 @@ CPP_TEST_CASES += \
|
||||||
inline_initializer \
|
inline_initializer \
|
||||||
kind \
|
kind \
|
||||||
langobj \
|
langobj \
|
||||||
|
li_attribute \
|
||||||
li_carrays \
|
li_carrays \
|
||||||
li_cdata \
|
li_cdata \
|
||||||
li_cpointer \
|
li_cpointer \
|
||||||
|
|
|
||||||
47
SWIG/Examples/test-suite/disown.i
Normal file
47
SWIG/Examples/test-suite/disown.i
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
%module disown
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include <iostream>
|
||||||
|
%}
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
%module li_attribute
|
%module li_attribute
|
||||||
|
|
||||||
|
%include exception.i
|
||||||
%include attribute.i
|
%include attribute.i
|
||||||
|
|
||||||
%attribute(A, int, a, get_a, set_a);
|
%attribute(A, int, a, get_a, set_a);
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,11 @@ top_builddir = @top_builddir@
|
||||||
|
|
||||||
CPP_TEST_CASES += \
|
CPP_TEST_CASES += \
|
||||||
primitive_types \
|
primitive_types \
|
||||||
li_attribute \
|
li_cdata \
|
||||||
li_cstring \
|
li_cstring \
|
||||||
|
|
||||||
C_TEST_CASES += \
|
C_TEST_CASES += \
|
||||||
|
li_cdata \
|
||||||
li_cstring \
|
li_cstring \
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
10
SWIG/Examples/test-suite/perl5/disown_runme.pl
Normal file
10
SWIG/Examples/test-suite/perl5/disown_runme.pl
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
use disown;
|
||||||
|
|
||||||
|
if (1) {
|
||||||
|
$a = new disown::A();
|
||||||
|
$b = new disown::B();
|
||||||
|
$c = $b->acquire($a);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -24,7 +24,6 @@ CPP_TEST_CASES += \
|
||||||
input \
|
input \
|
||||||
inplaceadd \
|
inplaceadd \
|
||||||
kwargs \
|
kwargs \
|
||||||
li_attribute \
|
|
||||||
li_cstring \
|
li_cstring \
|
||||||
li_cwstring \
|
li_cwstring \
|
||||||
li_implicit \
|
li_implicit \
|
||||||
|
|
|
||||||
6
SWIG/Examples/test-suite/python/disown_runme.py
Normal file
6
SWIG/Examples/test-suite/python/disown_runme.py
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
from disown import *
|
||||||
|
|
||||||
|
a = A()
|
||||||
|
b = B()
|
||||||
|
|
||||||
|
b.acquire(a)
|
||||||
|
|
@ -15,10 +15,11 @@ CPP_TEST_CASES = \
|
||||||
track_objects \
|
track_objects \
|
||||||
track_objects_directors \
|
track_objects_directors \
|
||||||
primitive_types \
|
primitive_types \
|
||||||
li_attribute \
|
li_cdata \
|
||||||
li_cstring
|
li_cstring
|
||||||
|
|
||||||
C_TEST_CASES += \
|
C_TEST_CASES += \
|
||||||
|
li_cdata \
|
||||||
li_cstring
|
li_cstring
|
||||||
|
|
||||||
include $(srcdir)/../common.mk
|
include $(srcdir)/../common.mk
|
||||||
|
|
|
||||||
9
SWIG/Examples/test-suite/ruby/disown_runme.rb
Normal file
9
SWIG/Examples/test-suite/ruby/disown_runme.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
require 'disown'
|
||||||
|
|
||||||
|
include Disown
|
||||||
|
|
||||||
|
|
||||||
|
a = A.new
|
||||||
|
b = B.new
|
||||||
|
b.acquire(a)
|
||||||
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
%typemap(argout) Foo** foo {
|
%typemap(argout) Foo** foo {
|
||||||
/* %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};
|
%apply SWIGTYPE *DISOWN {Foo* ownedFoo};
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,13 @@ top_builddir = @top_builddir@
|
||||||
|
|
||||||
CPP_TEST_CASES += \
|
CPP_TEST_CASES += \
|
||||||
primitive_types \
|
primitive_types \
|
||||||
li_attribute \
|
li_cdata \
|
||||||
li_cstring \
|
li_cstring \
|
||||||
li_cwstring \
|
li_cwstring \
|
||||||
li_std_wstring
|
li_std_wstring
|
||||||
|
|
||||||
C_TEST_CASES += \
|
C_TEST_CASES += \
|
||||||
|
li_cdata \
|
||||||
li_cstring \
|
li_cstring \
|
||||||
li_cwstring
|
li_cwstring
|
||||||
|
|
||||||
|
|
|
||||||
16
SWIG/Examples/test-suite/tcl/disown_runme.tcl
Normal file
16
SWIG/Examples/test-suite/tcl/disown_runme.tcl
Normal file
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue