From 9c6308e2ff16a94c6a51b6412cd6b52e46acfe08 Mon Sep 17 00:00:00 2001 From: Rui Guo Date: Sat, 6 Jun 2009 16:03:41 +0800 Subject: [PATCH] Added calling interface to binding. 1. Added bd_call() interface to binding. 2. Tuned LuaCall() and fill it in the calling interface. 3. Do not directly call LuaCall anymore. --- src/lua.c | 7 ++++--- src/script.c | 9 ++++++++- src/script.h | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/lua.c b/src/lua.c index c734653..a6c01da 100644 --- a/src/lua.c +++ b/src/lua.c @@ -697,14 +697,14 @@ int LuaFinit(void) return 0; } -int LuaCall(char **argv) +int LuaCall(char *func, char **argv) { int argc; if (!L) return 0; - lua_getfield(L, LUA_GLOBALSINDEX, *argv); - for (argc = 0, argv++; *argv; argv++, argc++) + lua_getfield(L, LUA_GLOBALSINDEX, func); + for (argc = 0; *argv; argv++, argc++) { lua_pushstring(L, *argv); } @@ -778,6 +778,7 @@ struct binding lua_binding = 0, /*registered*/ LuaInit, LuaFinit, + LuaCall, LuaSource, 0, /*b_next*/ &LuaFuncs diff --git a/src/script.c b/src/script.c index 1ff127b..b2b3ccd 100644 --- a/src/script.c +++ b/src/script.c @@ -103,13 +103,20 @@ ScriptSource(int argc, const char **argv) LMsg(1, "Could not source specified script %s", script); } +int +ScriptCall(const char *func, const char **argv) +{ + /*TODO*/ + return LuaCall(func, argv); +} + void ScriptCmd(int argc, const char **argv) { const char * sub = *argv; argv++;argc--; if (!strcmp(sub, "call")) - LuaCall(argv); + ScriptCall(*argv, argv+1); else if (!strcmp(sub, "source")) ScriptSource(argc, argv); } diff --git a/src/script.h b/src/script.h index 2a23e83..2492984 100644 --- a/src/script.h +++ b/src/script.h @@ -38,6 +38,7 @@ struct binding int registered; int (*bd_Init) __P((void)); int (*bd_Finit) __P((void)); + int (*bd_call) __P((char *func, char **argv)); /*Returns zero on failure, non zero on success*/ int (*bd_Source) __P((const char *, int)); struct binding *b_next; -- 2.11.4.GIT