Commit f654d49d authored by Josh Haberman's avatar Josh Haberman

Updated upb from latest changes.

parent 78da6669
This diff is collapsed.
...@@ -193,13 +193,15 @@ ...@@ -193,13 +193,15 @@
template <> \ template <> \
class Pointer<cppname> : public PointerBase<cppname, cppbase> { \ class Pointer<cppname> : public PointerBase<cppname, cppbase> { \
public: \ public: \
explicit Pointer(cppname* ptr) : PointerBase(ptr) {} \ explicit Pointer(cppname* ptr) \
: PointerBase<cppname, cppbase>(ptr) {} \
}; \ }; \
template <> \ template <> \
class Pointer<const cppname> \ class Pointer<const cppname> \
: public PointerBase<const cppname, const cppbase> { \ : public PointerBase<const cppname, const cppbase> { \
public: \ public: \
explicit Pointer(const cppname* ptr) : PointerBase(ptr) {} \ explicit Pointer(const cppname* ptr) \
: PointerBase<const cppname, const cppbase>(ptr) {} \
}; \ }; \
} }
...@@ -211,13 +213,15 @@ ...@@ -211,13 +213,15 @@
template <> \ template <> \
class Pointer<cppname> : public PointerBase2<cppname, cppbase, cppbase2> { \ class Pointer<cppname> : public PointerBase2<cppname, cppbase, cppbase2> { \
public: \ public: \
explicit Pointer(cppname* ptr) : PointerBase2(ptr) {} \ explicit Pointer(cppname* ptr) \
: PointerBase2<cppname, cppbase, cppbase2>(ptr) {} \
}; \ }; \
template <> \ template <> \
class Pointer<const cppname> \ class Pointer<const cppname> \
: public PointerBase2<const cppname, const cppbase, const cppbase2> { \ : public PointerBase2<const cppname, const cppbase, const cppbase2> { \
public: \ public: \
explicit Pointer(const cppname* ptr) : PointerBase2(ptr) {} \ explicit Pointer(const cppname* ptr) \
: PointerBase2<const cppname, const cppbase, const cppbase2>(ptr) {} \
}; \ }; \
} }
...@@ -1537,11 +1541,26 @@ class upb::FieldDef { ...@@ -1537,11 +1541,26 @@ class upb::FieldDef {
uint32_t number() const; /* Returns 0 if uninitialized. */ uint32_t number() const; /* Returns 0 if uninitialized. */
bool is_extension() const; bool is_extension() const;
/* Get the JSON name for this field. This will copy the JSON name into the /* Copies the JSON name for this field into the given buffer. Returns the
* given buffer, which must have size of at least "strlen(name()) + 1". * actual size of the JSON name, including the NULL terminator. If the
* The string will be NULL-terminated. Returns false if uninitialized. * return value is 0, the JSON name is unset. If the return value is
* greater than len, the JSON name was truncated. The buffer is always
* NULL-terminated if len > 0.
*
* The JSON name always defaults to a camelCased version of the regular
* name. However if the regular name is unset, the JSON name will be unset
* also.
*/ */
bool GetJsonName(char* buf) const; size_t GetJsonName(char* buf, size_t len) const;
/* Convenience version of the above function which copies the JSON name
* into the given string, returning false if the name is not set. */
template <class T>
bool GetJsonName(T* str) {
str->resize(GetJsonName(NULL, 0));
GetJsonName(&(*str)[0], str->size());
return str->size() > 0;
}
/* For UPB_TYPE_MESSAGE fields only where is_tag_delimited() == false, /* For UPB_TYPE_MESSAGE fields only where is_tag_delimited() == false,
* indicates whether this field should have lazy parsing handlers that yield * indicates whether this field should have lazy parsing handlers that yield
...@@ -1782,7 +1801,7 @@ const char *upb_fielddef_name(const upb_fielddef *f); ...@@ -1782,7 +1801,7 @@ const char *upb_fielddef_name(const upb_fielddef *f);
bool upb_fielddef_isextension(const upb_fielddef *f); bool upb_fielddef_isextension(const upb_fielddef *f);
bool upb_fielddef_lazy(const upb_fielddef *f); bool upb_fielddef_lazy(const upb_fielddef *f);
bool upb_fielddef_packed(const upb_fielddef *f); bool upb_fielddef_packed(const upb_fielddef *f);
bool upb_fielddef_getjsonname(const upb_fielddef *f, char *buf); size_t upb_fielddef_getjsonname(const upb_fielddef *f, char *buf, size_t len);
const upb_msgdef *upb_fielddef_containingtype(const upb_fielddef *f); const upb_msgdef *upb_fielddef_containingtype(const upb_fielddef *f);
const upb_oneofdef *upb_fielddef_containingoneof(const upb_fielddef *f); const upb_oneofdef *upb_fielddef_containingoneof(const upb_fielddef *f);
upb_msgdef *upb_fielddef_containingtype_mutable(upb_fielddef *f); upb_msgdef *upb_fielddef_containingtype_mutable(upb_fielddef *f);
...@@ -2565,6 +2584,9 @@ inline const char* FieldDef::name() const { return upb_fielddef_name(this); } ...@@ -2565,6 +2584,9 @@ inline const char* FieldDef::name() const { return upb_fielddef_name(this); }
inline bool FieldDef::is_extension() const { inline bool FieldDef::is_extension() const {
return upb_fielddef_isextension(this); return upb_fielddef_isextension(this);
} }
inline size_t FieldDef::GetJsonName(char* buf, size_t len) const {
return upb_fielddef_getjsonname(this, buf, len);
}
inline bool FieldDef::lazy() const { inline bool FieldDef::lazy() const {
return upb_fielddef_lazy(this); return upb_fielddef_lazy(this);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment