diff options
author | Bo Yang <teboring@google.com> | 2017-05-30 15:34:33 -0700 |
---|---|---|
committer | Bo Yang <teboring@google.com> | 2017-05-31 14:21:07 -0700 |
commit | f15e6764bd1d27d33b5bbf0f5bc7c23bcc837128 (patch) | |
tree | b9dc70a8db0163dfbaa5a8c53a012fe8810188da /upb/descriptor/reader.c | |
parent | 3f3ee548f16a2c6d94c2c9cbe161e5b306269e79 (diff) |
Add new file option php_namespace.
Use this option to change the namespace of php generated classes.
Default is empty. When this option is empty, the package name will be
used for determining the namespace.
Diffstat (limited to 'upb/descriptor/reader.c')
-rw-r--r-- | upb/descriptor/reader.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/upb/descriptor/reader.c b/upb/descriptor/reader.c index af3f83d..f982300 100644 --- a/upb/descriptor/reader.c +++ b/upb/descriptor/reader.c @@ -237,6 +237,22 @@ static size_t file_onpackage(void *closure, const void *hd, const char *buf, return n; } +static size_t file_onphpnamespace(void *closure, const void *hd, + const char *buf, size_t n, + const upb_bufhandle *handle) { + upb_descreader *r = closure; + char *php_namespace; + bool ok; + UPB_UNUSED(hd); + UPB_UNUSED(handle); + + php_namespace = upb_gstrndup(buf, n); + ok = upb_filedef_setphpnamespace(r->file, php_namespace, NULL); + upb_gfree(php_namespace); + UPB_ASSERT(ok); + 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; @@ -781,6 +797,8 @@ static void reghandlers(const void *closure, upb_handlers *h) { } else if (upbdefs_google_protobuf_FileOptions_is(m)) { upb_handlers_setstring(h, F(FileOptions, php_class_prefix), &file_onphpprefix, NULL); + upb_handlers_setstring(h, F(FileOptions, php_namespace), + &file_onphpnamespace, NULL); } UPB_ASSERT(upb_ok(upb_handlers_status(h))); |