*/
static int Task_new(lua_State * L)
{
+ XBT_DEBUG("Task new...");
const char *name = luaL_checkstring(L, 1);
int comp_size = luaL_checkint(L, 2);
int msg_size = luaL_checkint(L, 3);
{"self",Host_self},
{"getPropValue",Host_get_property_value},
// Bypass XML Methods
- {"new", console_add_host},
{"setFunction", console_set_function},
{0, 0}
};
*/
static const luaL_reg AS_methods[] = {
{"new", console_add_AS},
- {0, 0}
-};
-
-
-/*
- * Link Methods
- */
-static const luaL_reg Link_methods[] = {
- {"new", console_add_link},
- {0, 0}
-};
-
-/*
- * Route Methods
- */
-static const luaL_reg Route_methods[] = {
- {"new", console_add_route},
+ {"addHost",console_add_host},
+ {"addLink",console_add_link},
+ {"addRoute",console_add_route},
{0, 0}
};
* Environment related
*/
-extern lua_State *simgrid_lua_state;
+//extern lua_State *simgrid_lua_state;
static int run_lua_code(int argc, char **argv)
{
/* Start the co-routine */
lua_getglobal(L, argv[0]);
- xbt_assert1(lua_isfunction(L, -1),
+ xbt_assert(lua_isfunction(L, -1),
"The lua function %s does not seem to exist", argv[0]);
// push arguments onto the stack
lua_pushstring(L, argv[i]);
// Call the function (in resume)
- xbt_assert2(lua_pcall(L, argc - 1, 1, 0) == 0,
- "error running function `%s': %s", argv[0], lua_tostring(L,
- -1));
+ int err;
+ err = lua_pcall(L, argc - 1, 1, 0);
+ xbt_assert(err == 0, "error running function `%s': %s", argv[0],
+ lua_tostring(L, -1));
/* retrieve result */
if (lua_isnumber(L, -1)) {
/* module management functions */
/* ********************************************************************************* */
-
#define LUA_MAX_ARGS_COUNT 10 /* maximum amount of arguments we can get from lua on command line */
#define TEST
int luaopen_simgrid(lua_State * L); // Fuck gcc: we don't need that prototype
int luaopen_simgrid(lua_State * L)
{
-
+ XBT_DEBUG("Luaopen_Simgrid *****");
char **argv = malloc(sizeof(char *) * LUA_MAX_ARGS_COUNT);
int argc = 1;
argv[0] = (char *) "/usr/bin/lua"; /* Lie on the argv[0] so that the stack dumping facilities find the right binary. FIXME: what if lua is not in that location? */
if (lua_isnil(L, -1)) {
done = 1;
} else {
- xbt_assert1(lua_isstring(L, -1),
+ xbt_assert(lua_isstring(L, -1),
"argv[%d] got from lua is no string", argc - 1);
- xbt_assert2(argc < LUA_MAX_ARGS_COUNT,
+ xbt_assert(argc < LUA_MAX_ARGS_COUNT,
"Too many arguments, please increase LUA_MAX_ARGS_COUNT in %s before recompiling SimGrid if you insist on having more than %d args on command line",
__FILE__, LUA_MAX_ARGS_COUNT - 1);
argv[argc - 1] = (char *) luaL_checkstring(L, -1);
luaL_newmetatable(L, AS_MODULE_NAME);
lua_pop(L, 1);
- /* register the links methods to lua */
- luaL_openlib(L, LINK_MODULE_NAME, Link_methods, 0);
- luaL_newmetatable(L, LINK_MODULE_NAME);
- lua_pop(L, 1);
- /*register the routes methods to lua */
- luaL_openlib(L, ROUTE_MODULE_NAME, Route_methods, 0);
- luaL_newmetatable(L, ROUTE_MODULE_NAME);
- lua_pop(L, 1);
/*register the Tracing functions to lua */
luaL_openlib(L, TRACE_MODULE_NAME, Trace_methods, 0);