diff options
author | chai <chaifix@163.com> | 2021-11-08 01:17:11 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-11-08 01:17:11 +0800 |
commit | efce5b6bd5c9d4f8214a71e0f7a7c35751710a4c (patch) | |
tree | 0789475ded5c377667165a3ddb047ca6703bcf33 /ThirdParty/toluapp/src/tests/tdirectivebind.c | |
parent | ed78df90944bbe6b7de7308bda2bf3a7f1bc3de6 (diff) |
+ tolua
+ lpeg
Diffstat (limited to 'ThirdParty/toluapp/src/tests/tdirectivebind.c')
-rw-r--r-- | ThirdParty/toluapp/src/tests/tdirectivebind.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/ThirdParty/toluapp/src/tests/tdirectivebind.c b/ThirdParty/toluapp/src/tests/tdirectivebind.c new file mode 100644 index 0000000..28c1234 --- /dev/null +++ b/ThirdParty/toluapp/src/tests/tdirectivebind.c @@ -0,0 +1,85 @@ +/* +** Lua binding: tdirective +** Generated automatically by tolua 5.0a-CDLVS2 on 08/08/03 17:06:24. +*/ + +#ifndef __cplusplus +#include "stdlib.h" +#endif +#include "string.h" + +#include "tolua.h" + +/* Exported function */ +TOLUA_API int tolua_tdirective_open (lua_State* tolua_S); + +#include "lualib.h" +#include "lauxlib.h" +int a; +extern int a; +int main (void) +{ + lua_State* L = lua_open(); + luaopen_base(L); + tolua_tdirective_open(L); + lua_dofile(L,"tdirective.lua"); + lua_close(L); + return 0; +} + +/* function to register type */ +static void tolua_reg_types (lua_State* tolua_S) +{ +} + +/* get function: a */ +static int tolua_get_a(lua_State* tolua_S) +{ + tolua_pushnumber(tolua_S,(double)a); + return 1; +} + +/* set function: a */ +static int tolua_set_a(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + a = ((int) tolua_tonumber(tolua_S,2,0)); + return 0; +} + +/* Open function */ +TOLUA_API int tolua_tdirective_open (lua_State* tolua_S) +{ + tolua_open(tolua_S); + tolua_reg_types(tolua_S); + tolua_module(tolua_S,NULL,1); + tolua_beginmodule(tolua_S,NULL); + tolua_variable(tolua_S,"a",tolua_get_a,tolua_set_a); +{ + a = 3; +} + + { /* begin embedded lua code */ + static unsigned char B[] = { + 10, 65, 32, 61, 32, 52,32 + }; + lua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code"); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + static unsigned char B[] = { + 10,102,117,110, 99,116,105,111,110, 32,102,117,110, 99, 32, + 40, 41, 10,114,101,116,117,114,110, 32, 53, 10,101,110,100, + 32 + }; + lua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code"); + } /* end of embedded lua code */ + + tolua_endmodule(tolua_S); + return 1; +} |