From e2840a4aa1b6a7a2ca1421d0d6da3e56992e5090 Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Sun, 17 May 2015 16:11:07 -0700 Subject: Restructure tables for C89 port and smaller size. Changes the data layout of tables slightly so that string keys are prefixed with their size, rather than the size being inline in the table itself. This has a few benefits: 1. inttables shrink a bit, because there is no longer a wasted and unused size field sitting in them. 2. This avoids the need to have a union in the table. This is important for an impending C89 port of upb, since C89 has literally no way of statically initializing a non-first union member. --- upb/bindings/lua/upb/table.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'upb/bindings') diff --git a/upb/bindings/lua/upb/table.c b/upb/bindings/lua/upb/table.c index e574ab0..4bda63d 100644 --- a/upb/bindings/lua/upb/table.c +++ b/upb/bindings/lua/upb/table.c @@ -66,9 +66,11 @@ static void lupbtable_pushent(lua_State *L, const upb_tabent *e, lua_newtable(L); if (!upb_tabent_isempty(e)) { if (inttab) { - lua_pushnumber(L, e->key.num); + lua_pushnumber(L, e->key); } else { - lua_pushlstring(L, e->key.s.str, e->key.s.length); + uint32_t len; + const char *str = upb_tabstr(e->key, &len); + lua_pushlstring(L, str, len); } lua_setfield(L, -2, "key"); lupbtable_pushval(L, e->val, ctype); -- cgit v1.2.3