diff --git a/src/bind_order.c b/src/bind_order.c new file mode 100644 index 000000000..90fc7d3b0 --- /dev/null +++ b/src/bind_order.c @@ -0,0 +1,47 @@ +#include +#include + +/* kernel includes */ +#include +#include + +/* lua includes */ +#include + +#include + +static int tolua_order_get_token(lua_State *L) { + order *ord = (order *)tolua_tousertype(L, 1, 0); + int n = (int)tolua_tonumber(L, 2, 0); + const char * str = 0; + init_order(ord); + while (n-->0) { + str = getstrtoken(); + if (!str) { + return 0; + } + } + + tolua_pushstring(L, str); + return 1; +} + +void tolua_order_open(lua_State * L) +{ + /* register user types */ + tolua_usertype(L, TOLUA_CAST "order"); + + tolua_module(L, NULL, 0); + tolua_beginmodule(L, NULL); + { + tolua_cclass(L, TOLUA_CAST "order", TOLUA_CAST "order", TOLUA_CAST "", + NULL); + tolua_beginmodule(L, TOLUA_CAST "order"); + { + tolua_function(L, TOLUA_CAST "token", tolua_order_get_token); + } + tolua_endmodule(L); + } + tolua_endmodule(L); +} + diff --git a/src/bind_order.h b/src/bind_order.h new file mode 100644 index 000000000..efe1ef373 --- /dev/null +++ b/src/bind_order.h @@ -0,0 +1,14 @@ +#ifndef H_BIND_ORDER_H +#define H_BIND_ORDER_H +#ifdef __cplusplus +extern "C" { +#endif + + struct lua_State; + void tolua_order_open(struct lua_State *L); + +#ifdef __cplusplus +} +#endif + +#endif