src/nexus_lua.h
author Tero Marttila <terom@fixme.fi>
Wed, 01 Apr 2009 01:41:08 +0300
changeset 106 f00661136ac2
parent 105 b6b183fbf373
child 116 92e71129074d
permissions -rw-r--r--
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
#ifndef NEXUS_LUA_H
#define NEXUS_LUA_H

/**
 * @file
 *
 * Defines the lua environment for use with nexus
 */
#include "nexus.h"

#include <lua5.1/lua.h>

/**
 * The global lua state
 */
struct nexus_lua {
    /** The nexus we are operating on */
    struct nexus *nexus;

    /** The lua state */
    lua_State *st;
};

/**
 * Create a new lua state for nexus
 */
err_t nexus_lua_create (struct nexus_lua **lua_ptr, struct nexus *nexus, struct error_info *err);

/**
 * Destroy the lua state
 */
void nexus_lua_destroy (struct nexus_lua *lua);

/**
 * Handle a Lua error by converting the given error code into a ERR_LUA_* code, inspecting the error object at
 * the top of the stack.
 *
 * Please note that the resulting error_info points into strings inside the lua stack - once you pop the error, the
 * error_info might not be valid anymore.
 */
err_t nexus_lua_error (lua_State *L, int ret, struct error_info *err);

#endif /* NEXUS_LUA_H */