lm.c
changeset 19 d775d7289fe4
parent 17 ab4470465a0c
child 23 13f03e604c8a
equal deleted inserted replaced
18:6effa1929af7 19:d775d7289fe4
    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_pushliteral (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_pushliteral (L, "__mode");        // 4 metatable key
    27 	lua_pushliteral (L, "v");             // 4 metatable value
    28 	lua_pushliteral (L, "v");             // 5 metatable value
    28 	lua_setfield (L, -2, "__mode");       // 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
       
    32 	
    31 	
    33 	lua_createtable (L, 6, 0);
    32 	lua_createtable (L, 6, 0);
    34 
       
    35 	lua_pushliteral (L, "message_node");
       
    36 	luaopen_lm_message_node (L);
    33 	luaopen_lm_message_node (L);
    37 	lua_settable (L, -3);
    34 	lua_setfield (L, -2, "message_node");
    38 	lua_pushliteral (L, "message");
       
    39 	luaopen_lm_message (L);
    35 	luaopen_lm_message (L);
    40 	lua_settable (L, -3);
    36 	lua_setfield (L, -2, "message");
    41 	lua_pushliteral (L, "message_handler");
       
    42 	luaopen_lm_message_handler (L);
    37 	luaopen_lm_message_handler (L);
    43 	lua_settable (L, -3);
    38 	lua_setfield (L, -2, "message_handler");
    44 	lua_pushliteral (L, "proxy");
       
    45 	luaopen_lm_proxy (L);
    39 	luaopen_lm_proxy (L);
    46 	lua_settable (L, -3);
    40 	lua_setfield (L, -2, "proxy");
    47 	lua_pushliteral (L, "ssl");
       
    48 	luaopen_lm_ssl (L);
    41 	luaopen_lm_ssl (L);
    49 	lua_settable (L, -3);
    42 	lua_setfield (L, -2, "ssl");
    50 	lua_pushliteral (L, "connection");
       
    51 	luaopen_lm_connection (L);
    43 	luaopen_lm_connection (L);
    52 	lua_settable (L, -3);
    44 	lua_setfield (L, -2, "connection");
    53 
    45 
    54 	return 1;
    46 	return 1;
    55 }
    47 }
    56 
    48