2014-07-17 17:45:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the libsigrok project.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Martin Ling <martin-sigrok@earth.li>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2014-07-19 14:27:41 +00:00
|
|
|
#pragma SWIG nowarn=325,401
|
|
|
|
|
2014-07-17 17:45:05 +00:00
|
|
|
%{
|
2015-08-15 14:10:36 +00:00
|
|
|
#include <libsigrokcxx/libsigrokcxx.hpp>
|
2014-07-17 17:45:05 +00:00
|
|
|
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"
|
|
|
|
|
|
|
|
%{
|
|
|
|
|
|
|
|
static int swig_exception_code(int sigrok_exception_code) {
|
|
|
|
switch (sigrok_exception_code) {
|
|
|
|
case SR_ERR_MALLOC:
|
|
|
|
return SWIG_MemoryError;
|
|
|
|
case SR_ERR_ARG:
|
|
|
|
return SWIG_ValueError;
|
|
|
|
default:
|
|
|
|
return SWIG_RuntimeError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
%exception {
|
|
|
|
try {
|
|
|
|
$action
|
|
|
|
} catch (sigrok::Error &e) {
|
|
|
|
SWIG_exception(swig_exception_code(e.result),
|
|
|
|
const_cast<char*>(e.what()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template< class T > class enable_shared_from_this;
|
|
|
|
|
|
|
|
%template(ContextShared) enable_shared_from_this<Context>;
|
|
|
|
|
|
|
|
%shared_ptr(sigrok::Context);
|
|
|
|
%shared_ptr(sigrok::Driver);
|
|
|
|
%shared_ptr(sigrok::Device);
|
|
|
|
%shared_ptr(sigrok::Configurable);
|
|
|
|
%shared_ptr(sigrok::HardwareDevice);
|
|
|
|
%shared_ptr(sigrok::Channel);
|
|
|
|
%shared_ptr(sigrok::ChannelGroup);
|
|
|
|
%shared_ptr(sigrok::EventSource);
|
|
|
|
%shared_ptr(sigrok::Session);
|
2014-09-06 15:06:00 +00:00
|
|
|
%shared_ptr(sigrok::SessionDevice);
|
2014-07-17 17:45:05 +00:00
|
|
|
%shared_ptr(sigrok::Packet);
|
|
|
|
%shared_ptr(sigrok::PacketPayload);
|
2014-07-20 01:20:13 +00:00
|
|
|
%shared_ptr(sigrok::Header);
|
|
|
|
%shared_ptr(sigrok::Meta);
|
2014-07-17 17:45:05 +00:00
|
|
|
%shared_ptr(sigrok::Analog);
|
|
|
|
%shared_ptr(sigrok::Logic);
|
|
|
|
%shared_ptr(sigrok::InputFormat);
|
2014-08-24 00:40:19 +00:00
|
|
|
%shared_ptr(sigrok::Input);
|
|
|
|
%shared_ptr(sigrok::InputDevice);
|
2014-07-26 15:03:25 +00:00
|
|
|
%shared_ptr(sigrok::Option);
|
2014-07-17 17:45:05 +00:00
|
|
|
%shared_ptr(sigrok::OutputFormat);
|
|
|
|
%shared_ptr(sigrok::Output);
|
|
|
|
%shared_ptr(sigrok::Trigger);
|
|
|
|
%shared_ptr(sigrok::TriggerStage);
|
|
|
|
%shared_ptr(sigrok::TriggerMatch);
|
2014-11-12 02:23:02 +00:00
|
|
|
%shared_ptr(sigrok::UserDevice);
|
2014-07-17 17:45:05 +00:00
|
|
|
|
|
|
|
%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>;
|
|
|
|
|
2014-07-26 15:03:25 +00:00
|
|
|
%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>;
|
|
|
|
|
2014-07-17 17:45:05 +00:00
|
|
|
%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> >;
|
|
|
|
|
|
|
|
#define SR_API
|
|
|
|
#define SR_PRIV
|
|
|
|
|
|
|
|
%ignore sigrok::DatafeedCallbackData;
|
|
|
|
%ignore sigrok::SourceCallbackData;
|
|
|
|
|
|
|
|
#define SWIG_ATTRIBUTE_TEMPLATE
|
|
|
|
|
|
|
|
%include "attribute.i"
|
|
|
|
|
|
|
|
%inline {
|
|
|
|
typedef std::map<std::string, std::shared_ptr<sigrok::Driver> >
|
|
|
|
map_string_Driver;
|
|
|
|
typedef std::map<std::string, std::shared_ptr<sigrok::InputFormat> >
|
|
|
|
map_string_InputFormat;
|
|
|
|
typedef std::map<std::string, std::shared_ptr<sigrok::OutputFormat> >
|
|
|
|
map_string_OutputFormat;
|
|
|
|
typedef std::map<std::string, std::shared_ptr<sigrok::ChannelGroup> >
|
|
|
|
map_string_ChannelGroup;
|
2014-07-26 15:03:25 +00:00
|
|
|
typedef std::map<std::string, std::shared_ptr<sigrok::Option> >
|
|
|
|
map_string_Option;
|
|
|
|
typedef std::map<std::string, Glib::VariantBase>
|
|
|
|
map_string_Variant;
|
2014-07-20 01:20:13 +00:00
|
|
|
typedef std::map<const sigrok::ConfigKey *, Glib::VariantBase>
|
|
|
|
map_ConfigKey_Variant;
|
2014-07-17 17:45:05 +00:00
|
|
|
}
|
|
|
|
|
2014-11-11 14:50:55 +00:00
|
|
|
%attributemap(Context,
|
2014-09-11 20:25:52 +00:00
|
|
|
map_string_Driver, drivers, drivers);
|
2014-11-11 14:50:55 +00:00
|
|
|
%attributemap(Context,
|
2014-09-11 20:25:52 +00:00
|
|
|
map_string_InputFormat, input_formats, input_formats);
|
2014-11-11 14:50:55 +00:00
|
|
|
%attributemap(Context,
|
2014-09-11 20:25:52 +00:00
|
|
|
map_string_OutputFormat, output_formats, output_formats);
|
2014-07-17 17:45:05 +00:00
|
|
|
|
|
|
|
%attributestring(sigrok::Context,
|
2014-09-11 20:25:52 +00:00
|
|
|
std::string, package_version, package_version);
|
2014-07-17 17:45:05 +00:00
|
|
|
%attributestring(sigrok::Context,
|
2014-09-11 20:25:52 +00:00
|
|
|
std::string, lib_version, lib_version);
|
2014-07-17 17:45:05 +00:00
|
|
|
|
|
|
|
%attribute(sigrok::Context,
|
2014-09-11 20:25:52 +00:00
|
|
|
const sigrok::LogLevel *, log_level, log_level, set_log_level);
|
2014-07-17 17:45:05 +00:00
|
|
|
|
|
|
|
%attributestring(sigrok::Context,
|
2014-09-11 20:25:52 +00:00
|
|
|
std::string, log_domain, log_domain, set_log_domain);
|
2014-07-17 17:45:05 +00:00
|
|
|
|
2014-09-11 20:25:52 +00:00
|
|
|
%attributestring(sigrok::Driver, std::string, name, name);
|
|
|
|
%attributestring(sigrok::Driver, std::string, long_name, long_name);
|
2014-07-17 17:45:05 +00:00
|
|
|
|
|
|
|
%attributestring(sigrok::InputFormat,
|
2014-09-11 20:25:52 +00:00
|
|
|
std::string, name, name);
|
2014-07-17 17:45:05 +00:00
|
|
|
%attributestring(sigrok::InputFormat,
|
2014-09-11 20:25:52 +00:00
|
|
|
std::string, description, description);
|
2014-07-17 17:45:05 +00:00
|
|
|
|
2014-08-24 00:40:19 +00:00
|
|
|
%attributestring(sigrok::Input,
|
2014-09-11 20:25:52 +00:00
|
|
|
std::shared_ptr<sigrok::InputDevice>, device, device);
|
2014-08-24 00:40:19 +00:00
|
|
|
|
2014-07-26 15:03:25 +00:00
|
|
|
%attributestring(sigrok::Option,
|
2014-09-11 20:25:52 +00:00
|
|
|
std::string, id, id);
|
2014-07-26 15:03:25 +00:00
|
|
|
%attributestring(sigrok::Option,
|
2014-09-11 20:25:52 +00:00
|
|
|
std::string, name, name);
|
2014-07-26 15:03:25 +00:00
|
|
|
%attributestring(sigrok::Option,
|
2014-09-11 20:25:52 +00:00
|
|
|
std::string, description, description);
|
2014-07-26 15:03:25 +00:00
|
|
|
/* Currently broken on Python due to some issue with variant typemaps. */
|
2014-11-11 14:50:55 +00:00
|
|
|
/* %attributevector(Option,
|
2014-09-11 20:25:52 +00:00
|
|
|
Glib::VariantBase, default_value, default_value); */
|
2014-11-11 14:50:55 +00:00
|
|
|
%attributevector(Option,
|
2014-09-11 20:25:52 +00:00
|
|
|
std::vector<Glib::VariantBase>, values, values);
|
2014-07-26 15:03:25 +00:00
|
|
|
|
2014-07-17 17:45:05 +00:00
|
|
|
%attributestring(sigrok::OutputFormat,
|
2014-09-11 20:25:52 +00:00
|
|
|
std::string, name, name);
|
2014-07-17 17:45:05 +00:00
|
|
|
%attributestring(sigrok::OutputFormat,
|
2014-09-11 20:25:52 +00:00
|
|
|
std::string, description, description);
|
2014-11-11 14:50:55 +00:00
|
|
|
%attributemap(OutputFormat,
|
2014-09-11 20:25:52 +00:00
|
|
|
map_string_Option, options, options);
|
2014-07-17 17:45:05 +00:00
|
|
|
|
2014-09-11 20:25:52 +00:00
|
|
|
%attributestring(sigrok::Device, std::string, vendor, vendor);
|
|
|
|
%attributestring(sigrok::Device, std::string, model, model);
|
|
|
|
%attributestring(sigrok::Device, std::string, version, version);
|
2014-07-17 17:45:05 +00:00
|
|
|
|
2014-11-11 14:50:55 +00:00
|
|
|
%attributevector(Device,
|
2014-07-17 17:45:05 +00:00
|
|
|
std::vector<std::shared_ptr<sigrok::Channel> >,
|
2014-09-11 20:25:52 +00:00
|
|
|
channels, channels);
|
2014-07-17 17:45:05 +00:00
|
|
|
|
2014-11-11 14:50:55 +00:00
|
|
|
%attributemap(Device, map_string_ChannelGroup,
|
2014-09-11 20:25:52 +00:00
|
|
|
channel_groups, channel_groups);
|
2014-07-24 11:41:49 +00:00
|
|
|
|
2014-07-17 17:45:05 +00:00
|
|
|
/* Using %attributestring for shared_ptr attribute. See
|
|
|
|
http://sourceforge.net/p/swig/mailman/message/31832070/ */
|
|
|
|
%attributestring(sigrok::HardwareDevice,
|
2014-09-11 20:25:52 +00:00
|
|
|
std::shared_ptr<sigrok::Driver>, driver, driver);
|
2014-07-17 17:45:05 +00:00
|
|
|
|
2014-09-11 20:25:52 +00:00
|
|
|
%attributestring(sigrok::Channel, std::string, name, name, set_name);
|
|
|
|
%attribute(sigrok::Channel, bool, enabled, enabled, set_enabled);
|
|
|
|
%attribute(sigrok::Channel, const sigrok::ChannelType *, type, type);
|
|
|
|
%attribute(sigrok::Channel, unsigned int, index, index);
|
2014-07-17 17:45:05 +00:00
|
|
|
|
2014-09-11 20:25:52 +00:00
|
|
|
%attributestring(sigrok::ChannelGroup, std::string, name, name);
|
2014-11-11 14:50:55 +00:00
|
|
|
%attributevector(ChannelGroup,
|
2014-07-17 17:45:05 +00:00
|
|
|
std::vector<std::shared_ptr<sigrok::Channel> >,
|
2014-09-11 20:25:52 +00:00
|
|
|
channels, channels);
|
2014-07-17 17:45:05 +00:00
|
|
|
|
2014-09-11 20:25:52 +00:00
|
|
|
%attributestring(sigrok::Trigger, std::string, name, name);
|
2014-11-11 14:50:55 +00:00
|
|
|
%attributevector(Trigger,
|
2014-07-17 17:45:05 +00:00
|
|
|
std::vector<std::shared_ptr<sigrok::TriggerStage> >,
|
2014-09-11 20:25:52 +00:00
|
|
|
stages, stages);
|
2014-07-17 17:45:05 +00:00
|
|
|
|
2014-09-11 20:25:52 +00:00
|
|
|
%attribute(sigrok::TriggerStage, int, number, number);
|
2014-11-11 14:50:55 +00:00
|
|
|
%attributevector(TriggerStage,
|
2014-07-17 17:45:05 +00:00
|
|
|
std::vector<std::shared_ptr<sigrok::TriggerMatch> >,
|
2014-09-11 20:25:52 +00:00
|
|
|
matches, matches);
|
2014-07-17 17:45:05 +00:00
|
|
|
|
|
|
|
%attributestring(sigrok::TriggerMatch,
|
2014-09-11 20:25:52 +00:00
|
|
|
std::shared_ptr<sigrok::Channel>, channel, channel);
|
|
|
|
%attribute(sigrok::TriggerMatch, const sigrok::TriggerMatchType *, type, type);
|
|
|
|
%attribute(sigrok::TriggerMatch, float, value, value);
|
2014-07-17 17:45:05 +00:00
|
|
|
|
2014-11-11 14:50:55 +00:00
|
|
|
%attributevector(Session,
|
2014-07-17 17:45:05 +00:00
|
|
|
std::vector<std::shared_ptr<sigrok::Device> >,
|
2014-09-11 20:25:52 +00:00
|
|
|
devices, devices);
|
2014-07-17 17:45:05 +00:00
|
|
|
|
2014-07-19 21:45:35 +00:00
|
|
|
%attributestring(sigrok::Session,
|
2014-09-11 20:25:52 +00:00
|
|
|
std::shared_ptr<sigrok::Trigger>, trigger, trigger, set_trigger);
|
2014-07-19 21:45:35 +00:00
|
|
|
|
2014-10-12 16:53:10 +00:00
|
|
|
%attributestring(sigrok::Session, std::string, filename, filename);
|
|
|
|
|
2014-10-10 18:37:47 +00:00
|
|
|
%attribute(sigrok::Packet,
|
|
|
|
const sigrok::PacketType *, type, type);
|
2014-07-20 01:20:13 +00:00
|
|
|
|
2014-11-11 14:50:55 +00:00
|
|
|
%attributemap(Meta, map_ConfigKey_Variant, config, config);
|
2014-07-17 17:45:05 +00:00
|
|
|
|
2014-11-11 23:54:39 +00:00
|
|
|
%attributevector(Analog,
|
|
|
|
std::vector<std::shared_ptr<sigrok::Channel> >, channels, channels);
|
2014-09-11 20:25:52 +00:00
|
|
|
%attribute(sigrok::Analog, int, num_samples, num_samples);
|
|
|
|
%attribute(sigrok::Analog, const sigrok::Quantity *, mq, mq);
|
|
|
|
%attribute(sigrok::Analog, const sigrok::Unit *, unit, unit);
|
2014-11-11 14:50:55 +00:00
|
|
|
%attributevector(Analog, std::vector<const sigrok::QuantityFlag *>, mq_flags, mq_flags);
|
2014-09-11 20:25:52 +00:00
|
|
|
|
2015-08-15 14:10:36 +00:00
|
|
|
%include <libsigrokcxx/libsigrokcxx.hpp>
|
2014-09-11 20:25:52 +00:00
|
|
|
|
2015-08-15 17:43:29 +00:00
|
|
|
%include "swig/enums.i"
|
2014-11-11 01:18:58 +00:00
|
|
|
|
|
|
|
namespace sigrok {
|
2015-08-15 14:10:36 +00:00
|
|
|
%include <libsigrokcxx/enums.hpp>
|
2014-09-11 20:25:52 +00:00
|
|
|
}
|