add java example and missing cvsignore files
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8137 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
24497eaf54
commit
bb84cbb4f6
9 changed files with 87 additions and 0 deletions
|
|
@ -21,3 +21,4 @@ std_vector
|
||||||
template
|
template
|
||||||
value
|
value
|
||||||
variables
|
variables
|
||||||
|
java
|
||||||
|
|
|
||||||
1
SWIG/Examples/ruby/free_function/.cvsignore
Normal file
1
SWIG/Examples/ruby/free_function/.cvsignore
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
example_wrap.cxx
|
||||||
2
SWIG/Examples/ruby/java/.cvsignore
Normal file
2
SWIG/Examples/ruby/java/.cvsignore
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
example_wrap.cxx
|
||||||
|
Example.class Example.h
|
||||||
29
SWIG/Examples/ruby/java/Example.java
Normal file
29
SWIG/Examples/ruby/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
SWIG/Examples/ruby/java/Makefile
Normal file
28
SWIG/Examples/ruby/java/Makefile
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
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='' ruby_cpp
|
||||||
|
|
||||||
|
|
||||||
|
clean::
|
||||||
|
$(MAKE) -f $(TOP)/Makefile python_clean
|
||||||
|
rm -f *.class Example.h
|
||||||
|
|
||||||
|
check: all
|
||||||
|
|
||||||
|
run:
|
||||||
|
ruby runme.rb
|
||||||
|
|
||||||
|
Example.class: Example.java
|
||||||
|
gcj -v || exit 0
|
||||||
|
gcj -fPIC -C -c -g Example.java
|
||||||
|
gcjh Example
|
||||||
|
|
||||||
0
SWIG/Examples/ruby/java/example.cxx
Normal file
0
SWIG/Examples/ruby/java/example.cxx
Normal file
9
SWIG/Examples/ruby/java/example.i
Normal file
9
SWIG/Examples/ruby/java/example.i
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
%module example
|
||||||
|
%include <gcj/cni.i>
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include "Example.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
%include Example.h
|
||||||
16
SWIG/Examples/ruby/java/runme.rb
Normal file
16
SWIG/Examples/ruby/java/runme.rb
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
require 'example'
|
||||||
|
|
||||||
|
Example.JvCreateJavaVM(nil)
|
||||||
|
Example.JvAttachCurrentThread(nil, nil)
|
||||||
|
|
||||||
|
e1 = Example::Example.new(1)
|
||||||
|
e2 = Example::Example.new(2)
|
||||||
|
|
||||||
|
print e1.Add(1,2),"\n"
|
||||||
|
print e1.Add(1.0,2.0),"\n"
|
||||||
|
e3 = e1.Add(e1,e2)
|
||||||
|
print e3.mPublicInt,"\n"
|
||||||
|
|
||||||
|
|
||||||
|
Example.JvDetachCurrentThread()
|
||||||
|
|
||||||
1
SWIG/Examples/ruby/mark_function/.cvsignore
Normal file
1
SWIG/Examples/ruby/mark_function/.cvsignore
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
example_wrap.cxx
|
||||||
Loading…
Add table
Add a link
Reference in a new issue