[Libxtract-commits] SF.net SVN: libxtract: [95] trunk
Status: Alpha
Brought to you by:
postlude
From: <pos...@us...> - 2007-09-06 14:05:48
|
Revision: 95 http://libxtract.svn.sourceforge.net/libxtract/?rev=95&view=rev Author: postlude Date: 2007-09-06 07:05:37 -0700 (Thu, 06 Sep 2007) Log Message: ----------- Java bindings (with simple test) now working. Unified Python and Java bindings tests. Modified Paths: -------------- trunk/configure.in trunk/src/scalar.c trunk/swig/java/Makefile.am trunk/swig/java/test.java trunk/swig/python/test.py trunk/xtract/xtract_scalar.h Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2007-09-05 17:57:09 UTC (rev 94) +++ trunk/configure.in 2007-09-06 14:05:37 UTC (rev 95) @@ -85,6 +85,15 @@ echo ]) +dnl set a specific java compiler +AC_ARG_WITH(javac, + [ --with-javac=compiler set a specific java compiler (determined automatically if not set) ], + [JAVAC="$withval" + echo + echo "JAVAC is set to $withval" + echo + ]) + dnl If --enable-swig, make with java bindings AC_ARG_WITH(java, [ --with-java If --enable-swig - make with java bindings (default=no) ], @@ -150,12 +159,14 @@ fi if [[ "$with_java" = "true" ]] ; then - AC_PROG_JAVAC + if test "$JAVAC" = "" + then + AC_PROG_JAVAC + fi if test "$JAVAC" = "javac" then AC_JNI_INCLUDE_DIR - for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS do CFLAGS="$CFLAGS -I$JNI_INCLUDE_DIR" Modified: trunk/src/scalar.c =================================================================== --- trunk/src/scalar.c 2007-09-05 17:57:09 UTC (rev 94) +++ trunk/src/scalar.c 2007-09-06 14:05:37 UTC (rev 95) @@ -36,7 +36,7 @@ #define expf exp #endif -int test(void){ +void test(void){ printf("Hello world"); } Modified: trunk/swig/java/Makefile.am =================================================================== --- trunk/swig/java/Makefile.am 2007-09-05 17:57:09 UTC (rev 94) +++ trunk/swig/java/Makefile.am 2007-09-06 14:05:37 UTC (rev 95) @@ -1,22 +1,10 @@ -SWIG_JAVA_DIR = $(top_srcdir)/swig/java - -SWIG_CMD = $(SWIG) -I$(SWIG_JAVA_DIR) -I$(top_srcdir) -java - -swigjavafiles = \ +javasources = \ 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 \ @@ -24,46 +12,29 @@ SWIGTYPE_p_float.class \ SWIGTYPE_p_void.class -$(swiggenfiles): ../xtract.i - $(SWIG_CMD) -package xtract.core -o xtractjavac_wrap.c ../xtract.i +MAINTAINERCLEANFILES = $(javasources) Makefile.in -# Must have "exec" in the name. -execjavawrapperdir = ${libdir} +BUILT_SOURCES = $(srcdir)/xtract_wrap.c +SWIG_SOURCES = ../xtract.i -libxtract = $(top_builddir)/src/libxtract$(LIB_TAG).la +lib_LTLIBRARIES = libjxtract.la +libjxtract_la_SOURCES = $(srcdir)/xtract_wrap.c $(SWIG_SOURCES) +libjxtract_la_CFLAGS = $(SWIG_PYTHON_CPPFLAGS) -I$(top_srcdir)/src +ibjxtract_la_LDFLAGS = -module -lxtract +libjxtract_la_LIBADD = $(top_srcdir)/src/libxtract.la -AM_CPPFLAGS = -I$(top_srcdir)/include $(INCLTDL) $(JAVAINCCMD) +SWIG_JAVA_OPT = -java -package xtract.core -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) - -noinst_DATA = jar-stamp -# -jar-stamp: $(javaclasses) $(javafiles) +xtract_wrap.c : $(SWIG_SOURCES) + $(SWIG) $(SWIG_JAVA_OPT) -I$(top_srcdir) -o $@ $< + $(JAVAC) $(javasources) mkdir -p xtract/core mkdir -p xtract/core/src - cp $(javafiles) xtract/core/src - cp $(javaclasses) xtract/core - touch jar-stamp -# -execjavawrapper_LTLIBRARIES = xtractjavac_wrap.la + mv $(javasources) xtract/core/src + mv $(javaclasses) xtract/core + $(JAVAC) test.java -install-exec-hook: - ( cd $(DESTDIR)$(execjavawrapperdir) ; \ - rm -f *.a *.la ) - clean-local: - rm -rf xtract + -rm -f libjxtract.so xtract_wrap.c $(javasources) $(javaclasses) test.class + -rm -rf xtract -CLEANFILES = $(javaclasses) jar-stamp - -MAINTAINERCLEANFILES = $(swiggenfiles) Makefile.in Modified: trunk/swig/java/test.java =================================================================== --- trunk/swig/java/test.java 2007-09-05 17:57:09 UTC (rev 94) +++ trunk/swig/java/test.java 2007-09-06 14:05:37 UTC (rev 95) @@ -3,8 +3,17 @@ public class test { public static void main(String argv[]) { -// System.loadLibrary("xtract"); + try { + System.loadLibrary("jxtract"); + } + catch (UnsatisfiedLinkError e) { + System.out.println("Failed to load the library \"jxtract\""); + System.out.println(e.toString()); + } + + System.out.println("\nRunning libxtract Java bindings test...\n"); + int len = 5; int retval = 0; float result[]; @@ -13,11 +22,20 @@ result = new float[1]; - for (int i = 0; i < len; i++) + System.out.print("The mean of: "); + + for (int i = 0; i < len; i++){ + System.out.print(i * 2 + ", "); a.setitem(i, i * 2); + } + System.out.print("is: "); + retval = xtract.xtract_mean(a.cast(), len, myvoid, result); - System.out.println(result); + System.out.print(result[0] + "\n"); + + System.out.println("\nFinished!\n\n"); + } } Modified: trunk/swig/python/test.py =================================================================== --- trunk/swig/python/test.py 2007-09-05 17:57:09 UTC (rev 94) +++ trunk/swig/python/test.py 2007-09-06 14:05:37 UTC (rev 95) @@ -1,15 +1,22 @@ #!/usr/bin/python -import xtract +try: + import xtract +except ImportError: + print 'Failed to load the library "jxtract"' +print '\nRunning libxtract Python bindings test...\n' + len = 5 a = xtract.floatArray(len) +temp = [] for i in range(0, len): a[i] = 2 * i + temp.append(str(a[i])) -retval,result = xtract.xtract_mean(a,len,None) +print 'The mean of ' + ', '.join(temp) + ' is: %.2f' % \ + xtract.xtract_mean(a,len,None)[1] -print result - +print '\nFinished!\n' Modified: trunk/xtract/xtract_scalar.h =================================================================== --- trunk/xtract/xtract_scalar.h 2007-09-05 17:57:09 UTC (rev 94) +++ trunk/xtract/xtract_scalar.h 2007-09-06 14:05:37 UTC (rev 95) @@ -34,6 +34,8 @@ * @{ */ +void test(void); + /** \brief Extract the mean of an input vector * * \param *data: a pointer to the first element This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |