Skip to content

Commit

Permalink
print pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasvlevi committed May 10, 2024
1 parent fa62b48 commit 1d347a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion examples/text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ function setup()

-- Replace these with your font paths
font_arial = loadFont("./examples/fonts/Arial.ttf");
font_times = loadFont("./examples/fonts/Times.ttf");
font_times = loadFont("./examples/fonts/Tims.ttf");
font_hack = loadFont("./examples/fonts/Hack.ttf");

print(font_arial, font_times, font_hack)
end

function draw()
Expand Down
12 changes: 9 additions & 3 deletions src/lu5_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,19 @@ void lu5_print_any(lua_State *L, int index, int nested, char sep)
lu5_print_list(L, index, nested, sep);
break;
}
case LUA_TLIGHTUSERDATA:
if (lua_islightuserdata(L, index)) {
void* ptr = lua_touserdata(L, index);

printf("\x1b[35m[ptr: %p]\x1b[0m%c", ptr, sep);
}
break;
// TODO: Handle these
case LUA_TUSERDATA:
case LUA_TUSERDATA:
case LUA_TTHREAD:
case LUA_TLIGHTUSERDATA:
default:
const char* typename = lua_typename(L, type);
printf("[unknown %s%c]", typename, sep);
printf("[unknown %s]%c", typename, sep);
break;
}
}
Expand Down

0 comments on commit 1d347a5

Please sign in to comment.