author | Myhailo Danylenko <isbear@ukrpost.net> |
Fri, 27 Mar 2009 09:43:25 +0200 | |
changeset 15 | 1a5dd51722f5 |
parent 8 | 951f92c66821 |
child 16 | 09b375e9ce32 |
permissions | -rw-r--r-- |
0 | 1 |
|
2 |
#include <lua.h> |
|
3 |
||
4 |
#include "lm_types.h" |
|
5 |
#include "lm_message_node.h" |
|
6 |
#include "lm_message.h" |
|
7 |
#include "lm_message_handler.h" |
|
8 |
#include "lm_proxy.h" |
|
9 |
#include "lm_ssl.h" |
|
10 |
#include "lm_connection.h" |
|
11 |
||
8 | 12 |
/// Some common principles: |
13 |
/// Most methods can be used in two way: |
|
14 |
/// * to get value they are invoked without their last argument. Returned value is either a value or pair of nil and error message. |
|
15 |
/// * 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). |
|
16 |
/// Every object have pointer method to return pointer (lightuserdata) to underlying C loudmouth structure. |
|
17 |
/// Every module have a bless method to convert given pointer (lightuserdata) to corresponding lua object. |
|
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 |
/// 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 |
||
0 | 21 |
int luaopen_loudmouth (lua_State *L) |
22 |
{ |
|
23 |
lua_pushstring (L, LLM_OBJREGISTRY); // 1 registry key |
|
24 |
lua_newtable (L); // 2 registry value (table) |
|
25 |
lua_createtable (L, 0, 1); // 3 metatable |
|
26 |
lua_pushstring (L, "__mode"); // 4 metatable key |
|
27 |
lua_pushstring (L, "v"); // 5 metatable value |
|
28 |
lua_settable (L, -3); // 3 metatable |
|
29 |
lua_setmetatable (L, -2); // 2 registry value |
|
30 |
lua_rawset (L, LUA_REGISTRYINDEX); // 0 |
|
31 |
||
32 |
lua_createtable (L, 6, 0); |
|
7
5db1448eb857
Message have node methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
6
diff
changeset
|
33 |
lua_pushvalue (L, -1); |
5db1448eb857
Message have node methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
6
diff
changeset
|
34 |
lua_setglobal (L, "lm"); |
0 | 35 |
|
36 |
luaopen_lm_message_node (L); |
|
37 |
luaopen_lm_message (L); |
|
38 |
luaopen_lm_message_handler (L); |
|
39 |
luaopen_lm_proxy (L); |
|
40 |
luaopen_lm_ssl (L); |
|
41 |
luaopen_lm_connection (L); |
|
42 |
lua_pop (L, 6); |
|
43 |
||
44 |
return 1; |
|
45 |
} |
|
46 |