18 /// Every unique C loudmouth object have only one corresponding lua object. Thus, result of "lm.message.bless ( message1:pointer () )" will be exactly message1 object (not its copy). |
19 /// Every unique C loudmouth object have only one corresponding lua object. Thus, result of "lm.message.bless ( message1:pointer () )" will be exactly message1 object (not its copy). |
19 /// Where message handler object is expected, message handler function can be specified. However, you can unregister handler only if you have message handler object. |
20 /// Where message handler object is expected, message handler function can be specified. However, you can unregister handler only if you have message handler object. |
20 |
21 |
21 int luaopen_loudmouth (lua_State *L) |
22 int luaopen_loudmouth (lua_State *L) |
22 { |
23 { |
23 lua_pushstring (L, LLM_OBJREGISTRY); // 1 registry key |
24 lua_pushconststring (L, LLM_OBJREGISTRY); // 1 registry key |
24 lua_newtable (L); // 2 registry value (table) |
25 lua_newtable (L); // 2 registry value (table) |
25 lua_createtable (L, 0, 1); // 3 metatable |
26 lua_createtable (L, 0, 1); // 3 metatable |
26 lua_pushstring (L, "__mode"); // 4 metatable key |
27 lua_pushconststring (L, "__mode"); // 4 metatable key |
27 lua_pushstring (L, "v"); // 5 metatable value |
28 lua_pushconststring (L, "v"); // 5 metatable value |
28 lua_settable (L, -3); // 3 metatable |
29 lua_settable (L, -3); // 3 metatable |
29 lua_setmetatable (L, -2); // 2 registry value |
30 lua_setmetatable (L, -2); // 2 registry value |
30 lua_rawset (L, LUA_REGISTRYINDEX); // 0 |
31 lua_rawset (L, LUA_REGISTRYINDEX); // 0 |
31 |
32 |
32 lua_createtable (L, 6, 0); |
33 lua_createtable (L, 6, 0); |
33 lua_pushvalue (L, -1); |
|
34 lua_setglobal (L, "lm"); |
|
35 |
34 |
|
35 lua_pushconststring (L, "message_node"); |
36 luaopen_lm_message_node (L); |
36 luaopen_lm_message_node (L); |
|
37 lua_settable (L, -3); |
|
38 lua_pushconststring (L, "message"); |
37 luaopen_lm_message (L); |
39 luaopen_lm_message (L); |
|
40 lua_settable (L, -3); |
|
41 lua_pushconststring (L, "message_handler"); |
38 luaopen_lm_message_handler (L); |
42 luaopen_lm_message_handler (L); |
|
43 lua_settable (L, -3); |
|
44 lua_pushconststring (L, "proxy"); |
39 luaopen_lm_proxy (L); |
45 luaopen_lm_proxy (L); |
|
46 lua_settable (L, -3); |
|
47 lua_pushconststring (L, "ssl"); |
40 luaopen_lm_ssl (L); |
48 luaopen_lm_ssl (L); |
|
49 lua_settable (L, -3); |
|
50 lua_pushconststring (L, "connection"); |
41 luaopen_lm_connection (L); |
51 luaopen_lm_connection (L); |
42 lua_pop (L, 6); |
52 lua_settable (L, -3); |
43 |
53 |
44 return 1; |
54 return 1; |
45 } |
55 } |
46 |
56 |