src/lua_config.c
author Tero Marttila <terom@fixme.fi>
Thu, 21 May 2009 17:08:47 +0300
changeset 214 0d5d46ab49d5
parent 106 f00661136ac2
child 217 7728d6ec3abf
permissions -rw-r--r--
merge lua_thread_setup bcak into _lua_thread_start, as everything can be done on the main lua state
106
f00661136ac2 add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
#include "lua_config.h"
f00661136ac2 add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
f00661136ac2 add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
#include <lua5.1/lauxlib.h>
f00661136ac2 add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
f00661136ac2 add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
err_t lua_config_load (struct nexus_lua *lua, const char *path, struct error_info *err)
f00661136ac2 add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
{
f00661136ac2 add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
    // just use luaL_loadfile and translate the error code
f00661136ac2 add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
    if (nexus_lua_error(lua->st, luaL_loadfile(lua->st, path), err))
f00661136ac2 add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
        // XXX: pollute the stack
f00661136ac2 add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
        return ERROR_CODE(err);
f00661136ac2 add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
    
f00661136ac2 add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    12
    // execute it
f00661136ac2 add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    13
    // XXX; error handler with debug info
f00661136ac2 add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    14
    return nexus_lua_error(lua->st, lua_pcall(lua->st, 0, 0, 0), err);
f00661136ac2 add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    15
}
f00661136ac2 add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    16