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 /// 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). |
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 /// Where message handler object is expected, message handler function can be specified. However, you can unregister handler only if you have message handler object. |
21 |
21 |
22 int luaopen_loudmouth (lua_State *L) |
22 int luaopen_loudmouth (lua_State *L) |
23 { |
23 { |
24 lua_pushconststring (L, LLM_OBJREGISTRY); // 1 registry key |
24 lua_pushliteral (L, LLM_OBJREGISTRY); // 1 registry key |
25 lua_newtable (L); // 2 registry value (table) |
25 lua_newtable (L); // 2 registry value (table) |
26 lua_createtable (L, 0, 1); // 3 metatable |
26 lua_createtable (L, 0, 1); // 3 metatable |
27 lua_pushconststring (L, "__mode"); // 4 metatable key |
27 lua_pushliteral (L, "__mode"); // 4 metatable key |
28 lua_pushconststring (L, "v"); // 5 metatable value |
28 lua_pushliteral (L, "v"); // 5 metatable value |
29 lua_settable (L, -3); // 3 metatable |
29 lua_settable (L, -3); // 3 metatable |
30 lua_setmetatable (L, -2); // 2 registry value |
30 lua_setmetatable (L, -2); // 2 registry value |
31 lua_rawset (L, LUA_REGISTRYINDEX); // 0 |
31 lua_rawset (L, LUA_REGISTRYINDEX); // 0 |
32 |
32 |
33 lua_createtable (L, 6, 0); |
33 lua_createtable (L, 6, 0); |
34 |
34 |
35 lua_pushconststring (L, "message_node"); |
35 lua_pushliteral (L, "message_node"); |
36 luaopen_lm_message_node (L); |
36 luaopen_lm_message_node (L); |
37 lua_settable (L, -3); |
37 lua_settable (L, -3); |
38 lua_pushconststring (L, "message"); |
38 lua_pushliteral (L, "message"); |
39 luaopen_lm_message (L); |
39 luaopen_lm_message (L); |
40 lua_settable (L, -3); |
40 lua_settable (L, -3); |
41 lua_pushconststring (L, "message_handler"); |
41 lua_pushliteral (L, "message_handler"); |
42 luaopen_lm_message_handler (L); |
42 luaopen_lm_message_handler (L); |
43 lua_settable (L, -3); |
43 lua_settable (L, -3); |
44 lua_pushconststring (L, "proxy"); |
44 lua_pushliteral (L, "proxy"); |
45 luaopen_lm_proxy (L); |
45 luaopen_lm_proxy (L); |
46 lua_settable (L, -3); |
46 lua_settable (L, -3); |
47 lua_pushconststring (L, "ssl"); |
47 lua_pushliteral (L, "ssl"); |
48 luaopen_lm_ssl (L); |
48 luaopen_lm_ssl (L); |
49 lua_settable (L, -3); |
49 lua_settable (L, -3); |
50 lua_pushconststring (L, "connection"); |
50 lua_pushliteral (L, "connection"); |
51 luaopen_lm_connection (L); |
51 luaopen_lm_connection (L); |
52 lua_settable (L, -3); |
52 lua_settable (L, -3); |
53 |
53 |
54 return 1; |
54 return 1; |
55 } |
55 } |