]> sigrok.org Git - libsigrok.git/blobdiff - bindings/java/org/sigrok/core/classes/classes.i
bindings: Use SR_DF_ANALOG, drop SR_DF_ANALOG_OLD support.
[libsigrok.git] / bindings / java / org / sigrok / core / classes / classes.i
index 3ca7d1aaa8a94daac0af6057006bfa2f4ad887bb..34323b16a8df7f24131cde337b38360f3aba1a69 100644 (file)
@@ -16,7 +16,7 @@
  * ------------
  * 
  * The sigrok-java API provides an object-oriented Java interface to the
- * functionality in libsigrok. It is built on top of the sigrok++ C++ API.
+ * functionality in libsigrok. It is built on top of the libsigrokcxx C++ API.
  * 
  * Getting started
  * ---------------
 
 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"
-%typemap(jstype) int fd "java.io.FileDescriptor"
-%typemap(javain) int fd "$javainput"
-
-%typemap(in) int fd {
-  jclass FileDescriptor = jenv->FindClass("java/io/FileDescriptor");
-  jfieldID fd = jenv->GetFieldID(FileDescriptor, "fd", "I");
-  $1 = jenv->GetIntField($input, fd);
-}
-
 /* Map Glib::VariantBase to a Variant class in Java */
 %rename(Variant) VariantBase;
 namespace Glib {
@@ -137,6 +124,11 @@ VECTOR(std::shared_ptr<sigrok::HardwareDevice>, HardwareDevice)
 
 MAP_COMMON(std::string, std::string, String, String)
 
+%typemap(jni) std::map<std::string, std::string>
+  "jobject"
+%typemap(jtype) std::map<std::string, std::string>
+  "java.util.Map<String,String>"
+
 %typemap(out) std::map<std::string, std::string> {
   jclass HashMap = jenv->FindClass("java/util/HashMap");
   jmethodID init = jenv->GetMethodID(HashMap, "<init>", "()V");
@@ -216,31 +208,69 @@ MAP_COMMON(const sigrok::ConfigKey *, Glib::VariantBase, ConfigKey, Variant)
 }
 
 /* Support Driver.scan() with no arguments. */
+%ignore sigrok::Driver::scan;
+
 %extend sigrok::Driver {
   std::vector<std::shared_ptr<sigrok::HardwareDevice> > scan()
   {
     std::map<const sigrok::ConfigKey *, Glib::VariantBase> options;
     return $self->scan(options);
   }
+
+  std::vector<std::shared_ptr<sigrok::HardwareDevice> > scan(
+    std::map<const sigrok::ConfigKey *, Glib::VariantBase> options)
+  {
+    return $self->scan(options);
+  }
 }
 
-/* Support InputFormat.create_input() with no options. */
+/* Support InputFormat.create_input() with or without options. */
+%ignore sigrok::InputFormat::create_input;
+
 %extend sigrok::InputFormat {
   std::shared_ptr<sigrok::Input> create_input()
   {
-    std::map<std::string, Glib::VariantBase> options;
+    return $self->create_input();
+  }
+
+  std::shared_ptr<sigrok::Input> create_input(
+    std::map<std::string, Glib::VariantBase> options)
+  {
     return $self->create_input(options);
   }
 }
 
-/* Support OutputFormat.create_output(device) with no options. */
+/* Support OutputFormat.create_output() with or without options. */
+%ignore sigrok::OutputFormat::create_output;
+
 %extend sigrok::OutputFormat {
   std::shared_ptr<sigrok::Output> create_output(
     std::shared_ptr<sigrok::Device> device)
   {
-    std::map<std::string, Glib::VariantBase> options;
+    return $self->create_output(device);
+  }
+
+  std::shared_ptr<sigrok::Output> create_output(
+    std::shared_ptr<sigrok::Device> device,
+    std::map<std::string, Glib::VariantBase> options)
+  {
     return $self->create_output(device, options);
   }
+
+  std::shared_ptr<sigrok::Output> create_output(
+    std::string filename,
+    std::shared_ptr<sigrok::Device> device)
+  {
+    return $self->create_output(filename, device);
+  }
+
+  std::shared_ptr<sigrok::Output> create_output(
+    std::string filename,
+    std::shared_ptr<sigrok::Device> device,
+    std::map<std::string, Glib::VariantBase> options)
+  {
+    return $self->create_output(filename, device, options);
+  }
 }
 
 /* Pass JNIEnv parameter to C++ extension methods requiring it. */
@@ -341,41 +371,6 @@ typedef jobject jdatafeedcallback;
   }
 }
 
-/* Support Java event source callbacks. */
-
-%typemap(javaimports) sigrok::EventSource
-  "import org.sigrok.core.interfaces.SourceCallback;"
-
-%inline {
-typedef jobject jsourcecallback;
-}
-
-%typemap(jni) jsourcecallback "jsourcecallback"
-%typemap(jtype) jsourcecallback "SourceCallback"
-%typemap(jstype) jsourcecallback "SourceCallback"
-%typemap(javain) jsourcecallback "$javainput"
-
-%extend sigrok::EventSource
-{
-  std::shared_ptr<sigrok::EventSource> create(
-    int fd, Glib::IOCondition events, int timeout,
-    JNIEnv *env, jsourcecallback obj)
-  {
-    (void) $self;
-    jclass obj_class = env->GetObjectClass(obj);
-    jmethodID method = env->GetMethodID(obj_class, "run", "(I)V");
-    jobject obj_ref = env->NewGlobalRef(obj);
-
-    return sigrok::EventSource::create(fd, events, timeout, [=] (int revents)
-    {
-      bool result = env->CallBooleanMethod(obj_ref, method, revents);
-      if (env->ExceptionCheck())
-        throw sigrok::Error(SR_ERR);
-      return result;
-    });
-  }
-}
-
 %include "doc.i"
 
 %define %attributevector(Class, Type, Name, Get)
@@ -389,4 +384,8 @@ typedef jobject jsourcecallback;
 %define %enumextras(Class)
 %enddef
 
+/* Ignore this for now, needs a fix. */
+%ignore sigrok::Context::create_analog_packet;
+
 %include "bindings/swig/classes.i"
+