2
2
* STFL - The Structured Terminal Forms Language/Library
3
* Copyright (C) 2006 Clifford Wolf <clifford@clifford.at>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
3
* Copyright (C) 2006, 2007 Clifford Wolf <clifford@clifford.at>
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 3 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
* stfl.i: The STFL SWIG bindings
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
* basedecls.i: SWIG bindings core
24
27
#include <stdlib.h>
26
31
typedef struct stfl_form stfl_form;
33
struct stfl_ipool *ipool = 0;
35
static void inline ipool_reset() {
37
ipool = stfl_ipool_create("UTF8");
38
stfl_ipool_flush(ipool);
41
static void ipool_destroy() {
42
stfl_ipool_destroy(ipool);
46
#define TOWC(_t) stfl_ipool_towc(ipool, _t)
47
#define FROMWC(_t) stfl_ipool_fromwc(ipool, _t)
34
56
stfl_form(char *text) {
35
return stfl_create(text);
58
return stfl_create(TOWC(text));
40
64
const char *run(int timeout) {
41
return stfl_run(self, timeout);
43
const char *stfl_get(const char *name) {
44
return stfl_get(self, name);
46
void stfl_set(const char *name, const char *value) {
47
return stfl_set(self, name, value);
66
return FROMWC(stfl_run(self, timeout));
68
const char *get(const char *name) {
70
return FROMWC(stfl_get(self, TOWC(name)));
72
void set(const char *name, const char *value) {
74
return stfl_set(self, TOWC(name), TOWC(value));
49
76
const char *get_focus() {
50
return stfl_get_focus(self);
78
return FROMWC(stfl_get_focus(self));
52
80
void set_focus(const char *name) {
53
stfl_set_focus(self, name);
82
stfl_set_focus(self, TOWC(name));
55
84
const char *dump(const char *name, const char *prefix, int focus) {
56
return stfl_dump(self, name, prefix, focus);
86
return FROMWC(stfl_dump(self, TOWC(name), TOWC(prefix), focus));
58
88
void modify(const char *name, const char *mode, const char *text) {
59
stfl_modify(self, name, mode, text);
90
stfl_modify(self, TOWC(name), TOWC(mode), TOWC(text));
61
92
const char *lookup(const char *path, const char *newname) {
62
return stfl_lookup(self, path, newname);
94
return FROMWC(stfl_lookup(self, TOWC(path), TOWC(newname)));
66
extern struct stfl_form *stfl_create(const char *text);
67
// extern void stfl_free(struct stfl_form *f);
69
extern const char *stfl_run(struct stfl_form *f, int timeout);
100
static struct stfl_form *stfl_create_wrapper(const char *text)
103
return stfl_create(TOWC(text));
106
static const char *stfl_run_wrapper(struct stfl_form *f, int timeout)
109
return FROMWC(stfl_run(f, timeout));
112
static const char *stfl_get_wrapper(struct stfl_form *f, const char *name)
115
return FROMWC(stfl_get(f, TOWC(name)));
118
static void stfl_set_wrapper(struct stfl_form *f, const char *name, const char *value)
121
return stfl_set(f, TOWC(name), TOWC(value));
124
static const char *stfl_get_focus_wrapper(struct stfl_form *f)
127
return FROMWC(stfl_get_focus(f));
130
static void stfl_set_focus_wrapper(struct stfl_form *f, const char *name)
133
stfl_set_focus(f, TOWC(name));
136
static const char *stfl_quote_wrapper(const char *text)
139
return FROMWC(stfl_quote(TOWC(text)));
142
static const char *stfl_dump_wrapper(struct stfl_form *f, const char *name, const char *prefix, int focus)
145
return FROMWC(stfl_dump(f, TOWC(name), TOWC(prefix), focus));
148
static void stfl_modify_wrapper(struct stfl_form *f, const char *name, const char *mode, const char *text)
151
stfl_modify(f, TOWC(name), TOWC(mode), TOWC(text));
154
static const char *stfl_lookup_wrapper(struct stfl_form *f, const char *path, const char *newname)
157
return FROMWC(stfl_lookup(f, TOWC(path), TOWC(newname)));
160
static const char *stfl_error_wrapper()
163
return FROMWC(stfl_error());
166
static void stfl_error_action_wrapper(const char *mode)
169
stfl_error_action(TOWC(mode));
174
static struct stfl_form *stfl_create_wrapper(const char *text);
175
static const char *stfl_run_wrapper(struct stfl_form *f, int timeout);
176
static const char *stfl_get_wrapper(struct stfl_form *f, const char *name);
177
static void stfl_set_wrapper(struct stfl_form *f, const char *name, const char *value);
178
static const char *stfl_get_focus_wrapper(struct stfl_form *f);
179
static void stfl_set_focus_wrapper(struct stfl_form *f, const char *name);
180
static const char *stfl_quote_wrapper(const char *text);
181
static const char *stfl_dump_wrapper(struct stfl_form *f, const char *name, const char *prefix, int focus);
182
static void stfl_modify_wrapper(struct stfl_form *f, const char *name, const char *mode, const char *text);
183
static const char *stfl_lookup_wrapper(struct stfl_form *f, const char *path, const char *newname);
184
static const char *stfl_error_wrapper();
185
static void stfl_error_action_wrapper(const char *mode);
70
186
extern void stfl_reset();
72
extern const char *stfl_get(struct stfl_form *f, const char *name);
73
extern void stfl_set(struct stfl_form *f, const char *name, const char *value);
75
extern const char *stfl_get_focus(struct stfl_form *f);
76
extern void stfl_set_focus(struct stfl_form *f, const char *name);
78
extern const char *stfl_quote(const char *text);
79
extern const char *stfl_dump(struct stfl_form *f, const char *name, const char *prefix, int focus);
80
extern void stfl_modify(struct stfl_form *f, const char *name, const char *mode, const char *text);
81
extern const char *stfl_lookup(struct stfl_form *f, const char *path, const char *newname);
83
extern const char *stfl_error();
84
extern void stfl_error_action(const char *mode);
87
189
atexit(stfl_reset);
190
atexit(ipool_destroy);