From e9d79d2441732264e2b990a5b2dc76d13724db07 Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Wed, 16 Mar 2016 18:07:32 -0700 Subject: Added upb::FileDef, which represents the file defs are declared in. It is entirely optional: MessageDef/EnumDef can still exist on their own. But this can represent a def's file when it is desirable to do so (eg. for code generators). This approach will require that we change the way we handle extensions. But I think it will be a good change overall. Specifically, we previously handled extensions by duplicating the extended message and then adding the extension as a regular field to the duplicated message. This required also duplicating any messages that could reach the extended message. In the new world we will need a way of declaring and looking up extensions separately from the message being extended. This change also involves some notable changes to the generated code: - files are now called foo.upbdefs.h instead of foo.upb.h. This reflects the fact that we might possibly generate several different output files for a .proto file, and this one is just for defs. - we no longer generate selectors in the .h file. - the upbdefs.c no longer vends a SymbolTable. Now it vends the individual messages (and possibly a FileDef later). I think this will compose better once we can generate files where one generated files imports another. We also make the descriptor reader vend a list of FileDefs now. This is the best conceptual match for parsing a FileDescriptorSet. --- tests/test_handlers.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'tests/test_handlers.c') diff --git a/tests/test_handlers.c b/tests/test_handlers.c index b591ad2..fe6fb82 100644 --- a/tests/test_handlers.c +++ b/tests/test_handlers.c @@ -1,6 +1,6 @@ #include "upb/handlers.h" -#include "upb/descriptor/descriptor.upb.h" +#include "upb/descriptor/descriptor.upbdefs.h" #include "upb_test.h" #include #include @@ -13,10 +13,9 @@ static bool startmsg(void *c, const void *hd) { static void test_error() { /* Test creating handlers of a static msgdef. */ - const upb_symtab *s = upbdefs_google_protobuf_descriptor(&s); - upb_handlers *h = - upb_handlers_new(upbdefs_google_protobuf_DescriptorProto(s), &h); - upb_symtab_unref(s, &s); + const upb_msgdef *m = upbdefs_google_protobuf_DescriptorProto_get(&m); + upb_handlers *h = upb_handlers_new(m, &h); + upb_msgdef_unref(m, &m); /* Attempt to set the same handler twice causes error. */ ASSERT(upb_ok(upb_handlers_status(h))); -- cgit v1.2.3