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:
parent
cdd920a6ca
commit
f84342a301
13 changed files with 205 additions and 36 deletions
|
|
@ -1105,11 +1105,9 @@ c: $(SRCS)
|
|||
$(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES)
|
||||
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(CLIBPREFIX)$(TARGET)$(SO)
|
||||
$(CC) $(MAIN) $(TARGET)_proxy.c -L. -l$(TARGET)
|
||||
LD_LIBRARY_PATH=`pwd`:LD_LIBRARY_PATH; export LD_LIBRARY_PATH
|
||||
|
||||
c_cpp: $(SRCS)
|
||||
$(SWIG) -c++ -c $(SWIGOPT) $(INTERFACE)
|
||||
$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
|
||||
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(CLIBPREFIX)$(TARGET)$(SO)
|
||||
$(CC) $(MAIN) $(TARGET)_proxy.c -L. -l$(TARGET)
|
||||
LD_LIBRARY_PATH=`pwd`:LD_LIBRARY_PATH; export LD_LIBRARY_PATH
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ all::
|
|||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MAIN='$(MAIN)' c_cpp
|
||||
|
||||
clean:
|
||||
rm -f *.o *.out *.so *.a
|
||||
rm -f *.o *.out *.so *.a *.dll *.exe *_wrap* *_proxy* *~
|
||||
|
||||
|
|
|
|||
14
Examples/c/reference/Makefile
Normal file
14
Examples/c/reference/Makefile
Normal 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* *~
|
||||
|
||||
19
Examples/c/reference/example.cxx
Normal file
19
Examples/c/reference/example.cxx
Normal 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());
|
||||
}
|
||||
|
||||
16
Examples/c/reference/example.h
Normal file
16
Examples/c/reference/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; }
|
||||
};
|
||||
|
||||
/*void foo_by_val(Bar bar);
|
||||
void foo_by_ref(Bar& bar);*/
|
||||
void foo_by_ptr(Bar* bar);
|
||||
|
||||
8
Examples/c/reference/example.i
Normal file
8
Examples/c/reference/example.i
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
%module example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include "example.h"
|
||||
|
||||
12
Examples/c/reference/main.c
Normal file
12
Examples/c/reference/main.c
Normal 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;
|
||||
}
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
SWIG = $(TOP)/../preinst-swig -debug-module 4 > tree.txt
|
||||
SRCS = example.c
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
|
|
@ -10,5 +10,5 @@ all::
|
|||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MAIN='$(MAIN)' c
|
||||
|
||||
clean:
|
||||
rm -f *.o *.so *.out *.a *~
|
||||
rm -f *.o *.so *.out *.a *.exe *.dll *_wrap* *_proxy* *~
|
||||
|
||||
|
|
|
|||
|
|
@ -22,5 +22,3 @@ int gcd(int x, int y) {
|
|||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@
|
|||
#include "example.h"
|
||||
%}
|
||||
|
||||
%typemap(in) double {
|
||||
/* hello */
|
||||
}
|
||||
|
||||
/* Let's just grab the original header file here */
|
||||
%include "example.h"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue