Trying to work out the best solution for special cases of argument passing (arrays of objects, etc.). Some hacks in Swig_typemap_search() to distinguish between built-in types and objects, but this is experimental by now.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10652 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Maciej Drwal 2008-07-05 21:29:07 +00:00
commit 125f362852
10 changed files with 289 additions and 98 deletions

View file

@ -0,0 +1,14 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig -debug-module 4 > tree.txt
CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
MAIN = test.c
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MAIN='$(MAIN)' c_cpp
clean:
rm -f *.o *.out *.so *.a *.dll *.exe *_wrap* *_proxy* *~

View file

@ -0,0 +1,2 @@
#include "example.h"

View file

@ -0,0 +1,32 @@
#include <stdio.h>
class A {
public:
int i;
A(int i) : i(i) {}
};
class MyClass {
public:
void foo(A a, A* aa, A* aaa[5]) {
printf("a.i = %d\n", a.i);
printf("aa->i = %d\n", aa->i);
int i = 0;
while (aaa[i]) {
printf("aaa[%d]->i = %d\n", i, aaa[i]->i);
i++;
}
}
void bar(int x, int* px, int* xs[5]) {
printf("x = %d\n", x);
printf("*px = %d\n", *px);
int i = 0;
while (xs[i]) {
printf("*xs[%d] = %d\n", i, *xs[i]);
i++;
}
}
};

View file

@ -0,0 +1,8 @@
%module example
%{
#include "example.h"
%}
%include "example.h"

View file

@ -0,0 +1,26 @@
#include <stdio.h>
#include "example_proxy.h"
int main(int argc, char** argv) {
MyClass* mc = new_MyClass();
A* a = new_A(123), *b = new_A(234), *as[5];
int i, j = 321, *js[5];
for (i = 0; i < 4; ++i) {
as[i] = new_A(20 + i);
js[i] = (int*) malloc(sizeof(int));
*js[i] = 10 + i;
}
as[i] = 0;
js[i] = 0;
MyClass_bar(mc, j, &j, js);
MyClass_foo(mc, *a, b, as);
delete_A(a);
delete_MyClass(mc);
}