From 949aeee3f19f893a1581627efbd79ce24141ea6c Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Tue, 6 Dec 2016 23:42:01 -0800 Subject: Changes for PR comments. --- upb/bindings/lua/msg.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'upb/bindings/lua/msg.c') diff --git a/upb/bindings/lua/msg.c b/upb/bindings/lua/msg.c index 6783b23..e7c3f2e 100644 --- a/upb/bindings/lua/msg.c +++ b/upb/bindings/lua/msg.c @@ -256,10 +256,19 @@ static int lupb_msgfactory_new(lua_State *L) { * lupb_msgfactory_getmsgclass() * * Handles: - * MessageClass = factory.get_message_class(msgdef) + * MessageClass = factory.get_message_class(message_name) */ static int lupb_msgfactory_getmsgclass(lua_State *L) { - lupb_msgfactory_pushmsgclass(L, 1, lupb_msgdef_check(L, 2)); + lupb_msgfactory *lfactory = lupb_msgfactory_check(L, 1); + const upb_symtab *symtab = upb_msgfactory_symtab(lfactory->factory); + const upb_msgdef *m = upb_symtab_lookupmsg(symtab, luaL_checkstring(L, 2)); + + if (!m) { + luaL_error(L, "No such message type: %s\n", lua_tostring(L, 2)); + } + + lupb_msgfactory_pushmsgclass(L, 1, m); + return 1; } -- cgit v1.2.3