summaryrefslogtreecommitdiff
path: root/upb/def.h
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2016-04-19 15:41:33 -0700
committerJoshua Haberman <jhaberman@gmail.com>2016-04-19 15:41:33 -0700
commite6fa3f9d869765544b8e424e8573fe8d9af35534 (patch)
tree3e56beb3bd80470ddad130b2c7f703fb5bb6b5fd /upb/def.h
parent68bc62a7fa5febbf5c8ab2fe8f6171121d18690f (diff)
Changed schema for JSON test to be defined in a .proto file. (#54)
* Changed schema for JSON test to be defined in a .proto file. Before we had lots of code to build these schemas manually, but this was verbose and made it difficult to add to the schema easily. Now we can just write a .proto file and adding fields is easy. To avoid making the tests depend on upbc (and thus Lua) we check in the generated schema. * Made protobuf-compiler a dependency of "make genfiles." * For genfiles download recent protoc that can handle proto3. * Only use new protoc for genfiles.
Diffstat (limited to 'upb/def.h')
-rw-r--r--upb/def.h23
1 files changed, 18 insertions, 5 deletions
diff --git a/upb/def.h b/upb/def.h
index d4808a6..87e1766 100644
--- a/upb/def.h
+++ b/upb/def.h
@@ -272,6 +272,11 @@ typedef enum {
UPB_DESCRIPTOR_TYPE_SINT64 = 18
} upb_descriptortype_t;
+typedef enum {
+ UPB_SYNTAX_PROTO2 = 2,
+ UPB_SYNTAX_PROTO3 = 3
+} upb_syntax_t;
+
/* Maximum field number allowed for FieldDefs. This is an inherent limit of the
* protobuf wire format. */
#define UPB_MAX_FIELDNUMBER ((1 << 29) - 1)
@@ -721,6 +726,11 @@ class upb::MessageDef {
bool AddOneof(OneofDef* o, Status* s);
bool AddOneof(const reffed_ptr<OneofDef>& o, Status* s);
+ upb_syntax_t syntax() const;
+
+ /* Returns false if we don't support this syntax value. */
+ bool set_syntax(upb_syntax_t syntax);
+
/* Set this to false to indicate that primitive fields should not have
* explicit presence information associated with them. This will affect all
* fields added to this message. Defaults to true. */
@@ -913,6 +923,7 @@ bool upb_msgdef_freeze(upb_msgdef *m, upb_status *status);
const char *upb_msgdef_fullname(const upb_msgdef *m);
const char *upb_msgdef_name(const upb_msgdef *m);
+upb_syntax_t upb_msgdef_syntax(const upb_msgdef *m);
bool upb_msgdef_setfullname(upb_msgdef *m, const char *fullname, upb_status *s);
upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner);
@@ -963,6 +974,7 @@ UPB_INLINE upb_oneofdef *upb_msgdef_ntoo_mutable(upb_msgdef *m,
void upb_msgdef_setmapentry(upb_msgdef *m, bool map_entry);
bool upb_msgdef_mapentry(const upb_msgdef *m);
+bool upb_msgdef_setsyntax(upb_msgdef *m, upb_syntax_t syntax);
/* Well-known field tag numbers for map-entry messages. */
#define UPB_MAPENTRY_KEY 1
@@ -1284,11 +1296,6 @@ UPB_END_EXTERN_C
/* upb::FileDef ***************************************************************/
-typedef enum {
- UPB_SYNTAX_PROTO2 = 2,
- UPB_SYNTAX_PROTO3 = 3
-} upb_syntax_t;
-
#ifdef __cplusplus
/* Class that represents a .proto file with some things defined in it.
@@ -1651,12 +1658,18 @@ inline const char *MessageDef::full_name() const {
inline const char *MessageDef::name() const {
return upb_msgdef_name(this);
}
+inline upb_syntax_t MessageDef::syntax() const {
+ return upb_msgdef_syntax(this);
+}
inline bool MessageDef::set_full_name(const char* fullname, Status* s) {
return upb_msgdef_setfullname(this, fullname, s);
}
inline bool MessageDef::set_full_name(const std::string& fullname, Status* s) {
return upb_msgdef_setfullname(this, upb_safecstr(fullname), s);
}
+inline bool MessageDef::set_syntax(upb_syntax_t syntax) {
+ return upb_msgdef_setsyntax(this, syntax);
+}
inline bool MessageDef::Freeze(Status* status) {
return upb_msgdef_freeze(this, status);
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback