]> sigrok.org Git - libsigrok.git/blob - bindings/swig/libsigrok.i
python: Finish input format support.
[libsigrok.git] / bindings / swig / libsigrok.i
1 /*
2  * This file is part of the libsigrok project.
3  *
4  * Copyright (C) 2013 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 %include "cpointer.i"
21 %include "carrays.i"
22 %include "stdint.i"
23
24 %{
25 #include "libsigrok/libsigrok.h"
26 %}
27
28 typedef void *gpointer;
29
30 typedef struct _GSList GSList;
31
32 struct _GSList
33 {
34         gpointer data;
35         GSList *next;
36 };
37
38 void g_slist_free(GSList *list);
39
40 GVariant *g_variant_new_uint64(uint64_t value);
41 GVariant *g_variant_new_boolean(gboolean value);
42 GVariant *g_variant_new_double(double value);
43 GVariant *g_variant_new_string(char *value);
44 GVariant *g_variant_new_tuple(GVariant *children[], unsigned long n_children);
45 char *g_variant_get_type_string(GVariant *value);
46 uint64_t g_variant_get_uint64(GVariant *value);
47 gboolean g_variant_get_boolean(GVariant *value);
48 double g_variant_get_double(GVariant *value);
49 char *g_variant_get_string(GVariant *value, unsigned long *length);
50 GVariant *g_variant_get_child_value(GVariant *value, unsigned long index);
51
52 typedef guint (*GHashFunc)(gconstpointer key);
53 typedef gboolean (*GEqualFunc)(gconstpointer a, gconstpointer b);
54 typedef void (*GDestroyNotify)(gpointer data);
55
56 GHashTable *g_hash_table_new_full(GHashFunc hash_func, GEqualFunc key_equal_func,
57         GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func);
58 void g_hash_table_insert(GHashTable *hash_table, gpointer key, gpointer value);
59 void g_hash_table_destroy(GHashTable *hash_table);
60
61 %constant guint g_str_hash(gconstpointer v);
62 %constant gboolean g_str_equal(gconstpointer v1, gconstpointer v2);;
63 %constant void g_free(gpointer mem);
64
65 gchar *g_strdup(const char *str);
66
67 %include "libsigrok/libsigrok.h"
68 #undef SR_API
69 #define SR_API
70 %ignore sr_config_info_name_get;
71 %include "libsigrok/proto.h"
72 %include "libsigrok/version.h"
73
74 %array_class(float, float_array);
75 %pointer_functions(GVariant *, gvariant_ptr_ptr);
76 %array_functions(GVariant *, gvariant_ptr_array);
77 %pointer_functions(struct sr_context *, sr_context_ptr_ptr);
78 %array_functions(struct sr_dev_driver *, sr_dev_driver_ptr_array);
79 %array_functions(struct sr_input_format *, sr_input_format_ptr_array);
80 %array_functions(struct sr_output_format *, sr_output_format_ptr_array);
81 %pointer_cast(gpointer, struct sr_dev_inst *, gpointer_to_sr_dev_inst_ptr);
82 %pointer_cast(void *, struct sr_datafeed_logic *, void_ptr_to_sr_datafeed_logic_ptr)
83 %pointer_cast(void *, struct sr_datafeed_analog *, void_ptr_to_sr_datafeed_analog_ptr)
84 %pointer_cast(void *, struct sr_probe *, void_ptr_to_sr_probe_ptr)
85 %pointer_cast(void *, struct sr_probe_group *, void_ptr_to_sr_probe_group_ptr)
86
87 %extend sr_input_format {
88         int call_format_match(const char *filename) {
89                 return $self->format_match(filename);
90         }
91
92         int call_init(struct sr_input *in, const char *filename) {
93                 return $self->init(in, filename);
94         }
95
96         int call_loadfile(struct sr_input *in, const char *filename) {
97                 return $self->loadfile(in, filename);
98         }
99 }