Go to the source code of this file.
Defines | |
| #define | BEGIN_NOEXCEPTION try { |
| #define | END_NOEXCEPTION |
Functions | |
| const char * | script_getLeaderName () |
| Scripter * | script_getLeader (lua_State *L) |
| int | script_debugStack (lua_State *L) |
| char *debugStack(error_message) | |
| int | script_file_include (lua_State *L) throw () |
| void file_include(filename) | |
| int | script_file_exists (lua_State *L) throw () |
| bool file_exists(filename) | |
|
|
Definition at line 17 of file def-script.h. |
|
|
Value: } \ catch (std::exception &e) { \ luaL_error(L, e.what()); \ } \ catch (...) { \ luaL_error(L, "unknown exception"); \ } Definition at line 18 of file def-script.h. |
|
|
char *debugStack(error_message)
Definition at line 35 of file def-script.cpp. 00036 {
00037 //NOTE: stolen from "lua/ldblib.c"
00038 /* size of the first part of the stack */
00039 static const int LEVELS1 = 12;
00040 /* size of the second part of the stack */
00041 static const int LEVELS2 = 10;
00042
00043 int level = 1; /* skip level 0 (it's this function) */
00044 int firstpart = 1; /* still before eventual `...' */
00045 lua_Debug ar;
00046 if (lua_gettop(L) == 0)
00047 lua_pushliteral(L, "");
00048 else if (!lua_isstring(L, 1)) return 1; /* no string message */
00049 else lua_pushliteral(L, "\n");
00050 lua_pushliteral(L, "stack traceback:");
00051 while (lua_getstack(L, level++, &ar)) {
00052 if (level > LEVELS1 && firstpart) {
00053 /* no more than `LEVELS2' more levels? */
00054 if (!lua_getstack(L, level+LEVELS2, &ar))
00055 level--; /* keep going */
00056 else {
00057 lua_pushliteral(L, "\n\t..."); /* too many levels */
00058 while (lua_getstack(L, level+LEVELS2, &ar)) /* find last levels */
00059 level++;
00060 }
00061 firstpart = 0;
00062 continue;
00063 }
00064 lua_pushliteral(L, "\n\t");
00065 lua_getinfo(L, "Snl", &ar);
00066 lua_pushfstring(L, "%s:", ar.short_src);
00067 if (ar.currentline > 0)
00068 lua_pushfstring(L, "%d:", ar.currentline);
00069 switch (*ar.namewhat) {
00070 case 'g': /* global */
00071 case 'l': /* local */
00072 case 'f': /* field */
00073 case 'm': /* method */
00074 lua_pushfstring(L, " in function `%s'", ar.name);
00075 break;
00076 default: {
00077 if (*ar.what == 'm') /* main? */
00078 lua_pushfstring(L, " in main chunk");
00079 else if (*ar.what == 'C' || *ar.what == 't')
00080 lua_pushliteral(L, " ?"); /* C function or tail call */
00081 else
00082 lua_pushfstring(L, " in function <%s:%d>",
00083 ar.short_src, ar.linedefined);
00084 }
00085 }
00086 lua_concat(L, lua_gettop(L));
00087 }
00088 lua_concat(L, lua_gettop(L));
00089 //NOTE: return debug_message
00090 return 1;
00091 }
|
|
|
bool file_exists(filename) Returns true when such file exists in userdir or systemdir. Definition at line 116 of file def-script.cpp. 00117 {
00118 BEGIN_NOEXCEPTION;
00119 const char *filename = luaL_checkstring(L, 1);
00120
00121 bool exists = Path::dataReadPath(filename).exists();
00122 lua_pushboolean(L, exists);
00123 END_NOEXCEPTION;
00124 //NOTE: return exists
00125 return 1;
00126 }
|
|
|
void file_include(filename) Do file in usedir or systemdir. Definition at line 100 of file def-script.cpp. 00101 {
00102 BEGIN_NOEXCEPTION;
00103 const char *filename = luaL_checkstring(L, 1);
00104
00105 script_getLeader(L)->scriptInclude(Path::dataReadPath(filename));
00106 END_NOEXCEPTION;
00107 return 0;
00108 }
|
|
|
Definition at line 16 of file def-script.cpp. 00017 {
00018 lua_pushstring(L, script_getLeaderName());
00019 lua_rawget(L, LUA_REGISTRYINDEX);
00020 if (lua_isnil(L, -1)) {
00021 luaL_error(L, ExInfo("no leader")
00022 .addInfo("key", script_getLeaderName()).what());
00023 }
00024 luaL_checktype(L, -1, LUA_TLIGHTUSERDATA);
00025 Scripter *result = static_cast<Scripter*>(lua_touserdata(L, -1));
00026 lua_pop(L, 1);
00027
00028 return result;
00029 }
|
|
|
Definition at line 27 of file def-script.h. 00027 { return "script_leader"; }
|
1.4.2