From 60d3f2cac1342cc25b46ea0eb5a854590e2b5d7d Mon Sep 17 00:00:00 2001 From: takase1121 <20792268+takase1121@users.noreply.github.com> Date: Thu, 8 Jul 2021 14:55:43 +0800 Subject: [PATCH] add __tostring metamethod --- src/api/process.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/api/process.c b/src/api/process.c index 1250ee3b..60b3f0b6 100644 --- a/src/api/process.c +++ b/src/api/process.c @@ -198,6 +198,14 @@ static int f_gc(lua_State* L) return 0; } +static int f_tostring(lua_State* L) +{ + luaL_checkudata(L, 1, API_TYPE_PROCESS); + + lua_pushliteral(L, API_TYPE_PROCESS); + return 1; +} + static int f_pid(lua_State* L) { process_t* self = (process_t*) lua_touserdata(L, 1); @@ -351,6 +359,7 @@ static const struct luaL_Reg lib[] = { {"start", process_start}, {"strerror", process_strerror}, {"__gc", f_gc}, + {"__tostring", f_tostring}, {"pid", f_pid}, {"returncode", f_returncode}, {"read", f_read},