summaryrefslogtreecommitdiffstats
path: root/src/frontend/mame/luaengine.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/mame/luaengine.h')
-rw-r--r--src/frontend/mame/luaengine.h33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/frontend/mame/luaengine.h b/src/frontend/mame/luaengine.h
index 6c5f572885d..27761eb85b5 100644
--- a/src/frontend/mame/luaengine.h
+++ b/src/frontend/mame/luaengine.h
@@ -34,7 +34,6 @@ class lua_engine
{
public:
// helper structures
- class buffer_helper;
template <typename T> struct devenum;
template <typename T> struct simple_list_wrapper;
template <typename T> struct tag_object_ptr_map;
@@ -48,8 +47,9 @@ public:
~lua_engine();
void initialize();
- void load_script(const char *filename);
- void load_string(const char *value);
+ sol::load_result load_script(std::string const &filename);
+ sol::load_result load_string(std::string const &value);
+ sol::environment make_environment();
bool frame_hook();
@@ -122,9 +122,27 @@ public:
sol::state_view &sol() const { return *m_sol_state; }
+ template <typename Func, typename... Params>
+ static std::decay_t<std::invoke_result_t<Func, Params...> > invoke(Func &&func, Params&&... args)
+ {
+ g_profiler.start(PROFILER_LUA);
+ try
+ {
+ auto result = func(std::forward<Params>(args)...);
+ g_profiler.stop();
+ return result;
+ }
+ catch (...)
+ {
+ g_profiler.stop();
+ throw;
+ }
+ }
+
private:
- template<typename T, size_t SIZE> class enum_parser;
+ template <typename T, size_t Size> class enum_parser;
+ class buffer_helper;
struct addr_space;
class tap_helper;
class addr_space_change_notif;
@@ -170,17 +188,12 @@ private:
void resume(int nparam);
void register_function(sol::function func, const char *id);
- int enumerate_functions(const char *id, std::function<bool(const sol::protected_function &func)> &&callback);
+ template <typename T> size_t enumerate_functions(const char *id, T &&callback);
bool execute_function(const char *id);
sol::object call_plugin(const std::string &name, sol::object in);
void close();
- void run(sol::load_result res);
-
- template <typename TFunc, typename... TArgs>
- sol::protected_function_result invoke(TFunc &&func, TArgs&&... args);
-
void initialize_debug(sol::table &emu);
void initialize_input(sol::table &emu);
void initialize_memory(sol::table &emu);