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:
parent
97ffcf1da7
commit
125f362852
10 changed files with 289 additions and 98 deletions
14
Examples/c/arguments/Makefile
Normal file
14
Examples/c/arguments/Makefile
Normal 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* *~
|
||||
|
||||
2
Examples/c/arguments/example.cxx
Normal file
2
Examples/c/arguments/example.cxx
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#include "example.h"
|
||||
|
||||
32
Examples/c/arguments/example.h
Normal file
32
Examples/c/arguments/example.h
Normal 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++;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
8
Examples/c/arguments/example.i
Normal file
8
Examples/c/arguments/example.i
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
%module example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include "example.h"
|
||||
|
||||
26
Examples/c/arguments/test.c
Normal file
26
Examples/c/arguments/test.c
Normal 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);
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue