Add a whole bunch of chicken runme scripts, and fix the bugs exposed by those scripts
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7155 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c4dc892c23
commit
420ba48099
72 changed files with 1085 additions and 412 deletions
52
SWIG/Examples/test-suite/cpp_basic.i
Normal file
52
SWIG/Examples/test-suite/cpp_basic.i
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/* This is a basic test of proxy classes, used by chicken */
|
||||
|
||||
%module cpp_basic
|
||||
|
||||
%newobject Bar::testFoo;
|
||||
|
||||
%inline %{
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
Foo(int a) : num(a) {}
|
||||
int num;
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
%{
|
||||
static Foo init_ref = Foo(-4);
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
class Bar {
|
||||
public:
|
||||
Bar() : fptr(0), fref(init_ref), fval(15) , cint(3) {}
|
||||
|
||||
Foo *fptr;
|
||||
Foo &fref;
|
||||
Foo fval;
|
||||
|
||||
const int cint;
|
||||
static const int global_cint = -4;
|
||||
|
||||
static Foo *global_fptr;
|
||||
static Foo &global_fref;
|
||||
static Foo global_fval;
|
||||
|
||||
int test(int a, Foo *f) {
|
||||
return a + (f ? f->num : 0) + fval.num;
|
||||
}
|
||||
|
||||
Foo *testFoo(int a, Foo *f) {
|
||||
return new Foo(2 * a + (f ? f->num : 0) + fval.num);
|
||||
}
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
%{
|
||||
Foo *Bar::global_fptr = NULL;
|
||||
Foo &Bar::global_fref = init_ref;
|
||||
Foo Bar::global_fval = Foo(3);
|
||||
%}
|
||||
Loading…
Add table
Add a link
Reference in a new issue