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
This commit is contained in:
parent
c567ffaf27
commit
e4b8871ae2
13 changed files with 659 additions and 2 deletions
29
Examples/python/java/Example.java
Normal file
29
Examples/python/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);
|
||||
}
|
||||
}
|
||||
|
||||
27
Examples/python/java/Makefile
Normal file
27
Examples/python/java/Makefile
Normal file
|
|
@ -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
|
||||
|
||||
0
Examples/python/java/example.cxx
Normal file
0
Examples/python/java/example.cxx
Normal file
11
Examples/python/java/example.i
Normal file
11
Examples/python/java/example.i
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
%module example
|
||||
%include <gcj/cni.i>
|
||||
|
||||
%include <jstring.i>
|
||||
|
||||
%{
|
||||
#include "Example.h"
|
||||
%}
|
||||
|
||||
|
||||
%include Example.h
|
||||
16
Examples/python/java/runme.py
Normal file
16
Examples/python/java/runme.py
Normal file
|
|
@ -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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue