]> sigrok.org Git - libsigrok.git/blobdiff - bindings/java/org/sigrok/core/classes/classes.i
bindings: Support per-language extensions to EnumValue wrappers.
[libsigrok.git] / bindings / java / org / sigrok / core / classes / classes.i
index 5fdbc83e17cb97d590aa2591fb1c7f7ff888adf2..3ca7d1aaa8a94daac0af6057006bfa2f4ad887bb 100644 (file)
@@ -7,6 +7,38 @@
   }
 %}
 
+/* Documentation & importing interfaces. */
+%pragma(java) jniclassimports=%{
+/**
+ * @mainpage API Reference
+ * 
+ * Introduction
+ * ------------
+ * 
+ * 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.
+ * 
+ * Getting started
+ * ---------------
+ * 
+ * Usage of the sigrok-java API needs to begin with a call to Context.create().
+ * This will create the global libsigrok context and returns a Context object.
+ * Methods on this object provide access to the hardware drivers, input and
+ * output formats supported by the library, as well as means of creating other
+ * objects such as sessions and triggers.
+ * 
+ * Error handling
+ * --------------
+ * 
+ * When any libsigrok C API call returns an error, an Error exception is raised,
+ * which provides access to the error code and description.
+ */
+
+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"
@@ -192,12 +224,21 @@ MAP_COMMON(const sigrok::ConfigKey *, Glib::VariantBase, ConfigKey, Variant)
   }
 }
 
+/* Support InputFormat.create_input() with no options. */
+%extend sigrok::InputFormat {
+  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. */
 %extend sigrok::OutputFormat {
   std::shared_ptr<sigrok::Output> create_output(
     std::shared_ptr<sigrok::Device> device)
   {
-    std::map<std::string, std::string> options;
+    std::map<std::string, Glib::VariantBase> options;
     return $self->create_output(device, options);
   }
 }
@@ -210,6 +251,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 +293,9 @@ typedef jobject jlogcallback;
 
 /* Support Java datafeed callbacks. */
 
+%typemap(javaimports) sigrok::Session
+  "import org.sigrok.core.interfaces.DatafeedCallback;"
+
 %inline {
 typedef jobject jdatafeedcallback;
 }
@@ -296,6 +343,9 @@ typedef jobject jdatafeedcallback;
 
 /* Support Java event source callbacks. */
 
+%typemap(javaimports) sigrok::EventSource
+  "import org.sigrok.core.interfaces.SourceCallback;"
+
 %inline {
 typedef jobject jsourcecallback;
 }
@@ -326,4 +376,17 @@ typedef jobject jsourcecallback;
   }
 }
 
+%include "doc.i"
+
+%define %attributevector(Class, Type, Name, Get)
+%attributeval(sigrok::Class, Type, Name, Get);
+%enddef
+
+%define %attributemap(Class, Type, Name, Get)
+%attributeval(sigrok::Class, Type, Name, Get);
+%enddef
+
+%define %enumextras(Class)
+%enddef
+
 %include "bindings/swig/classes.i"