~ubuntu-branches/ubuntu/intrepid/stfl/intrepid

« back to all changes in this revision

Viewing changes to swig/basedecls.i

  • Committer: Bazaar Package Importer
  • Author(s): Nico Golde
  • Date: 2007-08-07 13:06:54 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070807130654-fmvsraotulj0nbri
Tags: 0.15-3
Again added fPIC to CFLAGS. Hopefully all build issues
are fixed now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 *  STFL - The Structured Terminal Forms Language/Library
3
 
 *  Copyright (C) 2006  Clifford Wolf <clifford@clifford.at>
4
 
 *
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.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
 
3
 *  Copyright (C) 2006, 2007  Clifford Wolf <clifford@clifford.at>
 
4
 *
 
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.
 
9
 *  
 
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.
14
 
 *
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
18
 
 *
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.
 
14
 *  
 
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,
 
18
 *  MA 02110-1301 USA
 
19
 *
 
20
 *  basedecls.i: SWIG bindings core
20
21
 */
21
22
 
22
23
%module stfl
 
24
 
23
25
%{
 
26
 
24
27
#include <stdlib.h>
 
28
#include <wchar.h>
25
29
#include "stfl.h"
 
30
 
26
31
typedef struct stfl_form stfl_form;
 
32
 
 
33
struct stfl_ipool *ipool = 0;
 
34
 
 
35
static void inline ipool_reset() {
 
36
        if (!ipool)
 
37
                ipool = stfl_ipool_create("UTF8");
 
38
        stfl_ipool_flush(ipool);
 
39
}
 
40
 
 
41
static void ipool_destroy() {
 
42
        stfl_ipool_destroy(ipool);
 
43
        ipool = 0;
 
44
}
 
45
 
 
46
#define TOWC(_t) stfl_ipool_towc(ipool, _t)
 
47
#define FROMWC(_t) stfl_ipool_fromwc(ipool, _t)
 
48
 
27
49
%}
28
50
 
29
51
typedef struct {
32
54
%extend stfl_form
33
55
{
34
56
        stfl_form(char *text) {
35
 
                return stfl_create(text);
 
57
                ipool_reset();
 
58
                return stfl_create(TOWC(text));
36
59
        }
37
60
        ~stfl_form() {
 
61
                ipool_reset();
38
62
                stfl_free(self);
39
63
        }
40
64
        const char *run(int timeout) {
41
 
                return stfl_run(self, timeout);
42
 
        }
43
 
        const char *stfl_get(const char *name) {
44
 
                return stfl_get(self, name);
45
 
        }
46
 
        void stfl_set(const char *name, const char *value) {
47
 
                return stfl_set(self, name, value);
 
65
                ipool_reset();
 
66
                return FROMWC(stfl_run(self, timeout));
 
67
        }
 
68
        const char *get(const char *name) {
 
69
                ipool_reset();
 
70
                return FROMWC(stfl_get(self, TOWC(name)));
 
71
        }
 
72
        void set(const char *name, const char *value) {
 
73
                ipool_reset();
 
74
                return stfl_set(self, TOWC(name), TOWC(value));
48
75
        }
49
76
        const char *get_focus() {
50
 
                return stfl_get_focus(self);
 
77
                ipool_reset();
 
78
                return FROMWC(stfl_get_focus(self));
51
79
        }
52
80
        void set_focus(const char *name) {
53
 
                stfl_set_focus(self, name);
 
81
                ipool_reset();
 
82
                stfl_set_focus(self, TOWC(name));
54
83
        }
55
84
        const char *dump(const char *name, const char *prefix, int focus) {
56
 
                return stfl_dump(self, name, prefix, focus);
 
85
                ipool_reset();
 
86
                return FROMWC(stfl_dump(self, TOWC(name), TOWC(prefix), focus));
57
87
        }
58
88
        void modify(const char *name, const char *mode, const char *text) {
59
 
                stfl_modify(self, name, mode, text);
 
89
                ipool_reset();
 
90
                stfl_modify(self, TOWC(name), TOWC(mode), TOWC(text));
60
91
        }
61
92
        const char *lookup(const char *path, const char *newname) {
62
 
                return stfl_lookup(self, path, newname);
 
93
                ipool_reset();
 
94
                return FROMWC(stfl_lookup(self, TOWC(path), TOWC(newname)));
63
95
        }
64
96
}
65
97
 
66
 
extern struct stfl_form *stfl_create(const char *text);
67
 
// extern void stfl_free(struct stfl_form *f);
68
 
 
69
 
extern const char *stfl_run(struct stfl_form *f, int timeout);
 
98
%{
 
99
 
 
100
static struct stfl_form *stfl_create_wrapper(const char *text)
 
101
{
 
102
        ipool_reset();
 
103
        return stfl_create(TOWC(text));
 
104
}
 
105
 
 
106
static const char *stfl_run_wrapper(struct stfl_form *f, int timeout)
 
107
{
 
108
        ipool_reset();
 
109
        return FROMWC(stfl_run(f, timeout));
 
110
}
 
111
 
 
112
static const char *stfl_get_wrapper(struct stfl_form *f, const char *name)
 
113
{
 
114
        ipool_reset();
 
115
        return FROMWC(stfl_get(f, TOWC(name)));
 
116
}
 
117
 
 
118
static void stfl_set_wrapper(struct stfl_form *f, const char *name, const char *value)
 
119
{
 
120
        ipool_reset();
 
121
        return stfl_set(f, TOWC(name), TOWC(value));
 
122
}
 
123
 
 
124
static const char *stfl_get_focus_wrapper(struct stfl_form *f)
 
125
{
 
126
        ipool_reset();
 
127
        return FROMWC(stfl_get_focus(f));
 
128
}
 
129
 
 
130
static void stfl_set_focus_wrapper(struct stfl_form *f, const char *name)
 
131
{
 
132
        ipool_reset();
 
133
        stfl_set_focus(f, TOWC(name));
 
134
}
 
135
 
 
136
static const char *stfl_quote_wrapper(const char *text)
 
137
{
 
138
        ipool_reset();
 
139
        return FROMWC(stfl_quote(TOWC(text)));
 
140
}
 
141
 
 
142
static const char *stfl_dump_wrapper(struct stfl_form *f, const char *name, const char *prefix, int focus)
 
143
{
 
144
        ipool_reset();
 
145
        return FROMWC(stfl_dump(f, TOWC(name), TOWC(prefix), focus));
 
146
}
 
147
 
 
148
static void stfl_modify_wrapper(struct stfl_form *f, const char *name, const char *mode, const char *text)
 
149
{
 
150
        ipool_reset();
 
151
        stfl_modify(f, TOWC(name), TOWC(mode), TOWC(text));
 
152
}
 
153
 
 
154
static const char *stfl_lookup_wrapper(struct stfl_form *f, const char *path, const char *newname)
 
155
{
 
156
        ipool_reset();
 
157
        return FROMWC(stfl_lookup(f, TOWC(path), TOWC(newname)));
 
158
}
 
159
 
 
160
static const char *stfl_error_wrapper()
 
161
{
 
162
        ipool_reset();
 
163
        return FROMWC(stfl_error());
 
164
}
 
165
 
 
166
static void stfl_error_action_wrapper(const char *mode)
 
167
{
 
168
        ipool_reset();
 
169
        stfl_error_action(TOWC(mode));
 
170
}
 
171
 
 
172
%}
 
173
 
 
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();
71
187
 
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);
74
 
 
75
 
extern const char *stfl_get_focus(struct stfl_form *f);
76
 
extern void stfl_set_focus(struct stfl_form *f, const char *name);
77
 
 
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);
82
 
 
83
 
extern const char *stfl_error();
84
 
extern void stfl_error_action(const char *mode);
85
 
 
86
188
%init %{
87
189
        atexit(stfl_reset);
 
190
        atexit(ipool_destroy);
88
191
%}
89
192