pull/13171/head
Joshua Haberman 3 years ago
parent 9f45814dd7
commit cd4981133f
  1. 18
      upb/bindings/lua/def.c
  2. 1
      upb/def.h
  3. 13
      upb/def.hpp

@ -171,12 +171,6 @@ static int lupb_fielddef_label(lua_State *L) {
return 1;
}
static int lupb_fielddef_lazy(lua_State *L) {
const upb_fielddef *f = lupb_fielddef_check(L, 1);
lua_pushboolean(L, upb_fielddef_lazy(f));
return 1;
}
static int lupb_fielddef_name(lua_State *L) {
const upb_fielddef *f = lupb_fielddef_check(L, 1);
lua_pushstring(L, upb_fielddef_name(f));
@ -229,7 +223,6 @@ static const struct luaL_Reg lupb_fielddef_m[] = {
{"index", lupb_fielddef_index},
{"is_extension", lupb_fielddef_isextension},
{"label", lupb_fielddef_label},
{"lazy", lupb_fielddef_lazy},
{"name", lupb_fielddef_name},
{"number", lupb_fielddef_number},
{"packed", lupb_fielddef_packed},
@ -689,28 +682,28 @@ static int lupb_filedef_depcount(lua_State *L) {
static int lupb_filedef_enum(lua_State *L) {
const upb_filedef *f = lupb_filedef_check(L, 1);
int index = luaL_checkint(L, 2);
const upb_enumdef *e = upb_filedef_enum(f, index);
const upb_enumdef *e = upb_filedef_toplvlenum(f, index);
lupb_wrapper_pushwrapper(L, 1, e, LUPB_ENUMDEF);
return 1;
}
static int lupb_filedef_enumcount(lua_State *L) {
const upb_filedef *f = lupb_filedef_check(L, 1);
lua_pushnumber(L, upb_filedef_enumcount(f));
lua_pushnumber(L, upb_filedef_toplvlenumcount(f));
return 1;
}
static int lupb_filedef_msg(lua_State *L) {
const upb_filedef *f = lupb_filedef_check(L, 1);
int index = luaL_checkint(L, 2);
const upb_msgdef *m = upb_filedef_msg(f, index);
const upb_msgdef *m = upb_filedef_toplvlmsg(f, index);
lupb_wrapper_pushwrapper(L, 1, m, LUPB_MSGDEF);
return 1;
}
static int lupb_filedef_msgcount(lua_State *L) {
const upb_filedef *f = lupb_filedef_check(L, 1);
lua_pushnumber(L, upb_filedef_msgcount(f));
lua_pushnumber(L, upb_filedef_toplvlmsgcount(f));
return 1;
}
@ -916,8 +909,7 @@ static int lupb_symtab_lookupenumval(lua_State *L) {
static int lupb_symtab_tostring(lua_State *L) {
const upb_symtab *s = lupb_symtab_check(L, 1);
lua_pushfstring(L, "<upb.SymbolTable file_count=%d>",
(int)upb_symtab_filecount(s));
lua_pushfstring(L, "<upb.SymbolTable>");
return 1;
}

@ -122,7 +122,6 @@ uint32_t upb_fielddef_number(const upb_fielddef *f);
const char *upb_fielddef_name(const upb_fielddef *f);
const char *upb_fielddef_jsonname(const upb_fielddef *f);
bool upb_fielddef_isextension(const upb_fielddef *f);
bool upb_fielddef_lazy(const upb_fielddef *f);
bool upb_fielddef_packed(const upb_fielddef *f);
const upb_filedef *upb_fielddef_file(const upb_fielddef *f);
const upb_msgdef *upb_fielddef_containingtype(const upb_fielddef *f);

@ -67,20 +67,11 @@ class FieldDefPtr {
uint32_t number() const { return upb_fielddef_number(ptr_); }
bool is_extension() const { return upb_fielddef_isextension(ptr_); }
// For UPB_TYPE_MESSAGE fields only where is_tag_delimited() == false,
// indicates whether this field should have lazy parsing handlers that yield
// the unparsed string for the submessage.
//
// TODO(haberman): I think we want to move this into a FieldOptions container
// when we add support for custom options (the FieldOptions struct will
// contain both regular FieldOptions like "lazy" *and* custom options).
bool lazy() const { return upb_fielddef_lazy(ptr_); }
// For non-string, non-submessage fields, this indicates whether binary
// protobufs are encoded in packed or non-packed format.
//
// TODO(haberman): see note above about putting options like this into a
// FieldOptions container.
// Note: this accessor reflects the fact that "packed" has different defaults
// depending on whether the proto is proto2 or proto3.
bool packed() const { return upb_fielddef_packed(ptr_); }
// An integer that can be used as an index into an array of fields for

Loading…
Cancel
Save