24#define ConsoleJoinWordsA(x, y) x##y
26#define ConsoleJoinWordsB(x, y) ConsoleJoinWordsA(x, y)
37#define RegisterLuaFunctionAsIs(func_name) \
38 static char ConsoleJoinWordsB(unique_var_name_luacfunc_##func_name##_, \
40 chi::Console::AddFunctionToRegistryGlobalNamespace(#func_name, \
50#define RegisterLuaFunction(function, namespace_name, func_name) \
51 static char ConsoleJoinWordsB(unique_var_name_luacfunc_##func_name##_, \
53 chi::Console::AddFunctionToRegistryInNamespaceWithName( \
54 function, #namespace_name, #func_name)
56#define RegisterWrapperFunction( \
57 namespace_name, name_in_lua, syntax_function, actual_function) \
58 static char ConsoleJoinWordsB(unique_var_name_luacfunc_##name_in_lua##_, \
60 chi::Console::AddWrapperToRegistryInNamespaceWithName( \
61 #namespace_name, #name_in_lua, syntax_function, actual_function)
63#define RegisterLuaConstant(namespace_name, name_in_lua, value) \
64 static char ConsoleJoinWordsB( \
65 unique_var_name_luaconst_##namespace_name##_##name_in_lua, __COUNTER__) = \
66 chi::Console::AddLuaConstantToRegistry( \
67 #namespace_name, #name_in_lua, value)
69#define RegisterLuaConstantAsIs(name_in_lua, value) \
70 static char ConsoleJoinWordsB( \
71 unique_var_name_luaconst_##name_in_lua, __COUNTER__) = \
72 chi::Console::AddLuaConstantToRegistry( \
73 "", #name_in_lua, value)
81struct RegistryStatuses;
133 const std::map<std::string, LuaFunctionRegistryEntry>&
139 const std::map<std::string, LuaFunctionRegistryEntry>&
148 int ExecuteFile(
const std::string& fileName,
int argc,
char** argv)
const;
149 void PostMPIInfo(
int location_id,
int number_of_processes)
const;
155 lua_CFunction function_ptr);
161 lua_CFunction function_ptr);
167 const std::string& namespace_name,
168 const std::string& function_name);
172 const std::string& constant_name,
180 const std::string& namespace_name,
181 const std::string& name_in_lua,
184 bool ignore_null_call_func =
false);
189 lua_CFunction function_ptr);
static void AddFunctionToRegistry(const std::string &name_in_lua, lua_CFunction function_ptr)
static double GetMemoryUsageInMB()
Get current memory usage in Megabytes.
chi::ParameterBlock(*)(const chi::InputParameters &) WrapperCallFunc
std::map< std::string, chi_data_types::Varying > lua_constants_registry_
void UpdateConsoleBindings(const chi::RegistryStatuses &old_statuses)
static void SetLuaFuncWrapperNamespaceTableStructure(const std::string &full_lua_name)
Formats a namespace structure as a table, but the last entry is a function call.
int ExecuteFile(const std::string &fileName, int argc, char **argv) const
void LoadRegisteredLuaItems()
std::map< std::string, LuaFuncWrapperRegEntry > function_wrapper_registry_
chi::InputParameters(*)() WrapperGetInParamsFunc
std::map< std::string, LuaFunctionRegistryEntry > lua_function_registry_
lua_State *& GetConsoleState()
static char AddLuaConstantToRegistry(const std::string &namespace_name, const std::string &constant_name, const chi_data_types::Varying &value)
Adds a constant to the lua state.
static CSTMemory GetMemoryUsage()
Get current memory usage.
static char AddFunctionToRegistryInNamespaceWithName(lua_CFunction function_ptr, const std::string &namespace_name, const std::string &function_name)
Adds a lua_CFunction to the registry. With namespace-table analogy.
std::vector< std::string > & GetCommandBuffer()
static void SetLuaConstant(const std::string &constant_name, const chi_data_types::Varying &value)
void PostMPIInfo(int location_id, int number_of_processes) const
static int LuaWrapperCall(lua_State *L)
Generic entry point for wrapper calls.
static Console & GetInstance() noexcept
lua_State * console_state_
Pointer to lua console state.
void FlushConsole()
Flushes any commands in the command buffer.
const std::map< std::string, LuaFunctionRegistryEntry > & GetLuaFunctionRegistry() const
static void SetObjectNamespaceTableStructure(const std::string &full_lua_name)
Formats a namespace structure as a table, but the last entry contains a "Create" function and a type.
static InputParameters DefaultGetInParamsFunc()
A default function for returning empty input parameters.
void DumpRegister() const
Dumps the object registry to stdout.
void RunConsoleLoop(char *fileName=nullptr) const
std::vector< std::string > command_buffer_
Buffer of commands to execute.
const std::map< std::string, LuaFunctionRegistryEntry > & GetFunctionWrapperRegistry() const
static void FleshOutLuaTableStructure(const std::vector< std::string > &table_names)
Makes sure a table structure exists for the list of table names.
static char AddFunctionToRegistryGlobalNamespace(const std::string &raw_name_in_lua, lua_CFunction function_ptr)
Adds a lua_CFunction to the registry.
static char AddWrapperToRegistryInNamespaceWithName(const std::string &namespace_name, const std::string &name_in_lua, WrapperGetInParamsFunc syntax_function, WrapperCallFunc actual_function, bool ignore_null_call_func=false)
Adds a function wrapper to the lua registry.
static void SetLuaFuncNamespaceTableStructure(const std::string &full_lua_name, lua_CFunction function_ptr)
Formats a namespace structure as table.
WrapperGetInParamsFunc get_in_params_func
WrapperCallFunc call_func
lua_CFunction function_ptr
std::string function_raw_name