author | Myhailo Danylenko <isbear@ukrpost.net> |
Sat, 05 Mar 2016 17:32:20 +0200 | |
changeset 64 | 82fc7c385c9a |
parent 43 | bb5aaea5dd21 |
permissions | -rw-r--r-- |
23 | 1 |
|
2 |
/* Copyright 2009 Myhailo Danylenko |
|
3 |
||
4 |
This file is part of lua-lm. |
|
5 |
||
6 |
lua-lm is free software: you can redistribute it and/or modify |
|
7 |
it under the terms of the GNU General Public License as published by |
|
8 |
the Free Software Foundation, either version 2 of the License, or |
|
9 |
(at your option) any later version. |
|
10 |
||
11 |
This program is distributed in the hope that it will be useful, |
|
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
GNU General Public License for more details. |
|
15 |
||
16 |
You should have received a copy of the GNU General Public License |
|
17 |
along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
|
0 | 18 |
|
19 |
#include <lua.h> |
|
20 |
||
16
09b375e9ce32
Switch to new module organization scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
8
diff
changeset
|
21 |
#include "config.h" |
0 | 22 |
#include "lm_types.h" |
23 |
#include "lm_message_node.h" |
|
24 |
#include "lm_message.h" |
|
25 |
#include "lm_message_handler.h" |
|
26 |
#include "lm_proxy.h" |
|
27 |
#include "lm_ssl.h" |
|
28 |
#include "lm_connection.h" |
|
29 |
||
43
bb5aaea5dd21
Small documentation update
Myhailo Danylenko <isbear@ukrpost.net>
parents:
23
diff
changeset
|
30 |
/// Some common principles |
8 | 31 |
/// Most methods can be used in two way: |
32 |
/// * to get value they are invoked without their last argument. Returned value is either a value or pair of nil and error message. |
|
33 |
/// * 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). |
|
34 |
/// Every object have pointer method to return pointer (lightuserdata) to underlying C loudmouth structure. |
|
35 |
/// Every module have a bless method to convert given pointer (lightuserdata) to corresponding lua object. |
|
36 |
/// 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). |
|
37 |
/// Where message handler object is expected, message handler function can be specified. However, you can unregister handler only if you have message handler object. |
|
38 |
||
0 | 39 |
int luaopen_loudmouth (lua_State *L) |
40 |
{ |
|
17 | 41 |
lua_pushliteral (L, LLM_OBJREGISTRY); // 1 registry key |
19
d775d7289fe4
Use lua_pushliteral and lua_setfield
Myhailo Danylenko <isbear@ukrpost.net>
parents:
17
diff
changeset
|
42 |
lua_newtable (L); // 2 registry value (table) |
d775d7289fe4
Use lua_pushliteral and lua_setfield
Myhailo Danylenko <isbear@ukrpost.net>
parents:
17
diff
changeset
|
43 |
lua_createtable (L, 0, 1); // 3 metatable |
d775d7289fe4
Use lua_pushliteral and lua_setfield
Myhailo Danylenko <isbear@ukrpost.net>
parents:
17
diff
changeset
|
44 |
lua_pushliteral (L, "v"); // 4 metatable value |
d775d7289fe4
Use lua_pushliteral and lua_setfield
Myhailo Danylenko <isbear@ukrpost.net>
parents:
17
diff
changeset
|
45 |
lua_setfield (L, -2, "__mode"); // 3 metatable |
d775d7289fe4
Use lua_pushliteral and lua_setfield
Myhailo Danylenko <isbear@ukrpost.net>
parents:
17
diff
changeset
|
46 |
lua_setmetatable (L, -2); // 2 registry value |
d775d7289fe4
Use lua_pushliteral and lua_setfield
Myhailo Danylenko <isbear@ukrpost.net>
parents:
17
diff
changeset
|
47 |
lua_rawset (L, LUA_REGISTRYINDEX); // 0 |
0 | 48 |
|
49 |
lua_createtable (L, 6, 0); |
|
50 |
luaopen_lm_message_node (L); |
|
19
d775d7289fe4
Use lua_pushliteral and lua_setfield
Myhailo Danylenko <isbear@ukrpost.net>
parents:
17
diff
changeset
|
51 |
lua_setfield (L, -2, "message_node"); |
0 | 52 |
luaopen_lm_message (L); |
19
d775d7289fe4
Use lua_pushliteral and lua_setfield
Myhailo Danylenko <isbear@ukrpost.net>
parents:
17
diff
changeset
|
53 |
lua_setfield (L, -2, "message"); |
0 | 54 |
luaopen_lm_message_handler (L); |
19
d775d7289fe4
Use lua_pushliteral and lua_setfield
Myhailo Danylenko <isbear@ukrpost.net>
parents:
17
diff
changeset
|
55 |
lua_setfield (L, -2, "message_handler"); |
0 | 56 |
luaopen_lm_proxy (L); |
19
d775d7289fe4
Use lua_pushliteral and lua_setfield
Myhailo Danylenko <isbear@ukrpost.net>
parents:
17
diff
changeset
|
57 |
lua_setfield (L, -2, "proxy"); |
0 | 58 |
luaopen_lm_ssl (L); |
19
d775d7289fe4
Use lua_pushliteral and lua_setfield
Myhailo Danylenko <isbear@ukrpost.net>
parents:
17
diff
changeset
|
59 |
lua_setfield (L, -2, "ssl"); |
0 | 60 |
luaopen_lm_connection (L); |
19
d775d7289fe4
Use lua_pushliteral and lua_setfield
Myhailo Danylenko <isbear@ukrpost.net>
parents:
17
diff
changeset
|
61 |
lua_setfield (L, -2, "connection"); |
0 | 62 |
|
63 |
return 1; |
|
64 |
} |
|
65 |