source: tags/arb-7.0/BINDINGS/ARB.i

Last change on this file was 8848, checked in by epruesse, 12 years ago

Added Python bindings using SWIG

Build and clean targets are "bindings" and "bindings_clean"; they
are not added to all and clean yet. The "test.py" shows a bit of
the python usage of the interface. You need to have swig installed,
of course.

The bindings are not build from arb_prot.h like the perl bindings.
Rather, ARB.i defines the exported functions. This is to make the
interface smaller and have an avenue of keeping it stable in case
the library interface needs to be changed. It also cuts down on
compile time a lot.

The idea is to eventually build the perl bindings with SWIG as well.
I haven't figured out how to provide the BIO:: module with the
ARB module yet, though, which would be required for backwards
compatability with pre-existing amc scripts.

File size: 3.6 KB
Line 
1%{
2#include <arbdb.h>
3#include <arbdbt.h>
4
5GB_shell thegbshell;
6%}
7
8
9/* map GB_error to char pointer -- errors are message strings */
10%typemap(out) GB_ERROR = const char*;
11
12%inline %{
13
14/* ARB:: */
15
16/* Accessing database */
17
18GBDATA*
19open(const char *path, const char *opent) {
20    return GB_open(path, opent);
21}
22
23GB_ERROR
24save(GBDATA *gb, const char *path, const char *savetype) {
25    return GB_save(gb, path, savetype);
26}
27
28GB_ERROR
29save_as(GBDATA *gb, const char *path, const char *savetype) {
30    return GB_save_as(gb, path, savetype);
31}
32
33void
34close(GBDATA *gbd) {
35    GB_close(gbd);
36}
37
38const char*
39get_db_path(GBDATA *gbd) {
40    return GB_get_db_path(gbd);
41}
42
43/* transactions */
44
45GB_ERROR
46abort_transaction(GBDATA *gbd) {
47    return GB_abort_transaction(gbd);
48}
49
50GB_ERROR
51begin_transaction(GBDATA *gbd) {
52    return GB_begin_transaction(gbd);
53}
54
55GB_ERROR
56commit_transaction(GBDATA *gbd) {
57    return GB_commit_transaction(gbd);
58}
59
60/* read/write operations */
61
62char*
63read_as_string(GBDATA *gbd) {
64    return GB_read_as_string(gbd);
65}
66
67char*
68read_string(GBDATA *gbd) {
69    return GB_read_string(gbd);
70}
71
72GB_ERROR
73write_string(GBDATA *gbd, const char *s) {
74    return GB_write_string(gbd, s);
75}
76
77void
78write_flag(GBDATA *gbd, long flag) {
79    return GB_write_flag(gbd, flag);
80}
81
82int
83read_flag(GBDATA *gbd) {
84    return GB_read_flag(gbd);
85}
86
87GB_ERROR
88check_key(const char *key) {
89    return GB_check_key(key);
90}
91
92GBDATA*
93search(GBDATA *gbd, const char *fieldpath, GB_TYPES create) {
94    return GB_search(gbd, fieldpath, create);
95}
96
97/* others */
98
99GB_ERROR
100await_error(void) {
101    return GB_await_error();
102}
103
104uint32_t
105checksum(const char *seq, long length, int ignore_case, const char *exclude) {
106    return GB_checksum(seq, length, ignore_case, exclude);
107}
108
109
110/* BIO */
111
112/* read and write database (GBDATA) items */
113
114char*
115read_string(GBDATA *gb_container, const char *fieldpath) {
116    return GBT_read_string(gb_container, fieldpath);
117}
118
119char*
120read_as_string(GBDATA *gb_container, const char *fieldpath) {
121    return GBT_read_as_string(gb_container, fieldpath);
122}
123
124GB_CSTR
125read_name(GBDATA *gb_item) {
126    return GBT_read_name(gb_item);
127}
128
129GB_ERROR
130write_int(GBDATA *gb_container, const char *fieldpath, long content) {
131    return GBT_write_int(gb_container, fieldpath, content);
132}
133
134GB_ERROR
135write_string(GBDATA *gb_container, const char *fieldpath, const char *content) {
136    return GBT_write_string(gb_container, fieldpath, content);
137}
138
139/* access AWARS (values from GUI) */
140
141GB_ERROR
142remote_action(GBDATA *gb_main, const char *application, const char *action_name) {
143    return GBT_remote_action(gb_main, application, action_name);
144}
145
146GB_ERROR
147remote_awar(GBDATA *gb_main, const char *application, const char *awar_name, const char *value) {
148    return GBT_remote_awar(gb_main, application, awar_name, value);
149}
150
151GB_ERROR
152remote_read_awar(GBDATA *gb_main, const char *application, const char *awar_name) {
153    return GBT_remote_read_awar(gb_main, application, awar_name);
154}
155
156/* iterate through species */
157
158GBDATA*
159first_species(GBDATA *gb_main) {
160    return GBT_first_species(gb_main);
161}
162
163GBDATA*
164next_species(GBDATA *gb_species) {
165    return GBT_next_species(gb_species);
166}
167
168GBDATA*
169first_marked_species(GBDATA *gb_main) {
170    return GBT_first_marked_species(gb_main);
171}
172
173GBDATA*
174next_marked_species(GBDATA *gb_species) {
175    return GBT_next_marked_species(gb_species);
176}
177
178/* other */
179
180/*
181char *get_name_of_next_tree(GBDATA *gb_main, const char *tree_name) {
182    return GBT_get_name_of_next_tree(gb_main, tree_name);
183}
184*/
185
186char*
187get_default_alignment(GBDATA *gb_main) {
188    GBT_get_default_alignment(gb_main);
189}
190
191void
192message(GBDATA *gb_main, const char *msg) {
193    GBT_message(gb_main, msg);
194}
195
196%}
Note: See TracBrowser for help on using the repository browser.