]> sigrok.org Git - libsigrok.git/blob - bindings/swig/templates.i
bindings: Wrap enum sr_configcap as Capability class.
[libsigrok.git] / bindings / swig / templates.i
1 /*
2  * This file is part of the libsigrok project.
3  *
4  * Copyright (C) 2015 Martin Ling <martin-sigrok@earth.li>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 %{
21 #include <libsigrokcxx/libsigrokcxx.hpp>
22 using namespace std;
23 %}
24
25 %include "std_string.i"
26 %include "std_shared_ptr.i"
27 %include "std_vector.i"
28 %include "std_map.i"
29 #ifdef SWIGJAVA
30 namespace std {
31   template <class _Key> class set {};
32 }
33 #else
34 %include "std_set.i"
35 #endif
36
37 %template(StringMap) std::map<std::string, std::string>;
38
39 %template(DriverMap)
40     std::map<std::string, std::shared_ptr<sigrok::Driver> >;
41 %template(InputFormatMap)
42     std::map<std::string, std::shared_ptr<sigrok::InputFormat> >;
43 %template(OutputFormatMap)
44     std::map<std::string, std::shared_ptr<sigrok::OutputFormat> >;
45
46 %template(HardwareDeviceVector)
47     std::vector<std::shared_ptr<sigrok::HardwareDevice> >;
48
49 %template(DeviceVector)
50     std::vector<std::shared_ptr<sigrok::Device> >;
51
52 %template(ChannelVector)
53     std::vector<std::shared_ptr<sigrok::Channel> >;
54
55 %template(ChannelGroupMap)
56     std::map<std::string, std::shared_ptr<sigrok::ChannelGroup> >;
57
58 /* Workaround for SWIG bug. The vector template instantiation
59    isn't needed but somehow fixes a bug that stops the wrapper
60    for the map instantiation from compiling. */
61 %template(ConfigVector)
62     std::vector<const sigrok::ConfigKey *>;
63 %template(ConfigMap)
64     std::map<const sigrok::ConfigKey *, Glib::VariantBase>;
65
66 /* Currently broken on Python. */
67 #ifndef SWIGPYTHON
68
69 %template(CapabilitySet)
70     std::set<const sigrok::Capability *>;
71
72 %template(ConfigKeys)
73     std::map<const sigrok::ConfigKey *, std::set<const sigrok::Capability *> >;
74
75 #endif
76
77 %template(OptionVector)
78     std::vector<std::shared_ptr<sigrok::Option> >;
79 %template(OptionMap)
80     std::map<std::string, std::shared_ptr<sigrok::Option> >;
81
82 %template(VariantVector)
83     std::vector<Glib::VariantBase>;
84 %template(VariantMap)
85     std::map<std::string, Glib::VariantBase>;
86
87 %template(QuantityFlagVector)
88     std::vector<const sigrok::QuantityFlag *>;
89
90 %template(TriggerStageVector)
91  std::vector<std::shared_ptr<sigrok::TriggerStage> >;
92
93 %template(TriggerMatchVector)
94  std::vector<std::shared_ptr<sigrok::TriggerMatch> >;