pull/13171/head
Joshua Haberman 16 years ago
parent 2c5c3fdc25
commit 485b964662
  1. 376
      descriptor.c
  2. 21
      test_table.cc
  3. 5
      upb.h
  4. 13
      upb_context.c
  5. 1
      upb_msg.c
  6. 4
      upb_parse.c
  7. 1
      upb_table.c

File diff suppressed because it is too large Load Diff

@ -227,13 +227,32 @@ int32_t *get_contiguous_keys(int32_t num)
int main()
{
vector<string> keys;
keys.push_back("google.protobuf.FileDescriptorSet");
keys.push_back("google.protobuf.FileDescriptorProto");
keys.push_back("google.protobuf.DescriptorProto");
keys.push_back("google.protobuf.DescriptorProto.ExtensionRange");
keys.push_back("google.protobuf.FieldDescriptorProto");
keys.push_back("google.protobuf.EnumDescriptorProto");
keys.push_back("google.protobuf.EnumValueDescriptorProto");
keys.push_back("google.protobuf.ServiceDescriptorProto");
keys.push_back("google.protobuf.MethodDescriptorProto");
keys.push_back("google.protobuf.FileOptions");
keys.push_back("google.protobuf.MessageOptions");
keys.push_back("google.protobuf.FieldOptions");
keys.push_back("google.protobuf.EnumOptions");
keys.push_back("google.protobuf.EnumValueOptions");
keys.push_back("google.protobuf.ServiceOptions");
keys.push_back("google.protobuf.MethodOptions");
keys.push_back("google.protobuf.UninterpretedOption");
keys.push_back("google.protobuf.UninterpretedOption.NamePart");
keys.push_back("A");
keys.push_back("B");
keys.push_back("C");
keys.push_back("D");
keys.push_back("E");
keys.push_back("F");
test_strtable(keys, 5);
test_strtable(keys, 18);
return 0;
int32_t *keys1 = get_contiguous_keys(8);
printf("Contiguous 1-8 ====\n");

@ -54,6 +54,11 @@ INLINE void upb_strcpy(struct upb_string *dest, struct upb_string *src) {
dest->byte_len = src->byte_len;
}
INLINE void upb_print(struct upb_string *str) {
fwrite(str->ptr, str->byte_len, 1, stdout);
fputc('\n', stdout);
}
/* A list of types as they are encoded on-the-wire. */
enum upb_wire_type {
UPB_WIRE_TYPE_VARINT = 0,

@ -165,9 +165,12 @@ static bool insert_message(struct upb_strtable *t,
return false;
}
upb_strtable_insert(t, &e.e);
printf("Inserted ");
upb_print(&e.e.key);
/* Add nested messages and enums. */
if(d->set_flags.has.nested_type)
//if(d->set_flags.has.nested_type)
if(d->nested_type)
for(unsigned int i = 0; i < d->nested_type->len; i++)
if(!insert_message(t, d->nested_type->elements[i], &fqname))
return false;
@ -220,12 +223,14 @@ bool upb_context_addfd(struct upb_context *c,
google_protobuf_FieldDescriptorProto *fd = m->field_descriptors[i];
union upb_symbol_ref ref;
if(fd->type == GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_MESSAGE)
ref = resolve2(&c->symtab, &tmp, &e->e.key, fd->name, UPB_SYM_MESSAGE);
ref = resolve2(&c->symtab, &tmp, &e->e.key, fd->type_name, UPB_SYM_MESSAGE);
else if(fd->type == GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_ENUM)
ref = resolve2(&c->symtab, &tmp, &e->e.key, fd->name, UPB_SYM_ENUM);
ref = resolve2(&c->symtab, &tmp, &e->e.key, fd->type_name, UPB_SYM_ENUM);
else
continue; /* No resolving necessary. */
if(!ref.msg) goto error; /* Ref. to undefined symbol. */
upb_print(&e->e.key);
if(!ref.msg) { printf("FAILED!\n"); goto error; } /* Ref. to undefined symbol. */
printf("Successful!\n");
upb_msg_ref(m, f, ref);
}
}

@ -40,6 +40,7 @@ bool upb_msg_init(struct upb_msg *m, struct google_protobuf_DescriptorProto *d)
upb_strtable_init(&m->fields_by_name, d->field->len,
sizeof(struct upb_fieldsbyname_entry));
m->descriptor = d;
m->num_fields = d->field->len;
m->set_flags_bytes = div_round_up(m->num_fields, 8);
/* These are incremented in the loop. */

@ -100,8 +100,8 @@ static upb_status_t get_f_uint64_t(void *restrict *buf, void *end,
*buf = uint64_end;
#else
uint32_t lo32, hi32;
get_f_uint32_t(buf, &lo32);
get_f_uint32_t(buf, &hi32);
get_f_uint32_t(buf, &lo32, end);
get_f_uint32_t(buf, &hi32, end);
*val = lo32 | ((uint64_t)hi32 << 32);
#endif
return UPB_STATUS_OK;

@ -173,6 +173,7 @@ static void strinsert(struct upb_strtable *t, struct upb_strtable_entry *e)
}
memcpy(table_e, e, t->t.entry_size);
table_e->next = UPB_END_OF_CHAIN;
assert(upb_strtable_lookup(t, &e->key) == table_e);
}
void upb_strtable_insert(struct upb_strtable *t, struct upb_strtable_entry *e)

Loading…
Cancel
Save