isbear@23: isbear@23: /* Copyright 2009 Myhailo Danylenko isbear@23: isbear@23: This file is part of lua-lm. isbear@23: isbear@23: lua-lm is free software: you can redistribute it and/or modify isbear@23: it under the terms of the GNU General Public License as published by isbear@23: the Free Software Foundation, either version 2 of the License, or isbear@23: (at your option) any later version. isbear@23: isbear@23: This program is distributed in the hope that it will be useful, isbear@23: but WITHOUT ANY WARRANTY; without even the implied warranty of isbear@23: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the isbear@23: GNU General Public License for more details. isbear@23: isbear@23: You should have received a copy of the GNU General Public License isbear@23: along with this program. If not, see . */ isbear@0: isbear@0: #include isbear@0: isbear@16: #include "config.h" isbear@0: #include "lm_types.h" isbear@0: #include "lm_message_node.h" isbear@0: #include "lm_message.h" isbear@0: #include "lm_message_handler.h" isbear@0: #include "lm_proxy.h" isbear@0: #include "lm_ssl.h" isbear@0: #include "lm_connection.h" isbear@0: isbear@8: /// Some common principles: isbear@8: /// Most methods can be used in two way: isbear@8: /// * to get value they are invoked without their last argument. Returned value is either a value or pair of nil and error message. isbear@8: /// * to set value they are invoked with last arg (value) specified. Returned value in most cases is an object, on which operation is performed (to allow chain-initialization). isbear@8: /// Every object have pointer method to return pointer (lightuserdata) to underlying C loudmouth structure. isbear@8: /// Every module have a bless method to convert given pointer (lightuserdata) to corresponding lua object. isbear@8: /// 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). isbear@8: /// Where message handler object is expected, message handler function can be specified. However, you can unregister handler only if you have message handler object. isbear@8: isbear@0: int luaopen_loudmouth (lua_State *L) isbear@0: { isbear@17: lua_pushliteral (L, LLM_OBJREGISTRY); // 1 registry key isbear@19: lua_newtable (L); // 2 registry value (table) isbear@19: lua_createtable (L, 0, 1); // 3 metatable isbear@19: lua_pushliteral (L, "v"); // 4 metatable value isbear@19: lua_setfield (L, -2, "__mode"); // 3 metatable isbear@19: lua_setmetatable (L, -2); // 2 registry value isbear@19: lua_rawset (L, LUA_REGISTRYINDEX); // 0 isbear@0: isbear@0: lua_createtable (L, 6, 0); isbear@0: luaopen_lm_message_node (L); isbear@19: lua_setfield (L, -2, "message_node"); isbear@0: luaopen_lm_message (L); isbear@19: lua_setfield (L, -2, "message"); isbear@0: luaopen_lm_message_handler (L); isbear@19: lua_setfield (L, -2, "message_handler"); isbear@0: luaopen_lm_proxy (L); isbear@19: lua_setfield (L, -2, "proxy"); isbear@0: luaopen_lm_ssl (L); isbear@19: lua_setfield (L, -2, "ssl"); isbear@0: luaopen_lm_connection (L); isbear@19: lua_setfield (L, -2, "connection"); isbear@0: isbear@0: return 1; isbear@0: } isbear@0: