naev 0.11.5
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_dochunkenv( nlua_env env, int chunk, const char *name );
40int nlua_loadStandard( nlua_env env );
41int nlua_errTrace( lua_State *L );
42int nlua_pcall( nlua_env env, int nargs, int nresults );
43int nlua_refenv( nlua_env env, const char *name );
44int nlua_refenvtype( nlua_env env, const char *name, int type );
45int nlua_reffield( int objref, const char *name );
46
47/* Reference stuff. */
48int nlua_ref( lua_State *L, int idx );
49void nlua_unref( lua_State *L, int idx );
50
51/* Hack to handle resizes. */
52void nlua_resize (void);
53
54#if DEBUGGING
55void nlua_pushEnvTable( lua_State *L );
56#endif /* DEBUGGING */
void nlua_unref(lua_State *L, int idx)
Removes a reference set with nlua_ref.
Definition nlua.c:961
int nlua_refenv(nlua_env env, const char *name)
Gets the reference of a global in a lua environment.
Definition nlua.c:903
int nlua_ref(lua_State *L, int idx)
Creates a new reference to a Lua structure at a position.
Definition nlua.c:952
int nlua_loadStandard(nlua_env env)
Loads the standard Naev Lua API.
Definition nlua.c:798
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:920
int nlua_reffield(int objref, const char *name)
Gets the reference to the specified field from an object reference.
Definition nlua.c:936
void nlua_resize(void)
Propagates a resize event to all the environments forcibly.
Definition nlua.c:970
int nlua_errTrace(lua_State *L)
Gets a trace from Lua.
Definition nlua.c:830