Renamed medit lua package to 'moo'

master
Yevgen Muntyan 2011-01-22 22:12:20 -08:00
parent d80f9b90a9
commit 0f5d84f71c
22 changed files with 117 additions and 124 deletions

View File

@ -438,7 +438,8 @@ static void *%(func)s (void)
all_method_cfuncs[cls.name] = method_cfuncs
all_static_method_cfuncs[cls.short_name] = static_method_cfuncs
dic = dict(module=module.name.lower())
package_name=module.name.lower()
dic = dict(module=module.name.lower(), package_name=package_name)
all_func_cfuncs = []
@ -468,11 +469,11 @@ static void *%(func)s (void)
self.__write_register_module(module, all_method_cfuncs)
self.out.write("""\
void %(module)s_lua_api_add_to_lua (lua_State *L, const char *package_name)
void %(module)s_lua_api_add_to_lua (lua_State *L)
{
%(module)s_lua_api_register ();
luaL_register (L, package_name, %(module)s_lua_functions);
luaL_register (L, "%(package_name)s", %(module)s_lua_functions);
""" % dic)
@ -480,11 +481,11 @@ void %(module)s_lua_api_add_to_lua (lua_State *L, const char *package_name)
cfuncs = all_static_method_cfuncs[cls_name]
if not cfuncs:
continue
self.out.write(' moo_lua_register_static_methods (L, package_name, "%s", %s_lua_functions);\n' % (cls_name, cls_name))
self.out.write(' moo_lua_register_static_methods (L, "%s", "%s", %s_lua_functions);\n' % (package_name, cls_name, cls_name))
self.out.write('\n')
for enum in module.get_enums():
self.out.write(' moo_lua_register_enum (L, package_name, %s, "%s");\n' % (enum.gtype_id, module.name.upper() + '_'))
self.out.write(' moo_lua_register_enum (L, "%s", %s, "%s");\n' % (package_name, enum.gtype_id, module.name.upper() + '_'))
self.out.write("}\n")

View File

@ -134,12 +134,16 @@ endif
EXTRA_DIST = help built/moo-help-sections.h built/medit.1
install-data-local:
$(MKDIR_P) $(DESTDIR)$(MOO_HELP_DIR)/img
$(MKDIR_P) $(DESTDIR)$(MOO_HELP_DIR)/img $(DESTDIR)$(MOO_HELP_DIR)/script
cd $(srcdir) && $(INSTALL_DATA) help/*.html help/*.css $(DESTDIR)$(MOO_HELP_DIR)
cd $(srcdir) && $(INSTALL_DATA) help/script/*.html $(DESTDIR)$(MOO_HELP_DIR)/script
cd $(srcdir) && $(INSTALL_DATA) help/img/*.png $(DESTDIR)$(MOO_HELP_DIR)/img
uninstall-local:
rm -f $(DESTDIR)$(MOO_HELP_DIR)/*.html $(DESTDIR)$(MOO_HELP_DIR)/*.css $(DESTDIR)$(MOO_HELP_DIR)/img/*.png
rm -f $(DESTDIR)$(MOO_HELP_DIR)/*.html \
$(DESTDIR)$(MOO_HELP_DIR)/*.css \
$(DESTDIR)$(MOO_HELP_DIR)/script/*.html \
$(DESTDIR)$(MOO_HELP_DIR)/img/*.png
if MOO_OS_UNIX
dist_man_MANS = built/medit.1

View File

@ -4,6 +4,7 @@
%medit-defines;
]>
<chapter id="chapter-script-lua-gtk">
<?dbhtml filename="lua-gtk.html"?>
<title>&medit; Gtk API for Lua scripts</title>
<sect1>
<title>Introduction</title>

View File

@ -4,6 +4,7 @@
%medit-defines;
]>
<chapter id="chapter-script-lua">
<?dbhtml filename="lua-moo.html"?>
<title>&medit; Lua API</title>
<sect1 id="section-script-lua-introduction">

View File

@ -4,6 +4,7 @@
%medit-defines;
]>
<chapter id="chapter-script-python">
<?dbhtml filename="python-moo.html"?>
<title>&medit; Python API</title>
<sect1>
<title>Introduction</title>

View File

@ -384,10 +384,10 @@ or scripts into <filename><envar>DATA_DIR</envar>/scripts/</filename> to be used
<title>Lua scripts</title>
<para>
<ulink url="script-lua.html">Medit API for Lua scripts</ulink>.
<ulink url="script/lua-moo.html">Medit API for Lua scripts</ulink>.
</para>
<para>
<ulink url="script-lua-gtk.html">Gtk API for Lua scripts</ulink>.
<ulink url="script/lua-gtk.html">Gtk API for Lua scripts</ulink>.
</para>
</sect1>
@ -397,7 +397,7 @@ or scripts into <filename><envar>DATA_DIR</envar>/scripts/</filename> to be used
<title>Python scripts</title>
<para>
<ulink url="script-python.html">Medit API for Python scripts</ulink>.
<ulink url="script/python-moo.html">Medit API for Python scripts</ulink>.
</para>
</sect1>

View File

@ -1,4 +1,4 @@
local medit = require("medit")
local moo = require("moo")
local function _tassert(cond, msg, ...)
local info = debug.getinfo(3, "Slf")
@ -8,9 +8,9 @@ local function _tassert(cond, msg, ...)
if name then
message = string.format('in function %s: %s', name, message)
end
medit.test_assert_impl(false, message, info.short_src, info.currentline)
moo.test_assert_impl(false, message, info.short_src, info.currentline)
else
medit.test_assert_impl(true, '', info.short_src, info.currentline)
moo.test_assert_impl(true, '', info.short_src, info.currentline)
end
end

View File

@ -1,8 +1,5 @@
-- -%- indent-width:2 -%- --
require("munit")
require("gtk")
os = require("moo.os")
os = require("_moo.os")
if os.name == 'nt' then
name1 = 'c:\\tmp\\foo'

View File

@ -1,20 +1,18 @@
require("munit")
require("medit")
require("gtk")
require("moo.os")
require("_moo.os")
editor = medit.Editor.instance()
editor = moo.Editor.instance()
tassert(medit.LE_NATIVE ~= nil)
tassert(medit.LE_UNIX ~= nil)
tassert(medit.LE_WIN32 ~= nil)
tassert(moo.os.name == 'nt' or medit.LE_NATIVE ~= medit.LE_WIN32)
tassert(moo.os.name ~= 'nt' or medit.LE_NATIVE == medit.LE_WIN32)
tassert(moo.LE_NATIVE ~= nil)
tassert(moo.LE_UNIX ~= nil)
tassert(moo.LE_WIN32 ~= nil)
tassert(_moo.os.name == 'nt' or moo.LE_NATIVE ~= moo.LE_WIN32)
tassert(_moo.os.name ~= 'nt' or moo.LE_NATIVE == moo.LE_WIN32)
text_unix = 'line1\nline2\nline3\n'
text_win32 = 'line1\r\nline2\r\nline3\r\n'
text_mix = 'line1\nline2\r\nline3\r\n'
if moo.os.name == 'nt' then
if _moo.os.name == 'nt' then
text_native = text_win32
else
text_native = text_unix
@ -35,80 +33,80 @@ end
function test_default()
doc = editor.new_doc()
filename = medit.tempnam()
tassert(doc.get_line_end_type() == medit.LE_NATIVE)
filename = moo.tempnam()
tassert(doc.get_line_end_type() == moo.LE_NATIVE)
doc.set_text(text_unix)
tassert(doc.save_as(medit.SaveInfo.new_path(filename)))
tassert(doc.save_as(moo.SaveInfo.new_path(filename)))
tassert(read_file(filename) == text_native)
tassert(doc.get_line_end_type() == medit.LE_NATIVE)
tassert(doc.get_line_end_type() == moo.LE_NATIVE)
doc.set_text(text_win32)
tassert(doc.save_as(medit.SaveInfo.new_path(filename)))
tassert(doc.save_as(moo.SaveInfo.new_path(filename)))
tassert(read_file(filename) == text_native)
tassert(doc.get_line_end_type() == medit.LE_NATIVE)
tassert(doc.get_line_end_type() == moo.LE_NATIVE)
doc.set_modified(false)
editor.close_doc(doc)
end
function test_set()
doc = editor.new_doc()
filename = medit.tempnam()
filename = moo.tempnam()
tassert(doc.get_line_end_type() == medit.LE_NATIVE)
tassert(doc.get_line_end_type() == moo.LE_NATIVE)
doc.set_text(text_unix)
tassert(doc.save_as(medit.SaveInfo.new_path(filename)))
tassert(doc.save_as(moo.SaveInfo.new_path(filename)))
tassert(read_file(filename) == text_native)
tassert(doc.get_line_end_type() == medit.LE_NATIVE)
tassert(doc.get_line_end_type() == moo.LE_NATIVE)
doc.set_line_end_type(medit.LE_UNIX)
tassert(doc.get_line_end_type() == medit.LE_UNIX)
tassert(doc.save_as(medit.SaveInfo.new_path(filename)))
doc.set_line_end_type(moo.LE_UNIX)
tassert(doc.get_line_end_type() == moo.LE_UNIX)
tassert(doc.save_as(moo.SaveInfo.new_path(filename)))
tassert(read_file(filename) == text_unix)
tassert(doc.get_line_end_type() == medit.LE_UNIX)
tassert(doc.get_line_end_type() == moo.LE_UNIX)
doc.set_line_end_type(medit.LE_WIN32)
tassert(doc.get_line_end_type() == medit.LE_WIN32)
tassert(doc.save_as(medit.SaveInfo.new_path(filename)))
doc.set_line_end_type(moo.LE_WIN32)
tassert(doc.get_line_end_type() == moo.LE_WIN32)
tassert(doc.save_as(moo.SaveInfo.new_path(filename)))
tassert(read_file(filename) == text_win32)
tassert(doc.get_line_end_type() == medit.LE_WIN32)
tassert(doc.get_line_end_type() == moo.LE_WIN32)
doc.set_modified(false)
editor.close_doc(doc)
end
function test_load()
filename = medit.tempnam()
filename = moo.tempnam()
save_file(filename, text_unix)
doc = editor.open_file(medit.OpenInfo.new_path(filename))
doc = editor.open_file(moo.OpenInfo.new_path(filename))
tassert(doc.get_filename() == filename)
tassert(doc.get_line_end_type() == medit.LE_UNIX)
tassert(doc.get_line_end_type() == moo.LE_UNIX)
doc.close()
save_file(filename, text_win32)
doc = editor.open_file(medit.OpenInfo.new_path(filename))
doc = editor.open_file(moo.OpenInfo.new_path(filename))
tassert(doc.get_filename() == filename)
tassert(doc.get_line_end_type() == medit.LE_WIN32)
tassert(doc.get_line_end_type() == moo.LE_WIN32)
doc.close()
end
function test_mix()
filename = medit.tempnam()
filename = moo.tempnam()
save_file(filename, text_mix)
doc = editor.open_file(medit.OpenInfo.new_path(filename))
doc = editor.open_file(moo.OpenInfo.new_path(filename))
tassert(doc.get_filename() == filename)
tassert(doc.get_line_end_type() == medit.LE_NATIVE)
tassert(doc.get_line_end_type() == moo.LE_NATIVE)
tassert(doc.save())
tassert(doc.get_line_end_type() == medit.LE_NATIVE)
tassert(doc.get_line_end_type() == moo.LE_NATIVE)
tassert(read_file(filename) == text_unix)
save_file(filename, text_mix)
tassert(doc.reload())
tassert(doc.get_line_end_type() == medit.LE_NATIVE)
doc.set_line_end_type(medit.LE_WIN32)
tassert(doc.get_line_end_type() == moo.LE_NATIVE)
doc.set_line_end_type(moo.LE_WIN32)
tassert(doc.save())
tassert(doc.get_line_end_type() == medit.LE_WIN32)
tassert(doc.get_line_end_type() == moo.LE_WIN32)
tassert(read_file(filename) == text_win32)
doc.close()

View File

@ -1,10 +1,7 @@
-- -%- indent-width:2 -%- --
require("munit")
require("medit")
require("moo.os")
require("_moo.os")
app = medit.App.instance()
app = moo.App.instance()
editor = app.get_editor()
local __docs_to_cleanup = {}
@ -27,11 +24,11 @@ local function test_active_window()
tassert(w1 ~= w2, 'old window != new window')
tassert(#editor.get_windows() == 2, 'two window')
editor.set_active_window(w2)
medit.spin_main_loop(0.1)
moo.spin_main_loop(0.1)
tassert(w2 == editor.get_active_window(), 'w2 == editor.get_active_window()')
if moo.os.name == 'posix' then
if _moo.os.name == 'posix' then
editor.set_active_window(w1)
medit.spin_main_loop(0.1)
moo.spin_main_loop(0.1)
tassert(w1 == editor.get_active_window(), 'w1 == editor.get_active_window()')
end
editor.close_window(w1)

View File

@ -1,9 +1,5 @@
-- -%- indent-width:2 -%- --
require("munit")
require("moo.builtin")._inject(_G)
function to_list(t)
local l = {}
for k, v in pairs(t) do

View File

@ -1,35 +1,33 @@
require("munit")
require("medit")
require("gtk")
editor = medit.Editor.instance()
editor = moo.Editor.instance()
tassert(medit.CLOSE_RESPONSE_CANCEL ~= nil)
tassert(medit.CLOSE_RESPONSE_CONTINUE ~= nil)
tassert(moo.CLOSE_RESPONSE_CANCEL ~= nil)
tassert(moo.CLOSE_RESPONSE_CONTINUE ~= nil)
function check_args_ew(editor, window)
tassert(editor == medit.Editor.instance())
tassert(editor == moo.Editor.instance())
tassert(editor == window.get_editor())
window.get_tabs()
end
function check_args_ed(editor, doc)
tassert(editor == medit.Editor.instance())
tassert(editor == moo.Editor.instance())
tassert(editor == doc.get_editor())
doc.get_display_basename()
end
function check_args_w(window)
tassert(medit.Editor.instance() == window.get_editor())
tassert(moo.Editor.instance() == window.get_editor())
window.get_tabs()
end
function check_args_e(editor)
tassert(medit.Editor.instance() == editor)
tassert(moo.Editor.instance() == editor)
end
function check_args_d(doc)
tassert(medit.Editor.instance() == doc.get_editor())
tassert(moo.Editor.instance() == doc.get_editor())
doc.get_display_basename()
end
@ -82,7 +80,7 @@ function test_before_close_window()
function(editor, window)
check_args_ew(editor, window)
seen_editor_before_close_window = seen_editor_before_close_window + 1
return medit.CLOSE_RESPONSE_CANCEL
return moo.CLOSE_RESPONSE_CANCEL
end)
window = editor.new_window()
@ -98,7 +96,7 @@ function test_before_close_window()
function(window)
check_args_w(window)
seen_window_before_close = seen_window_before_close + 1
return medit.CLOSE_RESPONSE_CANCEL
return moo.CLOSE_RESPONSE_CANCEL
end)
tassert(not editor.close_window(window))
@ -114,14 +112,14 @@ function test_before_close_window()
function(editor, window)
check_args_ew(editor, window)
seen_editor_before_close_window = seen_editor_before_close_window + 1
return medit.CLOSE_RESPONSE_CONTINUE
return moo.CLOSE_RESPONSE_CONTINUE
end)
window.connect('before-close',
function(window)
check_args_w(window)
seen_window_before_close = seen_window_before_close + 1
return medit.CLOSE_RESPONSE_CONTINUE
return moo.CLOSE_RESPONSE_CONTINUE
end)
tassert(window.close())
@ -170,9 +168,9 @@ function test_bad_callback()
tassert(cb_id1 ~= nil and cb_id1 ~= 0)
tassert(cb_id2 ~= nil and cb_id2 ~= 0)
was_silent = medit.test_set_silent_messages(true)
was_silent = moo.test_set_silent_messages(true)
tassert(editor.close_window(window))
medit.test_set_silent_messages(was_silent)
moo.test_set_silent_messages(was_silent)
tassert(n_callbacks == 6)
@ -181,8 +179,8 @@ function test_bad_callback()
end
function test_will_save()
path = medit.tempnam()
si = medit.SaveInfo.new_path(path)
path = moo.tempnam()
si = moo.SaveInfo.new_path(path)
doc = editor.new_doc()
doc.set_modified(true)
@ -279,12 +277,12 @@ function test_before_save()
check_args_ed(editor, doc)
check_args_f(gfile)
seen_editor_before_save = seen_editor_before_save + 1
return medit.SAVE_RESPONSE_CANCEL
return moo.SAVE_RESPONSE_CANCEL
end)
doc = editor.new_doc()
path = medit.tempnam()
si = medit.SaveInfo.new_path(path)
path = moo.tempnam()
si = moo.SaveInfo.new_path(path)
tassert(not editor.save_as(doc, si))
tassert(seen_editor_before_save == 1)
@ -298,7 +296,7 @@ function test_before_save()
check_args_d(doc)
check_args_f(gfile)
seen_doc_before_save = seen_doc_before_save + 1
return medit.SAVE_RESPONSE_CANCEL
return moo.SAVE_RESPONSE_CANCEL
end)
tassert(not editor.save_as(doc, si))
@ -315,7 +313,7 @@ function test_before_save()
check_args_ed(editor, doc)
check_args_f(gfile)
seen_editor_before_save = seen_editor_before_save + 1
return medit.SAVE_RESPONSE_CONTINUE
return moo.SAVE_RESPONSE_CONTINUE
end)
doc.connect('before-save',
@ -323,7 +321,7 @@ function test_before_save()
check_args_d(doc)
check_args_f(gfile)
seen_doc_before_save = seen_doc_before_save + 1
return medit.SAVE_RESPONSE_CONTINUE
return moo.SAVE_RESPONSE_CONTINUE
end)
tassert(doc.save_as(si))
@ -340,13 +338,13 @@ function test_before_save()
end
test_will_close_window()
-- medit.spin_main_loop(0.1)
-- moo.spin_main_loop(0.1)
test_before_close_window()
-- medit.spin_main_loop(0.1)
-- moo.spin_main_loop(0.1)
test_bad_callback()
-- medit.spin_main_loop(0.1)
-- moo.spin_main_loop(0.1)
test_will_save()
-- medit.spin_main_loop(0.1)
-- moo.spin_main_loop(0.1)
test_will_close_doc()
-- medit.spin_main_loop(0.1)
-- moo.spin_main_loop(0.1)
test_before_save()

View File

@ -1,7 +1,6 @@
require("munit")
require("medit")
editor = medit.Editor.instance()
editor = moo.Editor.instance()
doc = editor.new_doc()
tassert(doc.get_text() == '')

View File

@ -1,5 +1,5 @@
local _g = getfenv(0)
require("moo.builtin")._inject(_g)
local medit = require("medit")
_g.app = medit.App.instance()
require("_moo.builtin")._inject(_g)
local moo = require("moo")
_g.app = moo.App.instance()
_g.editor = _g.app.get_editor()

View File

@ -77,11 +77,11 @@ EXTRA_DIST += \
moolua/lua/slnunico.c
luadir = $(MOO_DATA_DIR)/lua
EXTRA_DIST += moolua/lua/moo
EXTRA_DIST += moolua/lua/_moo
install-data-local: install-lua-moo
uninstall-local: uninstall-lua-moo
install-lua-moo:
$(MKDIR_P) $(DESTDIR)$(luadir)/moo
cd $(srcdir) && $(INSTALL_DATA) moolua/lua/moo/*.lua $(DESTDIR)$(luadir)/moo/
$(MKDIR_P) $(DESTDIR)$(luadir)/_moo
cd $(srcdir) && $(INSTALL_DATA) moolua/lua/_moo/*.lua $(DESTDIR)$(luadir)/_moo/
uninstall-lua-moo:
rm -f $(DESTDIR)$(luadir)/moo/*.lua
rm -f $(DESTDIR)$(luadir)/_moo/*.lua

View File

@ -5,7 +5,7 @@ local table = table
local pairs, ipairs, select, unpack, require =
pairs, ipairs, select, unpack, require
module('moo._string')
module('_moo._string')
function startswith(s, prfx)
return s:sub(1, #prfx) == prfx

View File

@ -5,7 +5,7 @@ local table, math = table, math
local pairs, ipairs, select, unpack, require =
pairs, ipairs, select, unpack, require
module('moo._table')
module('_moo._table')
function count(t, x)
local c = 0

View File

@ -4,7 +4,7 @@ local _G = _G
local type, require, pairs =
type, require, pairs
module('moo._util')
module('_moo._util')
function inject_symbols(src, dest)
if type(src) == 'string' then

View File

@ -6,15 +6,15 @@ local math, table, string =
local pairs, ipairs, select, unpack, require, type, error =
pairs, ipairs, select, unpack, require, type, error
module('moo.builtin')
module('_moo.builtin')
function _inject(dest)
local util = require('moo._util')
util.inject_symbols('moo._table', table)
util.inject_symbols('moo._string', string)
util.inject_symbols('moo.builtin', dest)
dest.os = require('moo.os')
dest.os.path = require('moo.path')
local util = require('_moo._util')
util.inject_symbols('_moo._table', table)
util.inject_symbols('_moo._string', string)
util.inject_symbols('_moo.builtin', dest)
dest.os = require('_moo.os')
dest.os.path = require('_moo.path')
end
abs = math.abs

View File

@ -7,7 +7,7 @@ local _os = os
local lfs = require('lfs')
local _moo_utils = require("_moo_utils")
module('moo.os')
module('_moo.os')
if package.config:sub(1,1) == '/' then
name = 'posix'

View File

@ -4,10 +4,10 @@ local _G = _G
local math, table = math, table
local pairs, ipairs, select, unpack, require =
pairs, ipairs, select, unpack, require
local os = require('moo.os')
local os = require('_moo.os')
local lfs = require('lfs')
module('moo.path')
module('_moo.path')
function exists(path)
return lfs.attributes(path) ~= nil

View File

@ -116,8 +116,8 @@ moo_lua_state_run_string (MooLuaState *lua,
} // extern "C"
void gtk_lua_api_add_to_lua (lua_State *L, const char *package_name);
void moo_lua_api_add_to_lua (lua_State *L, const char *package_name);
void gtk_lua_api_add_to_lua (lua_State *L);
void moo_lua_api_add_to_lua (lua_State *L);
static bool
add_raw_api (lua_State *L)
@ -128,12 +128,12 @@ add_raw_api (lua_State *L)
g_assert (lua_gettop (L) == 0);
gtk_lua_api_add_to_lua (L, "gtk");
gtk_lua_api_add_to_lua (L);
lua_pop(L, 1);
g_assert (lua_gettop (L) == 0);
moo_lua_api_add_to_lua (L, "medit");
moo_lua_api_add_to_lua (L);
lua_pop(L, 1);
g_assert (lua_gettop (L) == 0);