]> sigrok.org Git - libsigrok.git/blobdiff - bindings/java/org/sigrok/core/classes/classes.i
java: Don't use SWIG attribute mechanism.
[libsigrok.git] / bindings / java / org / sigrok / core / classes / classes.i
index 44efc1c51e43f396c327e84b2710af2f292e3f5d..c5d9b27b6a36478d679156d2c3324931bc5ec5ff 100644 (file)
@@ -44,6 +44,8 @@ namespace Glib {
   class VariantBase {};
 }
 
+%include "bindings/swig/templates.i"
+
 /* Map between std::vector and java.util.Vector */
 %define VECTOR(CValue, JValue)
 
@@ -52,20 +54,12 @@ namespace Glib {
 %typemap(jstype) std::vector< CValue > "java.util.Vector<JValue>"
 
 %typemap(javain,
-    pre="  $javaclassname temp$javainput = $javaclassname.convertVector($javainput);",
+    pre="  $javaclassname temp$javainput = new $javaclassname();
+  for (JValue value : $javainput)
+    temp$javainput.add(value);",
     pgcppname="temp$javainput")
   std::vector< CValue > "$javaclassname.getCPtr(temp$javainput)"
 
-%typemap(javacode) std::vector< CValue > %{
-  static $javaclassname convertVector(java.util.Vector<JValue> in)
-  {
-    $javaclassname out = new $javaclassname();
-    for (JValue value : in)
-      out.add(value);
-    return out;
-  }
-%}
-
 %typemap(javaout) std::vector< CValue > {
   return (java.util.Vector<JValue>)$jnicall;
 }
@@ -100,20 +94,12 @@ VECTOR(std::shared_ptr<sigrok::HardwareDevice>, HardwareDevice)
   "java.util.Map<JKey, JValue>"
 
 %typemap(javain,
-    pre="  $javaclassname temp$javainput = $javaclassname.convertMap($javainput);",
+    pre="  $javaclassname temp$javainput = new $javaclassname();
+    for (java.util.Map.Entry<JKey, JValue> entry : $javainput.entrySet())
+      temp$javainput.set(entry.getKey(), entry.getValue());",
     pgcppname="temp$javainput")
   std::map< CKey, CValue > "$javaclassname.getCPtr(temp$javainput)"
 
-%typemap(javacode) std::map< CKey, CValue > %{
-  static $javaclassname convertMap(java.util.Map<JKey,JValue> in)
-  {
-    $javaclassname out = new $javaclassname();
-    for (java.util.Map.Entry<JKey, JValue> entry : in.entrySet())
-      out.set(entry.getKey(), entry.getValue());
-    return out;
-  }
-%}
-
 %typemap(javaout) std::map< CKey, CValue > {
   return (java.util.Map<JKey, JValue>)$jnicall;
 }
@@ -207,72 +193,6 @@ 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 or without options. */
-%ignore sigrok::InputFormat::create_input;
-
-%extend sigrok::InputFormat {
-  std::shared_ptr<sigrok::Input> create_input()
-  {
-    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() 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)
-  {
-    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. */
 
 %typemap(in, numinputs=0) JNIEnv * %{
@@ -373,19 +293,13 @@ typedef jobject jdatafeedcallback;
 
 %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_old_packet;
+/* Ignore these for now, need fixes. */
+%ignore sigrok::Context::create_analog_packet;
+%ignore sigrok::Context::create_meta_packet;
+%ignore sigrok::Meta::config;
 
 %include "bindings/swig/classes.i"