summaryrefslogtreecommitdiff
path: root/upb/def.c
diff options
context:
space:
mode:
authorBo Yang <teboring@google.com>2017-05-30 15:34:33 -0700
committerBo Yang <teboring@google.com>2017-05-31 14:21:07 -0700
commitf15e6764bd1d27d33b5bbf0f5bc7c23bcc837128 (patch)
treeb9dc70a8db0163dfbaa5a8c53a012fe8810188da /upb/def.c
parent3f3ee548f16a2c6d94c2c9cbe161e5b306269e79 (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/def.c')
-rw-r--r--upb/def.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/upb/def.c b/upb/def.c
index b5064be..01bbe5f 100644
--- a/upb/def.c
+++ b/upb/def.c
@@ -1860,6 +1860,7 @@ static void freefiledef(upb_refcounted *r) {
upb_gfree((void*)f->name);
upb_gfree((void*)f->package);
upb_gfree((void*)f->phpprefix);
+ upb_gfree((void*)f->phpnamespace);
upb_gfree(f);
}
@@ -1875,6 +1876,7 @@ upb_filedef *upb_filedef_new(const void *owner) {
f->package = NULL;
f->name = NULL;
f->phpprefix = NULL;
+ f->phpnamespace = NULL;
f->syntax = UPB_SYNTAX_PROTO2;
if (!upb_refcounted_init(upb_filedef_upcast_mutable(f), &upb_filedef_vtbl,
@@ -1913,6 +1915,10 @@ const char *upb_filedef_phpprefix(const upb_filedef *f) {
return f->phpprefix;
}
+const char *upb_filedef_phpnamespace(const upb_filedef *f) {
+ return f->phpnamespace;
+}
+
upb_syntax_t upb_filedef_syntax(const upb_filedef *f) {
return f->syntax;
}
@@ -1981,6 +1987,18 @@ bool upb_filedef_setphpprefix(upb_filedef *f, const char *phpprefix,
return true;
}
+bool upb_filedef_setphpnamespace(upb_filedef *f, const char *phpnamespace,
+ upb_status *s) {
+ phpnamespace = upb_gstrdup(phpnamespace);
+ if (!phpnamespace) {
+ upb_upberr_setoom(s);
+ return false;
+ }
+ upb_gfree((void*)f->phpnamespace);
+ f->phpnamespace = phpnamespace;
+ return true;
+}
+
bool upb_filedef_setsyntax(upb_filedef *f, upb_syntax_t syntax,
upb_status *s) {
UPB_UNUSED(s);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback