Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Define and use _XBT_STRINGIFY and _XBT_CONCAT{,2,3,4}.
[simgrid.git] / src / bindings / lua / lua_private.hpp
1 /* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 /* SimGrid Lua bindings                                                     */
7
8 #ifndef LUA_PRIVATE_HPP
9 #define LUA_PRIVATE_HPP
10
11 #include "simgrid/msg.h"
12 #include "simgrid_lua.hpp"
13
14 void sglua_register_host_functions(lua_State* L);
15 msg_host_t sglua_check_host(lua_State* L, int index);
16
17 void sglua_register_platf_functions(lua_State* L);
18
19 #define lua_ensure(...) _XBT_IF_ONE_ARG(_lua_ensure_ARG1, _lua_ensure_ARGN, __VA_ARGS__)(__VA_ARGS__)
20 #define _lua_ensure_ARG1(cond) _lua_ensure_ARGN(cond, "Assertion " _XBT_STRINGIFY(cond) " failed")
21 #define _lua_ensure_ARGN(cond, ...)                                                                                    \
22   do {                                                                                                                 \
23     if (!(cond)) {                                                                                                     \
24       luaL_error(L, __VA_ARGS__);                                                                                      \
25       return -1;                                                                                                       \
26     }                                                                                                                  \
27   } while (0)
28
29 #endif