X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=bindings%2Fswig%2Fclasses.i;h=b87bbe1b06a33c3566c19e62a188fcb45078536c;hb=d0fa4ac1e786490b47b9f4284ad045f65d1e058d;hp=b688a857494fdb0a4b273b60b6db0720188eadc6;hpb=1411f7d8e9fa5d90d8140fc51eb44562dd626b7c;p=libsigrok.git diff --git a/bindings/swig/classes.i b/bindings/swig/classes.i index b688a857..b87bbe1b 100644 --- a/bindings/swig/classes.i +++ b/bindings/swig/classes.i @@ -19,16 +19,7 @@ #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; - -%template(DriverMap) - std::map >; -%template(InputFormatMap) - std::map >; -%template(OutputFormatMap) - std::map >; - -%template(HardwareDeviceVector) - std::vector >; - -%template(DeviceVector) - std::vector >; - -%template(ChannelVector) - std::vector >; - -%template(ChannelGroupMap) - std::map >; - -/* 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; -%template(ConfigMap) - std::map; - -%template(OptionVector) - std::vector >; -%template(OptionMap) - std::map >; - -%template(VariantVector) - std::vector; -%template(VariantMap) - std::map; - -%template(QuantityFlagVector) - std::vector; - -%template(TriggerStageVector) - std::vector >; - -%template(TriggerMatchVector) - std::vector >; +%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 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 %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,28 +137,27 @@ typedef std::map %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, 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, description, description); %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 >, channels, channels); -%attributeval(sigrok::Device, map_string_ChannelGroup, +%attributemap(Device, map_string_ChannelGroup, channel_groups, channel_groups); /* Using %attributestring for shared_ptr attribute. See @@ -231,17 +171,17 @@ typedef std::map %attribute(sigrok::Channel, unsigned int, index, index); %attributestring(sigrok::ChannelGroup, std::string, name, name); -%attributeval(sigrok::ChannelGroup, +%attributevector(ChannelGroup, std::vector >, channels, channels); %attributestring(sigrok::Trigger, std::string, name, name); -%attributeval(sigrok::Trigger, +%attributevector(Trigger, std::vector >, stages, stages); %attribute(sigrok::TriggerStage, int, number, number); -%attributeval(sigrok::TriggerStage, +%attributevector(TriggerStage, std::vector >, matches, matches); @@ -250,7 +190,7 @@ typedef std::map %attribute(sigrok::TriggerMatch, const sigrok::TriggerMatchType *, type, type); %attribute(sigrok::TriggerMatch, float, value, value); -%attributeval(sigrok::Session, +%attributevector(Session, std::vector >, devices, devices); @@ -261,18 +201,22 @@ typedef std::map %attribute(sigrok::Packet, const sigrok::PacketType *, type, type); -%attributestring(sigrok::Packet, - std::shared_ptr, payload, payload); -%attributeval(sigrok::Meta, map_ConfigKey_Variant, config, config); +%attributemap(Meta, map_ConfigKey_Variant, config, config); +%attributevector(Analog, + std::vector >, 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, mq_flags, mq_flags); +%attributevector(Analog, std::vector, mq_flags, mq_flags); + +#endif + +%include -%include "libsigrok/libsigrok.hpp" +%include "swig/enums.i" namespace sigrok { -%include "libsigrok/enums.hpp" +%include }