Freeciv-3.2: /fast/freeciv/nightly/S3_2/common/scriptcore/tolua_signal_gen.c Source File

Freeciv-3.2

Loading...
Searching...
No Matches
tolua_signal_gen.c
Go to the documentation of this file.
1/*
2** Lua binding: signal
3*/
4
5#include "tolua.h"
6
7#ifndef __cplusplus
8#include <stdlib.h>
9#endif
10#ifdef __cplusplus
11 extern "C" int tolua_bnd_takeownership (lua_State* L); // from tolua_map.c
12#else
13 int tolua_bnd_takeownership (lua_State* L); /* from tolua_map.c */
14#endif
15#include <string.h>
16
17/* Exported function */
18 TOLUA_API int tolua_signal_open (lua_State* tolua_S);
19 LUALIB_API int luaopen_signal (lua_State* tolua_S);
20
21#ifdef HAVE_CONFIG_H
22#include <fc_config.h>
23#endif
24#include "api_signal_base.h"
25#include "luascript_types.h"
26
27/* function to register type */
28 static void tolua_reg_types (lua_State* tolua_S)
29{
30}
31
32/* function: api_signal_connect */
33 static int tolua_signal_signal_connect00(lua_State* tolua_S)
34{
35#ifndef TOLUA_RELEASE
36 tolua_Error tolua_err;
37 if (
38 !tolua_isstring(tolua_S,1,0,&tolua_err) ||
39 !tolua_isstring(tolua_S,2,0,&tolua_err) ||
40 !tolua_isnoobj(tolua_S,3,&tolua_err)
41 )
42 goto tolua_lerror;
43 else
44#endif
45 {
46 lua_State* L = tolua_S;
47 const char* signal_name = ((const char*) tolua_tostring(tolua_S,1,0));
48 const char* callback_name = ((const char*) tolua_tostring(tolua_S,2,0));
49 {
50 api_signal_connect(L,signal_name,callback_name);
51 }
52 }
53 return 0;
54#ifndef TOLUA_RELEASE
55 tolua_lerror:
56 tolua_error(tolua_S,"#ferror in function 'connect'.",&tolua_err);
57 return 0;
58#endif
59}
60
61/* function: api_signal_remove */
62 static int tolua_signal_signal_remove00(lua_State* tolua_S)
63{
64#ifndef TOLUA_RELEASE
65 tolua_Error tolua_err;
66 if (
67 !tolua_isstring(tolua_S,1,0,&tolua_err) ||
68 !tolua_isstring(tolua_S,2,0,&tolua_err) ||
69 !tolua_isnoobj(tolua_S,3,&tolua_err)
70 )
71 goto tolua_lerror;
72 else
73#endif
74 {
75 lua_State* L = tolua_S;
76 const char* signal_name = ((const char*) tolua_tostring(tolua_S,1,0));
77 const char* callback_name = ((const char*) tolua_tostring(tolua_S,2,0));
78 {
79 api_signal_remove(L,signal_name,callback_name);
80 }
81 }
82 return 0;
83#ifndef TOLUA_RELEASE
84 tolua_lerror:
85 tolua_error(tolua_S,"#ferror in function 'remove'.",&tolua_err);
86 return 0;
87#endif
88}
89
90/* function: api_signal_defined */
91 static int tolua_signal_signal_defined00(lua_State* tolua_S)
92{
93#ifndef TOLUA_RELEASE
94 tolua_Error tolua_err;
95 if (
96 !tolua_isstring(tolua_S,1,0,&tolua_err) ||
97 !tolua_isstring(tolua_S,2,0,&tolua_err) ||
98 !tolua_isnoobj(tolua_S,3,&tolua_err)
99 )
100 goto tolua_lerror;
101 else
102#endif
103 {
104 lua_State* L = tolua_S;
105 const char* signal_name = ((const char*) tolua_tostring(tolua_S,1,0));
106 const char* callback_name = ((const char*) tolua_tostring(tolua_S,2,0));
107 {
108 bool tolua_ret = (bool) api_signal_defined(L,signal_name,callback_name);
109 tolua_pushboolean(tolua_S,(bool)tolua_ret);
110 }
111 }
112 return 1;
113#ifndef TOLUA_RELEASE
114 tolua_lerror:
115 tolua_error(tolua_S,"#ferror in function 'defined'.",&tolua_err);
116 return 0;
117#endif
118}
119
120/* function: api_signal_by_index */
121 static int tolua_signal_find_signal00(lua_State* tolua_S)
122{
123#ifndef TOLUA_RELEASE
124 tolua_Error tolua_err;
125 if (
126 !tolua_isnumber(tolua_S,1,0,&tolua_err) ||
127 !tolua_isnoobj(tolua_S,2,&tolua_err)
128 )
129 goto tolua_lerror;
130 else
131#endif
132 {
133 lua_State* L = tolua_S;
134 int sindex = ((int) tolua_tonumber(tolua_S,1,0));
135 {
136 const char* tolua_ret = (const char*) api_signal_by_index(L,sindex);
137 tolua_pushstring(tolua_S,(const char*)tolua_ret);
138 }
139 }
140 return 1;
141#ifndef TOLUA_RELEASE
142 tolua_lerror:
143 tolua_error(tolua_S,"#ferror in function 'signal'.",&tolua_err);
144 return 0;
145#endif
146}
147
148/* function: api_signal_callback_by_index */
149 static int tolua_signal_find_signal_callback00(lua_State* tolua_S)
150{
151#ifndef TOLUA_RELEASE
152 tolua_Error tolua_err;
153 if (
154 !tolua_isstring(tolua_S,1,0,&tolua_err) ||
155 !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
156 !tolua_isnoobj(tolua_S,3,&tolua_err)
157 )
158 goto tolua_lerror;
159 else
160#endif
161 {
162 lua_State* L = tolua_S;
163 const char* signal_name = ((const char*) tolua_tostring(tolua_S,1,0));
164 int sindex = ((int) tolua_tonumber(tolua_S,2,0));
165 {
166 const char* tolua_ret = (const char*) api_signal_callback_by_index(L,signal_name,sindex);
167 tolua_pushstring(tolua_S,(const char*)tolua_ret);
168 }
169 }
170 return 1;
171#ifndef TOLUA_RELEASE
172 tolua_lerror:
173 tolua_error(tolua_S,"#ferror in function 'signal_callback'.",&tolua_err);
174 return 0;
175#endif
176}
177
178/* Open lib function */
179 LUALIB_API int luaopen_signal (lua_State* tolua_S)
180{
181 tolua_open(tolua_S);
182 tolua_reg_types(tolua_S);
183 tolua_module(tolua_S,NULL,0);
184 tolua_beginmodule(tolua_S,NULL);
185 tolua_module(tolua_S,"signal",0);
186 tolua_beginmodule(tolua_S,"signal");
187 tolua_function(tolua_S,"connect",tolua_signal_signal_connect00);
188 tolua_function(tolua_S,"remove",tolua_signal_signal_remove00);
189 tolua_function(tolua_S,"defined",tolua_signal_signal_defined00);
190 tolua_endmodule(tolua_S);
191
192 { /* begin embedded lua code */
193 static unsigned char B[] = {
194 10,102,117,110, 99,116,105,111,110, 32,115,105,103,110, 97,
195 108, 46,108,105,115,116, 40, 41, 10,108,111, 99, 97,108, 32,
196 115,105,103,110, 97,108, 95,105,100, 32, 61, 32, 48, 59, 10,
197 108,111, 99, 97,108, 32,115,105,103,110, 97,108, 95,110, 97,
198 109,101, 32, 61, 32,110,105,108, 59, 10,108,111,103, 46,110,
199 111,114,109, 97,108, 40, 34, 76,105,115,116, 32,111,102, 32,
200 115,105,103,110, 97,108,115, 58, 34, 41, 59, 10,114,101,112,
201 101, 97,116, 10,108,111, 99, 97,108, 32,115,105,103,110, 97,
202 108, 95,110, 97,109,101, 32, 61, 32,102,105,110,100, 46,115,
203 105,103,110, 97,108, 40,115,105,103,110, 97,108, 95,105,100,
204 41, 59, 10,105,102, 32, 40,115,105,103,110, 97,108, 95,110,
205 97,109,101, 41, 32,116,104,101,110, 10,108,111, 99, 97,108,
206 32, 99, 97,108,108, 98, 97, 99,107, 95,105,100, 32, 61, 32,
207 48, 59, 10,108,111, 99, 97,108, 32, 99, 97,108,108, 98, 97,
208 99,107, 95,110, 97,109,101, 32, 61, 32,110,105,108, 59, 10,
209 108,111,103, 46,110,111,114,109, 97,108, 40, 34, 45, 32, 99,
210 97,108,108, 98, 97, 99,107,115, 32,102,111,114, 32,115,105,
211 103,110, 97,108, 32, 39, 37,115, 39, 58, 34, 44, 32,115,105,
212 103,110, 97,108, 95,110, 97,109,101, 41, 59, 10,114,101,112,
213 101, 97,116, 10,108,111, 99, 97,108, 32, 99, 97,108,108, 98,
214 97, 99,107, 95,110, 97,109,101, 32, 61, 32,102,105,110,100,
215 46,115,105,103,110, 97,108, 95, 99, 97,108,108, 98, 97, 99,
216 107, 40,115,105,103,110, 97,108, 95,110, 97,109,101, 44, 32,
217 99, 97,108,108, 98, 97, 99,107, 95,105,100, 41, 59, 10,105,
218 102, 32, 40, 99, 97,108,108, 98, 97, 99,107, 95,110, 97,109,
219 101, 41, 32,116,104,101,110, 10,108,111,103, 46,110,111,114,
220 109, 97,108, 40, 34, 32, 91, 37, 51,100, 93, 32, 39, 37,115,
221 39, 34, 44, 32, 99, 97,108,108, 98, 97, 99,107, 95,105,100,
222 44, 32, 99, 97,108,108, 98, 97, 99,107, 95,110, 97,109,101,
223 41, 59, 10,101,110,100, 10, 99, 97,108,108, 98, 97, 99,107,
224 95,105,100, 32, 61, 32, 99, 97,108,108, 98, 97, 99,107, 95,
225 105,100, 32, 43, 32, 49, 59, 10,117,110,116,105,108, 32, 40,
226 99, 97,108,108, 98, 97, 99,107, 95,110, 97,109,101, 32, 61,
227 61, 32,110,105,108, 41, 59, 10,115,105,103,110, 97,108, 95,
228 105,100, 32, 61, 32,115,105,103,110, 97,108, 95,105,100, 32,
229 43, 32, 49, 59, 10,101,110,100, 10,117,110,116,105,108, 32,
230 40,115,105,103,110, 97,108, 95,110, 97,109,101, 32, 61, 61,
231 32,110,105,108, 41, 59, 10,101,110,100, 10,102,117,110, 99,
232 116,105,111,110, 32,115,105,103,110, 97,108, 46,114,101,112,
233 108, 97, 99,101, 40,115,105,103,110, 97,108, 95,110, 97,109,
234 101, 44, 32, 99, 97,108,108, 98, 97, 99,107, 95,110, 97,109,
235 101, 41, 10,105,102, 32,115,105,103,110, 97,108, 46,100,101,
236 102,105,110,101,100, 40,115,105,103,110, 97,108, 95,110, 97,
237 109,101, 44, 32, 99, 97,108,108, 98, 97, 99,107, 95,110, 97,
238 109,101, 41, 32,116,104,101,110, 10,115,105,103,110, 97,108,
239 46,114,101,109,111,118,101, 40,115,105,103,110, 97,108, 95,
240 110, 97,109,101, 44, 32, 99, 97,108,108, 98, 97, 99,107, 95,
241 110, 97,109,101, 41, 10,101,110,100, 10,115,105,103,110, 97,
242 108, 46, 99,111,110,110,101, 99,116, 40,115,105,103,110, 97,
243 108, 95,110, 97,109,101, 44, 32, 99, 97,108,108, 98, 97, 99,
244 107, 95,110, 97,109,101, 41, 10,101,110,100,32
245 };
246 if (luaL_loadbuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code") == LUA_OK)
247 lua_pcall(tolua_S,0,LUA_MULTRET,0);
248 } /* end of embedded lua code */
249
250 tolua_module(tolua_S,"find",0);
251 tolua_beginmodule(tolua_S,"find");
252 tolua_function(tolua_S,"signal",tolua_signal_find_signal00);
253 tolua_function(tolua_S,"signal_callback",tolua_signal_find_signal_callback00);
254 tolua_endmodule(tolua_S);
255 tolua_endmodule(tolua_S);
256 return 1;
257}
258/* Open tolua function */
259 TOLUA_API int tolua_signal_open (lua_State* tolua_S)
260{
261 lua_pushcfunction(tolua_S, luaopen_signal);
262 lua_pushstring(tolua_S, "signal");
263 lua_call(tolua_S, 1, 0);
264 return 1;
265}
api_signal_callback_by_index
const char * api_signal_callback_by_index(lua_State *L, const char *signal_name, int sindex)
Definition api_signal_base.c:84
api_signal_defined
bool api_signal_defined(lua_State *L, const char *signal_name, const char *callback_name)
Definition api_signal_base.c:65
api_signal_by_index
const char * api_signal_by_index(lua_State *L, int sindex)
Definition api_signal_base.c:104
api_signal_connect
void api_signal_connect(lua_State *L, const char *signal_name, const char *callback_name)
Definition api_signal_base.c:27
api_signal_remove
void api_signal_remove(lua_State *L, const char *signal_name, const char *callback_name)
Definition api_signal_base.c:46
api_signal_base.h
incite_cost
char * incite_cost
Definition comments.c:74
luascript_types.h
bool
#define bool
Definition support.h:71
tolua_signal_signal_connect00
static int tolua_signal_signal_connect00(lua_State *tolua_S)
Definition tolua_signal_gen.c:33
tolua_signal_signal_remove00
static int tolua_signal_signal_remove00(lua_State *tolua_S)
Definition tolua_signal_gen.c:62
tolua_signal_find_signal_callback00
static int tolua_signal_find_signal_callback00(lua_State *tolua_S)
Definition tolua_signal_gen.c:149
luaopen_signal
LUALIB_API int luaopen_signal(lua_State *tolua_S)
Definition tolua_signal_gen.c:179
tolua_reg_types
static void tolua_reg_types(lua_State *tolua_S)
Definition tolua_signal_gen.c:28
tolua_signal_signal_defined00
static int tolua_signal_signal_defined00(lua_State *tolua_S)
Definition tolua_signal_gen.c:91
tolua_bnd_takeownership
int tolua_bnd_takeownership(lua_State *L)
tolua_signal_find_signal00
static int tolua_signal_find_signal00(lua_State *tolua_S)
Definition tolua_signal_gen.c:121
tolua_signal_open
TOLUA_API int tolua_signal_open(lua_State *tolua_S)
Definition tolua_signal_gen.c:259