2 * This file is part of the libsigrok project.
4 * Copyright (C) 2013 Martin Ling <martin-sigrok@earth.li>
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.
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.
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/>.
25 #include "libsigrok/libsigrok.h"
28 typedef void *gpointer;
31 typedef struct _GSList GSList;
39 void g_slist_free(GSList *list);
41 GVariant *g_variant_new_uint64(uint64_t value);
42 GVariant *g_variant_new_boolean(gboolean value);
43 GVariant *g_variant_new_double(double value);
44 GVariant *g_variant_new_string(char *value);
45 GVariant *g_variant_new_tuple(GVariant *children[], unsigned long n_children);
46 char *g_variant_get_type_string(GVariant *value);
47 uint64_t g_variant_get_uint64(GVariant *value);
48 gboolean g_variant_get_boolean(GVariant *value);
49 double g_variant_get_double(GVariant *value);
50 char *g_variant_get_string(GVariant *value, unsigned long *length);
51 GVariant *g_variant_get_child_value(GVariant *value, unsigned long index);
53 typedef guint (*GHashFunc)(gconstpointer key);
54 typedef gboolean (*GEqualFunc)(gconstpointer a, gconstpointer b);
55 typedef void (*GDestroyNotify)(gpointer data);
57 GHashTable *g_hash_table_new_full(GHashFunc hash_func, GEqualFunc key_equal_func,
58 GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func);
59 void g_hash_table_insert(GHashTable *hash_table, gpointer key, gpointer value);
60 void g_hash_table_destroy(GHashTable *hash_table);
63 guint g_str_hash(gconstpointer v);
64 gboolean g_str_equal(gconstpointer v1, gconstpointer v2);;
65 void g_free(gpointer mem);
68 gchar *g_strdup(const char *str);
70 typedef struct _GString GString;
79 gchar *g_string_free(GString *string, gboolean free_segment);
81 %include "libsigrok/libsigrok.h"
84 %ignore sr_config_info_name_get;
85 %include "libsigrok/proto.h"
86 %include "libsigrok/version.h"
88 %array_class(float, float_array);
89 %pointer_functions(uint8_t *, uint8_ptr_ptr);
90 %pointer_functions(uint64_t, uint64_ptr);
91 %pointer_functions(GString *, gstring_ptr_ptr);
92 %pointer_functions(GVariant *, gvariant_ptr_ptr);
93 %array_functions(GVariant *, gvariant_ptr_array);
94 %pointer_functions(struct sr_context *, sr_context_ptr_ptr);
95 %array_functions(struct sr_dev_driver *, sr_dev_driver_ptr_array);
96 %array_functions(struct sr_input_format *, sr_input_format_ptr_array);
97 %array_functions(struct sr_output_format *, sr_output_format_ptr_array);
98 %pointer_cast(gpointer, struct sr_dev_inst *, gpointer_to_sr_dev_inst_ptr);
99 %pointer_cast(void *, struct sr_datafeed_logic *, void_ptr_to_sr_datafeed_logic_ptr)
100 %pointer_cast(void *, struct sr_datafeed_analog *, void_ptr_to_sr_datafeed_analog_ptr)
101 %pointer_cast(void *, struct sr_channel *, void_ptr_to_sr_channel_ptr)
102 %pointer_cast(void *, struct sr_channel_group *, void_ptr_to_sr_channel_group_ptr)
104 %extend sr_input_format {
105 int call_format_match(const char *filename) {
106 return $self->format_match(filename);
109 int call_init(struct sr_input *in, const char *filename) {
110 return $self->init(in, filename);
113 int call_loadfile(struct sr_input *in, const char *filename) {
114 return $self->loadfile(in, filename);
118 %extend sr_output_format {
119 int call_init(struct sr_output *o) {
120 return $self->init(o);
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);
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);
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);
138 int call_cleanup(struct sr_output *o) {
139 return $self->cleanup(o);