|
|
@@ -44,39 +44,45 @@ class LuaEnvironment
|
|
|
public:
|
|
|
/// Constructor
|
|
|
LuaEnvironment();
|
|
|
-
|
|
|
+ /// Init Lua state and open libraries. Must be called first
|
|
|
void init();
|
|
|
-
|
|
|
+ /// Close Lua state and shutdown LuaEnvironment
|
|
|
void shutdown();
|
|
|
-
|
|
|
+ /// Return the __lua_State_ pointer required by each Lua function
|
|
|
lua_State* state();
|
|
|
|
|
|
const char* error();
|
|
|
-
|
|
|
+ /// Load Lua chunk as buffer. @a buffer contains lua chunk, @len is length of buffer
|
|
|
void load_buffer(const char* buffer, size_t len);
|
|
|
-
|
|
|
+ /// Load Lua chunk as file. @a file is path to lua file
|
|
|
void load_file(const char* file);
|
|
|
-
|
|
|
+ /// Load Lua chunk as string
|
|
|
void load_string(const char* str);
|
|
|
-
|
|
|
+ /// Get global symbol from Lua stack. @symbol is the name of required symbol
|
|
|
void get_global_symbol(const char* symbol);
|
|
|
-
|
|
|
+ /// Execute Lua chunk. @a args is the number of arguments required
|
|
|
+ /// @a results is the number of results returned
|
|
|
void execute(int32_t args, int32_t results);
|
|
|
-
|
|
|
+ /// Collect garbage generated by Lua
|
|
|
void collect_garbage();
|
|
|
-
|
|
|
+ /// Call init function in the Lua game file
|
|
|
void game_init();
|
|
|
-
|
|
|
+ /// Call shutdown function in the Lua game file
|
|
|
void game_shutdown();
|
|
|
-
|
|
|
+ /// Call frame function in the Lua game file
|
|
|
void game_frame(float dt);
|
|
|
|
|
|
+ /// Load a function which will be used in Lua. @a module is the name of table contenitor,
|
|
|
+ /// @a name is the name of function in module and @func is the pointer to the function.
|
|
|
+ /// _func_ must be a C/lua function (__int32_t function_name(lua_State* L)__)
|
|
|
void load_module_function(const char* module, const char* name, const lua_CFunction func);
|
|
|
-
|
|
|
+ /// Load a enum's value which will be used in Lua.
|
|
|
+ /// @a module is the name of table contenitor, generally take enum's name
|
|
|
+ /// @a name is module's name that refears _value_ and @value is an unsigned integer
|
|
|
void load_module_enum(const char* module, const char* name, uint32_t value);
|
|
|
|
|
|
private:
|
|
|
-
|
|
|
+ /// Thread used for garbage collection. It calls __collect_garbage()__
|
|
|
static void* background_thread(void* thiz);
|
|
|
|
|
|
void lua_error();
|
|
|
@@ -85,7 +91,7 @@ private:
|
|
|
LuaEnvironment& operator=(const LuaEnvironment&);
|
|
|
|
|
|
private:
|
|
|
- ///
|
|
|
+ /// Required by each Lua function
|
|
|
lua_State* m_state;
|
|
|
/// LuaEnvironment is used right now?
|
|
|
bool m_is_used;
|
|
|
@@ -103,6 +109,12 @@ private:
|
|
|
static const char* get_cmd_by_name;
|
|
|
|
|
|
static const char* tmp_print_table;
|
|
|
+
|
|
|
+ static const char* count_all;
|
|
|
+
|
|
|
+ // static const char* type_name;
|
|
|
+
|
|
|
+ // static const char* type_count;
|
|
|
};
|
|
|
|
|
|
|