Modified parameter handling using typemaps. 'Reference' example. Visibility hint now applies only to the global functions.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10603 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Maciej Drwal 2008-06-28 16:22:07 +00:00
commit f84342a301
13 changed files with 205 additions and 36 deletions

View file

@ -0,0 +1,14 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig -debug-module 4
CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
MAIN = main.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,19 @@
#include <stdio.h>
#include "example.h"
void foo_by_val(Bar foo) {
foo.set(123);
printf("inside foo_by_val: %d\n", foo.get());
}
void foo_by_ref(Bar& foo) {
foo.set(123);
printf("inside foo_by_ref: %d\n", foo.get());
}
void foo_by_ptr(Bar* foo) {
foo->set(123);
printf("inside foo_by_ptr: %d\n", foo->get());
}

View 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; }
};
/*void foo_by_val(Bar bar);
void foo_by_ref(Bar& bar);*/
void foo_by_ptr(Bar* bar);

View file

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

View file

@ -0,0 +1,12 @@
#include <stdio.h>
#include "example_proxy.h"
int main(int argc, char** argv) {
Bar * bar = new_Bar();
foo_by_ptr(bar);
delete_Bar(bar);
return 0;
}