forked from icculus/mojosetup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lua_glue.h
69 lines (51 loc) · 2.1 KB
/
lua_glue.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* MojoSetup; a portable, flexible installation application.
*
* Please see the file LICENSE.txt in the source's root directory.
*
* This file written by Ryan C. Gordon.
*/
#ifndef _INCL_LUA_GLUE_H_
#define _INCL_LUA_GLUE_H_
#include "universal.h"
#ifdef __cplusplus
extern "C" {
#endif
// License text for MojoSetup.
extern const char *GMojoSetupLicense;
// License text for Lua.
extern const char *GLuaLicense;
boolean MojoLua_initLua(void);
void MojoLua_deinitLua(void);
boolean MojoLua_initialized(void);
// Run the code in a given Lua file. This is JUST the base filename.
// We will look for it in GBaseArchive in the (dir) directory, both as
// fname.luac and fname.lua. This code chunk will accept no arguments, and
// return no results, but it can change the global state and alter tables,
// etc, so it can have lasting side effects.
// Will return false if the file couldn't be loaded, or true if the chunk
// successfully ran. Will not return if there's a runtime error in the
// chunk, as it will call fatal() instead.
boolean MojoLua_runFileFromDir(const char *dir, const char *name);
// This is shorthand for MojoLua_runFileFromDir("scripts", fname);
boolean MojoLua_runFile(const char *fname);
// Call a function in Lua. This calls MojoSetup.funcname, if it exists and
// is a function. It will not pass any parameters and it will not return
// any values. The call is made unprotected, so if Lua triggers an error,
// this C function will not return. Don't use this if you don't know what
// you're doing.
// Returns true if function was called, false otherwise.
boolean MojoLua_callProcedure(const char *funcname);
// Set a Lua variable in the MojoSetup namespace to a string:
// MojoLua_setString("bob", "name");
// in Lua: print(MojoSetup.name) -- outputs: bob
void MojoLua_setString(const char *str, const char *sym);
// Same as MojoLua_setString, but it creates an ordered table (array).
void MojoLua_setStringArray(int argc, const char **argv, const char *sym);
void MojoLua_collectGarbage(void);
void MojoLua_debugger(void);
#ifdef __cplusplus
}
#endif
#endif
// end of lua_glue.h ...