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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
/*
$Id: lua.h,v 1.14 2001/09/22 15:52:16 plasmoid Exp $
------------------------------------------------------------------------
ClanLib, the platform independent game SDK.
This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
version 2. See COPYING for details.
For a total list of contributers see CREDITS.
See http://www.clanlib.org
------------------------------------------------------------------------
*/
//! clanLua="Scripting"
//! header=lua.h
#ifndef header_lua_lib
#define header_lua_lib
extern "C" {
#include <lua.h>
#include <lualib.h>
}
/*
The original classes from Waldemer Celes adapted by Lenny Palozzi were replaced by this
to get it to work with Lua and tolua 4.0
jpsousa
*/
int tolua_clanbindings_open (lua_State* tolua_S);
void tolua_clanbindings_close (lua_State* tolua_S);
//: Lua Class
class CL_Lua{
public:
//! Variables:
//: state
static lua_State *state;
//: Initialised
static bool initialized;
//! Operations:
//: Init
static void init()
{
state=lua_open(0);
tolua_clanbindings_open(state);
lua_baselibopen(state);
initialized=true;
}
//: DeInit
static void deinit()
{
tolua_clanbindings_close(state);
lua_close(state);
initialized=false;
}
//: DoFile
static int dofile (char *filename)
{
cl_assert(initialized);
return lua_dofile(state,filename);
}
//: Open the IO library
static void iolibopen(void) { lua_iolibopen(state); }
//: Open the string library
static void strlibopen(void)
{
cl_assert(initialized);
lua_strlibopen(state);
}
//: Open the math library
static void mathlibopen(void)
{
cl_assert(initialized);
lua_mathlibopen(state);
}
//: Open the db library
static void dblibopen(void)
{
cl_assert(initialized);
lua_dblibopen(state);
}
};
#endif
|