]> sigrok.org Git - libsigrok.git/blame - bindings/swig/libsigrok.i
Rename 'struct sr_probe' to 'struct sr_channel' everywhere.
[libsigrok.git] / bindings / swig / libsigrok.i
CommitLineData
758b01ad 1/*
50985c20 2 * This file is part of the libsigrok project.
758b01ad
ML
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
758b01ad
ML
20%include "cpointer.i"
21%include "carrays.i"
ab0340c8 22%include "stdint.i"
758b01ad
ML
23
24%{
25#include "libsigrok/libsigrok.h"
26%}
27
8dc93c84 28typedef void *gpointer;
409d85b3 29typedef int gboolean;
7aafb892 30
758b01ad
ML
31typedef struct _GSList GSList;
32
33struct _GSList
34{
8dc93c84
UH
35 gpointer data;
36 GSList *next;
758b01ad
ML
37};
38
39void g_slist_free(GSList *list);
40
22f8cb54 41GVariant *g_variant_new_uint64(uint64_t value);
a8d162f6
ML
42GVariant *g_variant_new_boolean(gboolean value);
43GVariant *g_variant_new_double(double value);
44GVariant *g_variant_new_string(char *value);
45GVariant *g_variant_new_tuple(GVariant *children[], unsigned long n_children);
46char *g_variant_get_type_string(GVariant *value);
47uint64_t g_variant_get_uint64(GVariant *value);
48gboolean g_variant_get_boolean(GVariant *value);
49double g_variant_get_double(GVariant *value);
50char *g_variant_get_string(GVariant *value, unsigned long *length);
51GVariant *g_variant_get_child_value(GVariant *value, unsigned long index);
22f8cb54 52
f0e764de
ML
53typedef guint (*GHashFunc)(gconstpointer key);
54typedef gboolean (*GEqualFunc)(gconstpointer a, gconstpointer b);
55typedef void (*GDestroyNotify)(gpointer data);
56
57GHashTable *g_hash_table_new_full(GHashFunc hash_func, GEqualFunc key_equal_func,
58 GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func);
59void g_hash_table_insert(GHashTable *hash_table, gpointer key, gpointer value);
60void g_hash_table_destroy(GHashTable *hash_table);
61
409d85b3
ML
62%callback("%s_ptr");
63guint g_str_hash(gconstpointer v);
64gboolean g_str_equal(gconstpointer v1, gconstpointer v2);;
65void g_free(gpointer mem);
66%nocallback;
f0e764de
ML
67
68gchar *g_strdup(const char *str);
69
409d85b3
ML
70typedef struct _GString GString;
71
72struct _GString
73{
74 char *str;
75 gsize len;
76 gsize allocated_len;
77};
78
79gchar *g_string_free(GString *string, gboolean free_segment);
80
758b01ad
ML
81%include "libsigrok/libsigrok.h"
82#undef SR_API
83#define SR_API
84%ignore sr_config_info_name_get;
85%include "libsigrok/proto.h"
86%include "libsigrok/version.h"
87
15574a3c 88%array_class(float, float_array);
409d85b3
ML
89%pointer_functions(uint8_t *, uint8_ptr_ptr);
90%pointer_functions(uint64_t, uint64_ptr);
91%pointer_functions(GString *, gstring_ptr_ptr);
a8d162f6
ML
92%pointer_functions(GVariant *, gvariant_ptr_ptr);
93%array_functions(GVariant *, gvariant_ptr_array);
758b01ad
ML
94%pointer_functions(struct sr_context *, sr_context_ptr_ptr);
95%array_functions(struct sr_dev_driver *, sr_dev_driver_ptr_array);
a64198c8
ML
96%array_functions(struct sr_input_format *, sr_input_format_ptr_array);
97%array_functions(struct sr_output_format *, sr_output_format_ptr_array);
758b01ad 98%pointer_cast(gpointer, struct sr_dev_inst *, gpointer_to_sr_dev_inst_ptr);
966fcbe3 99%pointer_cast(void *, struct sr_datafeed_logic *, void_ptr_to_sr_datafeed_logic_ptr)
15574a3c 100%pointer_cast(void *, struct sr_datafeed_analog *, void_ptr_to_sr_datafeed_analog_ptr)
91aea754 101%pointer_cast(void *, struct sr_channel *, void_ptr_to_sr_channel_ptr)
660e398f 102%pointer_cast(void *, struct sr_channel_group *, void_ptr_to_sr_channel_group_ptr)
f0e764de
ML
103
104%extend sr_input_format {
105 int call_format_match(const char *filename) {
106 return $self->format_match(filename);
107 }
108
109 int call_init(struct sr_input *in, const char *filename) {
110 return $self->init(in, filename);
111 }
112
113 int call_loadfile(struct sr_input *in, const char *filename) {
114 return $self->loadfile(in, filename);
115 }
116}
409d85b3
ML
117
118%extend sr_output_format {
119 int call_init(struct sr_output *o) {
120 return $self->init(o);
121 }
122
123 int call_event(struct sr_output *o, int event_type, uint8_t **data_out,
124 uint64_t *length_out) {
125 return $self->event(o, event_type, data_out, length_out);
126 }
127
128 int call_data(struct sr_output *o, const void *data_in,
129 uint64_t length_in, uint8_t **data_out, uint64_t *length_out) {
130 return $self->data(o, data_in, length_in, data_out, length_out);
131 }
132
133 int call_receive(struct sr_output *o, const struct sr_dev_inst *sdi,
134 const struct sr_datafeed_packet *packet, GString **out) {
135 return $self->receive(o, sdi, packet, out);
136 }
137
138 int call_cleanup(struct sr_output *o) {
139 return $self->cleanup(o);
140 }
141}