MCPcopy Create free account
hub / github.com/TASEmulators/fceux / savestateobj2filename

Function savestateobj2filename

src/lua-engine.cpp:2941–2960  ·  view source on GitHub ↗

Helper function to convert a savestate object to the filename it represents.

Source from the content-addressed store, hash-verified

2939
2940// Helper function to convert a savestate object to the filename it represents.
2941static const char *savestateobj2filename(lua_State *L, int offset) {
2942
2943 // First we get the metatable of the indicated object
2944 int result = lua_getmetatable(L, offset);
2945
2946 if (!result)
2947 luaL_error(L, "object not a savestate object");
2948
2949 // Also check that the type entry is set
2950 lua_getfield(L, -1, "__metatable");
2951 if (strcmp(lua_tostring(L,-1), "FCEU Savestate") != 0)
2952 luaL_error(L, "object not a savestate object");
2953 lua_pop(L,1);
2954
2955 // Now, get the field we want
2956 lua_getfield(L, -1, "filename");
2957
2958 // Return it
2959 return lua_tostring(L, -1);
2960}
2961
2962// Helper function for garbage collection.
2963static int savestate_gc(lua_State *L) {

Callers 1

savestate_loadscriptdataFunction · 0.85

Calls 3

lua_getmetatableFunction · 0.85
luaL_errorFunction · 0.85
lua_getfieldFunction · 0.85

Tested by

no test coverage detected