diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-09-27 04:01:18 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-09-27 04:01:18 +0000 |
commit | a04f15d1ca440006a53bd0d9f98c12e5abebd969 (patch) | |
tree | 30d37d74b5c99d5d0e7489a421ec44ad0150113f /src/luasocket.c | |
parent | e1d318f26cf53ce9b2c3044d8d138956150488c7 (diff) | |
download | luasocket-a04f15d1ca440006a53bd0d9f98c12e5abebd969.tar.gz luasocket-a04f15d1ca440006a53bd0d9f98c12e5abebd969.tar.bz2 luasocket-a04f15d1ca440006a53bd0d9f98c12e5abebd969.zip |
Using new module scheme. Still needs fine tuning.
Diffstat (limited to 'src/luasocket.c')
-rw-r--r-- | src/luasocket.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/luasocket.c b/src/luasocket.c index 735235a..ebe9f5f 100644 --- a/src/luasocket.c +++ b/src/luasocket.c | |||
@@ -19,6 +19,7 @@ | |||
19 | \*=========================================================================*/ | 19 | \*=========================================================================*/ |
20 | #include <lua.h> | 20 | #include <lua.h> |
21 | #include <lauxlib.h> | 21 | #include <lauxlib.h> |
22 | #include <compat-5.1.h> | ||
22 | 23 | ||
23 | /*=========================================================================*\ | 24 | /*=========================================================================*\ |
24 | * LuaSocket includes | 25 | * LuaSocket includes |
@@ -85,9 +86,8 @@ static int global_unload(lua_State *L) { | |||
85 | \*-------------------------------------------------------------------------*/ | 86 | \*-------------------------------------------------------------------------*/ |
86 | static int base_open(lua_State *L) { | 87 | static int base_open(lua_State *L) { |
87 | if (sock_open()) { | 88 | if (sock_open()) { |
88 | /* whoever is loading the library replaced the global environment | 89 | /* export functions (and leave namespace table on top of stack) */ |
89 | * with the namespace table */ | 90 | luaL_module(L, "socket", func, 0); |
90 | lua_pushvalue(L, LUA_GLOBALSINDEX); | ||
91 | #ifdef LUASOCKET_DEBUG | 91 | #ifdef LUASOCKET_DEBUG |
92 | lua_pushstring(L, "DEBUG"); | 92 | lua_pushstring(L, "DEBUG"); |
93 | lua_pushboolean(L, 1); | 93 | lua_pushboolean(L, 1); |
@@ -97,8 +97,6 @@ static int base_open(lua_State *L) { | |||
97 | lua_pushstring(L, "VERSION"); | 97 | lua_pushstring(L, "VERSION"); |
98 | lua_pushstring(L, LUASOCKET_VERSION); | 98 | lua_pushstring(L, LUASOCKET_VERSION); |
99 | lua_rawset(L, -3); | 99 | lua_rawset(L, -3); |
100 | /* export other functions */ | ||
101 | luaL_openlib(L, NULL, func, 0); | ||
102 | return 1; | 100 | return 1; |
103 | } else { | 101 | } else { |
104 | lua_pushstring(L, "unable to initialize library"); | 102 | lua_pushstring(L, "unable to initialize library"); |
@@ -110,7 +108,7 @@ static int base_open(lua_State *L) { | |||
110 | /*-------------------------------------------------------------------------*\ | 108 | /*-------------------------------------------------------------------------*\ |
111 | * Initializes all library modules. | 109 | * Initializes all library modules. |
112 | \*-------------------------------------------------------------------------*/ | 110 | \*-------------------------------------------------------------------------*/ |
113 | LUASOCKET_API int luaopen_socket(lua_State *L) { | 111 | LUASOCKET_API int luaopen_lsocket(lua_State *L) { |
114 | int i; | 112 | int i; |
115 | base_open(L); | 113 | base_open(L); |
116 | for (i = 0; mod[i].name; i++) mod[i].func(L); | 114 | for (i = 0; mod[i].name; i++) mod[i].func(L); |