aboutsummaryrefslogtreecommitdiff
path: root/swig/java
diff options
context:
space:
mode:
Diffstat (limited to 'swig/java')
-rw-r--r--swig/java/Makefile.am69
-rw-r--r--swig/java/test.java23
2 files changed, 92 insertions, 0 deletions
diff --git a/swig/java/Makefile.am b/swig/java/Makefile.am
new file mode 100644
index 0000000..5ced699
--- /dev/null
+++ b/swig/java/Makefile.am
@@ -0,0 +1,69 @@
+SWIG_JAVA_DIR = $(top_srcdir)/swig/java
+
+SWIG_CMD = $(SWIG) -I$(SWIG_JAVA_DIR) -I$(top_srcdir) -java
+
+swigjavafiles = \
+ xtractJNI.java \
+ xtract.java \
+ floatArray.java \
+ SWIGTYPE_p_float.java \
+ SWIGTYPE_p_void.java
+
+swigcfiles = xtractjavac_wrap.c
+
+swiggenfiles = $(swigjavafiles) $(swigcfiles)
+
+javafiles = $(swigjavafiles)
+
+# Note : the order of these is important since there is no formal
+# dependency checking.
+javaclasses = \
+ xtractJNI.class \
+ xtract.class \
+ floatArray.class \
+ SWIGTYPE_p_float.class \
+ SWIGTYPE_p_void.class
+
+$(swiggenfiles): ../xtract.i
+ $(SWIG_CMD) -package xtract.core -o xtractjavac_wrap.c ../xtract.i
+
+# Must have "exec" in the name.
+execjavawrapperdir = ${libdir}
+
+libxtract = $(top_builddir)/src/libxtract$(LIB_TAG).la
+
+AM_CPPFLAGS = -I$(top_srcdir)/include $(INCLTDL) $(JAVAINCCMD)
+
+nodist_xtractjavac_wrap_la_SOURCES = xtractjavac_wrap.c
+
+xtractjavac_wrap_la_LDFLAGS = \
+ -rpath $(execjavawrapperdir) \
+ -module \
+ -avoid-version \
+ -no-undefined \
+ $(libxtract)
+
+.java.class:
+ $(JAVAC) $(AM_JAVACFLAGS) $(JAVACFLAGS) $(swigjavafiles) -d . -classpath .
+ cp xtract/core/$@ .
+
+noinst_DATA = jar-stamp
+#
+jar-stamp: $(javaclasses) $(javafiles)
+ $(mkdir_p) xtract/core
+ $(mkdir_p) xtract/core/src
+ cp $(javafiles) xtract/core/src
+ touch jar-stamp
+#
+execjavawrapper_LTLIBRARIES = xtractjavac_wrap.la
+
+install-exec-hook:
+ ( cd $(DESTDIR)$(execjavawrapperdir) ; \
+ rm -f *.a *.la )
+
+clean-local:
+ rm -rf xtract
+
+CLEANFILES = $(javaclasses) jar-stamp
+
+MAINTAINERCLEANFILES = $(swiggenfiles) Makefile.in
diff --git a/swig/java/test.java b/swig/java/test.java
new file mode 100644
index 0000000..d20461a
--- /dev/null
+++ b/swig/java/test.java
@@ -0,0 +1,23 @@
+
+import xtract.core.*;
+
+public class test {
+ public static void main(String argv[]) {
+// System.loadLibrary("xtract");
+
+ int len = 5;
+ int retval = 0;
+ float result[];
+ floatArray a = new floatArray(len);
+ SWIGTYPE_p_void myvoid = null;
+
+ result = new float[1];
+
+ for (int i = 0; i < len; i++)
+ a.setitem(i, i * 2);
+
+ retval = xtract.xtract_mean(a.cast(), len, myvoid, result);
+
+ System.out.println(result);
+ }
+}