X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=bindings%2Fjava%2Forg%2Fsigrok%2Fcore%2Fclasses%2Fclasses.i;h=413fb93ab44c6813672df832f51250dbc48ab371;hb=b71356d63104635116e556cd51daa0904e28fc99;hp=20e55d572dbd1947c78bbb5b97a836cdf6fc14fe;hpb=9fcf4d0b5b9969b0b7770e71994b960f15f7757f;p=libsigrok.git diff --git a/bindings/java/org/sigrok/core/classes/classes.i b/bindings/java/org/sigrok/core/classes/classes.i index 20e55d57..413fb93a 100644 --- a/bindings/java/org/sigrok/core/classes/classes.i +++ b/bindings/java/org/sigrok/core/classes/classes.i @@ -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" @@ -157,6 +189,10 @@ STRING_TO_SHARED_PTR_MAP(OutputFormat) MAP_COMMON(const sigrok::ConfigKey *, Glib::VariantBase, ConfigKey, Variant) +%typemap(jni) std::map "jobject" +%typemap(jtype) std::map + "java.util.Map" + %typemap(out) std::map { jclass HashMap = jenv->FindClass("java/util/HashMap"); jmethodID HashMap_init = jenv->GetMethodID(HashMap, "", "()V"); @@ -188,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 create_input() + { + std::map options; + return $self->create_input(options); + } +} + /* Support OutputFormat.create_output(device) with no options. */ %extend sigrok::OutputFormat { std::shared_ptr create_output( std::shared_ptr device) { - std::map options; + std::map options; return $self->create_output(device, options); } } @@ -206,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; } @@ -245,6 +293,9 @@ typedef jobject jlogcallback; /* Support Java datafeed callbacks. */ +%typemap(javaimports) sigrok::Session + "import org.sigrok.core.interfaces.DatafeedCallback;" + %inline { typedef jobject jdatafeedcallback; } @@ -292,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; } @@ -322,4 +376,21 @@ 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 + +/* Ignore this for now, needs a fix. */ +%ignore sigrok::Context::create_analog_packet; + %include "bindings/swig/classes.i" +