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