summaryrefslogtreecommitdiff
path: root/upb/bindings
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2016-12-07 00:52:25 -0800
committerJosh Haberman <jhaberman@gmail.com>2016-12-07 00:52:25 -0800
commitba4e23f1702996336f580312dcdc67d55ed29ae7 (patch)
treef812e99d4f43bfc6654123f4579c97e866c58518 /upb/bindings
parent949aeee3f19f893a1581627efbd79ce24141ea6c (diff)
Added a few missing __gc metamethods.
Diffstat (limited to 'upb/bindings')
-rw-r--r--upb/bindings/lua/def.c1
-rw-r--r--upb/bindings/lua/msg.c7
2 files changed, 8 insertions, 0 deletions
diff --git a/upb/bindings/lua/def.c b/upb/bindings/lua/def.c
index c2df140..638abb6 100644
--- a/upb/bindings/lua/def.c
+++ b/upb/bindings/lua/def.c
@@ -720,6 +720,7 @@ static const struct luaL_Reg lupb_oneofdef_m[] = {
};
static const struct luaL_Reg lupb_oneofdef_mm[] = {
+ {"__gc", lupb_refcounted_gc},
{"__len", lupb_oneofdef_len},
{NULL, NULL}
};
diff --git a/upb/bindings/lua/msg.c b/upb/bindings/lua/msg.c
index e7c3f2e..d77c429 100644
--- a/upb/bindings/lua/msg.c
+++ b/upb/bindings/lua/msg.c
@@ -950,6 +950,12 @@ int lupb_msg_pushref(lua_State *L, int msgclass, void *msg) {
return 1;
}
+static int lupb_msg_gc(lua_State *L) {
+ lupb_msg *lmsg = lupb_msg_check(L, 1);
+ upb_msg_uninit(lmsg->msg, lmsg->lmsgclass->layout);
+ return 0;
+}
+
/* lupb_msg Public API */
/**
@@ -1053,6 +1059,7 @@ static int lupb_msg_newindex(lua_State *L) {
}
static const struct luaL_Reg lupb_msg_mm[] = {
+ {"__gc", lupb_msg_gc},
{"__index", lupb_msg_index},
{"__newindex", lupb_msg_newindex},
{NULL, NULL}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback