Skip to content

Commit

Permalink
adding rdis.loader(), a lua call which runs rdis internal loaders on …
Browse files Browse the repository at this point in the history
…a file
  • Loading branch information
endeav0r committed Dec 29, 2012
1 parent e4d0136 commit 8be1fde
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/script/rdis_lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ static const struct luaL_Reg rl_rdis_lib_f [] = {
{"poke", rl_rdis_poke},
{"node", rl_rdis_node},
{"load", rl_rdis_load},
{"loader", rl_rdis_loader},
{NULL, NULL}
};

Expand Down Expand Up @@ -738,4 +739,52 @@ int rl_rdis_load (lua_State * L)
rdis_lua->rdis->memory = memory;

return 0;
}


int rl_rdis_loader (lua_State * L)
{
printf("rdis loader\n");
struct _rdis_lua * rdis_lua = rl_get_rdis_lua(L);

const char * filename = luaL_checkstring(L, -1);

// do we get a valid loader from this file?
_loader * loader = loader_create(filename);

if (loader == NULL) {
char tmp[256];
snprintf(tmp, 256, "No valid loader for %s\n", filename);
rdis_console(rdis_lua->rdis, tmp);
lua_pop(L, 1);
lua_pushboolean(L, 0);
return 1;
}

// clear all gui windows
rdis_clear_gui(rdis_lua->rdis);

// clear rdis
objects_delete(rdis_lua->rdis->loader,
rdis_lua->rdis->graph,
rdis_lua->rdis->labels,
rdis_lua->rdis->functions,
rdis_lua->rdis->memory,
NULL);

// reset rdis
rdis_lua->rdis->loader = loader;
rdis_lua->rdis->memory = loader_memory_map(loader);
rdis_lua->rdis->functions = loader_functions(loader,
rdis_lua->rdis->memory);
rdis_lua->rdis->graph = loader_graph_functions(loader,
rdis_lua->rdis->memory,
rdis_lua->rdis->functions);
rdis_lua->rdis->labels = loader_labels_functions(loader,
rdis_lua->rdis->memory,
rdis_lua->rdis->functions);

lua_pop(L, 1);
lua_pushboolean(L, 1);
return 1;
}
1 change: 1 addition & 0 deletions src/script/rdis_lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@ int rl_rdis_peek (lua_State * L);
int rl_rdis_poke (lua_State * L);
int rl_rdis_node (lua_State * L);
int rl_rdis_load (lua_State * L);
int rl_rdis_loader (lua_State * L);

#endif

0 comments on commit 8be1fde

Please sign in to comment.