diff options
author | Marcelo Matus <mmatus@acms.arizona.edu> | 2005-12-30 08:54:56 +0000 |
---|---|---|
committer | Marcelo Matus <mmatus@acms.arizona.edu> | 2005-12-30 08:54:56 +0000 |
commit | e4b8871ae2774c12edc6c510f6ed73b4be28a624 (patch) | |
tree | 6bd1f9b883531c32814f0292aa5ae1cd7c252260 /Examples | |
parent | c567ffaf2704c24fad89944e0d44f90e1f7f3148 (diff) | |
download | swig-e4b8871ae2774c12edc6c510f6ed73b4be28a624.tar.gz |
add gcj and java->python initial support
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8134 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Examples')
-rw-r--r-- | Examples/python/check.list | 2 | ||||
-rw-r--r-- | Examples/python/java/Example.java | 29 | ||||
-rw-r--r-- | Examples/python/java/Makefile | 27 | ||||
-rw-r--r-- | Examples/python/java/example.cxx | 0 | ||||
-rw-r--r-- | Examples/python/java/example.i | 11 | ||||
-rw-r--r-- | Examples/python/java/runme.py | 16 |
6 files changed, 85 insertions, 0 deletions
diff --git a/Examples/python/check.list b/Examples/python/check.list index bc0303a04..0f969efd7 100644 --- a/Examples/python/check.list +++ b/Examples/python/check.list @@ -26,3 +26,5 @@ swigrun template varargs variables +java + diff --git a/Examples/python/java/Example.java b/Examples/python/java/Example.java new file mode 100644 index 000000000..91ddb1ac5 --- /dev/null +++ b/Examples/python/java/Example.java @@ -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); + } +} + diff --git a/Examples/python/java/Makefile b/Examples/python/java/Makefile new file mode 100644 index 000000000..6542a55b1 --- /dev/null +++ b/Examples/python/java/Makefile @@ -0,0 +1,27 @@ +CXX = gcj +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" \ + CXXSHARED="gcj -fPIC -shared Example.class" DEFS='' python_cpp + + +clean:: + $(MAKE) -f $(TOP)/Makefile python_clean + rm -f $(TARGET).py + rm -f *.class Example.h + +check: all + + +Example.class: Example.java + gcj -v || exit 0 + gcj -fPIC -C -c -g Example.java + gcjh Example + diff --git a/Examples/python/java/example.cxx b/Examples/python/java/example.cxx new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Examples/python/java/example.cxx diff --git a/Examples/python/java/example.i b/Examples/python/java/example.i new file mode 100644 index 000000000..eaf284a0a --- /dev/null +++ b/Examples/python/java/example.i @@ -0,0 +1,11 @@ +%module example +%include <gcj/cni.i> + +%include <jstring.i> + +%{ +#include "Example.h" +%} + + +%include Example.h diff --git a/Examples/python/java/runme.py b/Examples/python/java/runme.py new file mode 100644 index 000000000..0cec8a7cb --- /dev/null +++ b/Examples/python/java/runme.py @@ -0,0 +1,16 @@ +from example import * + +JvCreateJavaVM(None) +JvAttachCurrentThread(None, None) + +e1 = Example(1) +e2 = Example(2) + +print e1.Add(1,2) +print e1.Add(1.0,2.0) +e3 = e1.Add(e1,e2) +print e3.mPublicInt + +print e1.Add("1","2") + +JvDetachCurrentThread() |