MCPcopy Create free account
hub / github.com/DFHack/dfhack / lua_expr_to_addr

Function lua_expr_to_addr

plugins/devel/memutils.cpp:48–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46 static cleaner g_cleaner;
47
48 void *lua_expr_to_addr(const char *expr)
49 {
50 initializer init;
51 Lua::PushModulePublic(*out, state, "utils", "df_expr_to_ref");
52 lua_pushstring(state, expr);
53 if (!Lua::SafeCall(*out, state, 1, 1))
54 {
55 out->printerr("Failed to evaluate {}\n", expr);
56 return NULL;
57 }
58
59 Lua::PushModulePublic(*out, state, "utils", "addressof");
60 lua_swap(state);
61 if (!Lua::SafeCall(*out, state, 1, 1) || !lua_isinteger(state, -1))
62 {
63 out->printerr("Failed to get address: {}\n", expr);
64 return NULL;
65 }
66
67 auto addr = uintptr_t(lua_tointeger(state, -1));
68 return (void*)addr;
69 }
70}

Callers 1

memviewFunction · 0.85

Calls 5

PushModulePublicFunction · 0.85
lua_pushstringFunction · 0.85
SafeCallFunction · 0.85
lua_swapFunction · 0.85
lua_isintegerFunction · 0.85

Tested by

no test coverage detected