Better handling of return values. Some bugfixes.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10618 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ea05035844
commit
f74439e215
16 changed files with 208 additions and 58 deletions
14
Examples/c/return/Makefile
Normal file
14
Examples/c/return/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* *~
|
||||
|
||||
10
Examples/c/return/example.cxx
Normal file
10
Examples/c/return/example.cxx
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#include "example.h"
|
||||
|
||||
Bar foo_ret_val() {
|
||||
return Bar();
|
||||
}
|
||||
|
||||
Bar* foo_ret_ptr(Bar* bar) {
|
||||
return bar;
|
||||
}
|
||||
|
||||
16
Examples/c/return/example.h
Normal file
16
Examples/c/return/example.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include <stdio.h>
|
||||
|
||||
class Bar {
|
||||
private:
|
||||
int x;
|
||||
public:
|
||||
Bar() : x(0) {}
|
||||
~Bar() {}
|
||||
void set(int x) { this->x = x; }
|
||||
int get() { return x; }
|
||||
};
|
||||
|
||||
Bar foo_ret_val();
|
||||
//Bar& foo_ret_ref(Bar* bar);
|
||||
Bar* foo_ret_ptr(Bar* bar);
|
||||
|
||||
8
Examples/c/return/example.i
Normal file
8
Examples/c/return/example.i
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
%module example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include "example.h"
|
||||
|
||||
10
Examples/c/return/test.c
Normal file
10
Examples/c/return/test.c
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "example_proxy.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
Bar b = foo_ret_val();
|
||||
//Bar * bp = foo_ret_ptr(NULL);
|
||||
printf("x = %d\n", Bar_get(&b));
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue