]> sigrok.org Git - libsigrok.git/blobdiff - bindings/swig/classes.i
java: Don't use SWIG attribute mechanism.
[libsigrok.git] / bindings / swig / classes.i
index 1bbba90fd3fd53d4a482c8c7b99e58b42ae5aa3e..b87bbe1b06a33c3566c19e62a188fcb45078536c 100644 (file)
 
 #pragma SWIG nowarn=325,401
 
-%{
-#include "libsigrok/libsigrok.hpp"
-using namespace std;
-%}
-
 %include "typemaps.i"
-%include "std_string.i"
-%include "std_vector.i"
-%include "std_map.i"
-%include "std_shared_ptr.i"
 %include "exception.i"
 
 %{
@@ -66,7 +57,6 @@ template< class T > class enable_shared_from_this;
 %shared_ptr(sigrok::HardwareDevice);
 %shared_ptr(sigrok::Channel);
 %shared_ptr(sigrok::ChannelGroup);
-%shared_ptr(sigrok::EventSource);
 %shared_ptr(sigrok::Session);
 %shared_ptr(sigrok::SessionDevice);
 %shared_ptr(sigrok::Packet);
@@ -84,60 +74,14 @@ template< class T > class enable_shared_from_this;
 %shared_ptr(sigrok::Trigger);
 %shared_ptr(sigrok::TriggerStage);
 %shared_ptr(sigrok::TriggerMatch);
-
-%template(StringMap) std::map<std::string, std::string>;
-
-%template(DriverMap)
-    std::map<std::string, std::shared_ptr<sigrok::Driver> >;
-%template(InputFormatMap)
-    std::map<std::string, std::shared_ptr<sigrok::InputFormat> >;
-%template(OutputFormatMap)
-    std::map<std::string, std::shared_ptr<sigrok::OutputFormat> >;
-
-%template(HardwareDeviceVector)
-    std::vector<std::shared_ptr<sigrok::HardwareDevice> >;
-
-%template(DeviceVector)
-    std::vector<std::shared_ptr<sigrok::Device> >;
-
-%template(ChannelVector)
-    std::vector<std::shared_ptr<sigrok::Channel> >;
-
-%template(ChannelGroupMap)
-    std::map<std::string, std::shared_ptr<sigrok::ChannelGroup> >;
-
-/* Workaround for SWIG bug. The vector template instantiation
-   isn't needed but somehow fixes a bug that stops the wrapper
-   for the map instantiation from compiling. */
-%template(ConfigVector)
-    std::vector<const sigrok::ConfigKey *>;
-%template(ConfigMap)
-    std::map<const sigrok::ConfigKey *, Glib::VariantBase>;
-
-%template(OptionVector)
-    std::vector<std::shared_ptr<sigrok::Option> >;
-%template(OptionMap)
-    std::map<std::string, std::shared_ptr<sigrok::Option> >;
-
-%template(VariantVector)
-    std::vector<Glib::VariantBase>;
-%template(VariantMap)
-    std::map<std::string, Glib::VariantBase>;
-
-%template(QuantityFlagVector)
-    std::vector<const sigrok::QuantityFlag *>;
-
-%template(TriggerStageVector)
- std::vector<std::shared_ptr<sigrok::TriggerStage> >;
-
-%template(TriggerMatchVector)
- std::vector<std::shared_ptr<sigrok::TriggerMatch> >;
+%shared_ptr(sigrok::UserDevice);
 
 #define SR_API
 #define SR_PRIV
 
 %ignore sigrok::DatafeedCallbackData;
-%ignore sigrok::SourceCallbackData;
+
+#ifndef SWIGJAVA
 
 #define SWIG_ATTRIBUTE_TEMPLATE
 
@@ -160,11 +104,11 @@ typedef std::map<const sigrok::ConfigKey *, Glib::VariantBase>
     map_ConfigKey_Variant;
 }
 
-%attributeval(sigrok::Context,
+%attributemap(Context,
     map_string_Driver, drivers, drivers);
-%attributeval(sigrok::Context,
+%attributemap(Context,
     map_string_InputFormat, input_formats, input_formats);
-%attributeval(sigrok::Context,
+%attributemap(Context,
     map_string_OutputFormat, output_formats, output_formats);
 
 %attributestring(sigrok::Context,
@@ -175,9 +119,6 @@ typedef std::map<const sigrok::ConfigKey *, Glib::VariantBase>
 %attribute(sigrok::Context,
     const sigrok::LogLevel *, log_level, log_level, set_log_level);
 
-%attributestring(sigrok::Context,
-    std::string, log_domain, log_domain, set_log_domain);
-
 %attributestring(sigrok::Driver, std::string, name, name);
 %attributestring(sigrok::Driver, std::string, long_name, long_name);
 
@@ -196,27 +137,27 @@ typedef std::map<const sigrok::ConfigKey *, Glib::VariantBase>
 %attributestring(sigrok::Option,
     std::string, description, description);
 /* Currently broken on Python due to some issue with variant typemaps. */
-/* %attributeval(sigrok::Option,
+/* %attributevector(Option,
     Glib::VariantBase, default_value, default_value); */
-%attributeval(sigrok::Option,
+%attributevector(Option,
     std::vector<Glib::VariantBase>, values, values);
 
 %attributestring(sigrok::OutputFormat,
     std::string, name, name);
 %attributestring(sigrok::OutputFormat,
     std::string, description, description);
-%attributeval(sigrok::OutputFormat,
+%attributemap(OutputFormat,
     map_string_Option, options, options);
 
 %attributestring(sigrok::Device, std::string, vendor, vendor);
 %attributestring(sigrok::Device, std::string, model, model);
 %attributestring(sigrok::Device, std::string, version, version);
 
-%attributeval(sigrok::Device,
+%attributevector(Device,
     std::vector<std::shared_ptr<sigrok::Channel> >,
     channels, channels);
 
-%attributeval(sigrok::Device, map_string_ChannelGroup,
+%attributemap(Device, map_string_ChannelGroup,
     channel_groups, channel_groups);
 
 /* Using %attributestring for shared_ptr attribute. See
@@ -230,17 +171,17 @@ typedef std::map<const sigrok::ConfigKey *, Glib::VariantBase>
 %attribute(sigrok::Channel, unsigned int, index, index);
 
 %attributestring(sigrok::ChannelGroup, std::string, name, name);
-%attributeval(sigrok::ChannelGroup,
+%attributevector(ChannelGroup,
     std::vector<std::shared_ptr<sigrok::Channel> >,
     channels, channels);
 
 %attributestring(sigrok::Trigger, std::string, name, name);
-%attributeval(sigrok::Trigger,
+%attributevector(Trigger,
     std::vector<std::shared_ptr<sigrok::TriggerStage> >,
     stages, stages);
 
 %attribute(sigrok::TriggerStage, int, number, number);
-%attributeval(sigrok::TriggerStage,
+%attributevector(TriggerStage,
     std::vector<std::shared_ptr<sigrok::TriggerMatch> >,
     matches, matches);
 
@@ -249,7 +190,7 @@ typedef std::map<const sigrok::ConfigKey *, Glib::VariantBase>
 %attribute(sigrok::TriggerMatch, const sigrok::TriggerMatchType *, type, type);
 %attribute(sigrok::TriggerMatch, float, value, value);
 
-%attributeval(sigrok::Session,
+%attributevector(Session,
     std::vector<std::shared_ptr<sigrok::Device> >,
     devices, devices);
 
@@ -260,20 +201,22 @@ typedef std::map<const sigrok::ConfigKey *, Glib::VariantBase>
 
 %attribute(sigrok::Packet,
     const sigrok::PacketType *, type, type);
-%attributestring(sigrok::Packet,
-    std::shared_ptr<sigrok::PacketPayload>, payload, payload);
 
-%attributeval(sigrok::Meta, map_ConfigKey_Variant, config, config);
+%attributemap(Meta, map_ConfigKey_Variant, config, config);
 
+%attributevector(Analog,
+    std::vector<std::shared_ptr<sigrok::Channel> >, channels, channels);
 %attribute(sigrok::Analog, int, num_samples, num_samples);
 %attribute(sigrok::Analog, const sigrok::Quantity *, mq, mq);
 %attribute(sigrok::Analog, const sigrok::Unit *, unit, unit);
-%attributeval(sigrok::Analog, std::vector<const sigrok::QuantityFlag *>, mq_flags, mq_flags);
+%attributevector(Analog, std::vector<const sigrok::QuantityFlag *>, mq_flags, mq_flags);
+
+#endif
 
-%include "libsigrok/libsigrok.hpp"
+%include <libsigrokcxx/libsigrokcxx.hpp>
 
-%include "enums.i"
+%include "swig/enums.i"
 
 namespace sigrok {
-%include "libsigrok/enums.hpp"
+%include <libsigrokcxx/enums.hpp>
 }