From f15e6764bd1d27d33b5bbf0f5bc7c23bcc837128 Mon Sep 17 00:00:00 2001 From: Bo Yang Date: Tue, 30 May 2017 15:34:33 -0700 Subject: 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. --- upb/def.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'upb/def.h') diff --git a/upb/def.h b/upb/def.h index 29bb3ea..81c553b 100644 --- a/upb/def.h +++ b/upb/def.h @@ -1299,10 +1299,16 @@ class upb::FileDef { bool set_package(const char* package, Status* s); /* Sets the php class prefix which is prepended to all php generated classes - / from this .proto. Default is empty. */ + * from this .proto. Default is empty. */ const char* phpprefix() const; bool set_phpprefix(const char* phpprefix, Status* s); + /* 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. */ + const char* phpnamespace() const; + bool set_phpnamespace(const char* phpnamespace, Status* s); + /* Syntax for the file. Defaults to proto2. */ upb_syntax_t syntax() const; void set_syntax(upb_syntax_t syntax); @@ -1357,6 +1363,7 @@ UPB_REFCOUNTED_CMETHODS(upb_filedef, upb_filedef_upcast) const char *upb_filedef_name(const upb_filedef *f); const char *upb_filedef_package(const upb_filedef *f); const char *upb_filedef_phpprefix(const upb_filedef *f); +const char *upb_filedef_phpnamespace(const upb_filedef *f); upb_syntax_t upb_filedef_syntax(const upb_filedef *f); size_t upb_filedef_defcount(const upb_filedef *f); size_t upb_filedef_depcount(const upb_filedef *f); @@ -1368,6 +1375,8 @@ bool upb_filedef_setname(upb_filedef *f, const char *name, upb_status *s); bool upb_filedef_setpackage(upb_filedef *f, const char *package, upb_status *s); bool upb_filedef_setphpprefix(upb_filedef *f, const char *phpprefix, upb_status *s); +bool upb_filedef_setphpnamespace(upb_filedef *f, const char *phpnamespace, + upb_status *s); bool upb_filedef_setsyntax(upb_filedef *f, upb_syntax_t syntax, upb_status *s); bool upb_filedef_adddef(upb_filedef *f, upb_def *def, const void *ref_donor, @@ -2132,6 +2141,12 @@ inline const char* FileDef::phpprefix() const { inline bool FileDef::set_phpprefix(const char* phpprefix, Status* s) { return upb_filedef_setphpprefix(this, phpprefix, s); } +inline const char* FileDef::phpnamespace() const { + return upb_filedef_phpnamespace(this); +} +inline bool FileDef::set_phpnamespace(const char* phpnamespace, Status* s) { + return upb_filedef_setphpnamespace(this, phpnamespace, s); +} inline int FileDef::def_count() const { return upb_filedef_defcount(this); } -- cgit v1.2.3