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
|
|
|
%include "typemaps.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::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);
|
2015-10-02 14:18:35 +00:00
|
|
|
%shared_ptr(sigrok::Analog);
|
2014-07-17 17:45:05 +00:00
|
|
|
%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
|
|
|
|
|
|
|
#define SR_API
|
|
|
|
#define SR_PRIV
|
|
|
|
|
|
|
|
%ignore sigrok::DatafeedCallbackData;
|
|
|
|
|
2015-10-20 23:29:50 +00:00
|
|
|
#ifndef SWIGJAVA
|
|
|
|
|
2014-07-17 17:45:05 +00:00
|
|
|
#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
|
|
|
|
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
|
|
|
|
2015-10-02 14:18:35 +00:00
|
|
|
%attributevector(Analog,
|
2014-11-11 23:54:39 +00:00
|
|
|
std::vector<std::shared_ptr<sigrok::Channel> >, channels, channels);
|
2015-10-02 14:18:35 +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);
|
|
|
|
%attributevector(Analog, std::vector<const sigrok::QuantityFlag *>, mq_flags, mq_flags);
|
2014-09-11 20:25:52 +00:00
|
|
|
|
2015-10-20 23:29:50 +00:00
|
|
|
#endif
|
|
|
|
|
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
|
|
|
}
|