1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/* vim:set et ts=4: */
/*
* ibus-anthy - The Anthy engine for IBus
*
* Copyright (c) 2007-2008 Peng Huang <shawn.p.huang@gmail.com>
* Copyright (c) 2010-2013 Takao Fujiwara <takao.fujiwara1@gmail.com>
* Copyright (c) 2007-2013 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
%module anthy
%{
/* Put header files here or function declarations like below */
#include <anthy/anthy.h>
%}
%init %{
anthy_init ();
%}
/* anthy_context_t */
%include anthy/anthy.h
struct anthy_context {};
%extend anthy_context {
anthy_context () {
return anthy_create_context ();
}
void reset () {
anthy_reset_context (self);
}
int set_string (char *str) {
return anthy_set_string (self, str);
}
void resize_segment (int a1, int a2) {
anthy_resize_segment (self, a1, a2);
}
int get_stat (struct anthy_conv_stat *a1) {
return anthy_get_stat (self, a1);
}
int get_segment_stat (int a1, struct anthy_segment_stat *a2) {
return anthy_get_segment_stat (self, a1, a2);
}
char *get_segment (int a1, int a2) {
int len;
static char temp[512];
len = anthy_get_segment (self, a1, a2, temp, sizeof (temp));
if (len >= 0)
return temp;
else
return NULL;
}
int commit_segment (int a1, int a2) {
return anthy_commit_segment (self, a1, a2);
}
int set_prediction_string (const char *a1) {
return anthy_set_prediction_string (self, a1);
}
int get_prediction_stat (struct anthy_prediction_stat *a1) {
return anthy_get_prediction_stat (self, a1);
}
char *get_prediction (int a1) {
int len;
static char temp[512];
len = anthy_get_prediction (self, a1, temp, sizeof (temp));
if (len >= 0)
return temp;
else
return NULL;
}
int commit_prediction (int a1) {
return anthy_commit_prediction(self, a1);
}
void _print () {
anthy_print_context (self);
}
int _set_encoding (int encoding) {
return anthy_context_set_encoding (self, encoding);
}
int set_reconversion_mode (int mode) {
return anthy_set_reconversion_mode (self, mode);
}
int init_personality (void) {
return anthy_init_personality ();
}
int do_set_personality (const char *id) {
return anthy_do_set_personality (id);
}
~anthy_context () {
anthy_release_context (self);
}
};
|