naev 0.10.4
nlua.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
7#include <lua.h>
8#include <lauxlib.h>
11#define NLUA_LOAD_TABLE "_LOADED"
13#define NLUA_DONE "__done__"
14
15#define nluaL_optarg(L,ind,def,checkfunc) \
16 (lua_isnoneornil(L,ind) ? (def) : checkfunc(L,ind))
17
18typedef int nlua_env;
19extern lua_State *naevL;
20extern nlua_env __NLUA_CURENV;
21
22/*
23 * standard Lua stuff wrappers
24 */
25void lua_init (void);
26void lua_exit (void);
27nlua_env nlua_newEnv (void);
28void nlua_freeEnv(nlua_env env);
29void nlua_pushenv(lua_State* L, nlua_env env);
30void nlua_setenv(lua_State* L, nlua_env env, const char *name);
31void nlua_getenv(lua_State* L, nlua_env env, const char *name);
32void nlua_register(nlua_env env, const char *libname,
33 const luaL_Reg *l, int metatable);
34int nlua_dobufenv(nlua_env env,
35 const char *buff,
36 size_t sz,
37 const char *name);
38int nlua_dofileenv(nlua_env env, const char *filename);
39int nlua_loadStandard( nlua_env env );
40int nlua_errTrace( lua_State *L );
41int nlua_pcall( nlua_env env, int nargs, int nresults );
42int nlua_refenv( nlua_env env, const char *name );
43int nlua_refenvtype( nlua_env env, const char *name, int type );
44int nlua_reffield( int objref, const char *name );
45
46/* Reference stuff. */
47int nlua_ref( lua_State *L, int idx );
48void nlua_unref( lua_State *L, int idx );
49
50/* Hack to handle resizes. */
51void nlua_resize (void);
52
53#if DEBUGGING
54void nlua_pushEnvTable( lua_State *L );
55#endif /* DEBUGGING */
void nlua_unref(lua_State *L, int idx)
Removes a reference set with nlua_ref.
Definition: nlua.c:914
int nlua_refenv(nlua_env env, const char *name)
Gets the reference of a global in a lua environment.
Definition: nlua.c:856
int nlua_ref(lua_State *L, int idx)
Creates a new reference to a Lua structure at a position.
Definition: nlua.c:905
int nlua_loadStandard(nlua_env env)
Loads the standard Naev Lua API.
Definition: nlua.c:760
int nlua_refenvtype(nlua_env env, const char *name, int type)
Gets the reference of a global in a lua environment if it matches a type.
Definition: nlua.c:873
int nlua_reffield(int objref, const char *name)
Gets the reference to the specified field from an object reference.
Definition: nlua.c:889
void nlua_resize(void)
Propagates a resize event to all the environments forcibly.
Definition: nlua.c:923
int nlua_errTrace(lua_State *L)
Gets a trace from Lua.
Definition: nlua.c:792