v0.0.3 Module and command names include lua version
* change package naming convention: mcabber-mod-lua5.x
* command lua5.x
* installs alias lua -> lua5.x
* module name lua5.x
--- a/CMakeLists.txt Wed Nov 28 04:27:33 2012 +0200
+++ b/CMakeLists.txt Wed Nov 28 18:38:52 2012 +0200
@@ -16,15 +16,18 @@
cmake_minimum_required(VERSION 2.6)
project(lua C)
-set(PROJECT_VERSION "0.0.2")
+set(PROJECT_VERSION "0.0.3")
## User options
option(DEBUG "Enable debugging output" ON)
option(WANT_LUA52 "Use lua 5.2 instead of 5.1" OFF)
+option(ENABLE_LUA_ALIAS "Enable aliasing command '/lua' to corresponding '/lua5.x' at module loading time" ON)
option(LLM_CONNECTION_ENABLE "Enable exposing of mcabber loudmouth connection to lua" ON)
option(LLM_LOG_HANDLER "Enable registration of log messages handler for lua-loudmouth library's messages" ON)
set(ML_SOURCE_PRIORITY G_PRIORITY_HIGH_IDLE CACHE STRING "Glib event source priority for timeout and bgread")
set(ML_BGREAD_BUFFER 4096 CACHE STRING "Background pipe reading buffer size")
+set(OPT_MLUA_RC "lua_init_filename" CACHE STRING "Mcabber option name to specify lua initialization file")
+set(OPT_MLUA_LM_DEBUG "lua_lm_debug" CACHE STRING "Mcabber option name to enable/disable lua logging of LM messages")
## Gather information about system
find_package(PkgConfig REQUIRED)
@@ -74,7 +77,7 @@
${MCABBER_LIBRARRIES})
include_directories(${lua_SOURCE_DIR}
${lua_BINARY_DIR})
-set_target_properties(lua PROPERTIES COMPILE_FLAGS "-Wall")
+set_target_properties(lua PROPERTIES COMPILE_FLAGS "-Wall" OUTPUT_NAME "lua${LUA_VERSION}")
## Extra targets
if(DOCGEN_EXECUTABLE)
@@ -85,11 +88,11 @@
endif()
## Packaging information
-set(CPACK_PACKAGE_NAME libmcabber-lua)
+set(CPACK_PACKAGE_NAME mcabber-mod-lua${LUA_VERSION})
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_VENDOR "IsBear")
set(CPACK_PACKAGE_CONTACT "Myhailo Danylenko <isbear@ukrpost.net>")
-set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Mcabber lua module")
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Mcabber module for lua ${LUA_VERSION} scripting")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${lua_SOURCE_DIR}/README)
set(CPACK_RESOURCE_FILE_LICENSE ${lua_SOURCE_DIR}/COPYING)
set(CPACK_RESOURCE_FILE_README ${lua_SOURCE_DIR}/README)
@@ -117,7 +120,9 @@
else()
set(AVV_COMPL_VERSION "compl:3")
endif()
-configure_file(lua.avv.in lua.avv)
+string(REPLACE "." "_" AVV_FILENAME "lua${LUA_VERSION}")
+set(MODULE_RELATIVE_PATH "lib/mcabber/${CMAKE_SHARED_MODULE_PREFIX}lua${LUA_VERSION}${CMAKE_SHARED_MODULE_SUFFIX}")
+configure_file(lua.avv.in.in "${AVV_FILENAME}.avv.in" @ONLY)
## Set up installer
install(TARGETS lua DESTINATION lib/mcabber)
@@ -126,7 +131,8 @@
endif()
install(DIRECTORY examples DESTINATION share/doc/${CPACK_PACKAGE_NAME} PATTERN "*~" EXCLUDE)
install(FILES docs/readme.mdwn docs/todo.mdwn COPYING DESTINATION share/doc/${CPACK_PACKAGE_NAME})
-install(DIRECTORY help DESTINATION share/mcabber)
-install(FILES ${PROJECT_BINARY_DIR}/lua.avv DESTINATION share/mcabber/avv/modules RENAME lua)
+install(FILES help/en/hlp_lua.txt DESTINATION share/mcabber RENAME hlp_lua${LUA_VERSION}.txt) # XXX localizations/other help
+install(CODE "configure_file(${PROJECT_BINARY_DIR}/${AVV_FILENAME}.avv.in ${PROJECT_BINARY_DIR}/${AVV_FILENAME}.avv)")
+install(FILES ${PROJECT_BINARY_DIR}/${AVV_FILENAME}.avv DESTINATION share/mcabber/avv/modules RENAME ${AVV_FILENAME})
## The End ## vim: se ts=4 sw=4: ##
--- a/config.h.in Wed Nov 28 04:27:33 2012 +0200
+++ b/config.h.in Wed Nov 28 18:38:52 2012 +0200
@@ -27,6 +27,9 @@
// define this if you are building with lua 5.2
#cmakedefine HAVE_LUA52
+// define this if you want lua to create alias to '/lua' at module loading
+#cmakedefine ENABLE_LUA_ALIAS
+
// define this to enable exporting mcabber connection for lua-loudmouth
#cmakedefine LLM_CONNECTION_ENABLE
@@ -41,9 +44,14 @@
#define PROJECT_VERSION ( "${PROJECT_VERSION}" )
+#define MLUA_COMMAND_NAME "lua${LUA_VERSION}"
+#define OPT_MLUA_RC "${OPT_MLUA_RC}"
+#define OPT_MLUA_LM_DEBUG "${OPT_MLUA_LM_DEBUG}"
+
#ifndef HAVE_LUA52
# define lua_rawlen lua_objlen
# define luaL_setfuncs(STATE, REGTABLE, IGZERO) luaL_register ( STATE, NULL, REGTABLE )
+# define info_lua5_2 info_lua5_1
#endif
#ifdef DEBUG
--- a/docs/readme.mdwn Wed Nov 28 04:27:33 2012 +0200
+++ b/docs/readme.mdwn Wed Nov 28 18:38:52 2012 +0200
@@ -1,15 +1,21 @@
# Lua scripting for MCabber
-This module creates lua interpreter environment and puts some lua
-functions in it to interact with mcabber. Module provides command 'lua'
-to run lua expressions in that environment.
+This module creates lua 5.1 or 5.2 interpreter environment and puts some lua
+functions inside for your code to interact with mcabber.
+
+Module provides mcabber command `/lua5.1` or `/lua5.2` respectively and adds
+an alias `/lua` for that command. This command evaluates argument as lua code in
+created by module environment.
-Lua interface is available in api reference, built with 'docgen' help.
-It is also available online.
+Note: If you load both versions - `lua5.1` and `lua5.2`, alias will point to
+which was loaded last.
-In 'examples' dir there are some example scripts, that may be used as
-is or for reference. See also 'README' in 'examples' dir.
+Lua functions, available in environment are described in api reference, built
+with `docgen` help. It is also available online.
+
+In `examples` dir there are some example scripts, that may be used as is or for
+reference. See also `README` in `examples` dir.
# Installation
@@ -37,11 +43,20 @@
Debian users can instead of make install do:
$ make package
- # dpkg -i libmcabber-lua_*.deb
+ # dpkg -i mcabber-mod-lua5.?_*.deb
Users of other distributions can select appropriate package generator,
using cache editor.
+# Building options
+
+Through `make edit_cache` action you can adjust module parameters. Notably: if
+you set `WANT_LUA52`, module will be built against lua5.2, even if lua5.1 is
+present; you can disable aliasing `lua` command at module loading time by
+unsetting `ENABLE_LUA_ALIAS`; you can adjust mcabber option names to be
+version-specific, if you need both versions running simultaneously via
+`OPT_MLUA_RC` and `OPT_MLUA_DEBUG`.
+
# License
This code underlies terms of GNU GPL v2 or later. You can find it in
--- a/docs/todo.mdwn Wed Nov 28 04:27:33 2012 +0200
+++ b/docs/todo.mdwn Wed Nov 28 18:38:52 2012 +0200
@@ -1,30 +1,24 @@
* finish roster list information
* non-setting settings?
-* mcabber_config_file use option to set dir?
* do uninitialization of commands and features with objects?
* help system accessors (needs major rewrite and planning)
* object access to roster and buddies?
* in mcabber add hook/call to also handle room status changes
-* well, so, mcabber will pass all arguments to hooks in utf. but do we really need to convert names to utf?
+* well, so, mcabber will pass all arguments to hooks in utf. but do we really
+ need to convert names to utf?
* use glib filename charset conversion functions?
* toggle routine should handle multiple status toggles
-* think about how tune notification should act on start/quit
-* clarify situation with disco, maybe it is due to this we are unable to receive pep events
* lm debug should be more flexible
-* common pubsub infrastructure, in particular, xmlns-based event handlers?
* forms abandoning hook to inform server
* eliminate main.parse_args?
-* common disco routines should get connection object from outer space - no mcabber dependency, the same for forms parsing, pep sending (though it anyway needs to be converted to pubsub)...
-* tune should set self-song only on reply from server
+* common disco routines should get connection object from outer space - no
+ mcabber dependency, the same for forms parsing, pep sending (though it anyway
+ needs to be converted to pubsub)...
* test node config
* publish library handlers?
* check all that callbacks for empty 'to' fields in print_info
* reply routine?
-* put here mcabber headers snapshot
-* put here mcabber-modules patch
-* change module name to just lua?
-* go through TODO and remove done :/
-* update build system
* check for resource freeing on unloading
+* update TODO :/
--- a/lua.avv.in Wed Nov 28 04:27:33 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-
-Name: ${PROJECT_NAME}
-Method: glib
-Version: ${PROJECT_VERSION}
-Description: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}
-# commands depend on build environment: 4+3, 2+1
-# completion depends on constants: 3, 2+1
-Requires: utils:2 + ( roster:4 | roster:3 | roster:2 | roster:1 ) + ( commands:4 | commands:3 ) +
- ( ${AVV_COMPL_VERSION} ) + events:1 + utils:2 + ( hooks:5 | hooks:4 | hooks:3 | hooks:2 ) +
- ( xmpp:6 | xmpp:5 | xmpp:4 | xmpp:3 | xmpp:2 | xmpp:1 ) + api:1 + main:1 +
- ( screen:10 | screen:9 | screen:8 | screen:7 | screen:6 | screen:5 | screen:4 ) +
- logprint:3 + ( hbuf:3 | hbuf:2 | hbuf:1 ) + settings:1 +
- ( xmpp_helper:2 | xmpp_helper:1 )
-Provides: lua:1
-Init: mlua_init
-Uninit: mlua_uninit
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lua.avv.in.in Wed Nov 28 18:38:52 2012 +0200
@@ -0,0 +1,18 @@
+
+Name: @PROJECT_NAME@@LUA_VERSION@
+Method: glib
+Location: ${CMAKE_INSTALL_PREFIX}/@MODULE_RELATIVE_PATH@
+Version: @PROJECT_VERSION@
+Description: @CPACK_PACKAGE_DESCRIPTION_SUMMARY@
+# commands depend on build environment: 4+3, 2+1
+# completion depends on constants: 3, 2+1
+Requires: utils:2 + ( roster:4 | roster:3 | roster:2 | roster:1 ) + ( commands:4 | commands:3 ) +
+ ( ${AVV_COMPL_VERSION} ) + events:1 + utils:2 + ( hooks:5 | hooks:4 | hooks:3 | hooks:2 ) +
+ ( xmpp:6 | xmpp:5 | xmpp:4 | xmpp:3 | xmpp:2 | xmpp:1 ) + api:1 + main:1 +
+ ( screen:10 | screen:9 | screen:8 | screen:7 | screen:6 | screen:5 | screen:4 ) +
+ logprint:3 + ( hbuf:3 | hbuf:2 | hbuf:1 ) + settings:1 +
+ ( xmpp_helper:2 | xmpp_helper:1 )
+Provides: lua:1
+Init: mlua_init
+Uninit: mlua_uninit
+
--- a/lua.c Wed Nov 28 04:27:33 2012 +0200
+++ b/lua.c Wed Nov 28 18:38:52 2012 +0200
@@ -49,15 +49,9 @@
/// Module provides embedded lua environment with some accessors to
/// mcabber functionality.
-//
-// options
-//
-
/// Options
/// * lua_init_filename - lua script, that will be loaded at startup
/// * lua_lm_debug - if lm log handler is enabled, this option controls, whether lm log messages are dropped or passed to mcabber logging facility
-#define OPT_MLUA_RC "lua_init_filename"
-#define OPT_MLUA_LM_DEBUG "lua_lm_debug"
//
// module description
@@ -68,17 +62,17 @@
#ifdef LLM_LOG_HANDLER
#define DESCRIPTION ( \
- "Lua scripting interface\n" \
+ LUA_RELEASE " scripting interface\n" \
"Options: " OPT_MLUA_RC ", " OPT_MLUA_LM_DEBUG "\n" \
- "Command: /lua" )
+ "Command: /" MLUA_COMMAND_NAME )
#else
#define DESCRIPTION ( \
- "Lua scripting interface\n" \
+ LUA_RELEASE " scripting interface\n" \
"Options: " OPT_MLUA_RC "\n" \
- "Command: /lua" )
+ "Command: /" MLUA_COMMAND_NAME )
#endif
-module_info_t info_lua = {
+module_info_t info_lua5_2 = {
.branch = MCABBER_BRANCH,
.api = MCABBER_API_VERSION,
.version = PROJECT_VERSION,
@@ -1805,9 +1799,13 @@
}
#ifdef MCABBER_API_HAVE_CMD_ID
- lua_cmdid = cmd_add ("lua", "Evaluate lua string", 0, 0, (void (*) (char *p)) do_lua, lua);
+ lua_cmdid = cmd_add (MLUA_COMMAND_NAME, "Evaluate lua string", 0, 0, (void (*) (char *p)) do_lua, lua);
#else
- cmd_add ("lua", "Evaluate lua string", 0, 0, (void (*) (char *p)) do_lua, lua);
+ cmd_add (MLUA_COMMAND_NAME, "Evaluate lua string", 0, 0, (void (*) (char *p)) do_lua, lua);
+#endif
+
+#ifdef ENABLE_LUA_ALIAS
+ settings_set(SETTINGS_TYPE_ALIAS, "lua", MLUA_COMMAND_NAME);
#endif
#ifdef LLM_LOG_HANDLER
@@ -1907,7 +1905,7 @@
cmd_del (lua_cmdid);
lua_cmdid = NULL;
#else
- cmd_del ("lua");
+ cmd_del (MLUA_COMMAND_NAME);
#endif
lua_close (lua);