Pack movie data in memory
[lsnes.git] / include / core / lua.hpp
blob494b99a2fd85733b6a31e596d78a7b1569c7dd42
1 #ifndef _lua__hpp__included__
2 #define _lua__hpp__included__
4 #include "render.hpp"
5 #include "controllerframe.hpp"
7 struct lua_State;
9 /**
10 * Function implemented in C++ exported to Lua.
12 class lua_function
14 public:
15 /**
16 * Register function.
18 lua_function(const std::string& name) throw(std::bad_alloc);
19 /**
20 * Unregister function.
22 virtual ~lua_function() throw();
24 /**
25 * Invoke function.
27 virtual int invoke(lua_State* L) = 0;
28 protected:
29 std::string fname;
32 /**
33 * Register function pointer as lua function.
35 class function_ptr_luafun : public lua_function
37 public:
38 /**
39 * Register.
41 function_ptr_luafun(const std::string& name, int (*_fn)(lua_State* L, const std::string& fname))
42 : lua_function(name)
44 fn = _fn;
46 /**
47 * Invoke function.
49 int invoke(lua_State* L)
51 return fn(L, fname);
53 private:
54 int (*fn)(lua_State* L, const std::string& fname);
57 struct lua_render_context
59 uint32_t left_gap;
60 uint32_t right_gap;
61 uint32_t top_gap;
62 uint32_t bottom_gap;
63 struct render_queue* queue;
64 uint32_t width;
65 uint32_t height;
68 void init_lua() throw();
69 void quit_lua() throw();
70 void lua_callback_do_paint(struct lua_render_context* ctx) throw();
71 void lua_callback_do_video(struct lua_render_context* ctx) throw();
72 void lua_callback_do_input(controller_frame& data, bool subframe) throw();
73 void lua_callback_do_reset() throw();
74 void lua_callback_do_frame() throw();
75 void lua_callback_do_readwrite() throw();
76 void lua_callback_startup() throw();
77 void lua_callback_pre_load(const std::string& name) throw();
78 void lua_callback_err_load(const std::string& name) throw();
79 void lua_callback_post_load(const std::string& name, bool was_state) throw();
80 void lua_callback_pre_save(const std::string& name, bool is_state) throw();
81 void lua_callback_err_save(const std::string& name) throw();
82 void lua_callback_post_save(const std::string& name, bool is_state) throw();
83 void lua_callback_snoop_input(uint32_t port, uint32_t controller, uint32_t index, short value) throw();
84 void lua_callback_quit() throw();
86 extern bool lua_supported;
87 extern bool lua_requests_repaint;
88 extern bool lua_requests_subframe_paint;
90 #endif