#ifndef PW_SCRIPTING_RUNTIME_LUA_HPP
#define PW_SCRIPTING_RUNTIME_LUA_HPP

#include "sol/sol.hpp"
#include <lua.hpp>
#include <map>

#include <pw/core/debug.hpp>

namespace pw {

class runtime_lua {
public:
	typedef std::function<void(sol::state&,sol::table&)> register_function_t;
	typedef std::map<std::string,register_function_t> register_func_list_t;

	static runtime_lua& get();

	register_func_list_t register_functions() { return _register_function_list; }

	void add(const std::string& name,register_function_t f);

protected:

	runtime_lua();

	register_func_list_t _register_function_list;

};


#define PW_REGISTER_LUA(name) void register_##name##_lua() { runtime_lua::get().add(#name,register_##name##_function); }

#define PW_REGISTER_DECL_LUA(name) void register_##name##_lua();

#define PW_REGISTER_USE_LUA(name) register_##name##_lua();


}


#endif
