1 /* Lua scripting support
3 * Copyright (c) 2008 Sadrul Habib Chowdhury (sadrul@users.sf.net)
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program (see the file COPYING); if not, write to the
17 * Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
20 ****************************************************************
22 #include <sys/types.h>
39 static int StackDump(lua_State
*L
, const char *message
)
41 FILE *f
= fopen("/tmp/debug/stack", "ab");
42 int i
= lua_gettop(L
);
44 fprintf(f
, "%s", message
);
47 int t
= lua_type(L
, i
);
51 fprintf(f
, "String: %s\n", lua_tostring(L
, i
));
55 fprintf(f
, "Boolean: %s\n", lua_toboolean(L
, i
) ? "true" : "false");
59 fprintf(f
, "Number: %g\n", lua_tonumber(L
, i
));
63 fprintf(f
, "Type: %s\n", lua_typename(L
, t
));
73 extern struct win
*windows
, *fore
;
74 extern struct display
*displays
, *display
;
75 extern struct LayFuncs WinLf
;
76 extern struct layer
*flayer
;
78 static int LuaDispatch(void *handler
, const char *params
, va_list va
);
79 static int LuaRegEvent(lua_State
*L
);
80 static int LuaUnRegEvent(lua_State
*L
);
81 static void LuaShowErr(lua_State
*L
);
85 #define CHECK_TYPE(name, type) \
87 check_##name(lua_State *L, int index) \
90 luaL_checktype(L, index, LUA_TUSERDATA); \
91 var = (type **) luaL_checkudata(L, index, #name); \
93 luaL_typerror(L, index, #name); \
97 #define PUSH_TYPE(name, type) \
99 push_##name(lua_State *L, type **t) \
106 r = (type **)lua_newuserdata(L, sizeof(type *)); \
108 luaL_getmetatable(L, #name); \
109 lua_setmetatable(L,-2); \
113 /* Much of the following template comes from:
114 * http://lua-users.org/wiki/BindingWithMembersAndMethods
117 static int get_int (lua_State
*L
, void *v
)
119 lua_pushinteger (L
, *(int*)v
);
123 static int set_int (lua_State
*L
, void *v
)
125 *(int*)v
= luaL_checkint(L
, 3);
129 static int get_number (lua_State
*L
, void *v
)
131 lua_pushnumber(L
, *(lua_Number
*)v
);
135 static int set_number (lua_State
*L
, void *v
)
137 *(lua_Number
*)v
= luaL_checknumber(L
, 3);
141 static int get_string (lua_State
*L
, void *v
)
143 lua_pushstring(L
, (char*)v
);
147 static int set_string (lua_State
*L
, void *v
)
149 *(const char**)v
= luaL_checkstring(L
, 3);
153 typedef int (*Xet_func
) (lua_State
*L
, void *v
);
155 /* member info for get and set handlers */
158 const char *name
; /* member name */
159 Xet_func func
; /* get or set function for type of member */
160 size_t offset
; /* offset of member within the struct */
161 int (*absolute
)(lua_State
*);
164 static void Xet_add (lua_State
*L
, const struct Xet_reg
*l
)
170 lua_pushstring(L
, l
->name
);
171 lua_pushlightuserdata(L
, (void*)l
);
176 static int Xet_call (lua_State
*L
)
178 /* for get: stack has userdata, index, lightuserdata */
179 /* for set: stack has userdata, index, value, lightuserdata */
180 const struct Xet_reg
*m
= (const struct Xet_reg
*)lua_touserdata(L
, -1); /* member info */
181 lua_pop(L
, 1); /* drop lightuserdata */
182 luaL_checktype(L
, 1, LUA_TUSERDATA
);
184 return m
->absolute(L
);
185 return m
->func(L
, *(char**)lua_touserdata(L
, 1) + m
->offset
);
188 static int index_handler (lua_State
*L
)
190 /* stack has userdata, index */
191 lua_pushvalue(L
, 2); /* dup index */
192 lua_rawget(L
, lua_upvalueindex(1)); /* lookup member by name */
193 if (!lua_islightuserdata(L
, -1))
195 lua_pop(L
, 1); /* drop value */
196 lua_pushvalue(L
, 2); /* dup index */
197 lua_gettable(L
, lua_upvalueindex(2)); /* else try methods */
198 if (lua_isnil(L
, -1)) /* invalid member */
199 luaL_error(L
, "cannot get member '%s'", lua_tostring(L
, 2));
202 return Xet_call(L
); /* call get function */
205 static int newindex_handler (lua_State
*L
)
207 /* stack has userdata, index, value */
208 lua_pushvalue(L
, 2); /* dup index */
209 lua_rawget(L
, lua_upvalueindex(1)); /* lookup member by name */
210 if (!lua_islightuserdata(L
, -1)) /* invalid member */
211 luaL_error(L
, "cannot set member '%s'", lua_tostring(L
, 2));
212 return Xet_call(L
); /* call set function */
216 struct_register(lua_State
*L
, const char *name
, const luaL_reg fn_methods
[], const luaL_reg meta_methods
[],
217 const struct Xet_reg setters
[], const struct Xet_reg getters
[])
219 int metatable
, methods
;
221 /* create methods table & add it to the table of globals */
222 luaL_register(L
, name
, fn_methods
);
223 methods
= lua_gettop(L
);
225 /* create metatable & add it to the registry */
226 luaL_newmetatable(L
, name
);
227 luaL_register(L
, 0, meta_methods
); /* fill metatable */
229 /* To identify the type of object */
230 lua_pushstring(L
, "_objname");
231 lua_pushstring(L
, name
);
234 metatable
= lua_gettop(L
);
236 lua_pushliteral(L
, "__metatable");
237 lua_pushvalue(L
, methods
); /* dup methods table*/
238 lua_rawset(L
, metatable
); /* hide metatable:
239 metatable.__metatable = methods */
241 lua_pushliteral(L
, "__index");
242 lua_pushvalue(L
, metatable
); /* upvalue index 1 */
243 Xet_add(L
, getters
); /* fill metatable with getters */
244 lua_pushvalue(L
, methods
); /* upvalue index 2 */
245 lua_pushcclosure(L
, index_handler
, 2);
246 lua_rawset(L
, metatable
); /* metatable.__index = index_handler */
248 lua_pushliteral(L
, "__newindex");
249 lua_newtable(L
); /* table for members you can set */
250 Xet_add(L
, setters
); /* fill with setters */
251 lua_pushcclosure(L
, newindex_handler
, 1);
252 lua_rawset(L
, metatable
); /* metatable.__newindex = newindex_handler */
254 lua_pop(L
, 1); /* drop metatable */
255 return 1; /* return methods on the stack */
262 PUSH_TYPE(window
, struct win
)
264 CHECK_TYPE(window
, struct win
)
266 static int get_window(lua_State
*L
, void *v
)
268 push_window(L
, (struct win
**)v
);
273 window_change_title(lua_State
*L
)
275 struct win
*w
= check_window(L
, 1);
277 const char *title
= luaL_checklstring(L
, 2, &len
);
278 ChangeAKA(w
, (char *)title
, len
);
283 window_get_monitor_status(lua_State
*L
)
285 struct win
*w
= check_window(L
, 1);
286 int activity
= luaL_checkint(L
, 2);
289 lua_pushinteger(L
, w
->w_monitor
!= MON_OFF
);
292 lua_pushinteger(L
, w
->w_silence
== SILENCE_ON
? w
->w_silencewait
: 0);
297 static const luaL_reg window_methods
[] = {
298 {"get_monitor_status", window_get_monitor_status
},
299 {"hook", LuaRegEvent
},
304 window_tostring(lua_State
*L
)
307 struct win
*w
= check_window(L
, 1);
308 snprintf(str
, sizeof(str
), "{window #%d: '%s'}", w
->w_number
, w
->w_title
);
309 lua_pushstring(L
, str
);
314 window_equality(lua_State
*L
)
316 struct win
*w1
= check_window(L
, 1), *w2
= check_window(L
, 2);
317 lua_pushboolean(L
, (w1
== w2
|| (w1
&& w2
&& w1
->w_number
== w2
->w_number
)));
321 static const luaL_reg window_metamethods
[] = {
322 {"__tostring", window_tostring
},
323 {"__eq", window_equality
},
327 static const struct Xet_reg window_setters
[] = {
328 {"title", 0, 0, window_change_title
/*absolute setter*/},
332 static const struct Xet_reg window_getters
[] = {
333 {"title", get_string
, offsetof(struct win
, w_title
) + 8},
334 {"number", get_int
, offsetof(struct win
, w_number
)},
335 {"dir", get_string
, offsetof(struct win
, w_dir
)},
336 {"tty", get_string
, offsetof(struct win
, w_tty
)},
337 {"pid", get_int
, offsetof(struct win
, w_pid
)},
338 {"group", get_window
, offsetof(struct win
, w_group
)},
339 {"bell", get_int
, offsetof(struct win
, w_bell
)},
348 PUSH_TYPE(user
, struct acluser
)
350 CHECK_TYPE(user
, struct acluser
)
353 get_user(lua_State
*L
, void *v
)
355 push_user(L
, (struct acluser
**)v
);
359 static const luaL_reg user_methods
[] = {
364 user_tostring(lua_State
*L
)
367 struct acluser
*u
= check_user(L
, 1);
368 snprintf(str
, sizeof(str
), "{user '%s'}", u
->u_name
);
369 lua_pushstring(L
, str
);
373 static const luaL_reg user_metamethods
[] = {
374 {"__tostring", user_tostring
},
378 static const struct Xet_reg user_setters
[] = {
382 static const struct Xet_reg user_getters
[] = {
383 {"name", get_string
, offsetof(struct acluser
, u_name
)},
384 {"password", get_string
, offsetof(struct acluser
, u_password
)},
392 PUSH_TYPE(canvas
, struct canvas
)
394 CHECK_TYPE(canvas
, struct canvas
)
397 get_canvas(lua_State
*L
, void *v
)
399 push_canvas(L
, (struct canvas
**)v
);
404 canvas_select(lua_State
*L
)
406 struct canvas
*c
= check_canvas(L
, 1);
407 if (!display
|| D_forecv
== c
)
409 SetCanvasWindow(c
, Layer2Window(c
->c_layer
));
412 /* XXX: the following all is duplicated from process.c:DoAction.
413 * Should these be in some better place?
415 ResizeCanvas(&D_canvas
);
416 RecreateCanvasChain();
417 RethinkDisplayViewports();
418 ResizeLayersToCanvases(); /* redisplays */
419 fore
= D_fore
= Layer2Window(D_forecv
->c_layer
);
420 flayer
= D_forecv
->c_layer
;
422 if (D_xtermosc
[2] || D_xtermosc
[3])
432 flayer
= D_forecv
->c_layer
;
433 CV_CALL(D_forecv
, LayRestore();LaySetCursor());
434 WindowChanged(0, 'F');
438 static const luaL_reg canvas_methods
[] = {
439 {"select", canvas_select
},
443 static const luaL_reg canvas_metamethods
[] = {
447 static const struct Xet_reg canvas_setters
[] = {
452 canvas_get_window(lua_State
*L
)
454 struct canvas
*c
= check_canvas(L
, 1);
455 struct win
*win
= Layer2Window(c
->c_layer
);
457 push_window(L
, &win
);
463 static const struct Xet_reg canvas_getters
[] = {
464 {"next", get_canvas
, offsetof(struct canvas
, c_next
)},
465 {"xoff", get_int
, offsetof(struct canvas
, c_xoff
)},
466 {"yoff", get_int
, offsetof(struct canvas
, c_yoff
)},
467 {"xs", get_int
, offsetof(struct canvas
, c_xs
)},
468 {"ys", get_int
, offsetof(struct canvas
, c_ys
)},
469 {"xe", get_int
, offsetof(struct canvas
, c_xe
)},
470 {"ye", get_int
, offsetof(struct canvas
, c_ye
)},
471 {"window", 0, 0, canvas_get_window
},
479 PUSH_TYPE(layout
, struct layout
)
480 CHECK_TYPE(layout
, struct layout
)
482 static const struct Xet_reg layout_getters
[] = {
487 get_layout(lua_State
*L
, void *v
)
489 push_layout(L
, (struct layout
**)v
);
497 PUSH_TYPE(display
, struct display
)
499 CHECK_TYPE(display
, struct display
)
502 display_get_canvases(lua_State
*L
)
508 d
= check_display(L
, 1);
510 for (iter
= d
->d_cvlist
, count
= 0; iter
; iter
= iter
->c_next
, count
++) {
511 lua_pushinteger(L
, count
);
512 push_canvas(L
, &iter
);
519 static const luaL_reg display_methods
[] = {
520 {"get_canvases", display_get_canvases
},
525 display_tostring(lua_State
*L
)
528 struct display
*d
= check_display(L
, 1);
529 snprintf(str
, sizeof(str
), "{display: tty = '%s', term = '%s'}", d
->d_usertty
, d
->d_termname
);
530 lua_pushstring(L
, str
);
534 static const luaL_reg display_metamethods
[] = {
535 {"__tostring", display_tostring
},
539 static const struct Xet_reg display_setters
[] = {
543 static const struct Xet_reg display_getters
[] = {
544 {"tty", get_string
, offsetof(struct display
, d_usertty
)},
545 {"term", get_string
, offsetof(struct display
, d_termname
)},
546 {"fore", get_window
, offsetof(struct display
, d_fore
)},
547 {"other", get_window
, offsetof(struct display
, d_other
)},
548 {"width", get_int
, offsetof(struct display
, d_width
)},
549 {"height", get_int
, offsetof(struct display
, d_height
)},
550 {"user", get_user
, offsetof(struct display
, d_user
)},
551 {"layout", get_layout
, offsetof(struct display
, d_layout
)},
560 screen_get_windows(lua_State
*L
)
566 for (iter
= windows
, count
= 0; iter
; iter
= iter
->w_next
, count
++) {
567 lua_pushinteger(L
, iter
->w_number
);
568 push_window(L
, &iter
);
576 screen_get_displays(lua_State
*L
)
578 struct display
*iter
;
582 for (iter
= displays
, count
= 0; iter
; iter
= iter
->d_next
, count
++) {
583 lua_pushinteger(L
, count
);
584 push_display(L
, &iter
);
592 screen_get_display(lua_State
*L
)
594 push_display(L
, &display
);
599 screen_exec_command(lua_State
*L
)
604 command
= luaL_checklstring(L
, 1, &len
);
606 RcLine((char *)command
, len
);
612 screen_append_msg(lua_State
*L
)
614 const char *msg
, *color
;
616 msg
= luaL_checklstring(L
, 1, &len
);
620 color
= luaL_checklstring(L
, 2, &len
);
621 AppendWinMsgRend(msg
, color
);
626 script_input_fn(char *buf
, int len
, char *priv
)
628 lua_State
*L
= (lua_State
*)priv
;
629 lua_pushstring(L
, buf
);
630 if (lua_pcall(L
, 1, 0, 0) == LUA_ERRRUN
)
632 if(lua_isstring(L
, -1))
640 screen_input(lua_State
*L
)
642 char * prompt
= NULL
;
644 prompt
= (char *)luaL_checkstring(L
, 1);
645 Input(prompt
, 100, INP_COOKED
, script_input_fn
, (char *)L
, 0);
650 static const luaL_reg screen_methods
[] = {
651 {"windows", screen_get_windows
},
652 {"displays", screen_get_displays
},
653 {"display", screen_get_display
},
654 {"command", screen_exec_command
},
655 {"append_msg", screen_append_msg
},
656 {"hook", LuaRegEvent
},
657 {"unhook", LuaUnRegEvent
},
658 {"input", screen_input
},
662 static const luaL_reg screen_metamethods
[] = {
666 static const struct Xet_reg screen_setters
[] = {
670 static const struct Xet_reg screen_getters
[] = {
676 /** Public functions {{{ */
684 #define REGISTER(X) struct_register(L, #X , X ## _methods, X##_metamethods, X##_setters, X##_getters)
692 /* To store handler funcs */
693 luaL_getmetatable(L
, "screen");
694 lua_pushstring(L
, "_handlers");
702 /* An error message on top of the stack. */
704 LuaShowErr(lua_State
*L
)
706 struct display
*d
= display
;
708 const char *message
= luaL_checklstring(L
, -1, &len
);
709 LMsg(0, "%s", message
? message
: "Unknown error");
716 void (*push_fn
)(lua_State
*, void*);
721 LuaCallProcess(const char *name
, struct fn_def defs
[])
725 lua_getfield(L
, LUA_GLOBALSINDEX
, name
);
726 if (lua_isnil(L
, -1))
728 for (argc
= 0; defs
[argc
].push_fn
; argc
++)
729 defs
[argc
].push_fn(L
, defs
[argc
].value
);
730 if (lua_pcall(L
, argc
, 0, 0) == LUA_ERRRUN
&& lua_isstring(L
, -1))
738 int LuaSource(const char *file
, int async
)
743 if (stat(file
, &st
) == -1)
744 Msg(errno
, "Error loading lua script file '%s'", file
);
747 int len
= strlen(file
);
748 if (len
< 4 || strncmp(file
+ len
- 4, ".lua", 4) != 0)
750 if (luaL_dofile(L
, file
) && lua_isstring(L
, -1))
769 LuaProcessCaption(const char *caption
, struct win
*win
, int len
)
773 struct fn_def params
[] = {
774 {lua_pushstring
, caption
},
776 {lua_pushinteger
, len
},
779 return LuaCallProcess("process_caption", params
);
783 push_stringarray(lua_State
*L
, char **args
)
787 for (i
= 1; args
&& *args
; i
++) {
788 lua_pushinteger(L
, i
);
789 lua_pushstring(L
, *args
++);
795 LuaPushParams(lua_State
*L
, const char *params
, va_list va
)
803 lua_pushstring(L
, va_arg(va
, char *));
806 push_stringarray(L
, va_arg(va
, char **));
809 lua_pushinteger(L
, va_arg(va
, int));
817 int LuaCall(char *func
, char **argv
)
823 StackDump(L
, "Before LuaCall\n");
824 lua_getfield(L
, LUA_GLOBALSINDEX
, func
);
825 if (lua_isnil(L
, -1))
827 lua_pushstring(L
, "Could not find the script function\n");
831 for (argc
= 0; *argv
; argv
++, argc
++)
833 lua_pushstring(L
, *argv
);
835 if (lua_pcall(L
, argc
, 0, 0) == LUA_ERRRUN
)
837 if(lua_isstring(L
, -1))
839 StackDump(L
, "After LuaCall\n");
848 LuaDispatch(void *handler
, const char *params
, va_list va
)
850 const char *func
= handler
;
853 lua_getfield(L
, LUA_GLOBALSINDEX
, func
);
854 if (lua_isnil(L
, -1))
856 argc
= LuaPushParams(L
, params
, va
);
858 if (lua_pcall(L
, argc
, 1, 0) == LUA_ERRRUN
&& lua_isstring(L
, -1))
860 StackDump(L
, "After LuaDispatch\n");
864 retvalue
= lua_tonumber(L
, -1);
869 int LuaForeWindowChanged(void)
871 struct fn_def params
[] = {
872 {push_display
, &display
},
873 {push_window
, display
? &D_fore
: &fore
},
878 return LuaCallProcess("fore_changed", params
);
882 LuaCheckHandler(lua_State
*L
, int idx
, int reg
)
884 if (lua_isstring(L
, idx
))
886 const char * handler
;
887 /* registered with func name.*/
888 handler
= luaL_checkstring(L
, idx
);
889 lua_getfield(L
, LUA_GLOBALSINDEX
, handler
);
890 if (!lua_isfunction(L
, -1))
891 luaL_error(L
, "The specified handler %s in param #%d is not a function", handler
, idx
);
893 return SaveStr(handler
);
895 else if (lua_isfunction(L
, idx
))
900 idx
= lua_gettop(L
) + 1 - idx
;
902 luaL_getmetatable(L
, "screen");
903 lua_pushstring(L
, "_handlers");
905 if (lua_isnil(L
, -1))
906 luaL_error(L
, "Fatal! Should not happen! Fail to get global handler table!");
907 /* Map func to unique key and do reference count */
908 htable
= lua_gettop(L
);
909 lua_pushvalue(L
, idx
);
910 lua_gettable(L
, htable
);/*htable[func] ==?*/
911 if (lua_isnil(L
, -1))
916 lua_pushinteger(L
, 1);
917 key
= luaL_ref(L
, htable
); /*htable[key] = 1*/
918 lua_pushvalue(L
, idx
);
919 lua_pushinteger(L
, key
);
920 lua_settable(L
, htable
); /*htable[func]=key*/
925 key
= lua_tointeger(L
, -1);/*key = htable[func]*/
926 lua_gettable(L
, htable
);
927 cnt
= lua_tointeger(L
, -1);/*cnt = htable[key]*/
928 if (!reg
&& cnt
<= 1)
930 /*release the last reference*/
931 luaL_unref(L
, htable
, key
);
932 lua_pushvalue(L
, idx
);
934 lua_settable(L
, htable
); /*htable[func]=key*/
938 lua_pushinteger(L
, key
);
939 lua_pushinteger(L
, reg
? cnt
+ 1 : cnt
- 1);
940 lua_settable(L
, htable
); /*htable[key] = cnt + 1*/
945 snprintf(buf
, 20, "%d", key
);
949 luaL_error(L
, "Handler should be a function or the name of function");
953 #define SEVNAME_MAX 30
955 LuaRegEvent(lua_State
*L
)
957 /* signature: hook(obj, event, handler, priv);
958 * or: hook(event, handler, priv)
959 * returns: A ticket for later unregister. */
960 int idx
= 1, argc
= lua_gettop(L
);
961 unsigned int priv
= 31; /* Default privilege */
964 const char *objname
= "global";
966 static char evbuf
[SEVNAME_MAX
];
967 const char *event
, *handler
;
969 struct script_event
*sev
;
971 StackDump(L
, "Before RegEvent\n");
973 /* Identify the object, if specified */
974 if (luaL_getmetafield(L
, 1, "_objname"))
976 objname
= luaL_checkstring(L
, -1);
978 if (!strcmp("screen", objname
))
981 obj
= *(char **)lua_touserdata(L
, 1);
985 event
= luaL_checkstring(L
, idx
++);
986 snprintf(evbuf
, SEVNAME_MAX
, "%s_%s", objname
, event
);
988 /* Check and get the handler */
989 handler
= LuaCheckHandler(L
, idx
++, 1);
991 StackDump(L
, "In RegEvent\n");
994 priv
= luaL_checkinteger(L
, idx
);
996 sev
= object_get_event(obj
, evbuf
);
1000 l
= (struct listener
*)malloc(sizeof(struct listener
));
1002 return luaL_error(L
, "Out of memory");
1003 l
->handler
= (void *)handler
;
1005 l
->dispatcher
= LuaDispatch
;
1006 if (register_listener(sev
, l
))
1009 return luaL_error(L
, "Handler %s has already been registered", handler
);
1011 /*Return the handler for un-register*/
1012 lua_pushlightuserdata(L
, l
);
1015 return luaL_error(L
, "Invalid event specified: %s for object %s", event
, objname
);
1017 StackDump(L
, "After RegEvent\n");
1022 LuaUnRegEvent(lua_State
*L
)
1024 /* signature: release([obj], ticket, handler)
1025 * returns: true of success, false otherwise */
1028 const char *handler
;
1030 /* If the param is not as expected */
1031 if (!lua_islightuserdata(L
, idx
))
1033 /* Then it should be the userdata to be ignore, but if not ... */
1034 if (!lua_isuserdata(L
, idx
))
1035 luaL_checktype(L
, idx
, LUA_TLIGHTUSERDATA
);
1037 luaL_checktype(L
, idx
, LUA_TLIGHTUSERDATA
);
1040 l
= (struct listener
*)lua_touserdata(L
, idx
++);
1041 /* FIXME: May unref the func too earily*/
1042 handler
= LuaCheckHandler(L
, idx
++, 0);
1044 /*Validate the listener structure*/
1045 if (!l
|| !l
->handler
1046 || strncmp((char *)handler
, (char *)l
->handler
, SEVNAME_MAX
))
1049 lua_pushboolean(L
,0);
1054 unregister_listener(l
);
1055 lua_pushboolean(L
, 1);
1064 struct ScriptFuncs LuaFuncs
=
1066 LuaForeWindowChanged
,
1070 struct binding lua_binding
=