add tcl+java example
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8140 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ebcf1a041d
commit
b4e4fe23ca
10 changed files with 144 additions and 13 deletions
29
Examples/tcl/java/Example.java
Normal file
29
Examples/tcl/java/Example.java
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
public class Example {
|
||||
public int mPublicInt;
|
||||
|
||||
public Example() {
|
||||
mPublicInt = 0;
|
||||
}
|
||||
|
||||
public Example(int IntVal) {
|
||||
mPublicInt = IntVal;
|
||||
}
|
||||
|
||||
|
||||
public int Add(int a, int b) {
|
||||
return (a+b);
|
||||
}
|
||||
|
||||
public float Add(float a, float b) {
|
||||
return (a+b);
|
||||
}
|
||||
|
||||
public String Add(String a, String b) {
|
||||
return (a+b);
|
||||
}
|
||||
|
||||
public Example Add(Example a, Example b) {
|
||||
return new Example(a.mPublicInt + b.mPublicInt);
|
||||
}
|
||||
}
|
||||
|
||||
28
Examples/tcl/java/Makefile
Normal file
28
Examples/tcl/java/Makefile
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
CXX = g++
|
||||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
CXXSRCS =
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
LIBS = -lm
|
||||
|
||||
all:: Example.class
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" CFLAGS="-fPIC" \
|
||||
TCL_CXXSHARED="gcj -fPIC -shared Example.class -lstdc++ " DEFS='' tcl_cpp
|
||||
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile tcl_clean
|
||||
rm -f *.class Example.h
|
||||
|
||||
check: all
|
||||
|
||||
run:
|
||||
tclsh runme.tcl
|
||||
|
||||
Example.class: Example.java
|
||||
gcj -v || exit 0
|
||||
gcj -fPIC -C -c -g Example.java
|
||||
gcjh Example
|
||||
|
||||
10
Examples/tcl/java/example.i
Normal file
10
Examples/tcl/java/example.i
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
%module example
|
||||
%include <gcj/cni.i>
|
||||
%include <jstring.i>
|
||||
|
||||
%{
|
||||
#include "Example.h"
|
||||
%}
|
||||
|
||||
|
||||
%include Example.h
|
||||
15
Examples/tcl/java/runme.tcl
Normal file
15
Examples/tcl/java/runme.tcl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
catch { load ./example[info sharedlibextension] example}
|
||||
|
||||
JvCreateJavaVM NULL
|
||||
JvAttachCurrentThread NULL NULL
|
||||
Example e1 1
|
||||
Example e2 2
|
||||
|
||||
puts "[e1 cget -mPublicInt]"
|
||||
puts "[e2 cget -mPublicInt]"
|
||||
|
||||
puts "[e2 Add 1 2]"
|
||||
puts "[e2 Add 1.0 2.0]"
|
||||
puts "[e2 Add '1' '2']"
|
||||
|
||||
JvDetachCurrentThread
|
||||
Loading…
Add table
Add a link
Reference in a new issue