From: Martin Ling Date: Sat, 26 Jul 2014 18:11:11 +0000 (+0100) Subject: Java: Move interfaces into org.sigrok.core.interfaces, tidy build system. X-Git-Tag: libsigrok-0.4.0~1191 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=90bd7656401dd178756597d133581e08615093d7;p=libsigrok.git Java: Move interfaces into org.sigrok.core.interfaces, tidy build system. --- diff --git a/Makefile.am b/Makefile.am index 1168bf20..e81ead05 100644 --- a/Makefile.am +++ b/Makefile.am @@ -464,28 +464,29 @@ endif if BINDINGS_JAVA JDIR = bindings/java -JPKG = org/sigrok/core/classes -JINT = $(JDIR)/$(JPKG)/classes.i -JSRC = $(JDIR)/$(JPKG)/classes_wrap.cxx +JPKG = org/sigrok/core +JCLS = $(JDIR)/$(JPKG)/classes +JINT = $(JDIR)/$(JPKG)/interfaces +JSRC = $(JCLS)/*.java $(JINT)/*.java +JSWG = $(JCLS)/classes.i +JCXX = $(JCLS)/classes_wrap.cxx JLIB = $(JDIR)/libsigrok_java_core_classes.so JJAR = $(JDIR)/sigrok-core.jar java-build: $(JJAR) $(JLIB) -$(JSRC): $(JINT) bindings/swig/classes.i $(library_include_HEADERS) +$(JCXX): $(JSWG) bindings/swig/classes.i $(library_include_HEADERS) $(AM_V_GEN)swig -c++ -java -package org.sigrok.core.classes \ - -Iinclude -Ibindings/cxx/include \ - -outdir $(JDIR)/$(JPKG) $(JINT) + -Iinclude -Ibindings/cxx/include -outdir $(JCLS) $(JSWG) -$(JJAR): $(JSRC) $(JDIR)/$(JPKG)/*.java - $(AM_V_GEN)$(JAVAC) -sourcepath $(JDIR) $(JDIR)/$(JPKG)/*.java +$(JJAR): $(JCXX) + $(AM_V_GEN)$(JAVAC) -sourcepath $(JDIR) $(JSRC) $(AM_V_at)jar cf $(JJAR) -C $(JDIR) $(JPKG) -$(JLIB): $(JSRC) bindings/cxx/libsigrokxx.la $(library_include_HEADERS) +$(JLIB): $(JCXX) bindings/cxx/libsigrokxx.la $(library_include_HEADERS) $(AM_V_GEN)$(CXX) $(CXXFLAGS) -L.libs -Lbindings/cxx/.libs \ - -fno-strict-aliasing -fPIC -shared \ - $(JDIR)/$(JPKG)/classes_wrap.cxx -lsigrokxx \ - -o $(JLIB) + -fno-strict-aliasing -fPIC -shared $(JCLS)/classes_wrap.cxx \ + -lsigrokxx -o $(JLIB) java-install: $(INSTALL) -d $(libdir)/jni @@ -494,8 +495,10 @@ java-install: $(INSTALL) $(JJAR) -t $(datadir)/java java-clean: - rm -f $(JSRC) - rm -f $(JDIR)/$(JPKG)/*.class + rm -f $(JCXX) + rm -f $(JCLS)/*.java + rm -f $(JCLS)/*.class + rm -f $(JINT)/*.class rm -f $(JJAR) rm -f $(JLIB) diff --git a/bindings/java/org/sigrok/core/classes/DatafeedCallback.java b/bindings/java/org/sigrok/core/classes/DatafeedCallback.java deleted file mode 100644 index 82d1171f..00000000 --- a/bindings/java/org/sigrok/core/classes/DatafeedCallback.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.sigrok.core.classes; - -public interface DatafeedCallback -{ - public void run(Device device, Packet packet); -} diff --git a/bindings/java/org/sigrok/core/classes/LogCallback.java b/bindings/java/org/sigrok/core/classes/LogCallback.java deleted file mode 100644 index 4a09ab29..00000000 --- a/bindings/java/org/sigrok/core/classes/LogCallback.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.sigrok.core.classes; - -public interface LogCallback -{ - public void run(LogLevel loglevel, String message); -} diff --git a/bindings/java/org/sigrok/core/classes/SourceCallback.java b/bindings/java/org/sigrok/core/classes/SourceCallback.java deleted file mode 100644 index 53f59e3e..00000000 --- a/bindings/java/org/sigrok/core/classes/SourceCallback.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.sigrok.core.classes; - -public interface SourceCallback -{ - public void run(int revents); -} diff --git a/bindings/java/org/sigrok/core/classes/classes.i b/bindings/java/org/sigrok/core/classes/classes.i index b500dc6b..5e686dcb 100644 --- a/bindings/java/org/sigrok/core/classes/classes.i +++ b/bindings/java/org/sigrok/core/classes/classes.i @@ -7,6 +7,13 @@ } %} +/* Import interfaces. */ +%pragma(java) jniclassimports=%{ + import org.sigrok.core.interfaces.LogCallback; + import org.sigrok.core.interfaces.DatafeedCallback; + import org.sigrok.core.interfaces.SourceCallback; +%} + /* Map Java FileDescriptor objects to int fds */ %typemap(jni) int fd "jobject" %typemap(jtype) int fd "java.io.FileDescriptor" @@ -210,6 +217,9 @@ MAP_COMMON(const sigrok::ConfigKey *, Glib::VariantBase, ConfigKey, Variant) /* Support Java log callbacks. */ +%typemap(javaimports) sigrok::Context + "import org.sigrok.core.interfaces.LogCallback;" + %inline { typedef jobject jlogcallback; } @@ -249,6 +259,9 @@ typedef jobject jlogcallback; /* Support Java datafeed callbacks. */ +%typemap(javaimports) sigrok::Session + "import org.sigrok.core.interfaces.DatafeedCallback;" + %inline { typedef jobject jdatafeedcallback; } @@ -296,6 +309,9 @@ typedef jobject jdatafeedcallback; /* Support Java event source callbacks. */ +%typemap(javaimports) sigrok::EventSource + "import org.sigrok.core.interfaces.SourceCallback;" + %inline { typedef jobject jsourcecallback; } diff --git a/bindings/java/org/sigrok/core/interfaces/DatafeedCallback.java b/bindings/java/org/sigrok/core/interfaces/DatafeedCallback.java new file mode 100644 index 00000000..2c6036a6 --- /dev/null +++ b/bindings/java/org/sigrok/core/interfaces/DatafeedCallback.java @@ -0,0 +1,9 @@ +package org.sigrok.core.interfaces; + +import org.sigrok.core.classes.Device; +import org.sigrok.core.classes.Packet; + +public interface DatafeedCallback +{ + public void run(Device device, Packet packet); +} diff --git a/bindings/java/org/sigrok/core/interfaces/LogCallback.java b/bindings/java/org/sigrok/core/interfaces/LogCallback.java new file mode 100644 index 00000000..24ef4ed7 --- /dev/null +++ b/bindings/java/org/sigrok/core/interfaces/LogCallback.java @@ -0,0 +1,8 @@ +package org.sigrok.core.interfaces; + +import org.sigrok.core.classes.LogLevel; + +public interface LogCallback +{ + public void run(LogLevel loglevel, String message); +} diff --git a/bindings/java/org/sigrok/core/interfaces/SourceCallback.java b/bindings/java/org/sigrok/core/interfaces/SourceCallback.java new file mode 100644 index 00000000..a170fa90 --- /dev/null +++ b/bindings/java/org/sigrok/core/interfaces/SourceCallback.java @@ -0,0 +1,6 @@ +package org.sigrok.core.interfaces; + +public interface SourceCallback +{ + public void run(int revents); +}