diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2018-12-13 05:40:33 -0800 |
---|---|---|
committer | Joshua Haberman <jhaberman@gmail.com> | 2018-12-13 05:40:33 -0800 |
commit | 7ff8413a0317566d67b5b4abcb6ee2b72e9d465b (patch) | |
tree | a8dc1d08809103f65b1134536f01f0f4f5051e44 /upb | |
parent | 0fed529ea1795d728a7ec75c3f06d95e4ba3bd8d (diff) |
Ported some tests.
Diffstat (limited to 'upb')
-rw-r--r-- | upb/def.c | 15 | ||||
-rw-r--r-- | upb/def.h | 16 |
2 files changed, 18 insertions, 13 deletions
@@ -1359,14 +1359,21 @@ static void count_types_in_msg( size_t i; arr = google_protobuf_DescriptorProto_nested_type(msg_proto); - for (i = 0; i < upb_array_size(arr); i++) { - count_types_in_msg(upb_msgval_getptr(upb_array_get(arr, i)), counts); + if (arr) { + for (i = 0; i < upb_array_size(arr); i++) { + count_types_in_msg(upb_msgval_getptr(upb_array_get(arr, i)), counts); + } } arr = google_protobuf_DescriptorProto_enum_type(msg_proto); - counts->enum_count += upb_array_size(arr); + if (arr) { + counts->enum_count += upb_array_size(arr); + } + arr = google_protobuf_DescriptorProto_extension(msg_proto); - counts->ext_count += upb_array_size(arr); + if (arr) { + counts->ext_count += upb_array_size(arr); + } } static void count_types_in_file( @@ -564,8 +564,6 @@ class upb::OneofDef { upb_oneof_iter iter_; }; - iterator begin(); - iterator end(); const_iterator begin() const; const_iterator end() const; @@ -682,7 +680,8 @@ class upb::SymbolTable { /* TODO: iteration? */ /* Adds the given serialized FileDescriptorProto to the pool. */ - bool AddFile(const char *file, size_t len, Status *status); + bool AddFile(const google_protobuf_FileDescriptorProto *file_proto, + Status *status); /* Adds the given serialized FileDescriptorSet to the pool. */ bool AddSet(const char *set, size_t len, Status *status); @@ -703,6 +702,7 @@ const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym); const upb_msgdef *upb_symtab_lookupmsg2( const upb_symtab *s, const char *sym, size_t len); const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym); +int upb_symtab_filecount(const upb_symtab *s); bool upb_symtab_addfile(upb_symtab *s, const google_protobuf_FileDescriptorProto* file, upb_status *status); @@ -721,6 +721,10 @@ inline void SymbolTable::Free(SymbolTable* s) { inline const MessageDef *SymbolTable::LookupMessage(const char *sym) const { return upb_symtab_lookupmsg(this, sym); } +inline bool SymbolTable::AddFile( + const google_protobuf_FileDescriptorProto *file_proto, Status *status) { + return upb_symtab_addfile(this, file_proto, status); +} } /* namespace upb */ #endif @@ -767,9 +771,6 @@ inline const MessageDef* FieldDef::containing_type() const { inline const OneofDef* FieldDef::containing_oneof() const { return upb_fielddef_containingoneof(this); } -inline void FieldDef::clear_json_name() { - upb_fielddef_clearjsonname(this); -} inline bool FieldDef::IsSubMessage() const { return upb_fielddef_issubmsg(this); } @@ -994,9 +995,6 @@ inline const char* FileDef::phpprefix() const { inline const char* FileDef::phpnamespace() const { return upb_filedef_phpnamespace(this); } -inline int FileDef::def_count() const { - return upb_filedef_defcount(this); -} inline int FileDef::dependency_count() const { return upb_filedef_depcount(this); } |