aboutsummaryrefslogtreecommitdiff
path: root/src/serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/serial.c')
-rw-r--r--src/serial.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/serial.c b/src/serial.c
index 5b09e76..66e8da6 100644
--- a/src/serial.c
+++ b/src/serial.c
@@ -55,6 +55,8 @@ static luaL_Reg serial_methods[] = {
55}; 55};
56 56
57/* our socket creation function */ 57/* our socket creation function */
58/* this is an ad-hoc module that returns a single function
59 * as such, do not include other functions in this array. */
58static luaL_Reg func[] = { 60static luaL_Reg func[] = {
59 {"serial", global_create}, 61 {"serial", global_create},
60 {NULL, NULL} 62 {NULL, NULL}
@@ -69,11 +71,13 @@ LUASOCKET_API int luaopen_socket_serial(lua_State *L) {
69 auxiliar_newclass(L, "serial{client}", serial_methods); 71 auxiliar_newclass(L, "serial{client}", serial_methods);
70 /* create class groups */ 72 /* create class groups */
71 auxiliar_add2group(L, "serial{client}", "serial{any}"); 73 auxiliar_add2group(L, "serial{client}", "serial{any}");
72 /* make sure the function ends up in the package table */ 74#if LUA_VERSION_NUM > 501 && !defined(LUA_COMPAT_MODULE)
75 lua_pushcfunction(L, global_create);
76#else
77 /* set function into socket namespace */
73 luaL_openlib(L, "socket", func, 0); 78 luaL_openlib(L, "socket", func, 0);
74 /* return the function instead of the 'socket' table */ 79 lua_pushcfunction(L, global_create);
75 lua_pushstring(L, "serial"); 80#endif
76 lua_gettable(L, -2);
77 return 1; 81 return 1;
78} 82}
79 83