update PHP and Ruby to use the new accessors, delete the old ones
PiperOrigin-RevId: 493109199
diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h
index f3e625d..ca9b2d5 100755
--- a/ruby/ext/google/protobuf_c/ruby-upb.h
+++ b/ruby/ext/google/protobuf_c/ruby-upb.h
@@ -63,7 +63,14 @@
#define UPB_MAPTYPE_STRING 0
-/* UPB_INLINE: inline if possible, emit standalone code if required. */
+// UPB_EXPORT: always generate a public symbol.
+#if defined(__GNUC__) || defined(__clang__)
+#define UPB_EXPORT __attribute__((visibility("default"))) __attribute__((used))
+#else
+#define UPB_EXPORT
+#endif
+
+// UPB_INLINE: inline if possible, emit standalone code if required.
#ifdef __cplusplus
#define UPB_INLINE inline
#elif defined (__GNUC__) || defined(__clang__)
@@ -72,6 +79,14 @@
#define UPB_INLINE static
#endif
+#ifdef UPB_BUILD_API
+#define UPB_API UPB_EXPORT
+#define UPB_API_INLINE UPB_EXPORT
+#else
+#define UPB_API
+#define UPB_API_INLINE UPB_INLINE
+#endif
+
#define UPB_MALLOC_ALIGN 8
#define UPB_ALIGN_UP(size, align) (((size) + (align) - 1) / (align) * (align))
#define UPB_ALIGN_DOWN(size, align) ((size) / (align) * (align))
@@ -281,11 +296,11 @@
extern "C" {
#endif
-const char* upb_Status_ErrorMessage(const upb_Status* status);
-bool upb_Status_IsOk(const upb_Status* status);
+UPB_API const char* upb_Status_ErrorMessage(const upb_Status* status);
+UPB_API bool upb_Status_IsOk(const upb_Status* status);
// These are no-op if |status| is NULL.
-void upb_Status_Clear(upb_Status* status);
+UPB_API void upb_Status_Clear(upb_Status* status);
void upb_Status_SetErrorMessage(upb_Status* status, const char* msg);
void upb_Status_SetErrorFormat(upb_Status* status, const char* fmt, ...)
UPB_PRINTF(2, 3);
@@ -396,8 +411,8 @@
extern "C" {
#endif
-UPB_INLINE upb_StringView upb_StringView_FromDataAndSize(const char* data,
- size_t size) {
+UPB_API_INLINE upb_StringView upb_StringView_FromDataAndSize(const char* data,
+ size_t size) {
upb_StringView ret;
ret.data = data;
ret.size = size;
@@ -566,11 +581,13 @@
// Creates an arena from the given initial block (if any -- n may be 0).
// Additional blocks will be allocated from |alloc|. If |alloc| is NULL, this
// is a fixed-size arena and cannot grow.
-upb_Arena* upb_Arena_Init(void* mem, size_t n, upb_alloc* alloc);
+UPB_API upb_Arena* upb_Arena_Init(void* mem, size_t n, upb_alloc* alloc);
-void upb_Arena_Free(upb_Arena* a);
-bool upb_Arena_AddCleanup(upb_Arena* a, void* ud, upb_CleanupFunc* func);
-bool upb_Arena_Fuse(upb_Arena* a, upb_Arena* b);
+UPB_API void upb_Arena_Free(upb_Arena* a);
+UPB_API bool upb_Arena_AddCleanup(upb_Arena* a, void* ud,
+ upb_CleanupFunc* func);
+UPB_API bool upb_Arena_Fuse(upb_Arena* a, upb_Arena* b);
+
void* _upb_Arena_SlowMalloc(upb_Arena* a, size_t size);
size_t upb_Arena_SpaceAllocated(upb_Arena* arena);
uint32_t upb_Arena_DebugRefCount(upb_Arena* arena);
@@ -580,7 +597,7 @@
return (size_t)(h->end - h->ptr);
}
-UPB_INLINE void* upb_Arena_Malloc(upb_Arena* a, size_t size) {
+UPB_API_INLINE void* upb_Arena_Malloc(upb_Arena* a, size_t size) {
size = UPB_ALIGN_MALLOC(size);
if (UPB_UNLIKELY(_upb_ArenaHas(a) < size)) {
return _upb_Arena_SlowMalloc(a, size);
@@ -613,8 +630,8 @@
// REQUIRES: (ptr, oldsize) was the last malloc/realloc from this arena.
// We could also add a upb_Arena_TryShrinkLast() which is simply a no-op if
// this was not the last alloc.
-UPB_INLINE void upb_Arena_ShrinkLast(upb_Arena* a, void* ptr, size_t oldsize,
- size_t size) {
+UPB_API_INLINE void upb_Arena_ShrinkLast(upb_Arena* a, void* ptr,
+ size_t oldsize, size_t size) {
_upb_ArenaHead* h = (_upb_ArenaHead*)a;
oldsize = UPB_ALIGN_MALLOC(oldsize);
size = UPB_ALIGN_MALLOC(size);
@@ -623,8 +640,8 @@
h->ptr = (char*)ptr + size;
}
-UPB_INLINE void* upb_Arena_Realloc(upb_Arena* a, void* ptr, size_t oldsize,
- size_t size) {
+UPB_API_INLINE void* upb_Arena_Realloc(upb_Arena* a, void* ptr, size_t oldsize,
+ size_t size) {
_upb_ArenaHead* h = (_upb_ArenaHead*)a;
oldsize = UPB_ALIGN_MALLOC(oldsize);
size = UPB_ALIGN_MALLOC(size);
@@ -649,7 +666,7 @@
return ret;
}
-UPB_INLINE upb_Arena* upb_Arena_New(void) {
+UPB_API_INLINE upb_Arena* upb_Arena_New(void) {
return upb_Arena_Init(NULL, 0, &upb_alloc_global);
}
@@ -2253,17 +2270,17 @@
extern "C" {
#endif
-const upb_MiniTableField* upb_MiniTable_FindFieldByNumber(
+UPB_API const upb_MiniTableField* upb_MiniTable_FindFieldByNumber(
const upb_MiniTable* table, uint32_t number);
-upb_FieldType upb_MiniTableField_Type(const upb_MiniTableField* field);
+UPB_API upb_FieldType upb_MiniTableField_Type(const upb_MiniTableField* field);
-UPB_INLINE bool upb_MiniTableField_IsExtension(
+UPB_API_INLINE bool upb_MiniTableField_IsExtension(
const upb_MiniTableField* field) {
return field->mode & kUpb_LabelFlags_IsExtension;
}
-UPB_INLINE bool upb_MiniTableField_HasPresence(
+UPB_API_INLINE bool upb_MiniTableField_HasPresence(
const upb_MiniTableField* field) {
if (upb_MiniTableField_IsExtension(field)) {
return !upb_IsRepeatedOrMap(field);
@@ -2272,12 +2289,12 @@
}
}
-UPB_INLINE const upb_MiniTable* upb_MiniTable_GetSubMessageTable(
+UPB_API_INLINE const upb_MiniTable* upb_MiniTable_GetSubMessageTable(
const upb_MiniTable* mini_table, const upb_MiniTableField* field) {
return mini_table->subs[field->submsg_index].submsg;
}
-UPB_INLINE const upb_MiniTableEnum* upb_MiniTable_GetSubEnumTable(
+UPB_API_INLINE const upb_MiniTableEnum* upb_MiniTable_GetSubEnumTable(
const upb_MiniTable* mini_table, const upb_MiniTableField* field) {
return mini_table->subs[field->submsg_index].subenum;
}
@@ -2511,19 +2528,19 @@
// EVERYTHING ABOVE THIS LINE IS INTERNAL - DO NOT USE /////////////////////////
-UPB_INLINE void upb_MiniTable_ClearField(upb_Message* msg,
- const upb_MiniTableField* field) {
+UPB_API_INLINE void upb_MiniTable_ClearField(upb_Message* msg,
+ const upb_MiniTableField* field) {
_upb_MiniTable_ClearNonExtensionField(msg, field);
}
-UPB_INLINE bool upb_MiniTable_HasField(const upb_Message* msg,
- const upb_MiniTableField* field) {
+UPB_API_INLINE bool upb_MiniTable_HasField(const upb_Message* msg,
+ const upb_MiniTableField* field) {
return _upb_MiniTable_HasNonExtensionField(msg, field);
}
-UPB_INLINE bool upb_MiniTable_GetBool(const upb_Message* msg,
- const upb_MiniTableField* field,
- bool default_val) {
+UPB_API_INLINE bool upb_MiniTable_GetBool(const upb_Message* msg,
+ const upb_MiniTableField* field,
+ bool default_val) {
UPB_ASSUME(field->descriptortype == kUpb_FieldType_Bool);
UPB_ASSUME(!upb_IsRepeatedOrMap(field));
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_1Byte);
@@ -2532,18 +2549,18 @@
return ret;
}
-UPB_INLINE void upb_MiniTable_SetBool(upb_Message* msg,
- const upb_MiniTableField* field,
- bool value) {
+UPB_API_INLINE void upb_MiniTable_SetBool(upb_Message* msg,
+ const upb_MiniTableField* field,
+ bool value) {
UPB_ASSUME(field->descriptortype == kUpb_FieldType_Bool);
UPB_ASSUME(!upb_IsRepeatedOrMap(field));
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_1Byte);
_upb_MiniTable_SetNonExtensionField(msg, field, &value);
}
-UPB_INLINE int32_t upb_MiniTable_GetInt32(const upb_Message* msg,
- const upb_MiniTableField* field,
- int32_t default_val) {
+UPB_API_INLINE int32_t upb_MiniTable_GetInt32(const upb_Message* msg,
+ const upb_MiniTableField* field,
+ int32_t default_val) {
UPB_ASSUME(field->descriptortype == kUpb_FieldType_Int32 ||
field->descriptortype == kUpb_FieldType_SInt32 ||
field->descriptortype == kUpb_FieldType_SFixed32 ||
@@ -2555,9 +2572,9 @@
return ret;
}
-UPB_INLINE void upb_MiniTable_SetInt32(upb_Message* msg,
- const upb_MiniTableField* field,
- int32_t value) {
+UPB_API_INLINE void upb_MiniTable_SetInt32(upb_Message* msg,
+ const upb_MiniTableField* field,
+ int32_t value) {
UPB_ASSUME(field->descriptortype == kUpb_FieldType_Int32 ||
field->descriptortype == kUpb_FieldType_SInt32 ||
field->descriptortype == kUpb_FieldType_SFixed32);
@@ -2566,9 +2583,9 @@
_upb_MiniTable_SetNonExtensionField(msg, field, &value);
}
-UPB_INLINE uint32_t upb_MiniTable_GetUInt32(const upb_Message* msg,
- const upb_MiniTableField* field,
- uint32_t default_val) {
+UPB_API_INLINE uint32_t upb_MiniTable_GetUInt32(const upb_Message* msg,
+ const upb_MiniTableField* field,
+ uint32_t default_val) {
UPB_ASSUME(field->descriptortype == kUpb_FieldType_UInt32 ||
field->descriptortype == kUpb_FieldType_Fixed32);
UPB_ASSUME(!upb_IsRepeatedOrMap(field));
@@ -2578,9 +2595,9 @@
return ret;
}
-UPB_INLINE void upb_MiniTable_SetUInt32(upb_Message* msg,
- const upb_MiniTableField* field,
- uint32_t value) {
+UPB_API_INLINE void upb_MiniTable_SetUInt32(upb_Message* msg,
+ const upb_MiniTableField* field,
+ uint32_t value) {
UPB_ASSUME(field->descriptortype == kUpb_FieldType_UInt32 ||
field->descriptortype == kUpb_FieldType_Fixed32);
UPB_ASSUME(!upb_IsRepeatedOrMap(field));
@@ -2588,10 +2605,9 @@
_upb_MiniTable_SetNonExtensionField(msg, field, &value);
}
-UPB_INLINE void upb_MiniTable_SetEnumProto2(upb_Message* msg,
- const upb_MiniTable* msg_mini_table,
- const upb_MiniTableField* field,
- int32_t value) {
+UPB_API_INLINE void upb_MiniTable_SetEnumProto2(
+ upb_Message* msg, const upb_MiniTable* msg_mini_table,
+ const upb_MiniTableField* field, int32_t value) {
UPB_ASSERT(field->descriptortype == kUpb_FieldType_Enum);
UPB_ASSUME(!upb_IsRepeatedOrMap(field));
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_4Byte);
@@ -2600,9 +2616,9 @@
_upb_MiniTable_SetNonExtensionField(msg, field, &value);
}
-UPB_INLINE int64_t upb_MiniTable_GetInt64(const upb_Message* msg,
- const upb_MiniTableField* field,
- uint64_t default_val) {
+UPB_API_INLINE int64_t upb_MiniTable_GetInt64(const upb_Message* msg,
+ const upb_MiniTableField* field,
+ uint64_t default_val) {
UPB_ASSERT(field->descriptortype == kUpb_FieldType_Int64 ||
field->descriptortype == kUpb_FieldType_SInt64 ||
field->descriptortype == kUpb_FieldType_SFixed64);
@@ -2613,9 +2629,9 @@
return ret;
}
-UPB_INLINE void upb_MiniTable_SetInt64(upb_Message* msg,
- const upb_MiniTableField* field,
- int64_t value) {
+UPB_API_INLINE void upb_MiniTable_SetInt64(upb_Message* msg,
+ const upb_MiniTableField* field,
+ int64_t value) {
UPB_ASSERT(field->descriptortype == kUpb_FieldType_Int64 ||
field->descriptortype == kUpb_FieldType_SInt64 ||
field->descriptortype == kUpb_FieldType_SFixed64);
@@ -2624,9 +2640,9 @@
_upb_MiniTable_SetNonExtensionField(msg, field, &value);
}
-UPB_INLINE uint64_t upb_MiniTable_GetUInt64(const upb_Message* msg,
- const upb_MiniTableField* field,
- uint64_t default_val) {
+UPB_API_INLINE uint64_t upb_MiniTable_GetUInt64(const upb_Message* msg,
+ const upb_MiniTableField* field,
+ uint64_t default_val) {
UPB_ASSERT(field->descriptortype == kUpb_FieldType_UInt64 ||
field->descriptortype == kUpb_FieldType_Fixed64);
UPB_ASSUME(!upb_IsRepeatedOrMap(field));
@@ -2636,9 +2652,9 @@
return ret;
}
-UPB_INLINE void upb_MiniTable_SetUInt64(upb_Message* msg,
- const upb_MiniTableField* field,
- uint64_t value) {
+UPB_API_INLINE void upb_MiniTable_SetUInt64(upb_Message* msg,
+ const upb_MiniTableField* field,
+ uint64_t value) {
UPB_ASSERT(field->descriptortype == kUpb_FieldType_UInt64 ||
field->descriptortype == kUpb_FieldType_Fixed64);
UPB_ASSUME(!upb_IsRepeatedOrMap(field));
@@ -2646,9 +2662,9 @@
_upb_MiniTable_SetNonExtensionField(msg, field, &value);
}
-UPB_INLINE float upb_MiniTable_GetFloat(const upb_Message* msg,
- const upb_MiniTableField* field,
- float default_val) {
+UPB_API_INLINE float upb_MiniTable_GetFloat(const upb_Message* msg,
+ const upb_MiniTableField* field,
+ float default_val) {
UPB_ASSERT(field->descriptortype == kUpb_FieldType_Float);
UPB_ASSUME(!upb_IsRepeatedOrMap(field));
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_4Byte);
@@ -2657,18 +2673,18 @@
return ret;
}
-UPB_INLINE void upb_MiniTable_SetFloat(upb_Message* msg,
- const upb_MiniTableField* field,
- float value) {
+UPB_API_INLINE void upb_MiniTable_SetFloat(upb_Message* msg,
+ const upb_MiniTableField* field,
+ float value) {
UPB_ASSERT(field->descriptortype == kUpb_FieldType_Float);
UPB_ASSUME(!upb_IsRepeatedOrMap(field));
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_4Byte);
_upb_MiniTable_SetNonExtensionField(msg, field, &value);
}
-UPB_INLINE double upb_MiniTable_GetDouble(const upb_Message* msg,
- const upb_MiniTableField* field,
- double default_val) {
+UPB_API_INLINE double upb_MiniTable_GetDouble(const upb_Message* msg,
+ const upb_MiniTableField* field,
+ double default_val) {
UPB_ASSERT(field->descriptortype == kUpb_FieldType_Double);
UPB_ASSUME(!upb_IsRepeatedOrMap(field));
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_8Byte);
@@ -2677,16 +2693,16 @@
return ret;
}
-UPB_INLINE void upb_MiniTable_SetDouble(upb_Message* msg,
- const upb_MiniTableField* field,
- double value) {
+UPB_API_INLINE void upb_MiniTable_SetDouble(upb_Message* msg,
+ const upb_MiniTableField* field,
+ double value) {
UPB_ASSERT(field->descriptortype == kUpb_FieldType_Double);
UPB_ASSUME(!upb_IsRepeatedOrMap(field));
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_8Byte);
_upb_MiniTable_SetNonExtensionField(msg, field, &value);
}
-UPB_INLINE upb_StringView
+UPB_API_INLINE upb_StringView
upb_MiniTable_GetString(const upb_Message* msg, const upb_MiniTableField* field,
upb_StringView def_val) {
UPB_ASSERT(field->descriptortype == kUpb_FieldType_Bytes ||
@@ -2698,9 +2714,9 @@
return ret;
}
-UPB_INLINE void upb_MiniTable_SetString(upb_Message* msg,
- const upb_MiniTableField* field,
- upb_StringView value) {
+UPB_API_INLINE void upb_MiniTable_SetString(upb_Message* msg,
+ const upb_MiniTableField* field,
+ upb_StringView value) {
UPB_ASSERT(field->descriptortype == kUpb_FieldType_Bytes ||
field->descriptortype == kUpb_FieldType_String);
UPB_ASSUME(!upb_IsRepeatedOrMap(field));
@@ -2708,7 +2724,7 @@
_upb_MiniTable_SetNonExtensionField(msg, field, &value);
}
-UPB_INLINE const upb_Message* upb_MiniTable_GetMessage(
+UPB_API_INLINE const upb_Message* upb_MiniTable_GetMessage(
const upb_Message* msg, const upb_MiniTableField* field,
upb_Message* default_val) {
UPB_ASSERT(field->descriptortype == kUpb_FieldType_Message ||
@@ -2721,10 +2737,10 @@
return ret;
}
-UPB_INLINE void upb_MiniTable_SetMessage(upb_Message* msg,
- const upb_MiniTable* mini_table,
- const upb_MiniTableField* field,
- upb_Message* sub_message) {
+UPB_API_INLINE void upb_MiniTable_SetMessage(upb_Message* msg,
+ const upb_MiniTable* mini_table,
+ const upb_MiniTableField* field,
+ upb_Message* sub_message) {
UPB_ASSERT(field->descriptortype == kUpb_FieldType_Message ||
field->descriptortype == kUpb_FieldType_Group);
UPB_ASSUME(!upb_IsRepeatedOrMap(field));
@@ -2734,7 +2750,7 @@
_upb_MiniTable_SetNonExtensionField(msg, field, &sub_message);
}
-UPB_INLINE upb_Message* upb_MiniTable_GetMutableMessage(
+UPB_API_INLINE upb_Message* upb_MiniTable_GetMutableMessage(
upb_Message* msg, const upb_MiniTable* mini_table,
const upb_MiniTableField* field, upb_Arena* arena) {
UPB_ASSERT(field->descriptortype == kUpb_FieldType_Message ||
@@ -2751,7 +2767,7 @@
return sub_message;
}
-UPB_INLINE const upb_Array* upb_MiniTable_GetArray(
+UPB_API_INLINE const upb_Array* upb_MiniTable_GetArray(
const upb_Message* msg, const upb_MiniTableField* field) {
const upb_Array* ret;
const upb_Array* default_val = NULL;
@@ -2759,7 +2775,7 @@
return ret;
}
-UPB_INLINE upb_Array* upb_MiniTable_GetMutableArray(
+UPB_API_INLINE upb_Array* upb_MiniTable_GetMutableArray(
upb_Message* msg, const upb_MiniTableField* field) {
return (upb_Array*)upb_MiniTable_GetArray(msg, field);
}
@@ -7179,6 +7195,7 @@
const upb_OneofDef* upb_FieldDef_ContainingOneof(const upb_FieldDef* f);
const upb_MessageDef* upb_FieldDef_ContainingType(const upb_FieldDef* f);
upb_CType upb_FieldDef_CType(const upb_FieldDef* f);
+upb_MessageValue upb_FieldDef_Default(const upb_FieldDef* f);
const upb_EnumDef* upb_FieldDef_EnumSubDef(const upb_FieldDef* f);
const upb_MessageDef* upb_FieldDef_ExtensionScope(const upb_FieldDef* f);
const upb_FileDef* upb_FieldDef_File(const upb_FieldDef* f);
@@ -7611,62 +7628,87 @@
extern "C" {
#endif
-upb_MessageValue upb_FieldDef_Default(const upb_FieldDef* f);
-
-/* Returns the value associated with this field. */
-upb_MessageValue upb_Message_Get(const upb_Message* msg, const upb_FieldDef* f);
-
-/* Returns a mutable pointer to a map, array, or submessage value. If the given
- * arena is non-NULL this will construct a new object if it was not previously
- * present. May not be called for primitive fields. */
+// Returns a mutable pointer to a map, array, or submessage value. If the given
+// arena is non-NULL this will construct a new object if it was not previously
+// present. May not be called for primitive fields.
upb_MutableMessageValue upb_Message_Mutable(upb_Message* msg,
const upb_FieldDef* f,
upb_Arena* a);
-/* May only be called for fields where upb_FieldDef_HasPresence(f) == true. */
-bool upb_Message_Has(const upb_Message* msg, const upb_FieldDef* f);
-
-/* Returns the field that is set in the oneof, or NULL if none are set. */
+// Returns the field that is set in the oneof, or NULL if none are set.
const upb_FieldDef* upb_Message_WhichOneof(const upb_Message* msg,
const upb_OneofDef* o);
-/* Sets the given field to the given value. For a msg/array/map/string, the
- * caller must ensure that the target data outlives |msg| (by living either in
- * the same arena or a different arena that outlives it).
- *
- * Returns false if allocation fails. */
-bool upb_Message_Set(upb_Message* msg, const upb_FieldDef* f,
- upb_MessageValue val, upb_Arena* a);
+// Clear all data and unknown fields.
+void upb_Message_ClearByDef(upb_Message* msg, const upb_MessageDef* m);
-/* Clears any field presence and sets the value back to its default. */
-void upb_Message_ClearField(upb_Message* msg, const upb_FieldDef* f);
+// Clears any field presence and sets the value back to its default.
+void upb_Message_ClearFieldByDef(upb_Message* msg, const upb_FieldDef* f);
-/* Clear all data and unknown fields. */
-void upb_Message_Clear(upb_Message* msg, const upb_MessageDef* m);
+// May only be called for fields where upb_FieldDef_HasPresence(f) == true.
+bool upb_Message_HasFieldByDef(const upb_Message* msg, const upb_FieldDef* f);
-/* Iterate over present fields.
- *
- * size_t iter = kUpb_Message_Begin;
- * const upb_FieldDef *f;
- * upb_MessageValue val;
- * while (upb_Message_Next(msg, m, ext_pool, &f, &val, &iter)) {
- * process_field(f, val);
- * }
- *
- * If ext_pool is NULL, no extensions will be returned. If the given symtab
- * returns extensions that don't match what is in this message, those extensions
- * will be skipped.
- */
+// Returns the value in the message associated with this field def.
+upb_MessageValue upb_Message_GetFieldByDef(const upb_Message* msg,
+ const upb_FieldDef* f);
+
+// Sets the given field to the given value. For a msg/array/map/string, the
+// caller must ensure that the target data outlives |msg| (by living either in
+// the same arena or a different arena that outlives it).
+//
+// Returns false if allocation fails.
+bool upb_Message_SetFieldByDef(upb_Message* msg, const upb_FieldDef* f,
+ upb_MessageValue val, upb_Arena* a);
+
+// Iterate over present fields.
+//
+// size_t iter = kUpb_Message_Begin;
+// const upb_FieldDef *f;
+// upb_MessageValue val;
+// while (upb_Message_Next(msg, m, ext_pool, &f, &val, &iter)) {
+// process_field(f, val);
+// }
+//
+// If ext_pool is NULL, no extensions will be returned. If the given symtab
+// returns extensions that don't match what is in this message, those extensions
+// will be skipped.
#define kUpb_Message_Begin -1
+
bool upb_Message_Next(const upb_Message* msg, const upb_MessageDef* m,
const upb_DefPool* ext_pool, const upb_FieldDef** f,
upb_MessageValue* val, size_t* iter);
-/* Clears all unknown field data from this message and all submessages. */
+// Clears all unknown field data from this message and all submessages.
bool upb_Message_DiscardUnknown(upb_Message* msg, const upb_MessageDef* m,
int maxdepth);
+// DEPRECATED FUNCTIONS
+// PHP and Ruby need these until we can version-bump them to the current upb.
+
+UPB_INLINE void upb_Message_Clear(upb_Message* msg, const upb_MessageDef* m) {
+ return upb_Message_ClearByDef(msg, m);
+}
+
+UPB_INLINE void upb_Message_ClearField(upb_Message* msg,
+ const upb_FieldDef* f) {
+ return upb_Message_ClearFieldByDef(msg, f);
+}
+
+UPB_INLINE bool upb_Message_Has(const upb_Message* msg, const upb_FieldDef* f) {
+ return upb_Message_HasFieldByDef(msg, f);
+}
+
+UPB_INLINE upb_MessageValue upb_Message_Get(const upb_Message* msg,
+ const upb_FieldDef* f) {
+ return upb_Message_GetFieldByDef(msg, f);
+}
+
+UPB_INLINE bool upb_Message_Set(upb_Message* msg, const upb_FieldDef* f,
+ upb_MessageValue val, upb_Arena* a) {
+ return upb_Message_SetFieldByDef(msg, f, val, a);
+}
+
#ifdef __cplusplus
} /* extern "C" */
#endif
@@ -7956,9 +7998,9 @@
upb_MiniTablePlatform platform,
upb_Arena* arena, upb_Status* status);
-UPB_INLINE upb_MiniTable* upb_MiniTable_Build(const char* data, size_t len,
- upb_Arena* arena,
- upb_Status* status) {
+UPB_API_INLINE upb_MiniTable* upb_MiniTable_Build(const char* data, size_t len,
+ upb_Arena* arena,
+ upb_Status* status) {
return _upb_MiniTable_Build(data, len, kUpb_MiniTablePlatform_Native, arena,
status);
}
@@ -7969,14 +8011,15 @@
// to link the message field later, at which point it will no longer be treated
// as unknown. However there is no synchronization for this operation, which
// means parallel mutation requires external synchronization.
-void upb_MiniTable_SetSubMessage(upb_MiniTable* table,
- upb_MiniTableField* field,
- const upb_MiniTable* sub);
+UPB_API void upb_MiniTable_SetSubMessage(upb_MiniTable* table,
+ upb_MiniTableField* field,
+ const upb_MiniTable* sub);
// Links an enum field to a MiniTable for that enum. All enum fields must
// be linked prior to parsing.
-void upb_MiniTable_SetSubEnum(upb_MiniTable* table, upb_MiniTableField* field,
- const upb_MiniTableEnum* sub);
+UPB_API void upb_MiniTable_SetSubEnum(upb_MiniTable* table,
+ upb_MiniTableField* field,
+ const upb_MiniTableEnum* sub);
const char* _upb_MiniTableExtension_Build(const char* data, size_t len,
upb_MiniTableExtension* ext,
@@ -7985,16 +8028,16 @@
upb_MiniTablePlatform platform,
upb_Status* status);
-UPB_INLINE const char* upb_MiniTableExtension_Build(
+UPB_API_INLINE const char* upb_MiniTableExtension_Build(
const char* data, size_t len, upb_MiniTableExtension* ext,
const upb_MiniTable* extendee, upb_MiniTableSub sub, upb_Status* status) {
return _upb_MiniTableExtension_Build(data, len, ext, extendee, sub,
kUpb_MiniTablePlatform_Native, status);
}
-upb_MiniTableEnum* upb_MiniTableEnum_Build(const char* data, size_t len,
- upb_Arena* arena,
- upb_Status* status);
+UPB_API upb_MiniTableEnum* upb_MiniTableEnum_Build(const char* data, size_t len,
+ upb_Arena* arena,
+ upb_Status* status);
// Like upb_MiniTable_Build(), but the user provides a buffer of layout data so
// it can be reused from call to call, avoiding repeated realloc()/free().
@@ -8698,7 +8741,7 @@
#ifndef UPB_WIRE_DECODE_INTERNAL_H_
#define UPB_WIRE_DECODE_INTERNAL_H_
-#include "third_party/utf8_range/utf8_range.h"
+#include "utf8_range.h"
// Must be last.
@@ -8912,7 +8955,10 @@
#undef UPB_READ_ONEOF
#undef UPB_WRITE_ONEOF
#undef UPB_MAPTYPE_STRING
+#undef UPB_EXPORT
#undef UPB_INLINE
+#undef UPB_API
+#undef UPB_API_INLINE
#undef UPB_ALIGN_UP
#undef UPB_ALIGN_DOWN
#undef UPB_ALIGN_MALLOC