diff options
author | Bo Yang <teboring@google.com> | 2017-03-13 17:49:26 -0700 |
---|---|---|
committer | Bo Yang <teboring@google.com> | 2017-03-14 11:31:30 -0700 |
commit | 969ba5ef86a951cb262929cb8a3fa31df6014517 (patch) | |
tree | 40078b87840fff89e5c9e40d5986a9d1649eaa32 /upb/descriptor/reader.c | |
parent | 5a8467842acfbd117ec9231f8231fc33c3304035 (diff) |
Add new file option php_class_prefix.
This option will be prepended to all php generated classes. The PHP
runtime needs to know this option to figure out the class name for
specific message.
Diffstat (limited to 'upb/descriptor/reader.c')
-rw-r--r-- | upb/descriptor/reader.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/upb/descriptor/reader.c b/upb/descriptor/reader.c index 02019e1..106d4a7 100644 --- a/upb/descriptor/reader.c +++ b/upb/descriptor/reader.c @@ -237,6 +237,20 @@ static size_t file_onpackage(void *closure, const void *hd, const char *buf, return n; } +static size_t file_onphpprefix(void *closure, const void *hd, const char *buf, + size_t n, const upb_bufhandle *handle) { + upb_descreader *r = closure; + char *prefix; + bool ok; + UPB_UNUSED(hd); + UPB_UNUSED(handle); + + prefix = upb_gstrndup(buf, n); + ok = upb_filedef_setpackage(r->file, prefix, NULL); + UPB_ASSERT(ok); + return true; +} + static size_t file_onsyntax(void *closure, const void *hd, const char *buf, size_t n, const upb_bufhandle *handle) { upb_descreader *r = closure; @@ -763,6 +777,9 @@ static void reghandlers(const void *closure, upb_handlers *h) { upb_handlers_setbool(h, F(FieldOptions, packed), &field_onpacked, NULL); } else if (upbdefs_google_protobuf_MessageOptions_is(m)) { upb_handlers_setbool(h, F(MessageOptions, map_entry), &msg_onmapentry, NULL); + } else if (upbdefs_google_protobuf_FileOptions_is(m)) { + upb_handlers_setstring(h, F(FileOptions, php_class_prefix), + &file_onphpprefix, NULL); } UPB_ASSERT(upb_ok(upb_handlers_status(h))); |