[teklib-general] teklib: Lua module: some cleanup, removed TimeRequest; Lua loadl...
Timm S. Mueller
tmueller at neoscientists.org
Fri May 1 19:25:43 CEST 2009
details: http://hg.teklib.org/teklib/rev/1423a3fa5a22
changeset: 259:1423a3fa5a22
user: Timm S. Mueller <tmueller at neoscientists.org>
date: Tue Mar 24 11:13:56 2009 +0100
description:
Lua module: some cleanup, removed TimeRequest; Lua loadlib and modscan example now use TExecScanModules()
diffs (truncated from 303 to 100 lines):
diff -r 12d2d00ba17d -r 1423a3fa5a22 src/lua/lua_mod.c
--- a/src/lua/lua_mod.c Wed Mar 18 00:58:50 2009 +0100
+++ b/src/lua/lua_mod.c Tue Mar 24 11:13:56 2009 +0100
@@ -1,7 +1,7 @@
/*
** $Id: lua_mod.c,v 1.6 2006/11/11 14:19:10 tmueller Exp $
-** teklib/src/lua/lua_mod.c - LUA module API implementation
+** teklib/src/lua/lua_mod.c - Lua module API implementation
**
** Written by Timm S. Mueller <tmueller at neoscientists.org>
** See copyright notice in teklib/COPYRIGHT
@@ -19,15 +19,15 @@
** | (modsuper) | backptr |_____________|_ L
** | | | |
** | | | |
-** |____________| | LUA state |
+** |____________| | Lua state |
** | |
** |_____________|
**
** this layout solves these problems:
**
-** * changes in the LUA state structure do not affect binary
+** * changes in the Lua state structure do not affect binary
** compatibility
-** * the LUA state itself is the module base, API functions
+** * the Lua state itself is the module base, API functions
** need no additional modulebase argument
**
** caveats:
@@ -43,6 +43,7 @@
#include <tek/debug.h>
#include <tek/teklib.h>
#include <tek/proto/exec.h>
+#include <tek/inline/exec.h>
#include <tek/proto/io.h>
#include <tek/mod/time.h>
#include <tek/mod/luabase.h>
@@ -67,6 +68,7 @@
TMODENTRY TUINT
tek_init_lua5(struct TTask *task, TLUABASE *mod, TUINT16 version, TTAGITEM *tags)
{
+ struct TExecBase *TExecBase;
if (mod == TNULL)
{
if (version == 0xffff)
@@ -78,12 +80,12 @@
return 0;
}
- mod->tml_ExecBase = TGetExecBase(mod);
- mod->tml_Lock = TExecCreateLock(mod->tml_ExecBase, TNULL);
+ TExecBase = TGetExecBase(mod);
+ mod->tml_Lock = TCreateLock(TNULL);
if (mod->tml_Lock)
{
#ifdef TDEBUG
- mod->tml_MM = TExecCreateMemManager(mod->tml_ExecBase, TNULL,
+ mod->tml_MM = TCreateMemManager(TNULL,
TMMT_Tracking | TMMT_TaskSafe, TNULL);
#endif
@@ -356,45 +358,38 @@
static void
closeall(TLUABASE *mod)
{
- TExecCloseModule(mod->tml_ExecBase, (struct TModule *) mod->tml_IOBase);
- TExecCloseModule(mod->tml_ExecBase, (struct TModule *) mod->tml_UtilBase);
+ struct TExecBase *TExecBase = TGetExecBase(mod);
+ TCloseModule((struct TModule *) mod->tml_IOBase);
+ TCloseModule((struct TModule *) mod->tml_UtilBase);
}
static LUACFUNC TAPTR
tek_alloc(TAPTR ud, TAPTR ptr, size_t osize, size_t nsize)
{
TLUABASE *mod = ud;
-
+ struct TExecBase *TExecBase = TGetExecBase(mod);
if (nsize == 0)
{
- TDBPRINTF(2,("tek_free\n"));
- TExecFree(mod->tml_ExecBase, ptr);
+ TFree(ptr);
return TNULL;
}
-
if (ptr)
- {
- TDBPRINTF(2,("tek_realloc\n"));
- return TExecRealloc(mod->tml_ExecBase, ptr, nsize);
- }
-
- TDBPRINTF(2,("tek_alloc\n"));
- return TExecAlloc(mod->tml_ExecBase, mod->tml_MM, nsize);
+ return TRealloc(ptr, nsize);
+ return TAlloc(mod->tml_MM, nsize);
}
More information about the teklib-general
mailing list