diff options
40 files changed, 579 insertions, 582 deletions
diff --git a/tests/json/test.upbdefs.c b/tests/json/test.upbdefs.c index d270090..43dd66e 100644 --- a/tests/json/test.upbdefs.c +++ b/tests/json/test.upbdefs.c @@ -6,8 +6,6 @@ * Do not edit -- your changes will be discarded when the file is * regenerated. */ -#include <assert.h> - #include "upb/def.h" #include "upb/structdefs.int.h" diff --git a/tests/json/test.upbdefs.h b/tests/json/test.upbdefs.h index d3c23b3..8476060 100644 --- a/tests/json/test.upbdefs.h +++ b/tests/json/test.upbdefs.h @@ -73,43 +73,43 @@ UPB_INLINE bool upbdefs_upb_test_json_MyEnum_is(const upb_enumdef *e) { /* Functions to get a fielddef from a msgdef reference. */ -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_SubMessage_f_foo(const upb_msgdef *m) { assert(upbdefs_upb_test_json_SubMessage_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_f_key(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_f_value(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_f_key(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_f_value(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_f_key(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_f_value(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_f_key(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_f_value(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_f_key(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_f_value(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringStringEntry_f_key(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapStringStringEntry_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringStringEntry_f_value(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_MapStringStringEntry_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_bool_string(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 22); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_int32_string(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 21); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_string_bool(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 24); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_string_int32(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 23); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_string_msg(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 25); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_string_string(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 20); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_bool(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 7); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_bytes(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 6); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_enum(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 9); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_int32(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_int64(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_msg(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 8); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_string(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 5); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_uint32(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 3); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_uint64(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 4); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_bool(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 17); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_bytes(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 16); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_enum(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 19); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_int32(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 11); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_int64(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 12); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_msg(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 18); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_string(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 15); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_uint32(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 13); } -UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_uint64(const upb_msgdef *m) { assert(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 14); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_SubMessage_f_foo(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_SubMessage_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_f_key(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_f_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_f_key(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_f_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_f_key(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_f_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_f_key(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_f_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_f_key(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_f_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringStringEntry_f_key(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringStringEntry_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_MapStringStringEntry_f_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringStringEntry_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_bool_string(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 22); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_int32_string(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 21); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_string_bool(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 24); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_string_int32(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 23); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_string_msg(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 25); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_map_string_string(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 20); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_bool(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 7); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_bytes(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 6); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_enum(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 9); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_int32(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_int64(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_msg(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 8); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_string(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 5); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_uint32(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 3); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_optional_uint64(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 4); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_bool(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 17); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_bytes(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 16); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_enum(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 19); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_int32(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 11); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_int64(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 12); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_msg(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 18); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_string(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 15); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_uint32(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 13); } +UPB_INLINE const upb_fielddef *upbdefs_upb_test_json_TestMessage_f_repeated_uint64(const upb_msgdef *m) { UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); return upb_msgdef_itof(m, 14); } UPB_END_EXTERN_C @@ -124,7 +124,7 @@ class MyEnum : public ::upb::reffed_ptr<const ::upb::EnumDef> { public: MyEnum(const ::upb::EnumDef* e, const void *ref_donor = NULL) : reffed_ptr(e, ref_donor) { - assert(upbdefs_upb_test_json_MyEnum_is(e)); + UPB_ASSERT(upbdefs_upb_test_json_MyEnum_is(e)); } static MyEnum get() { const ::upb::EnumDef* e = upbdefs_upb_test_json_MyEnum_get(&e); @@ -136,7 +136,7 @@ class SubMessage : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: SubMessage(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_upb_test_json_SubMessage_is(m)); + UPB_ASSERT(upbdefs_upb_test_json_SubMessage_is(m)); } static SubMessage get() { @@ -149,7 +149,7 @@ class TestMessage : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: TestMessage(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_upb_test_json_TestMessage_is(m)); + UPB_ASSERT(upbdefs_upb_test_json_TestMessage_is(m)); } static TestMessage get() { @@ -161,7 +161,7 @@ class TestMessage : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: MapBoolStringEntry(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_is(m)); + UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapBoolStringEntry_is(m)); } static MapBoolStringEntry get() { @@ -174,7 +174,7 @@ class TestMessage : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: MapInt32StringEntry(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_is(m)); + UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapInt32StringEntry_is(m)); } static MapInt32StringEntry get() { @@ -187,7 +187,7 @@ class TestMessage : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: MapStringBoolEntry(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_is(m)); + UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringBoolEntry_is(m)); } static MapStringBoolEntry get() { @@ -200,7 +200,7 @@ class TestMessage : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: MapStringInt32Entry(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_is(m)); + UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringInt32Entry_is(m)); } static MapStringInt32Entry get() { @@ -213,7 +213,7 @@ class TestMessage : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: MapStringMsgEntry(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_is(m)); + UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringMsgEntry_is(m)); } static MapStringMsgEntry get() { @@ -226,7 +226,7 @@ class TestMessage : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: MapStringStringEntry(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_upb_test_json_TestMessage_MapStringStringEntry_is(m)); + UPB_ASSERT(upbdefs_upb_test_json_TestMessage_MapStringStringEntry_is(m)); } static MapStringStringEntry get() { diff --git a/tests/pb/test_decoder.cc b/tests/pb/test_decoder.cc index a01e999..702366a 100644 --- a/tests/pb/test_decoder.cc +++ b/tests/pb/test_decoder.cc @@ -116,11 +116,11 @@ void vappendf(string* str, const char *format, va_list args) { int count = vsnprintf(NULL, 0, format, args); if (count >= 0) { - assert(count < 32768); + UPB_ASSERT(count < 32768); char *buffer = new char[count + 1]; - assert(buffer); + UPB_ASSERT(buffer); count = vsnprintf(buffer, count + 1, format, copy); - assert(count >= 0); + UPB_ASSERT(count >= 0); str->append(buffer, count); delete [] buffer; } diff --git a/tests/test_util.h b/tests/test_util.h index 5d165de..f616c36 100644 --- a/tests/test_util.h +++ b/tests/test_util.h @@ -123,7 +123,7 @@ class VerboseParserEnvironment { skipped_with_null_ = true; } else { buf2 = (char*)malloc(bytes); - assert(buf2); + UPB_ASSERT(buf2); memcpy(buf2, buf_ + ofs_, bytes); } diff --git a/tools/dump_cinit.lua b/tools/dump_cinit.lua index e01e150..6135b03 100644 --- a/tools/dump_cinit.lua +++ b/tools/dump_cinit.lua @@ -407,7 +407,6 @@ local function dump_defs_c(filedef, append) -- Emit forward declarations. emit_file_warning(filedef, append) - append('#include <assert.h>\n\n') append('#include "upb/def.h"\n') append('#include "upb/structdefs.int.h"\n\n') append("static const upb_msgdef %s;\n", linktab:cdecl(upb.DEF_MSG)) @@ -639,7 +638,7 @@ local function print_message(def, map, indent, append) append("%s %s(const ::upb::MessageDef* m, const void *ref_donor = NULL)\n", indent, def:name()) append("%s : reffed_ptr(m, ref_donor) {\n", indent) - append("%s assert(upbdefs_%s_is(m));\n", indent, to_cident(def:full_name())) + append("%s UPB_ASSERT(upbdefs_%s_is(m));\n", indent, to_cident(def:full_name())) append("%s }\n", indent) append("\n") append("%s static %s get() {\n", indent, def:name()) @@ -659,7 +658,7 @@ local function print_enum(def, indent, append) append("%s %s(const ::upb::EnumDef* e, const void *ref_donor = NULL)\n", indent, def:name()) append("%s : reffed_ptr(e, ref_donor) {\n", indent) - append("%s assert(upbdefs_%s_is(e));\n", indent, to_cident(def:full_name())) + append("%s UPB_ASSERT(upbdefs_%s_is(e));\n", indent, to_cident(def:full_name())) append("%s }\n", indent) append("%s static %s get() {\n", indent, def:name()) append("%s const ::upb::EnumDef* e = upbdefs_%s_get(&e);\n", indent, to_cident(def:full_name())) @@ -748,7 +747,7 @@ local function dump_defs_h(file, append, linktab) local msg_cident = to_cident(f:containing_type():full_name()) local field_cident = to_cident(f:name()) append("UPB_INLINE const upb_fielddef *upbdefs_%s_f_%s(const upb_msgdef *m) {" .. - " assert(upbdefs_%s_is(m));" .. + " UPB_ASSERT(upbdefs_%s_is(m));" .. " return upb_msgdef_itof(m, %d); }\n", msg_cident, field_cident, msg_cident, f:number()) end diff --git a/upb/bindings/googlepb/bridge.cc b/upb/bindings/googlepb/bridge.cc index c196140..adba3e7 100644 --- a/upb/bindings/googlepb/bridge.cc +++ b/upb/bindings/googlepb/bridge.cc @@ -18,7 +18,7 @@ #define ASSERT_STATUS(status) do { \ if (!upb_ok(status)) { \ fprintf(stderr, "upb status failure: %s\n", upb_status_errmsg(status)); \ - assert(upb_ok(status)); \ + UPB_ASSERT(upb_ok(status)); \ } \ } while (0) @@ -49,7 +49,7 @@ const goog::Message* TryGetFieldPrototype(const goog::Message& m, const goog::Message* GetFieldPrototype(const goog::Message& m, const goog::FieldDescriptor* f) { const goog::Message* ret = TryGetFieldPrototype(m, f); - assert(ret); + UPB_ASSERT(ret); return ret; } @@ -66,7 +66,7 @@ const EnumDef* DefBuilder::GetEnumDef(const goog::EnumDescriptor* ed) { for (int i = 0; i < ed->value_count(); i++) { const goog::EnumValueDescriptor* val = ed->value(i); bool success = e->AddValue(val->name(), val->number(), &status); - UPB_ASSERT_VAR(success, success); + UPB_ASSERT(success); } e->Freeze(&status); @@ -96,7 +96,7 @@ const MessageDef* DefBuilder::GetMaybeUnfrozenMessageDef( for (size_t i = 0; i < fields.size(); i++) { const goog::FieldDescriptor* proto2_f = fields[i]; - assert(proto2_f); + UPB_ASSERT(proto2_f); md->AddField(NewFieldDef(proto2_f, m), &status); } ASSERT_STATUS(&status); @@ -128,7 +128,7 @@ reffed_ptr<FieldDef> DefBuilder::NewFieldDef(const goog::FieldDescriptor* f, subm = TryGetFieldPrototype(*m, f); if (upb_f->type() == UPB_TYPE_MESSAGE) { - assert(subm); + UPB_ASSERT(subm); } else if (subm) { // Weak field: subm will be weak prototype even though the proto2 // descriptor does not indicate a submessage field. @@ -250,14 +250,14 @@ const Handlers* CodeCache::GetMaybeUnfrozenWriteHandlers( if (!proto2_f) { proto2_f = d->file()->pool()->FindExtensionByNumber(d, upb_f->number()); } - assert(proto2_f); + UPB_ASSERT(proto2_f); bool ok = WriteHandlers::AddFieldHandler(m, proto2_f, h); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); if (upb_f->type() == UPB_TYPE_MESSAGE) { const goog::Message* prototype = GetFieldPrototype(m, proto2_f); - assert(prototype); + UPB_ASSERT(prototype); const upb::Handlers* sub_handlers = GetMaybeUnfrozenWriteHandlers(upb_f->message_subdef(), *prototype); h->SetSubHandlers(upb_f, sub_handlers); diff --git a/upb/bindings/googlepb/bridge.h b/upb/bindings/googlepb/bridge.h index ec8ac41..ce55dc6 100644 --- a/upb/bindings/googlepb/bridge.h +++ b/upb/bindings/googlepb/bridge.h @@ -128,7 +128,7 @@ class DefBuilder { template <class T> T* AddToCache(const void *proto2_descriptor, reffed_ptr<T> def) { - assert(def_cache_.find(proto2_descriptor) == def_cache_.end()); + UPB_ASSERT(def_cache_.find(proto2_descriptor) == def_cache_.end()); def_cache_[proto2_descriptor] = def; return def.get(); // Continued lifetime is guaranteed by cache. } @@ -207,7 +207,7 @@ class CodeCache { const MessageDef* md, const ::google::protobuf::Message& m); Handlers* AddToCache(const MessageDef* md, reffed_ptr<Handlers> handlers) { - assert(handlers_cache_.find(md) == handlers_cache_.end()); + UPB_ASSERT(handlers_cache_.find(md) == handlers_cache_.end()); handlers_cache_[md] = handlers; return handlers.get(); // Continue lifetime is guaranteed by the cache. } diff --git a/upb/bindings/googlepb/proto1.cc b/upb/bindings/googlepb/proto1.cc index fa51f79..c85bfca 100644 --- a/upb/bindings/googlepb/proto1.cc +++ b/upb/bindings/googlepb/proto1.cc @@ -35,7 +35,7 @@ namespace proto2 { class Arena; } #include "upb/sink.h" // Unconditionally evaluate, but also assert in debug mode. -#define CHKRET(x) do { bool ok = (x); UPB_UNUSED(ok); assert(ok); } while (0) +#define CHKRET(x) do { bool ok = (x); UPB_ASSERT(ok); } while (0) template <class T> static T* GetPointer(void* message, size_t offset) { return reinterpret_cast<T*>(static_cast<char*>(message) + offset); @@ -58,7 +58,7 @@ class P2R_Handlers { dynamic_cast<const _pi::Proto2Reflection*>(base_r); if (!r) return false; // Extensions don't exist in proto1. - assert(!proto2_f->is_extension()); + UPB_ASSERT(!proto2_f->is_extension()); #define PRIMITIVE(name, type_name) \ case _pi::CREP_REQUIRED_##name: \ @@ -107,7 +107,7 @@ class P2R_Handlers { SetWeakMessageHandlers(proto2_f, m, r, upb_f, h); return true; default: - assert(false); + UPB_ASSERT(false); return false; } } @@ -147,10 +147,10 @@ class P2R_Handlers { } else if (dynamic_cast<const _pi::Proto2Reflection*>(m.GetReflection())) { // Since proto1 has no dynamic message, it must be from the generated // factory. - assert(f->cpp_type() == proto2::FieldDescriptor::CPPTYPE_MESSAGE); + UPB_ASSERT(f->cpp_type() == proto2::FieldDescriptor::CPPTYPE_MESSAGE); ret = proto2::MessageFactory::generated_factory()->GetPrototype( f->message_type()); - assert(ret); + UPB_ASSERT(ret); return ret; } else { return NULL; @@ -175,7 +175,7 @@ class P2R_Handlers { } void SetHasbit(void* message) const { - assert(!is_repeated_); + UPB_ASSERT(!is_repeated_); uint8_t* byte = GetPointer<uint8_t>(message, hasbyte_); *byte |= mask_; } @@ -193,13 +193,13 @@ class P2R_Handlers { upb::Handlers::Type type) { upb::Handlers::Selector selector; bool ok = upb::Handlers::GetSelector(f, type, &selector); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return selector; } static int16_t GetHasbit(const proto2::FieldDescriptor* f, const _pi::Proto2Reflection* r) { - assert(!f->is_repeated()); + UPB_ASSERT(!f->is_repeated()); return (r->layout_->has_bit_offset * 8) + r->GetFieldLayout(f)->has_index; } @@ -303,7 +303,7 @@ class P2R_Handlers { const proto2::FieldDescriptor* proto2_f, const _pi::Proto2Reflection* r, const upb::FieldDef* f, upb::Handlers* h) { // This type is only used for non-repeated string fields. - assert(!f->IsSequence()); + UPB_ASSERT(!f->IsSequence()); CHKRET(h->SetStartStringHandler( f, UpbBind(StartOutOfLineString, new FieldOffset(proto2_f, r)))); CHKRET(h->SetStringHandler(f, UpbMakeHandler(OnStringBuf))); @@ -452,7 +452,7 @@ class P2R_Handlers { // around waiting for reuse, which we will not do. static void Delete(Type* t) { UPB_UNUSED(t); - assert(false); + UPB_ASSERT(false); } #else static ::proto2::Arena* GetArena(Type* t) { @@ -470,7 +470,7 @@ class P2R_Handlers { static void Delete(Type* t, ::proto2::Arena* arena) { UPB_UNUSED(t); UPB_UNUSED(arena); - assert(false); + UPB_ASSERT(false); } static void Merge(const Type& from, Type* to) { to->MergeFrom(from); diff --git a/upb/bindings/googlepb/proto2.cc b/upb/bindings/googlepb/proto2.cc index ee31d34..bfd5ba2 100644 --- a/upb/bindings/googlepb/proto2.cc +++ b/upb/bindings/googlepb/proto2.cc @@ -21,14 +21,14 @@ namespace { template<typename To, typename From> To CheckDownCast(From* f) { - assert(f == NULL || dynamic_cast<To>(f) != NULL); + UPB_ASSERT(f == NULL || dynamic_cast<To>(f) != NULL); return static_cast<To>(f); } } // Unconditionally evaluate, but also assert in debug mode. -#define CHKRET(x) do { bool ok = (x); UPB_UNUSED(ok); assert(ok); } while (0) +#define CHKRET(x) do { bool ok = (x); UPB_ASSERT(ok); } while (0) namespace upb { namespace google_google3 { class GMR_Handlers; } @@ -222,7 +222,7 @@ case goog::FieldDescriptor::cpptype: \ upb::Handlers::Type type) { upb::Handlers::Selector selector; bool ok = upb::Handlers::GetSelector(f, type, &selector); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return selector; } @@ -230,7 +230,7 @@ case goog::FieldDescriptor::cpptype: \ const goog::FieldDescriptor* f, const goog::internal::GeneratedMessageReflection* r) { // proto2 does not store hasbits for repeated fields. - assert(!f->is_repeated()); + UPB_ASSERT(!f->is_repeated()); return (r->has_bits_offset_ * 8) + f->index(); } @@ -238,7 +238,7 @@ case goog::FieldDescriptor::cpptype: \ static size_t GetOneofDiscriminantOffset( const goog::FieldDescriptor* f, const goog::internal::GeneratedMessageReflection* r) { - assert(f->containing_oneof()); + UPB_ASSERT(f->containing_oneof()); return r->oneof_case_offset_ + f->containing_oneof()->index(); } #endif @@ -326,7 +326,7 @@ case goog::FieldDescriptor::cpptype: \ } void SetHasbit(void* m) const { - assert(!is_repeated_); + UPB_ASSERT(!is_repeated_); uint8_t* byte = GetPointer<uint8_t>(m, hasbyte_); *byte |= mask_; } @@ -470,7 +470,7 @@ case goog::FieldDescriptor::cpptype: \ return ONEOF_TYPE_STRINGPIECE; #endif default: - assert(false); + UPB_ASSERT(false); return ONEOF_TYPE_NONE; } } @@ -582,7 +582,7 @@ case goog::FieldDescriptor::cpptype: \ } #ifdef GOOGLE_PROTOBUF_HAS_ONEOF else if (proto2_f->containing_oneof()) { - assert(!proto2_f->is_repeated()); + UPB_ASSERT(!proto2_f->is_repeated()); CHKRET(h->SetValueHandler<T>( f, UpbBindT(SetOneofPrimitive<T>, new OneofFieldHandlerData(proto2_f, r)))); @@ -656,7 +656,7 @@ case goog::FieldDescriptor::cpptype: \ const goog::FieldDescriptor* proto2_f, const goog::internal::GeneratedMessageReflection* r, const upb::FieldDef* f, upb::Handlers* h) { - assert(!proto2_f->is_extension()); + UPB_ASSERT(!proto2_f->is_extension()); scoped_ptr<EnumHandlerData> data(new EnumHandlerData(proto2_f, r, f)); if (f->IsSequence()) { CHKRET(h->SetInt32Handler(f, UpbBind(AppendEnum, data.release()))); @@ -696,7 +696,7 @@ case goog::FieldDescriptor::cpptype: \ const goog::FieldDescriptor* proto2_f, const goog::internal::GeneratedMessageReflection* r, const upb::FieldDef* f, upb::Handlers* h) { - assert(proto2_f->is_extension()); + UPB_ASSERT(proto2_f->is_extension()); scoped_ptr<ExtensionFieldData> data(new ExtensionFieldData(proto2_f, r)); if (f->IsSequence()) { CHKRET( @@ -745,11 +745,11 @@ case goog::FieldDescriptor::cpptype: \ const goog::internal::GeneratedMessageReflection* r, const upb::FieldDef* f, upb::Handlers* h) { - assert(!proto2_f->is_extension()); + UPB_ASSERT(!proto2_f->is_extension()); CHKRET(h->SetStringHandler(f, UpbMakeHandlerT(&OnStringBuf<T>))); #ifdef GOOGLE_PROTOBUF_HAS_ONEOF if (proto2_f->containing_oneof()) { - assert(!f->IsSequence()); + UPB_ASSERT(!f->IsSequence()); CHKRET(h->SetStartStringHandler( f, UpbBindT(&StartOneofString<T>, new OneofFieldHandlerData(proto2_f, r)))); @@ -835,7 +835,7 @@ case goog::FieldDescriptor::cpptype: \ const goog::FieldDescriptor* proto2_f, const goog::internal::GeneratedMessageReflection* r, const upb::FieldDef* f, upb::Handlers* h) { - assert(proto2_f->is_extension()); + UPB_ASSERT(proto2_f->is_extension()); CHKRET(h->SetStringHandler(f, UpbMakeHandlerT(OnStringBuf<T>))); scoped_ptr<ExtensionFieldData> data(new ExtensionFieldData(proto2_f, r)); if (f->IsSequence()) { @@ -908,7 +908,7 @@ case goog::FieldDescriptor::cpptype: \ new SubMessageHandlerData(proto2_f, r, field_prototype)); #ifdef GOOGLE_PROTOBUF_HAS_ONEOF if (proto2_f->containing_oneof()) { - assert(!f->IsSequence()); + UPB_ASSERT(!f->IsSequence()); CHKRET(h->SetStartSubMessageHandler( f, UpbBind(StartOneofSubMessage, new OneofSubMessageHandlerData( proto2_f, r, field_prototype)))); @@ -965,7 +965,7 @@ case goog::FieldDescriptor::cpptype: \ // around waiting for reuse, which we will not do. static void Delete(Type* t) { UPB_UNUSED(t); - assert(false); + UPB_ASSERT(false); } #endif // ifdef GOOGLE_PROTOBUF_HAS_ARENAS @@ -1089,7 +1089,7 @@ case goog::FieldDescriptor::cpptype: \ // "We could speed this up by using CordReader internals." Cord piece(*source_cord); piece.RemovePrefix(handle->object_offset() + (buf - handle->buffer())); - assert(piece.size() >= n); + UPB_ASSERT(piece.size() >= n); piece.RemoveSuffix(piece.size() - n); c->Append(piece); @@ -1102,7 +1102,7 @@ case goog::FieldDescriptor::cpptype: \ const proto2::FieldDescriptor* proto2_f, const proto2::internal::GeneratedMessageReflection* r, const upb::FieldDef* f, upb::Handlers* h) { - assert(!proto2_f->is_extension()); + UPB_ASSERT(!proto2_f->is_extension()); CHKRET(h->SetStringHandler(f, UpbMakeHandler(&OnCordBuf))); if (f->IsSequence()) { SetStartRepeatedField<Cord>(proto2_f, r, f, h); @@ -1139,7 +1139,7 @@ case goog::FieldDescriptor::cpptype: \ const proto2::FieldDescriptor* proto2_f, const proto2::internal::GeneratedMessageReflection* r, const upb::FieldDef* f, upb::Handlers* h) { - assert(!proto2_f->is_extension()); + UPB_ASSERT(!proto2_f->is_extension()); CHKRET(h->SetStringHandler(f, UpbMakeHandler(OnStringPieceBuf))); if (f->IsSequence()) { SetStartRepeatedPtrField<proto2::internal::StringPieceField>(proto2_f, r, @@ -1194,7 +1194,7 @@ case goog::FieldDescriptor::cpptype: \ const proto2::Message& m, const proto2::internal::GeneratedMessageReflection* r, const upb::FieldDef* f, upb::Handlers* h) { - assert(!proto2_f->is_repeated()); + UPB_ASSERT(!proto2_f->is_repeated()); const goog::Message* field_prototype = GetFieldPrototype(m, proto2_f); CHKRET(h->SetStringHandler(f, UpbMakeHandler(OnLazyFieldBuf))); if (proto2_f->is_extension()) { diff --git a/upb/bindings/lua/upb.c b/upb/bindings/lua/upb.c index 4768212..1483676 100644 --- a/upb/bindings/lua/upb.c +++ b/upb/bindings/lua/upb.c @@ -141,7 +141,7 @@ static void *newudata_with_userval(lua_State *L, size_t size, /* Set metatable. */ luaL_getmetatable(L, type); - assert(!lua_isnil(L, -1)); /* Should have been created by luaopen_upb. */ + UPB_ASSERT(!lua_isnil(L, -1)); /* Should have been created by luaopen_upb. */ lua_setmetatable(L, -2); lua_newtable(L); @@ -322,7 +322,7 @@ bool lupb_refcounted_pushwrapper(lua_State *L, const upb_refcounted *obj, /* Lookup our cache in the registry (we don't put our objects in the registry * directly because we need our cache to be a weak table). */ lua_getfield(L, LUA_REGISTRYINDEX, LUPB_OBJCACHE); - assert(!lua_isnil(L, -1)); /* Should have been created by luaopen_upb. */ + UPB_ASSERT(!lua_isnil(L, -1)); /* Should have been created by luaopen_upb. */ lua_pushlightuserdata(L, (void*)obj); lua_rawget(L, -2); /* Stack is now: objcache, cached value. */ @@ -382,7 +382,7 @@ void lupb_refcounted_pushnewrapper(lua_State *L, const upb_refcounted *obj, const char *type, const void *ref_donor) { bool created = lupb_refcounted_pushwrapper(L, obj, type, ref_donor, sizeof(void *)); - UPB_ASSERT_VAR(created, created == true); + UPB_ASSERT(created == true); } static int lupb_refcounted_gc(lua_State *L) { @@ -461,7 +461,7 @@ bool lupb_def_pushwrapper(lua_State *L, const upb_def *def, void lupb_def_pushnewrapper(lua_State *L, const upb_def *def, const void *ref_donor) { bool created = lupb_def_pushwrapper(L, def, ref_donor); - UPB_ASSERT_VAR(created, created == true); + UPB_ASSERT(created == true); } static int lupb_def_type(lua_State *L) { @@ -1310,7 +1310,7 @@ static int lupb_filedefiter_next(lua_State *L) { const upb_def *def; def = upb_filedef_def(f, i); - assert(def); + UPB_ASSERT(def); if (type == UPB_DEF_ANY || upb_def_type(def) == type) { lua_pushinteger(L, i + 1); @@ -1738,7 +1738,7 @@ static lupb_msgdef *lupb_msg_assignoffsets(lua_State *L, int narg) { upb_fielddef *f = upb_msg_iter_field(&i); if (upb_fielddef_type(f) == UPB_TYPE_MESSAGE) { bool created = lupb_def_pushwrapper(L, upb_fielddef_subdef(f), NULL); - UPB_ASSERT_VAR(created, !created); + UPB_ASSERT(!created); lupb_msg_assignoffsets(L, -1); lua_rawseti(L, -2, idx++); /* Append to uservalue. */ } diff --git a/upb/bindings/python/upb.c b/upb/bindings/python/upb.c index 778b821..1646acc 100644 --- a/upb/bindings/python/upb.c +++ b/upb/bindings/python/upb.c @@ -63,7 +63,7 @@ static PyObject *weakref_callback = NULL; static PyObject *PyUpb_StringForPointer(const void *ptr) { PyObject *o = PyString_FromStringAndSize((const char *)&ptr, sizeof(void*)); - assert(o); + UPB_ASSERT(o); return o; } @@ -73,11 +73,11 @@ static PyObject *PyUpb_ObjCacheDeleteCallback(PyObject *self, PyObject *ref) { // remove from the cache. As a result we are forced to keep a second map // mapping weakref->C pointer. PyObject *ptr_str = PyDict_GetItem(reverse_cache, ref); - assert(ptr_str); + UPB_ASSERT(ptr_str); int err = PyDict_DelItem(obj_cache, ptr_str); - assert(!err); + UPB_ASSERT(!err); err = PyDict_DelItem(reverse_cache, ref); - assert(!err); + UPB_ASSERT(!err); return Py_None; } @@ -87,7 +87,7 @@ static PyObject *PyUpb_ObjCacheGet(const void *obj, PyTypeObject *type) { PyObject *ret; if (ref) { ret = PyWeakref_GetObject(ref); - assert(ret != Py_None); + UPB_ASSERT(ret != Py_None); Py_INCREF(ret); } else { PyUpb_ObjWrapper *wrapper = (PyUpb_ObjWrapper*)type->tp_alloc(type, 0); @@ -95,12 +95,12 @@ static PyObject *PyUpb_ObjCacheGet(const void *obj, PyTypeObject *type) { wrapper->weakreflist = NULL; ret = (PyObject*)wrapper; ref = PyWeakref_NewRef(ret, weakref_callback); - assert(PyWeakref_GetObject(ref) == ret); - assert(ref); + UPB_ASSERT(PyWeakref_GetObject(ref) == ret); + UPB_ASSERT(ref); PyDict_SetItem(obj_cache, kv, ref); PyDict_SetItem(reverse_cache, ref, kv); } - assert(ret); + UPB_ASSERT(ret); Py_DECREF(kv); return ret; } diff --git a/upb/bindings/ruby/upb.c b/upb/bindings/ruby/upb.c index ea0fcc8..7598bac 100644 --- a/upb/bindings/ruby/upb.c +++ b/upb/bindings/ruby/upb.c @@ -161,8 +161,8 @@ static void objcache_init() { // Call to uninitialize the cache. Should be done once on process shutdown. static void objcache_uninit(ruby_vm_t *vm) { - assert(objcache_initialized); - assert(upb_inttable_count(&objcache) == 0); + UPB_ASSERT(objcache_initialized); + UPB_ASSERT(upb_inttable_count(&objcache) == 0); objcache_initialized = false; upb_inttable_uninit(&objcache); @@ -171,7 +171,7 @@ static void objcache_uninit(ruby_vm_t *vm) { // Looks up the given object in the cache. If the corresponding Ruby wrapper // object is found, returns it, otherwise creates the wrapper and returns that. static VALUE objcache_getorcreate(const void *obj, createfunc *func) { - assert(objcache_initialized); + UPB_ASSERT(objcache_initialized); upb_value v; if (!upb_inttable_lookupptr(&objcache, obj, &v)) { @@ -184,10 +184,10 @@ static VALUE objcache_getorcreate(const void *obj, createfunc *func) { // Removes the given object from the cache. Should only be called by the code // that is freeing the wrapper object. static void objcache_remove(const void *obj) { - assert(objcache_initialized); + UPB_ASSERT(objcache_initialized); bool removed = upb_inttable_removeptr(&objcache, obj, NULL); - UPB_ASSERT_VAR(removed, removed); + UPB_ASSERT(removed); } /* message layout *************************************************************/ @@ -256,7 +256,7 @@ static size_t rupb_sizeof(const upb_fielddef *f) { default: break; } - assert(false); + UPB_ASSERT(false); return 0; } @@ -656,7 +656,7 @@ static VALUE msg_accessor(int argc, VALUE *argv, VALUE obj) { rupb_Message *msg = msg_get(obj); // method_missing protocol: (method [, arg1, arg2, ...]) - assert(argc >= 1 && SYMBOL_P(argv[0])); + UPB_ASSERT(argc >= 1 && SYMBOL_P(argv[0])); // OPT(haberman): find a better way to get the method name. // This is allocating a new string each time, which should not be necessary. VALUE method = rb_id2str(SYM2ID(argv[0])); @@ -668,7 +668,7 @@ static VALUE msg_accessor(int argc, VALUE *argv, VALUE obj) { // foo.bar = x // // Ruby should guarantee that we have exactly one more argument (x) - assert(argc == 2); + UPB_ASSERT(argc == 2); return msg_setter(msg, method, argv[1]); } else { // Call was: @@ -1011,14 +1011,14 @@ static const upb_handlers *new_fill_handlers(const rupb_MessageDef *rmd, static upb_selector_t getsel(const upb_fielddef *f, upb_handlertype_t type) { upb_selector_t ret; bool ok = upb_handlers_getselector(f, type, &ret); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return ret; } static void putstr(VALUE str, const upb_fielddef *f, upb_sink *sink) { if (str == Qnil) return; - assert(BUILTIN_TYPE(str) == RUBY_T_STRING); + UPB_ASSERT(BUILTIN_TYPE(str) == RUBY_T_STRING); upb_sink subsink; upb_sink_startstr(sink, getsel(f, UPB_HANDLER_STARTSTR), RSTRING_LEN(str), @@ -1042,7 +1042,7 @@ static void putsubmsg(VALUE submsg, const upb_fielddef *f, upb_sink *sink) { static void putary(VALUE ary, const upb_fielddef *f, upb_sink *sink) { if (ary == Qnil) return; - assert(BUILTIN_TYPE(ary) == RUBY_T_ARRAY); + UPB_ASSERT(BUILTIN_TYPE(ary) == RUBY_T_ARRAY); upb_sink subsink; upb_sink_startseq(sink, getsel(f, UPB_HANDLER_STARTSEQ), &subsink); diff --git a/upb/bindings/stdc/io.c b/upb/bindings/stdc/io.c index a95eb48..fe82014 100644 --- a/upb/bindings/stdc/io.c +++ b/upb/bindings/stdc/io.c @@ -36,7 +36,7 @@ static upb_stdio_buf *upb_stdio_rotatebufs(upb_stdio *s) { reuse[num_reused++] = buf; } } - assert(num_reused + num_inuse == s->nbuf); + UPB_ASSERT(num_reused + num_inuse == s->nbuf); memcpy(s->bufs + num_inuse, reuse, num_reused * sizeof(upb_stdio_buf*)); if (num_reused == 0) { ++s->nbuf; @@ -78,7 +78,7 @@ retry: return upb_errno_is_wouldblock(errno) ? UPB_BYTE_WOULDBLOCK : UPB_BYTE_ERROR; } - assert(false); + UPB_ASSERT(false); } return UPB_BYTE_OK; } @@ -104,7 +104,7 @@ const char *upb_def_name(const upb_def *d) { } bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s) { - assert(!upb_def_isfrozen(def)); + UPB_ASSERT(!upb_def_isfrozen(def)); if (!upb_isident(fullname, strlen(fullname), true, s)) { return false; } @@ -133,7 +133,7 @@ upb_def *upb_def_dup(const upb_def *def, const void *o) { case UPB_DEF_ENUM: return upb_enumdef_upcast_mutable( upb_enumdef_dup(upb_downcast_enumdef(def), o)); - default: assert(false); return NULL; + default: UPB_ASSERT(false); return NULL; } } @@ -204,14 +204,14 @@ static bool upb_validate_field(upb_fielddef *f, upb_status *s) { bool has_default_number = upb_fielddef_enumhasdefaultint32(f); /* Previously verified by upb_validate_enumdef(). */ - assert(upb_enumdef_numvals(upb_fielddef_enumsubdef(f)) > 0); + UPB_ASSERT(upb_enumdef_numvals(upb_fielddef_enumsubdef(f)) > 0); /* We've already validated that we have an associated enumdef and that it * has at least one member, so at least one of these should be true. * Because if the user didn't set anything, we'll pick up the enum's * default, but if the user *did* set something we should at least pick up * the one they set (int32 or string). */ - assert(has_default_name || has_default_number); + UPB_ASSERT(has_default_name || has_default_number); if (!has_default_name) { upb_status_seterrf(s, @@ -267,7 +267,7 @@ static bool upb_validate_enumdef(const upb_enumdef *e, upb_status *s) { uint32_t field_rank(const upb_fielddef *f) { uint32_t ret = upb_fielddef_number(f); const uint32_t high_bit = 1 << 30; - assert(ret < high_bit); + UPB_ASSERT(ret < high_bit); if (!upb_fielddef_issubmsg(f)) ret |= high_bit; return ret; @@ -305,7 +305,7 @@ static bool assign_msg_indices(upb_msgdef *m, upb_status *s) { !upb_msg_field_done(&j); upb_msg_field_next(&j), i++) { upb_fielddef *f = upb_msg_iter_field(&j); - assert(f->msg.def == m); + UPB_ASSERT(f->msg.def == m); if (!upb_validate_field(f, s)) { upb_gfree(fields); return false; @@ -418,7 +418,7 @@ err: upb_def *def = defs[i]; def->came_from_user = false; } - assert(!(s && upb_ok(s))); + UPB_ASSERT(!(s && upb_ok(s))); return false; } @@ -537,19 +537,19 @@ bool upb_enumdef_addval(upb_enumdef *e, const char *name, int32_t num, if (upb_enumdef_numvals(e) == 1) { bool ok = upb_enumdef_setdefault(e, num, NULL); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); } return true; } int32_t upb_enumdef_default(const upb_enumdef *e) { - assert(upb_enumdef_iton(e, e->defaultval)); + UPB_ASSERT(upb_enumdef_iton(e, e->defaultval)); return e->defaultval; } bool upb_enumdef_setdefault(upb_enumdef *e, int32_t val, upb_status *s) { - assert(!upb_enumdef_isfrozen(e)); + UPB_ASSERT(!upb_enumdef_isfrozen(e)); if (!upb_enumdef_iton(e, val)) { upb_status_seterrf(s, "number '%d' is not in the enum.", val); return false; @@ -633,7 +633,7 @@ static void freefield(upb_refcounted *r) { static const char *enumdefaultstr(const upb_fielddef *f) { const upb_enumdef *e; - assert(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); + UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); e = upb_fielddef_enumsubdef(f); if (f->default_is_string && f->defaultval.bytes) { /* Default was explicitly set as a string. */ @@ -650,7 +650,7 @@ static const char *enumdefaultstr(const upb_fielddef *f) { /* Default is completely unset; pull enumdef default. */ if (upb_enumdef_numvals(e) > 0) { const char *name = upb_enumdef_iton(e, upb_enumdef_default(e)); - assert(name); + UPB_ASSERT(name); return name; } } @@ -660,7 +660,7 @@ static const char *enumdefaultstr(const upb_fielddef *f) { static bool enumdefaultint32(const upb_fielddef *f, int32_t *val) { const upb_enumdef *e; - assert(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); + UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); e = upb_fielddef_enumsubdef(f); if (!f->default_is_string) { /* Default was explicitly set as an integer. */ @@ -761,7 +761,7 @@ bool upb_fielddef_typeisset(const upb_fielddef *f) { } upb_fieldtype_t upb_fielddef_type(const upb_fielddef *f) { - assert(f->type_is_set_); + UPB_ASSERT(f->type_is_set_); return f->type_; } @@ -863,7 +863,7 @@ static void release_containingtype(upb_fielddef *f) { bool upb_fielddef_setcontainingtypename(upb_fielddef *f, const char *name, upb_status *s) { char *name_copy; - assert(!upb_fielddef_isfrozen(f)); + UPB_ASSERT(!upb_fielddef_isfrozen(f)); if (upb_fielddef_containingtype(f)) { upb_status_seterrmsg(s, "field has already been added to a message."); return false; @@ -894,7 +894,7 @@ bool upb_fielddef_setname(upb_fielddef *f, const char *name, upb_status *s) { static void chkdefaulttype(const upb_fielddef *f, upb_fieldtype_t type) { UPB_UNUSED(f); UPB_UNUSED(type); - assert(f->type_is_set_ && upb_fielddef_type(f) == type); + UPB_ASSERT(f->type_is_set_ && upb_fielddef_type(f) == type); } int64_t upb_fielddef_defaultint64(const upb_fielddef *f) { @@ -906,7 +906,7 @@ int32_t upb_fielddef_defaultint32(const upb_fielddef *f) { if (f->type_is_set_ && upb_fielddef_type(f) == UPB_TYPE_ENUM) { int32_t val; bool ok = enumdefaultint32(f, &val); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return val; } else { chkdefaulttype(f, UPB_TYPE_INT32); @@ -940,14 +940,14 @@ double upb_fielddef_defaultdouble(const upb_fielddef *f) { } const char *upb_fielddef_defaultstr(const upb_fielddef *f, size_t *len) { - assert(f->type_is_set_); - assert(upb_fielddef_type(f) == UPB_TYPE_STRING || + UPB_ASSERT(f->type_is_set_); + UPB_ASSERT(upb_fielddef_type(f) == UPB_TYPE_STRING || upb_fielddef_type(f) == UPB_TYPE_BYTES || upb_fielddef_type(f) == UPB_TYPE_ENUM); if (upb_fielddef_type(f) == UPB_TYPE_ENUM) { const char *ret = enumdefaultstr(f); - assert(ret); + UPB_ASSERT(ret); /* Enum defaults can't have embedded NULLs. */ if (len) *len = strlen(ret); return ret; @@ -1029,8 +1029,8 @@ bool upb_fielddef_setnumber(upb_fielddef *f, uint32_t number, upb_status *s) { } void upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type) { - assert(!upb_fielddef_isfrozen(f)); - assert(upb_fielddef_checktype(type)); + UPB_ASSERT(!upb_fielddef_isfrozen(f)); + UPB_ASSERT(upb_fielddef_checktype(type)); upb_fielddef_uninit_default(f); f->type_ = type; f->type_is_set_ = true; @@ -1038,7 +1038,7 @@ void upb_fielddef_settype(upb_fielddef *f, upb_fieldtype_t type) { } void upb_fielddef_setdescriptortype(upb_fielddef *f, int type) { - assert(!upb_fielddef_isfrozen(f)); + UPB_ASSERT(!upb_fielddef_isfrozen(f)); switch (type) { case UPB_DESCRIPTOR_TYPE_DOUBLE: upb_fielddef_settype(f, UPB_TYPE_DOUBLE); @@ -1080,7 +1080,7 @@ void upb_fielddef_setdescriptortype(upb_fielddef *f, int type) { case UPB_DESCRIPTOR_TYPE_ENUM: upb_fielddef_settype(f, UPB_TYPE_ENUM); break; - default: assert(false); + default: UPB_ASSERT(false); } if (type == UPB_DESCRIPTOR_TYPE_FIXED64 || @@ -1138,34 +1138,34 @@ upb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f) { } void upb_fielddef_setisextension(upb_fielddef *f, bool is_extension) { - assert(!upb_fielddef_isfrozen(f)); + UPB_ASSERT(!upb_fielddef_isfrozen(f)); f->is_extension_ = is_extension; } void upb_fielddef_setlazy(upb_fielddef *f, bool lazy) { - assert(!upb_fielddef_isfrozen(f)); + UPB_ASSERT(!upb_fielddef_isfrozen(f)); f->lazy_ = lazy; } void upb_fielddef_setpacked(upb_fielddef *f, bool packed) { - assert(!upb_fielddef_isfrozen(f)); + UPB_ASSERT(!upb_fielddef_isfrozen(f)); f->packed_ = packed; } void upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label) { - assert(!upb_fielddef_isfrozen(f)); - assert(upb_fielddef_checklabel(label)); + UPB_ASSERT(!upb_fielddef_isfrozen(f)); + UPB_ASSERT(upb_fielddef_checklabel(label)); f->label_ = label; } void upb_fielddef_setintfmt(upb_fielddef *f, upb_intfmt_t fmt) { - assert(!upb_fielddef_isfrozen(f)); - assert(upb_fielddef_checkintfmt(fmt)); + UPB_ASSERT(!upb_fielddef_isfrozen(f)); + UPB_ASSERT(upb_fielddef_checkintfmt(fmt)); f->intfmt = fmt; } void upb_fielddef_settagdelim(upb_fielddef *f, bool tag_delim) { - assert(!upb_fielddef_isfrozen(f)); + UPB_ASSERT(!upb_fielddef_isfrozen(f)); f->tagdelim = tag_delim; f->tagdelim = tag_delim; } @@ -1173,12 +1173,12 @@ void upb_fielddef_settagdelim(upb_fielddef *f, bool tag_delim) { static bool checksetdefault(upb_fielddef *f, upb_fieldtype_t type) { if (!f->type_is_set_ || upb_fielddef_isfrozen(f) || upb_fielddef_type(f) != type) { - assert(false); + UPB_ASSERT(false); return false; } if (f->default_is_string) { str_t *s = f->defaultval.bytes; - assert(s || type == UPB_TYPE_ENUM); + UPB_ASSERT(s || type == UPB_TYPE_ENUM); if (s) freestr(s); } f->default_is_string = false; @@ -1226,16 +1226,16 @@ void upb_fielddef_setdefaultdouble(upb_fielddef *f, double value) { bool upb_fielddef_setdefaultstr(upb_fielddef *f, const void *str, size_t len, upb_status *s) { str_t *str2; - assert(upb_fielddef_isstring(f) || f->type_ == UPB_TYPE_ENUM); + UPB_ASSERT(upb_fielddef_isstring(f) || f->type_ == UPB_TYPE_ENUM); if (f->type_ == UPB_TYPE_ENUM && !upb_isident(str, len, false, s)) return false; if (f->default_is_string) { str_t *s = f->defaultval.bytes; - assert(s || f->type_ == UPB_TYPE_ENUM); + UPB_ASSERT(s || f->type_ == UPB_TYPE_ENUM); if (s) freestr(s); } else { - assert(f->type_ == UPB_TYPE_ENUM); + UPB_ASSERT(f->type_ == UPB_TYPE_ENUM); } str2 = newstr(str, len); @@ -1246,18 +1246,18 @@ bool upb_fielddef_setdefaultstr(upb_fielddef *f, const void *str, size_t len, void upb_fielddef_setdefaultcstr(upb_fielddef *f, const char *str, upb_status *s) { - assert(f->type_is_set_); + UPB_ASSERT(f->type_is_set_); upb_fielddef_setdefaultstr(f, str, str ? strlen(str) : 0, s); } bool upb_fielddef_enumhasdefaultint32(const upb_fielddef *f) { int32_t val; - assert(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); + UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); return enumdefaultint32(f, &val); } bool upb_fielddef_enumhasdefaultstr(const upb_fielddef *f) { - assert(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); + UPB_ASSERT(f->type_is_set_ && f->type_ == UPB_TYPE_ENUM); return enumdefaultstr(f) != NULL; } @@ -1287,8 +1287,8 @@ static void release_subdef(upb_fielddef *f) { bool upb_fielddef_setsubdef(upb_fielddef *f, const upb_def *subdef, upb_status *s) { - assert(!upb_fielddef_isfrozen(f)); - assert(upb_fielddef_hassubdef(f)); + UPB_ASSERT(!upb_fielddef_isfrozen(f)); + UPB_ASSERT(upb_fielddef_hassubdef(f)); if (subdef && !upb_subdef_typecheck(f, subdef, s)) return false; release_subdef(f); f->sub.def = subdef; @@ -1310,7 +1310,7 @@ bool upb_fielddef_setenumsubdef(upb_fielddef *f, const upb_enumdef *subdef, bool upb_fielddef_setsubdefname(upb_fielddef *f, const char *name, upb_status *s) { char *name_copy; - assert(!upb_fielddef_isfrozen(f)); + UPB_ASSERT(!upb_fielddef_isfrozen(f)); if (!upb_fielddef_hassubdef(f)) { upb_status_seterrmsg(s, "field type does not accept a subdef"); return false; @@ -1443,7 +1443,7 @@ upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner) { NULL); newm->map_entry = m->map_entry; newm->syntax = m->syntax; - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); for(upb_msg_field_begin(&i, m); !upb_msg_field_done(&i); upb_msg_field_next(&i)) { @@ -1644,7 +1644,7 @@ bool upb_msgdef_lookupname(const upb_msgdef *m, const char *name, size_t len, *o = upb_trygetoneof(upb_value_getptr(val)); *f = upb_trygetfield(upb_value_getptr(val)); - assert((*o != NULL) ^ (*f != NULL)); /* Exactly one of the two should be set. */ + UPB_ASSERT((*o != NULL) ^ (*f != NULL)); /* Exactly one of the two should be set. */ return true; } @@ -1659,7 +1659,7 @@ int upb_msgdef_numoneofs(const upb_msgdef *m) { } void upb_msgdef_setmapentry(upb_msgdef *m, bool map_entry) { - assert(!upb_msgdef_isfrozen(m)); + UPB_ASSERT(!upb_msgdef_isfrozen(m)); m->map_entry = map_entry; } @@ -1772,7 +1772,7 @@ upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner) { upb_oneofdef *newo = upb_oneofdef_new(owner); if (!newo) return NULL; ok = upb_oneofdef_setname(newo, upb_oneofdef_name(o), NULL); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); for (upb_oneof_begin(&i, o); !upb_oneof_done(&i); upb_oneof_next(&i)) { upb_fielddef *f = upb_fielddef_dup(upb_oneof_iter_field(&i), &f); if (!f || !upb_oneofdef_addfield(newo, f, &f, NULL)) { @@ -1786,7 +1786,7 @@ upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner) { const char *upb_oneofdef_name(const upb_oneofdef *o) { return o->name; } bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s) { - assert(!upb_oneofdef_isfrozen(o)); + UPB_ASSERT(!upb_oneofdef_isfrozen(o)); if (upb_oneofdef_containingtype(o)) { upb_status_seterrmsg(s, "oneof already added to a message"); return false; @@ -1818,8 +1818,8 @@ int upb_oneofdef_numfields(const upb_oneofdef *o) { bool upb_oneofdef_addfield(upb_oneofdef *o, upb_fielddef *f, const void *ref_donor, upb_status *s) { - assert(!upb_oneofdef_isfrozen(o)); - assert(!o->parent || !upb_msgdef_isfrozen(o->parent)); + UPB_ASSERT(!upb_oneofdef_isfrozen(o)); + UPB_ASSERT(!o->parent || !upb_msgdef_isfrozen(o->parent)); /* This method is idempotent. Check if |f| is already part of this oneofdef * and return immediately if so. */ @@ -186,7 +186,7 @@ UPB_END_EXTERN_C return (upb_##lower *)def; \ } \ UPB_INLINE const upb_##lower *upb_downcast_##lower(const upb_def *def) { \ - assert(upb_def_type(def) == UPB_DEF_##upper); \ + UPB_ASSERT(upb_def_type(def) == UPB_DEF_##upper); \ return (const upb_##lower *)def; \ } \ UPB_INLINE upb_##lower *upb_dyncast_##lower##_mutable(upb_def *def) { \ @@ -1420,7 +1420,7 @@ UPB_END_EXTERN_C #ifdef __cplusplus UPB_INLINE const char* upb_safecstr(const std::string& str) { - assert(str.size() == std::strlen(str.c_str())); + UPB_ASSERT(str.size() == std::strlen(str.c_str())); return str.c_str(); } @@ -1459,19 +1459,19 @@ inline bool FieldDef::CheckIntegerFormat(int32_t val) { return upb_fielddef_checkintfmt(val); } inline FieldDef::Type FieldDef::ConvertType(int32_t val) { - assert(CheckType(val)); + UPB_ASSERT(CheckType(val)); return static_cast<FieldDef::Type>(val); } inline FieldDef::Label FieldDef::ConvertLabel(int32_t val) { - assert(CheckLabel(val)); + UPB_ASSERT(CheckLabel(val)); return static_cast<FieldDef::Label>(val); } inline FieldDef::DescriptorType FieldDef::ConvertDescriptorType(int32_t val) { - assert(CheckDescriptorType(val)); + UPB_ASSERT(CheckDescriptorType(val)); return static_cast<FieldDef::DescriptorType>(val); } inline FieldDef::IntegerFormat FieldDef::ConvertIntegerFormat(int32_t val) { - assert(CheckIntegerFormat(val)); + UPB_ASSERT(CheckIntegerFormat(val)); return static_cast<FieldDef::IntegerFormat>(val); } diff --git a/upb/descriptor/descriptor.upbdefs.c b/upb/descriptor/descriptor.upbdefs.c index d27adf4..da11d72 100644 --- a/upb/descriptor/descriptor.upbdefs.c +++ b/upb/descriptor/descriptor.upbdefs.c @@ -6,8 +6,6 @@ * Do not edit -- your changes will be discarded when the file is * regenerated. */ -#include <assert.h> - #include "upb/def.h" #include "upb/structdefs.int.h" diff --git a/upb/descriptor/descriptor.upbdefs.h b/upb/descriptor/descriptor.upbdefs.h index d8a22ca..274c486 100644 --- a/upb/descriptor/descriptor.upbdefs.h +++ b/upb/descriptor/descriptor.upbdefs.h @@ -184,111 +184,111 @@ UPB_INLINE bool upbdefs_google_protobuf_FileOptions_OptimizeMode_is(const upb_en /* Functions to get a fielddef from a msgdef reference. */ -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_end(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_start(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_end(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_start(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_enum_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 4); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 6); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension_range(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 5); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_field(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_nested_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_oneof_decl(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 8); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 7); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 10); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_range(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 9); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_allow_alias(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 3); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 999); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_number(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 999); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_default_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_extendee(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_json_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_label(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_number(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_oneof_index(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_ctype(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 3); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_jstype(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 6); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_lazy(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 5); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_packed(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 999); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_weak(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 10); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_dependency(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_enum_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_extension(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_message_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_public_dependency(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_service(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_source_code_info(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_syntax(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 12); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_weak_dependency(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 11); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorSet_f_file(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorSet_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_enable_arenas(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 31); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_generic_services(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 16); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_csharp_namespace(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 37); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 23); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_go_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 11); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generate_equals_and_hash(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 20); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generic_services(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 17); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_multiple_files(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 10); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_outer_classname(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 8); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_string_check_utf8(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 27); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_javanano_use_deprecated_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 38); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_objc_class_prefix(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 36); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_optimize_for(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 9); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_py_generic_services(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 18); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 999); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 3); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_map_entry(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 7); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_message_set_wire_format(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_no_standard_descriptor_accessor(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 999); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_client_streaming(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_input_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_output_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_server_streaming(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 33); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 999); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_OneofDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_OneofDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_method(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 33); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 999); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_comments(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 3); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_detached_comments(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 6); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_path(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_span(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_trailing_comments(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 4); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_f_location(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_is_extension(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_name_part(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 1); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_aggregate_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 8); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_double_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 6); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_identifier_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 3); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 2); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_negative_int_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 5); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_positive_int_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 4); } -UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_string_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 7); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_end(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_start(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_end(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_start(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_enum_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 4); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 6); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension_range(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 5); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_field(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_nested_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_oneof_decl(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 8); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 7); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 10); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_range(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 9); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_allow_alias(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 3); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 999); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_number(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 999); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_default_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_extendee(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_json_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_label(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_number(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_oneof_index(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_ctype(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 3); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_jstype(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 6); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_lazy(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 5); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_packed(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 999); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_weak(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 10); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_dependency(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_enum_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_extension(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_message_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_public_dependency(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_service(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_source_code_info(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_syntax(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 12); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_weak_dependency(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 11); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorSet_f_file(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorSet_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_enable_arenas(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 31); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_generic_services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 16); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_csharp_namespace(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 37); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 23); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_go_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 11); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generate_equals_and_hash(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 20); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generic_services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 17); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_multiple_files(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 10); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_outer_classname(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 8); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_string_check_utf8(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 27); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_javanano_use_deprecated_package(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 38); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_objc_class_prefix(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 36); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_optimize_for(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 9); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_py_generic_services(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 18); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 999); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 3); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_map_entry(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 7); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_message_set_wire_format(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_no_standard_descriptor_accessor(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 999); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_client_streaming(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_input_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_output_type(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_server_streaming(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 33); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 999); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_OneofDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_OneofDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_method(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_options(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_deprecated(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 33); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_uninterpreted_option(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 999); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_comments(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 3); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_detached_comments(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 6); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_path(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_span(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_trailing_comments(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 4); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_f_location(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_is_extension(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_name_part(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 1); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_aggregate_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 8); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_double_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 6); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_identifier_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 3); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_name(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 2); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_negative_int_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 5); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_positive_int_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 4); } +UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_string_value(const upb_msgdef *m) { UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 7); } UPB_END_EXTERN_C @@ -302,7 +302,7 @@ class DescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: DescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_DescriptorProto_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_is(m)); } static DescriptorProto get() { @@ -314,7 +314,7 @@ class DescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: ExtensionRange(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); } static ExtensionRange get() { @@ -327,7 +327,7 @@ class DescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: ReservedRange(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); } static ReservedRange get() { @@ -341,7 +341,7 @@ class EnumDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: EnumDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); } static EnumDescriptorProto get() { @@ -354,7 +354,7 @@ class EnumOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: EnumOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_EnumOptions_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_EnumOptions_is(m)); } static EnumOptions get() { @@ -367,7 +367,7 @@ class EnumValueDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDe public: EnumValueDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); } static EnumValueDescriptorProto get() { @@ -380,7 +380,7 @@ class EnumValueOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: EnumValueOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_EnumValueOptions_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_EnumValueOptions_is(m)); } static EnumValueOptions get() { @@ -393,7 +393,7 @@ class FieldDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: FieldDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); } static FieldDescriptorProto get() { @@ -405,7 +405,7 @@ class FieldDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: Label(const ::upb::EnumDef* e, const void *ref_donor = NULL) : reffed_ptr(e, ref_donor) { - assert(upbdefs_google_protobuf_FieldDescriptorProto_Label_is(e)); + UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_Label_is(e)); } static Label get() { const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Label_get(&e); @@ -417,7 +417,7 @@ class FieldDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: Type(const ::upb::EnumDef* e, const void *ref_donor = NULL) : reffed_ptr(e, ref_donor) { - assert(upbdefs_google_protobuf_FieldDescriptorProto_Type_is(e)); + UPB_ASSERT(upbdefs_google_protobuf_FieldDescriptorProto_Type_is(e)); } static Type get() { const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Type_get(&e); @@ -430,7 +430,7 @@ class FieldOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: FieldOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_FieldOptions_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_is(m)); } static FieldOptions get() { @@ -442,7 +442,7 @@ class FieldOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: CType(const ::upb::EnumDef* e, const void *ref_donor = NULL) : reffed_ptr(e, ref_donor) { - assert(upbdefs_google_protobuf_FieldOptions_CType_is(e)); + UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_CType_is(e)); } static CType get() { const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_CType_get(&e); @@ -454,7 +454,7 @@ class FieldOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: JSType(const ::upb::EnumDef* e, const void *ref_donor = NULL) : reffed_ptr(e, ref_donor) { - assert(upbdefs_google_protobuf_FieldOptions_JSType_is(e)); + UPB_ASSERT(upbdefs_google_protobuf_FieldOptions_JSType_is(e)); } static JSType get() { const ::upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_JSType_get(&e); @@ -467,7 +467,7 @@ class FileDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: FileDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorProto_is(m)); } static FileDescriptorProto get() { @@ -480,7 +480,7 @@ class FileDescriptorSet : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: FileDescriptorSet(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_FileDescriptorSet_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_FileDescriptorSet_is(m)); } static FileDescriptorSet get() { @@ -493,7 +493,7 @@ class FileOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: FileOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_FileOptions_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_FileOptions_is(m)); } static FileOptions get() { @@ -505,7 +505,7 @@ class FileOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: OptimizeMode(const ::upb::EnumDef* e, const void *ref_donor = NULL) : reffed_ptr(e, ref_donor) { - assert(upbdefs_google_protobuf_FileOptions_OptimizeMode_is(e)); + UPB_ASSERT(upbdefs_google_protobuf_FileOptions_OptimizeMode_is(e)); } static OptimizeMode get() { const ::upb::EnumDef* e = upbdefs_google_protobuf_FileOptions_OptimizeMode_get(&e); @@ -518,7 +518,7 @@ class MessageOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: MessageOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_MessageOptions_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_MessageOptions_is(m)); } static MessageOptions get() { @@ -531,7 +531,7 @@ class MethodDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> public: MethodDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); } static MethodDescriptorProto get() { @@ -544,7 +544,7 @@ class MethodOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: MethodOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_MethodOptions_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_MethodOptions_is(m)); } static MethodOptions get() { @@ -557,7 +557,7 @@ class OneofDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: OneofDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_OneofDescriptorProto_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_OneofDescriptorProto_is(m)); } static OneofDescriptorProto get() { @@ -570,7 +570,7 @@ class ServiceDescriptorProto : public ::upb::reffed_ptr<const ::upb::MessageDef> public: ServiceDescriptorProto(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); } static ServiceDescriptorProto get() { @@ -583,7 +583,7 @@ class ServiceOptions : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: ServiceOptions(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_ServiceOptions_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_ServiceOptions_is(m)); } static ServiceOptions get() { @@ -596,7 +596,7 @@ class SourceCodeInfo : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: SourceCodeInfo(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_SourceCodeInfo_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_is(m)); } static SourceCodeInfo get() { @@ -608,7 +608,7 @@ class SourceCodeInfo : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: Location(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); } static Location get() { @@ -622,7 +622,7 @@ class UninterpretedOption : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: UninterpretedOption(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_is(m)); } static UninterpretedOption get() { @@ -634,7 +634,7 @@ class UninterpretedOption : public ::upb::reffed_ptr<const ::upb::MessageDef> { public: NamePart(const ::upb::MessageDef* m, const void *ref_donor = NULL) : reffed_ptr(m, ref_donor) { - assert(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); + UPB_ASSERT(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); } static NamePart get() { diff --git a/upb/descriptor/reader.c b/upb/descriptor/reader.c index 9717f1d..82fd574 100644 --- a/upb/descriptor/reader.c +++ b/upb/descriptor/reader.c @@ -111,9 +111,9 @@ static bool upb_descreader_qualify(upb_filedef *f, char *str, int32_t start) { static upb_msgdef *upb_descreader_top(upb_descreader *r) { int index; - assert(r->stack_len > 1); + UPB_ASSERT(r->stack_len > 1); index = r->stack[r->stack_len-1].start - 1; - assert(index >= 0); + UPB_ASSERT(index >= 0); return upb_downcast_msgdef_mutable(upb_filedef_mutabledef(r->file, index)); } @@ -183,7 +183,7 @@ static size_t file_onname(void *closure, const void *hd, const char *buf, /* XXX: see comment at the top of the file. */ ok = upb_filedef_setname(r->file, name, NULL); upb_gfree(name); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return n; } @@ -199,7 +199,7 @@ static size_t file_onpackage(void *closure, const void *hd, const char *buf, /* XXX: see comment at the top of the file. */ upb_descreader_setscopename(r, package); ok = upb_filedef_setpackage(r->file, package, NULL); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return n; } @@ -218,7 +218,7 @@ static size_t file_onsyntax(void *closure, const void *hd, const char *buf, ok = false; } - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return n; } @@ -227,7 +227,7 @@ static void *file_startmsg(void *closure, const void *hd) { upb_msgdef *m = upb_msgdef_new(&m); bool ok = upb_filedef_addmsg(r->file, m, &m, NULL); UPB_UNUSED(hd); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return r; } @@ -236,7 +236,7 @@ static void *file_startenum(void *closure, const void *hd) { upb_enumdef *e = upb_enumdef_new(&e); bool ok = upb_filedef_addenum(r->file, e, &e, NULL); UPB_UNUSED(hd); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return r; } @@ -246,7 +246,7 @@ static void *file_startext(void *closure, const void *hd) { r->f = upb_fielddef_new(r); ok = upb_filedef_addext(r->file, r->f, r, NULL); UPB_UNUSED(hd); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return r; } @@ -332,7 +332,7 @@ static size_t enum_onname(void *closure, const void *hd, const char *buf, static bool field_startmsg(void *closure, const void *hd) { upb_descreader *r = closure; UPB_UNUSED(hd); - assert(r->f); + UPB_ASSERT(r->f); upb_gfree(r->default_string); r->default_string = NULL; @@ -418,9 +418,9 @@ static bool field_endmsg(void *closure, const void *hd, upb_status *status) { UPB_UNUSED(hd); /* TODO: verify that all required fields were present. */ - assert(upb_fielddef_number(f) != 0); - assert(upb_fielddef_name(f) != NULL); - assert((upb_fielddef_subdefname(f) != NULL) == upb_fielddef_hassubdef(f)); + UPB_ASSERT(upb_fielddef_number(f) != 0); + UPB_ASSERT(upb_fielddef_name(f) != NULL); + UPB_ASSERT((upb_fielddef_subdefname(f) != NULL) == upb_fielddef_hassubdef(f)); if (r->default_string) { if (upb_fielddef_issubmsg(f)) { @@ -479,7 +479,7 @@ static bool field_onnumber(void *closure, const void *hd, int32_t val) { UPB_UNUSED(hd); ok = upb_fielddef_setnumber(r->f, val, NULL); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return true; } @@ -577,7 +577,7 @@ static void *msg_startmsg(void *closure, const void *hd) { upb_msgdef *m = upb_msgdef_new(&m); bool ok = upb_filedef_addmsg(r->file, m, &m, NULL); UPB_UNUSED(hd); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return r; } @@ -586,7 +586,7 @@ static void *msg_startext(void *closure, const void *hd) { upb_fielddef *f = upb_fielddef_new(&f); bool ok = upb_filedef_addext(r->file, f, &f, NULL); UPB_UNUSED(hd); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return r; } @@ -694,7 +694,7 @@ static void reghandlers(const void *closure, upb_handlers *h) { upb_handlers_setbool(h, F(MessageOptions, map_entry), &msg_onmapentry, NULL); } - assert(upb_ok(upb_handlers_status(h))); + UPB_ASSERT(upb_ok(upb_handlers_status(h))); } #undef F diff --git a/upb/handlers-inl.h b/upb/handlers-inl.h index 8cec602..afc1382 100644 --- a/upb/handlers-inl.h +++ b/upb/handlers-inl.h @@ -833,7 +833,7 @@ struct ConvertParams<BoundFunc5<R, P1, P2, P3, P4, P5, F, I>, T> { inline bool Handlers::SetValueHandler<vtype>( \ const FieldDef *f, \ const Handlers::utype ## Handler& handler) { \ - assert(!handler.registered_); \ + UPB_ASSERT(!handler.registered_); \ handler.AddCleanup(this); \ handler.registered_ = true; \ return upb_handlers_set##ltype(this, f, handler.handler_, &handler.attr_); \ @@ -945,7 +945,7 @@ inline Handler<T>::Handler(F func) template <class T> inline Handler<T>::~Handler() { - assert(registered_); + UPB_ASSERT(registered_); } inline HandlerAttributes::HandlerAttributes() { upb_handlerattr_init(this); } @@ -1031,63 +1031,63 @@ inline bool Handlers::AddCleanup(void *p, upb_handlerfree *func) { } inline bool Handlers::SetStartMessageHandler( const Handlers::StartMessageHandler &handler) { - assert(!handler.registered_); + UPB_ASSERT(!handler.registered_); handler.registered_ = true; handler.AddCleanup(this); return upb_handlers_setstartmsg(this, handler.handler_, &handler.attr_); } inline bool Handlers::SetEndMessageHandler( const Handlers::EndMessageHandler &handler) { - assert(!handler.registered_); + UPB_ASSERT(!handler.registered_); handler.registered_ = true; handler.AddCleanup(this); return upb_handlers_setendmsg(this, handler.handler_, &handler.attr_); } inline bool Handlers::SetStartStringHandler(const FieldDef *f, const StartStringHandler &handler) { - assert(!handler.registered_); + UPB_ASSERT(!handler.registered_); handler.registered_ = true; handler.AddCleanup(this); return upb_handlers_setstartstr(this, f, handler.handler_, &handler.attr_); } inline bool Handlers::SetEndStringHandler(const FieldDef *f, const EndFieldHandler &handler) { - assert(!handler.registered_); + UPB_ASSERT(!handler.registered_); handler.registered_ = true; handler.AddCleanup(this); return upb_handlers_setendstr(this, f, handler.handler_, &handler.attr_); } inline bool Handlers::SetStringHandler(const FieldDef *f, const StringHandler& handler) { - assert(!handler.registered_); + UPB_ASSERT(!handler.registered_); handler.registered_ = true; handler.AddCleanup(this); return upb_handlers_setstring(this, f, handler.handler_, &handler.attr_); } inline bool Handlers::SetStartSequenceHandler( const FieldDef *f, const StartFieldHandler &handler) { - assert(!handler.registered_); + UPB_ASSERT(!handler.registered_); handler.registered_ = true; handler.AddCleanup(this); return upb_handlers_setstartseq(this, f, handler.handler_, &handler.attr_); } inline bool Handlers::SetStartSubMessageHandler( const FieldDef *f, const StartFieldHandler &handler) { - assert(!handler.registered_); + UPB_ASSERT(!handler.registered_); handler.registered_ = true; handler.AddCleanup(this); return upb_handlers_setstartsubmsg(this, f, handler.handler_, &handler.attr_); } inline bool Handlers::SetEndSubMessageHandler(const FieldDef *f, const EndFieldHandler &handler) { - assert(!handler.registered_); + UPB_ASSERT(!handler.registered_); handler.registered_ = true; handler.AddCleanup(this); return upb_handlers_setendsubmsg(this, f, handler.handler_, &handler.attr_); } inline bool Handlers::SetEndSequenceHandler(const FieldDef *f, const EndFieldHandler &handler) { - assert(!handler.registered_); + UPB_ASSERT(!handler.registered_); handler.registered_ = true; handler.AddCleanup(this); return upb_handlers_setendseq(this, f, handler.handler_, &handler.attr_); diff --git a/upb/handlers.c b/upb/handlers.c index 055eadf..09f9199 100644 --- a/upb/handlers.c +++ b/upb/handlers.c @@ -1,6 +1,6 @@ /* ** TODO(haberman): it's unclear whether a lot of the consistency checks should -** assert() or return false. +** UPB_ASSERT() or return false. */ #include "upb/handlers.h" @@ -113,7 +113,7 @@ oom: static int32_t trygetsel(upb_handlers *h, const upb_fielddef *f, upb_handlertype_t type) { upb_selector_t sel; - assert(!upb_handlers_isfrozen(h)); + UPB_ASSERT(!upb_handlers_isfrozen(h)); if (upb_handlers_msgdef(h) != upb_fielddef_containingtype(f)) { upb_status_seterrf( &h->status_, "type mismatch: field %s does not belong to message %s", @@ -133,7 +133,7 @@ static int32_t trygetsel(upb_handlers *h, const upb_fielddef *f, static upb_selector_t handlers_getsel(upb_handlers *h, const upb_fielddef *f, upb_handlertype_t type) { int32_t sel = trygetsel(h, f, type); - assert(sel >= 0); + UPB_ASSERT(sel >= 0); return sel; } @@ -149,7 +149,7 @@ static bool doset(upb_handlers *h, int32_t sel, const upb_fielddef *f, const void *closure_type; const void **context_closure_type; - assert(!upb_handlers_isfrozen(h)); + UPB_ASSERT(!upb_handlers_isfrozen(h)); if (sel < 0) { upb_status_seterrmsg(&h->status_, @@ -229,7 +229,7 @@ const void *effective_closure_type(upb_handlers *h, const upb_fielddef *f, const void *ret; upb_selector_t sel; - assert(type != UPB_HANDLER_STRING); + UPB_ASSERT(type != UPB_HANDLER_STRING); ret = h->top_closure_type; if (upb_fielddef_isseq(f) && @@ -284,7 +284,7 @@ upb_handlers *upb_handlers_new(const upb_msgdef *md, const void *owner) { int extra; upb_handlers *h; - assert(upb_msgdef_isfrozen(md)); + UPB_ASSERT(upb_msgdef_isfrozen(md)); extra = sizeof(upb_handlers_tabent) * (md->selector_count - 1); h = upb_calloc(sizeof(*h) + extra); @@ -333,18 +333,18 @@ const upb_handlers *upb_handlers_newfrozen(const upb_msgdef *m, r = upb_handlers_upcast_mutable(ret); ok = upb_refcounted_freeze(&r, 1, NULL, UPB_MAX_HANDLER_DEPTH); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return ret; } const upb_status *upb_handlers_status(upb_handlers *h) { - assert(!upb_handlers_isfrozen(h)); + UPB_ASSERT(!upb_handlers_isfrozen(h)); return &h->status_; } void upb_handlers_clearerr(upb_handlers *h) { - assert(!upb_handlers_isfrozen(h)); + UPB_ASSERT(!upb_handlers_isfrozen(h)); upb_status_clear(&h->status_); } @@ -380,16 +380,16 @@ bool upb_handlers_setstartmsg(upb_handlers *h, upb_startmsg_handlerfunc *func, bool upb_handlers_setendmsg(upb_handlers *h, upb_endmsg_handlerfunc *func, upb_handlerattr *attr) { - assert(!upb_handlers_isfrozen(h)); + UPB_ASSERT(!upb_handlers_isfrozen(h)); return doset(h, UPB_ENDMSG_SELECTOR, NULL, UPB_HANDLER_INT32, (upb_func *)func, attr); } bool upb_handlers_setsubhandlers(upb_handlers *h, const upb_fielddef *f, const upb_handlers *sub) { - assert(sub); - assert(!upb_handlers_isfrozen(h)); - assert(upb_fielddef_issubmsg(f)); + UPB_ASSERT(sub); + UPB_ASSERT(!upb_handlers_isfrozen(h)); + UPB_ASSERT(upb_fielddef_issubmsg(f)); if (SUBH_F(h, f)) return false; /* Can't reset. */ if (upb_msgdef_upcast(upb_handlers_msgdef(sub)) != upb_fielddef_subdef(f)) { return false; @@ -401,7 +401,7 @@ bool upb_handlers_setsubhandlers(upb_handlers *h, const upb_fielddef *f, const upb_handlers *upb_handlers_getsubhandlers(const upb_handlers *h, const upb_fielddef *f) { - assert(upb_fielddef_issubmsg(f)); + UPB_ASSERT(upb_fielddef_issubmsg(f)); return SUBH_F(h, f); } @@ -427,7 +427,7 @@ bool upb_handlers_addcleanup(upb_handlers *h, void *p, upb_handlerfree *func) { return false; } ok = upb_inttable_insertptr(&h->cleanup_, p, upb_value_fptr(func)); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return true; } @@ -528,7 +528,7 @@ upb_handlertype_t upb_handlers_getprimitivehandlertype(const upb_fielddef *f) { case UPB_TYPE_FLOAT: return UPB_HANDLER_FLOAT; case UPB_TYPE_DOUBLE: return UPB_HANDLER_DOUBLE; case UPB_TYPE_BOOL: return UPB_HANDLER_BOOL; - default: assert(false); return -1; /* Invalid input. */ + default: UPB_ASSERT(false); return -1; /* Invalid input. */ } } @@ -591,7 +591,7 @@ bool upb_handlers_getselector(const upb_fielddef *f, upb_handlertype_t type, *s = f->selector_base; break; } - assert((size_t)*s < upb_fielddef_containingtype(f)->selector_count); + UPB_ASSERT((size_t)*s < upb_fielddef_containingtype(f)->selector_count); return true; } diff --git a/upb/handlers.h b/upb/handlers.h index 8925d4f..54a3c1c 100644 --- a/upb/handlers.h +++ b/upb/handlers.h @@ -611,7 +611,7 @@ template <class T> class Handler { void AddCleanup(Handlers* h) const { if (cleanup_func_) { bool ok = h->AddCleanup(cleanup_data_, cleanup_func_); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); } } diff --git a/upb/json/parser.c b/upb/json/parser.c index a808616..9ee67c1 100644 --- a/upb/json/parser.c +++ b/upb/json/parser.c @@ -119,7 +119,7 @@ static upb_selector_t getsel_for_handlertype(upb_json_parser *p, upb_handlertype_t type) { upb_selector_t sel; bool ok = upb_handlers_getselector(p->top->f, type, &sel); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return sel; } @@ -141,7 +141,7 @@ static bool check_stack(upb_json_parser *p) { static void set_name_table(upb_json_parser *p, upb_jsonparser_frame *frame) { upb_value v; bool ok = upb_inttable_lookupptr(&p->method->name_tables, frame->m, &v); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); frame->name_table = upb_value_getptr(v); } @@ -264,7 +264,7 @@ otherchar: val = b64lookup(ptr[0]) << 18 | b64lookup(ptr[1]) << 12; - assert(!(val & 0x80000000)); + UPB_ASSERT(!(val & 0x80000000)); output = val >> 16; upb_sink_putstring(&p->top->sink, sel, &output, 1, NULL); return true; @@ -319,8 +319,8 @@ badpadding: static void assert_accumulate_empty(upb_json_parser *p) { UPB_UNUSED(p); - assert(p->accumulated == NULL); - assert(p->accumulated_len == 0); + UPB_ASSERT(p->accumulated == NULL); + UPB_ASSERT(p->accumulated_len == 0); } static void accumulate_clear(upb_json_parser *p) { @@ -386,7 +386,7 @@ static bool accumulate_append(upb_json_parser *p, const char *buf, size_t len, * call, and writes the length to *len. This with point either to the input * buffer or a temporary accumulate buffer. */ static const char *accumulate_getptr(upb_json_parser *p, size_t *len) { - assert(p->accumulated); + UPB_ASSERT(p->accumulated); *len = p->accumulated_len; return p->accumulated; } @@ -424,7 +424,7 @@ enum { * the end. */ static void multipart_startaccum(upb_json_parser *p) { assert_accumulate_empty(p); - assert(p->multipart_state == MULTIPART_INACTIVE); + UPB_ASSERT(p->multipart_state == MULTIPART_INACTIVE); p->multipart_state = MULTIPART_ACCUMULATE; } @@ -432,7 +432,7 @@ static void multipart_startaccum(upb_json_parser *p) { * value with the given selector. */ static void multipart_start(upb_json_parser *p, upb_selector_t sel) { assert_accumulate_empty(p); - assert(p->multipart_state == MULTIPART_INACTIVE); + UPB_ASSERT(p->multipart_state == MULTIPART_INACTIVE); p->multipart_state = MULTIPART_PUSHEAGERLY; p->string_selector = sel; } @@ -465,7 +465,7 @@ static bool multipart_text(upb_json_parser *p, const char *buf, size_t len, /* Note: this invalidates the accumulate buffer! Call only after reading its * contents. */ static void multipart_end(upb_json_parser *p) { - assert(p->multipart_state != MULTIPART_INACTIVE); + UPB_ASSERT(p->multipart_state != MULTIPART_INACTIVE); p->multipart_state = MULTIPART_INACTIVE; accumulate_clear(p); } @@ -478,13 +478,13 @@ static void multipart_end(upb_json_parser *p) { * region. */ static void capture_begin(upb_json_parser *p, const char *ptr) { - assert(p->multipart_state != MULTIPART_INACTIVE); - assert(p->capture == NULL); + UPB_ASSERT(p->multipart_state != MULTIPART_INACTIVE); + UPB_ASSERT(p->capture == NULL); p->capture = ptr; } static bool capture_end(upb_json_parser *p, const char *ptr) { - assert(p->capture); + UPB_ASSERT(p->capture); if (multipart_text(p, p->capture, ptr - p->capture, true)) { p->capture = NULL; return true; @@ -517,7 +517,7 @@ static void capture_suspend(upb_json_parser *p, const char **ptr) { static void capture_resume(upb_json_parser *p, const char *ptr) { if (p->capture) { - assert(p->capture == &suspend_capture); + UPB_ASSERT(p->capture == &suspend_capture); p->capture = ptr; } } @@ -539,7 +539,7 @@ static char escape_char(char in) { case '"': return '"'; case '\\': return '\\'; default: - assert(0); + UPB_ASSERT(0); return 'x'; } } @@ -563,7 +563,7 @@ static void hexdigit(upb_json_parser *p, const char *ptr) { } else if (ch >= 'a' && ch <= 'f') { p->digit += ((ch - 'a') + 10); } else { - assert(ch >= 'A' && ch <= 'F'); + UPB_ASSERT(ch >= 'A' && ch <= 'F'); p->digit += ((ch - 'A') + 10); } } @@ -694,7 +694,7 @@ static bool parse_number(upb_json_parser *p) { break; } default: - assert(false); + UPB_ASSERT(false); } multipart_end(p); @@ -720,13 +720,13 @@ static bool parser_putbool(upb_json_parser *p, bool val) { } ok = upb_sink_putbool(&p->top->sink, parser_getsel(p), val); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return true; } static bool start_stringval(upb_json_parser *p) { - assert(p->top->f); + UPB_ASSERT(p->top->f); if (upb_fielddef_isstring(p->top->f)) { upb_jsonparser_frame *inner; @@ -816,7 +816,7 @@ static bool end_stringval(upb_json_parser *p) { } default: - assert(false); + UPB_ASSERT(false); upb_status_seterrmsg(&p->status, "Internal error in JSON decoder"); upb_env_reporterror(p->env, &p->status); ok = false; @@ -829,7 +829,7 @@ static bool end_stringval(upb_json_parser *p) { } static void start_member(upb_json_parser *p) { - assert(!p->top->f); + UPB_ASSERT(!p->top->f); multipart_startaccum(p); } @@ -958,7 +958,7 @@ static bool handle_mapentry(upb_json_parser *p) { } static bool end_membername(upb_json_parser *p) { - assert(!p->top->f); + UPB_ASSERT(!p->top->f); if (p->top->is_map) { return handle_mapentry(p); @@ -990,7 +990,7 @@ static void end_member(upb_json_parser *p) { bool ok; const upb_fielddef *mapfield; - assert(p->top > p->stack); + UPB_ASSERT(p->top > p->stack); /* send ENDMSG on submsg. */ upb_sink_endmsg(&p->top->sink, &s); mapfield = p->top->mapfield; @@ -998,7 +998,7 @@ static void end_member(upb_json_parser *p) { /* send ENDSUBMSG in repeated-field-of-mapentries frame. */ p->top--; ok = upb_handlers_getselector(mapfield, UPB_HANDLER_ENDSUBMSG, &sel); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); upb_sink_endsubmsg(&p->top->sink, sel); } @@ -1006,7 +1006,7 @@ static void end_member(upb_json_parser *p) { } static bool start_subobject(upb_json_parser *p) { - assert(p->top->f); + UPB_ASSERT(p->top->f); if (upb_fielddef_ismap(p->top->f)) { upb_jsonparser_frame *inner; @@ -1075,7 +1075,7 @@ static bool start_array(upb_json_parser *p) { upb_jsonparser_frame *inner; upb_selector_t sel; - assert(p->top->f); + UPB_ASSERT(p->top->f); if (!upb_fielddef_isseq(p->top->f)) { upb_status_seterrf(&p->status, @@ -1103,7 +1103,7 @@ static bool start_array(upb_json_parser *p) { static void end_array(upb_json_parser *p) { upb_selector_t sel; - assert(p->top > p->stack); + UPB_ASSERT(p->top > p->stack); p->top--; sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSEQ); @@ -1634,7 +1634,7 @@ static void add_jsonname_table(upb_json_parsermethod *m, const upb_msgdef* md) { buf = upb_grealloc(buf, 0, field_len); len = field_len; len2 = upb_fielddef_getjsonname(f, buf, len); - UPB_ASSERT_VAR(len2, len == len2); + UPB_ASSERT(len == len2); } upb_strtable_insert(t, buf, upb_value_constptr(f)); @@ -1678,7 +1678,8 @@ upb_json_parser *upb_json_parser_create(upb_env *env, /* If this fails, uncomment and increase the value in parser.h. */ /* fprintf(stderr, "%zd\n", upb_env_bytesallocated(env) - size_before); */ - assert(upb_env_bytesallocated(env) - size_before <= UPB_JSON_PARSER_SIZE); + UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(env) - size_before <= + UPB_JSON_PARSER_SIZE); return p; } diff --git a/upb/json/parser.rl b/upb/json/parser.rl index b67f08d..b0fcdba 100644 --- a/upb/json/parser.rl +++ b/upb/json/parser.rl @@ -117,7 +117,7 @@ static upb_selector_t getsel_for_handlertype(upb_json_parser *p, upb_handlertype_t type) { upb_selector_t sel; bool ok = upb_handlers_getselector(p->top->f, type, &sel); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return sel; } @@ -139,7 +139,7 @@ static bool check_stack(upb_json_parser *p) { static void set_name_table(upb_json_parser *p, upb_jsonparser_frame *frame) { upb_value v; bool ok = upb_inttable_lookupptr(&p->method->name_tables, frame->m, &v); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); frame->name_table = upb_value_getptr(v); } @@ -262,7 +262,7 @@ otherchar: val = b64lookup(ptr[0]) << 18 | b64lookup(ptr[1]) << 12; - assert(!(val & 0x80000000)); + UPB_ASSERT(!(val & 0x80000000)); output = val >> 16; upb_sink_putstring(&p->top->sink, sel, &output, 1, NULL); return true; @@ -316,9 +316,8 @@ badpadding: * the true value in a contiguous buffer. */ static void assert_accumulate_empty(upb_json_parser *p) { - UPB_UNUSED(p); - assert(p->accumulated == NULL); - assert(p->accumulated_len == 0); + UPB_ASSERT(p->accumulated == NULL); + UPB_ASSERT(p->accumulated_len == 0); } static void accumulate_clear(upb_json_parser *p) { @@ -384,7 +383,7 @@ static bool accumulate_append(upb_json_parser *p, const char *buf, size_t len, * call, and writes the length to *len. This with point either to the input * buffer or a temporary accumulate buffer. */ static const char *accumulate_getptr(upb_json_parser *p, size_t *len) { - assert(p->accumulated); + UPB_ASSERT(p->accumulated); *len = p->accumulated_len; return p->accumulated; } @@ -422,7 +421,7 @@ enum { * the end. */ static void multipart_startaccum(upb_json_parser *p) { assert_accumulate_empty(p); - assert(p->multipart_state == MULTIPART_INACTIVE); + UPB_ASSERT(p->multipart_state == MULTIPART_INACTIVE); p->multipart_state = MULTIPART_ACCUMULATE; } @@ -430,7 +429,7 @@ static void multipart_startaccum(upb_json_parser *p) { * value with the given selector. */ static void multipart_start(upb_json_parser *p, upb_selector_t sel) { assert_accumulate_empty(p); - assert(p->multipart_state == MULTIPART_INACTIVE); + UPB_ASSERT(p->multipart_state == MULTIPART_INACTIVE); p->multipart_state = MULTIPART_PUSHEAGERLY; p->string_selector = sel; } @@ -463,7 +462,7 @@ static bool multipart_text(upb_json_parser *p, const char *buf, size_t len, /* Note: this invalidates the accumulate buffer! Call only after reading its * contents. */ static void multipart_end(upb_json_parser *p) { - assert(p->multipart_state != MULTIPART_INACTIVE); + UPB_ASSERT(p->multipart_state != MULTIPART_INACTIVE); p->multipart_state = MULTIPART_INACTIVE; accumulate_clear(p); } @@ -476,13 +475,13 @@ static void multipart_end(upb_json_parser *p) { * region. */ static void capture_begin(upb_json_parser *p, const char *ptr) { - assert(p->multipart_state != MULTIPART_INACTIVE); - assert(p->capture == NULL); + UPB_ASSERT(p->multipart_state != MULTIPART_INACTIVE); + UPB_ASSERT(p->capture == NULL); p->capture = ptr; } static bool capture_end(upb_json_parser *p, const char *ptr) { - assert(p->capture); + UPB_ASSERT(p->capture); if (multipart_text(p, p->capture, ptr - p->capture, true)) { p->capture = NULL; return true; @@ -515,7 +514,7 @@ static void capture_suspend(upb_json_parser *p, const char **ptr) { static void capture_resume(upb_json_parser *p, const char *ptr) { if (p->capture) { - assert(p->capture == &suspend_capture); + UPB_ASSERT(p->capture == &suspend_capture); p->capture = ptr; } } @@ -537,7 +536,7 @@ static char escape_char(char in) { case '"': return '"'; case '\\': return '\\'; default: - assert(0); + UPB_ASSERT(0); return 'x'; } } @@ -561,7 +560,7 @@ static void hexdigit(upb_json_parser *p, const char *ptr) { } else if (ch >= 'a' && ch <= 'f') { p->digit += ((ch - 'a') + 10); } else { - assert(ch >= 'A' && ch <= 'F'); + UPB_ASSERT(ch >= 'A' && ch <= 'F'); p->digit += ((ch - 'A') + 10); } } @@ -692,7 +691,7 @@ static bool parse_number(upb_json_parser *p) { break; } default: - assert(false); + UPB_ASSERT(false); } multipart_end(p); @@ -718,13 +717,13 @@ static bool parser_putbool(upb_json_parser *p, bool val) { } ok = upb_sink_putbool(&p->top->sink, parser_getsel(p), val); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return true; } static bool start_stringval(upb_json_parser *p) { - assert(p->top->f); + UPB_ASSERT(p->top->f); if (upb_fielddef_isstring(p->top->f)) { upb_jsonparser_frame *inner; @@ -814,7 +813,7 @@ static bool end_stringval(upb_json_parser *p) { } default: - assert(false); + UPB_ASSERT(false); upb_status_seterrmsg(&p->status, "Internal error in JSON decoder"); upb_env_reporterror(p->env, &p->status); ok = false; @@ -827,7 +826,7 @@ static bool end_stringval(upb_json_parser *p) { } static void start_member(upb_json_parser *p) { - assert(!p->top->f); + UPB_ASSERT(!p->top->f); multipart_startaccum(p); } @@ -956,7 +955,7 @@ static bool handle_mapentry(upb_json_parser *p) { } static bool end_membername(upb_json_parser *p) { - assert(!p->top->f); + UPB_ASSERT(!p->top->f); if (p->top->is_map) { return handle_mapentry(p); @@ -988,7 +987,7 @@ static void end_member(upb_json_parser *p) { bool ok; const upb_fielddef *mapfield; - assert(p->top > p->stack); + UPB_ASSERT(p->top > p->stack); /* send ENDMSG on submsg. */ upb_sink_endmsg(&p->top->sink, &s); mapfield = p->top->mapfield; @@ -996,7 +995,7 @@ static void end_member(upb_json_parser *p) { /* send ENDSUBMSG in repeated-field-of-mapentries frame. */ p->top--; ok = upb_handlers_getselector(mapfield, UPB_HANDLER_ENDSUBMSG, &sel); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); upb_sink_endsubmsg(&p->top->sink, sel); } @@ -1004,7 +1003,7 @@ static void end_member(upb_json_parser *p) { } static bool start_subobject(upb_json_parser *p) { - assert(p->top->f); + UPB_ASSERT(p->top->f); if (upb_fielddef_ismap(p->top->f)) { upb_jsonparser_frame *inner; @@ -1073,7 +1072,7 @@ static bool start_array(upb_json_parser *p) { upb_jsonparser_frame *inner; upb_selector_t sel; - assert(p->top->f); + UPB_ASSERT(p->top->f); if (!upb_fielddef_isseq(p->top->f)) { upb_status_seterrf(&p->status, @@ -1101,7 +1100,7 @@ static bool start_array(upb_json_parser *p) { static void end_array(upb_json_parser *p) { upb_selector_t sel; - assert(p->top > p->stack); + UPB_ASSERT(p->top > p->stack); p->top--; sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSEQ); @@ -1369,7 +1368,7 @@ static void add_jsonname_table(upb_json_parsermethod *m, const upb_msgdef* md) { buf = upb_grealloc(buf, 0, field_len); len = field_len; len2 = upb_fielddef_getjsonname(f, buf, len); - UPB_ASSERT_VAR(len2, len == len2); + UPB_ASSERT(len == len2); } upb_strtable_insert(t, buf, upb_value_constptr(f)); @@ -1413,7 +1412,8 @@ upb_json_parser *upb_json_parser_create(upb_env *env, /* If this fails, uncomment and increase the value in parser.h. */ /* fprintf(stderr, "%zd\n", upb_env_bytesallocated(env) - size_before); */ - assert(upb_env_bytesallocated(env) - size_before <= UPB_JSON_PARSER_SIZE); + UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(env) - size_before <= + UPB_JSON_PARSER_SIZE); return p; } diff --git a/upb/json/printer.c b/upb/json/printer.c index cc50417..0f9ca0e 100644 --- a/upb/json/printer.c +++ b/upb/json/printer.c @@ -54,7 +54,7 @@ strpc *newstrpc(upb_handlers *h, const upb_fielddef *f, ret->len = upb_fielddef_getjsonname(f, NULL, 0); ret->ptr = upb_gmalloc(ret->len); len = upb_fielddef_getjsonname(f, ret->ptr, ret->len); - UPB_ASSERT_VAR(len, len == ret->len); + UPB_ASSERT(len == ret->len); ret->len--; /* NULL */ } @@ -68,7 +68,7 @@ static void print_data( upb_json_printer *p, const char *buf, unsigned int len) { /* TODO: Will need to change if we support pushback from the sink. */ size_t n = upb_bytessink_putbuf(p->output_, p->subc_, buf, len, NULL); - UPB_ASSERT_VAR(n, n == len); + UPB_ASSERT(n == len); } static void print_comma(upb_json_printer *p) { @@ -418,7 +418,7 @@ static size_t putbytes(void *closure, const void *handler_data, const char *str, while (remaining > 2) { /* TODO(haberman): handle encoded lengths > sizeof(data) */ - UPB_ASSERT_VAR(limit, (limit - to) >= 4); + UPB_ASSERT((limit - to) >= 4); to[0] = base64[from[0] >> 2]; to[1] = base64[((from[0] & 0x3) << 4) | (from[1] >> 4)]; @@ -622,7 +622,7 @@ void printer_sethandlers_mapentry(const void *closure, bool preserve_fieldnames, upb_handlers_setstring(h, key_field, mapkey_bytes, &empty_attr); break; default: - assert(false); + UPB_ASSERT(false); break; } @@ -796,7 +796,8 @@ upb_json_printer *upb_json_printer_create(upb_env *e, const upb_handlers *h, upb_sink_reset(&p->input_, h, p); /* If this fails, increase the value in printer.h. */ - assert(upb_env_bytesallocated(e) - size_before <= UPB_JSON_PRINTER_SIZE); + UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(e) - size_before <= + UPB_JSON_PRINTER_SIZE); return p; } diff --git a/upb/pb/compile_decoder.c b/upb/pb/compile_decoder.c index 7724113..d86f840 100644 --- a/upb/pb/compile_decoder.c +++ b/upb/pb/compile_decoder.c @@ -183,7 +183,7 @@ bool op_has_longofs(int32_t instruction) { case OP_TAGN: return false; default: - assert(false); + UPB_ASSERT(false); return false; } } @@ -202,7 +202,7 @@ static void setofs(uint32_t *instruction, int32_t ofs) { } else { *instruction = (*instruction & ~0xff00) | ((ofs & 0xff) << 8); } - assert(getofs(*instruction) == ofs); /* Would fail in cases of overflow. */ + UPB_ASSERT(getofs(*instruction) == ofs); /* Would fail in cases of overflow. */ } static uint32_t pcofs(compiler *c) { return c->pc - c->group->bytecode; } @@ -214,7 +214,7 @@ static void label(compiler *c, unsigned int label) { int val; uint32_t *codep; - assert(label < MAXLABEL); + UPB_ASSERT(label < MAXLABEL); val = c->fwd_labels[label]; codep = (val == EMPTYLABEL) ? NULL : c->group->bytecode + val; while (codep) { @@ -235,7 +235,7 @@ static void label(compiler *c, unsigned int label) { * The returned value is the offset that should be written into the instruction. */ static int32_t labelref(compiler *c, int label) { - assert(label < MAXLABEL); + UPB_ASSERT(label < MAXLABEL); if (label == LABEL_DISPATCH) { /* No resolving required. */ return 0; @@ -335,7 +335,7 @@ static void putop(compiler *c, opcode op, ...) { int label = va_arg(ap, int); uint64_t tag = va_arg(ap, uint64_t); uint32_t instruction = op | (tag << 16); - assert(tag <= 0xffff); + UPB_ASSERT(tag <= 0xffff); setofs(&instruction, labelref(c, label)); put32(c, instruction); break; @@ -472,7 +472,7 @@ static uint64_t get_encoded_tag(const upb_fielddef *f, int wire_type) { uint32_t tag = (upb_fielddef_number(f) << 3) | wire_type; uint64_t encoded_tag = upb_vencode32(tag); /* No tag should be greater than 5 bytes. */ - assert(encoded_tag <= 0xffffffffff); + UPB_ASSERT(encoded_tag <= 0xffffffffff); return encoded_tag; } @@ -495,7 +495,7 @@ static void putchecktag(compiler *c, const upb_fielddef *f, static upb_selector_t getsel(const upb_fielddef *f, upb_handlertype_t type) { upb_selector_t selector; bool ok = upb_handlers_getselector(f, type, &selector); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return selector; } @@ -507,7 +507,7 @@ static uint64_t repack(uint64_t dispatch, int new_wt2) { uint8_t wt1; uint8_t old_wt2; upb_pbdecoder_unpackdispatch(dispatch, &ofs, &wt1, &old_wt2); - assert(old_wt2 == NO_WIRE_TYPE); /* wt2 should not be set yet. */ + UPB_ASSERT(old_wt2 == NO_WIRE_TYPE); /* wt2 should not be set yet. */ return upb_pbdecoder_packdispatch(ofs, wt1, new_wt2); } @@ -709,7 +709,7 @@ static void generate_primitivefield(compiler *c, const upb_fielddef *f, * setting in the fielddef. This will favor (in speed) whichever was * specified. */ - assert((int)parse_type >= 0 && parse_type <= OP_MAX); + UPB_ASSERT((int)parse_type >= 0 && parse_type <= OP_MAX); sel = getsel(f, upb_handlers_getprimitivehandlertype(f)); wire_type = upb_pb_native_wire_types[upb_fielddef_descriptortype(f)]; if (upb_fielddef_isseq(f)) { @@ -751,7 +751,7 @@ static void compile_method(compiler *c, upb_pbdecodermethod *method) { upb_msg_field_iter i; upb_value val; - assert(method); + UPB_ASSERT(method); /* Clear all entries in the dispatch table. */ upb_inttable_uninit(&method->dispatch); @@ -899,7 +899,7 @@ const mgroup *mgroup_new(const upb_handlers *dest, bool allowjit, bool lazy, compiler *c; UPB_UNUSED(allowjit); - assert(upb_handlers_isfrozen(dest)); + UPB_ASSERT(upb_handlers_isfrozen(dest)); g = newgroup(owner); c = newcompiler(g, lazy); @@ -920,13 +920,13 @@ const mgroup *mgroup_new(const upb_handlers *dest, bool allowjit, bool lazy, #ifdef UPB_DUMP_BYTECODE { FILE *f = fopen("/tmp/upb-bytecode", "w"); - assert(f); + UPB_ASSERT(f); dumpbc(g->bytecode, g->bytecode_end, stderr); dumpbc(g->bytecode, g->bytecode_end, f); fclose(f); f = fopen("/tmp/upb-bytecode.bin", "wb"); - assert(f); + UPB_ASSERT(f); fwrite(g->bytecode, 1, g->bytecode_end - g->bytecode, f); fclose(f); } @@ -976,7 +976,7 @@ const upb_pbdecodermethod *upb_pbcodecache_getdecodermethod( upb_inttable_push(&c->groups, upb_value_constptr(g)); ok = upb_inttable_lookupptr(&g->methods, opts->handlers, &v); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return upb_value_getptr(v); } diff --git a/upb/pb/compile_decoder_x64.c b/upb/pb/compile_decoder_x64.c index 88561d6..29dbcb1 100644 --- a/upb/pb/compile_decoder_x64.c +++ b/upb/pb/compile_decoder_x64.c @@ -184,7 +184,7 @@ static char *upb_vasprintf(const char *fmt, va_list args) { char *ret = malloc(len + 1); /* + 1 for NULL terminator. */ if (!ret) abort(); int written = _upb_vsnprintf(ret, len + 1, fmt, args); - UPB_ASSERT_VAR(written, written == len); + UPB_ASSERT(written == len); return ret; } @@ -221,9 +221,9 @@ static int getjmptarget(jitcompiler *jc, const void *key) { int pclabel = 0; bool ok; - assert(upb_inttable_lookupptr(&jc->jmpdefined, key, NULL)); + UPB_ASSERT_DEBUGVAR(upb_inttable_lookupptr(&jc->jmpdefined, key, NULL)); ok = try_getjmptarget(jc, key, &pclabel); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return pclabel; } @@ -289,10 +289,10 @@ uint32_t dispatchofs(jitcompiler *jc, const upb_pbdecodermethod *method, int mc_target = machine_code_ofs2(jc, method, pcofs); int ret; - assert(mc_base > 0); - assert(mc_target > 0); + UPB_ASSERT(mc_base > 0); + UPB_ASSERT(mc_target > 0); ret = mc_target - mc_base; - assert(ret > 0); + UPB_ASSERT(ret > 0); return ret; } @@ -327,7 +327,7 @@ static void patchdispatch(jitcompiler *jc) { /* Update offset and repack. */ ofs = dispatchofs(jc, method, ofs); newval = upb_pbdecoder_packdispatch(ofs, wt1, wt2); - assert((int64_t)newval > 0); + UPB_ASSERT((int64_t)newval > 0); } else { /* Secondary slot. Since we have 64 bits for the value, we use an * absolute offset. */ @@ -335,7 +335,7 @@ static void patchdispatch(jitcompiler *jc) { newval = (uint64_t)((char*)jc->group->jit_code + mcofs); } ok = upb_inttable_replace(dispatch, key, upb_value_uint64(newval)); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); } /* Update entry point for this method to point at mc base instead of bc @@ -467,7 +467,7 @@ void upb_pbdecoder_jit(mgroup *group) { group->debug_info = NULL; group->dl = NULL; - assert(group->bytecode); + UPB_ASSERT(group->bytecode); jc = newjitcompiler(group); emit_static_asm(jc); jitbytecode(jc); diff --git a/upb/pb/compile_decoder_x64.dasc b/upb/pb/compile_decoder_x64.dasc index edda7dd..512c174 100644 --- a/upb/pb/compile_decoder_x64.dasc +++ b/upb/pb/compile_decoder_x64.dasc @@ -153,7 +153,7 @@ static upb_func *gethandler(const upb_handlers *h, upb_selector_t sel) { static void asmlabel(jitcompiler *jc, const char *fmt, ...) { #ifndef NDEBUG int ofs = jc->dynasm->section->ofs; - assert(ofs != jc->lastlabelofs); + UPB_ASSERT(ofs != jc->lastlabelofs); jc->lastlabelofs = ofs; #endif @@ -183,7 +183,7 @@ static bool alwaysok(const upb_handlers *h, upb_selector_t sel) { bool ok = upb_handlers_getattr(h, sel, &attr); bool ret; - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); ret = upb_handlerattr_alwaysok(&attr); upb_handlerattr_uninit(&attr); return ret; @@ -641,7 +641,7 @@ static void jitprimitive(jitcompiler *jc, opcode op, case UPB_TYPE_STRING: case UPB_TYPE_BYTES: case UPB_TYPE_MESSAGE: - assert(false); break; + UPB_ASSERT(false); break; } | sethas CLOSURE, data->hasbit } else if (handler) { @@ -790,7 +790,7 @@ static void jitdispatch(jitcompiler *jc, | // Secondary wire type is a match, look up fn + UPB_MAX_FIELDNUMBER. | add rdx, UPB_MAX_FIELDNUMBER | // This key will never be in the array part, so do a hash lookup. - assert(has_hash_entries); + UPB_ASSERT(has_hash_entries); | ld64 dispatch | jmp ->hashlookup // Tail call. } @@ -815,7 +815,7 @@ static void jittag(jitcompiler *jc, uint64_t tag, int n, int ofs, uint32_t *delimend = (jc->pc - 1) + last_arg; const size_t ptr_words = sizeof(void*) / sizeof(uint32_t); - assert((last_instruction & 0xff) == OP_CHECKDELIM); + UPB_ASSERT((last_instruction & 0xff) == OP_CHECKDELIM); if (getop(*(jc->pc - 1)) == OP_TAGN) { jc->pc += ptr_words; @@ -1131,7 +1131,7 @@ static void jitbytecode(jitcompiler *jc) { | call =>jmptarget(jc, &method->dispatch) break; case OP_HALT: - assert(false); + UPB_ASSERT(false); } } diff --git a/upb/pb/compile_decoder_x64.h b/upb/pb/compile_decoder_x64.h index 5d2b95a..ce775c6 100644 --- a/upb/pb/compile_decoder_x64.h +++ b/upb/pb/compile_decoder_x64.h @@ -338,7 +338,7 @@ static upb_func *gethandler(const upb_handlers *h, upb_selector_t sel) { static void asmlabel(jitcompiler *jc, const char *fmt, ...) { #ifndef NDEBUG int ofs = jc->dynasm->section->ofs; - assert(ofs != jc->lastlabelofs); + UPB_ASSERT(ofs != jc->lastlabelofs); jc->lastlabelofs = ofs; #endif @@ -370,7 +370,7 @@ static bool alwaysok(const upb_handlers *h, upb_selector_t sel) { bool ok = upb_handlers_getattr(h, sel, &attr); bool ret; - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); ret = upb_handlerattr_alwaysok(&attr); upb_handlerattr_uninit(&attr); return ret; @@ -964,7 +964,7 @@ static void jitprimitive(jitcompiler *jc, opcode op, case UPB_TYPE_STRING: case UPB_TYPE_BYTES: case UPB_TYPE_MESSAGE: - assert(false); break; + UPB_ASSERT(false); break; } /*| sethas CLOSURE, data->hasbit */ if (data->hasbit >= 0) { @@ -1188,7 +1188,7 @@ static void jitdispatch(jitcompiler *jc, /*| // This key will never be in the array part, so do a hash lookup. */ dasm_put(Dst, 2035, UPB_MAX_FIELDNUMBER); # 793 "upb/pb/compile_decoder_x64.dasc" - assert(has_hash_entries); + UPB_ASSERT(has_hash_entries); /*| ld64 dispatch */ { uintptr_t v = (uintptr_t)dispatch; @@ -1240,7 +1240,7 @@ static void jittag(jitcompiler *jc, uint64_t tag, int n, int ofs, uint32_t *delimend = (jc->pc - 1) + last_arg; const size_t ptr_words = sizeof(void*) / sizeof(uint32_t); - assert((last_instruction & 0xff) == OP_CHECKDELIM); + UPB_ASSERT((last_instruction & 0xff) == OP_CHECKDELIM); if (getop(*(jc->pc - 1)) == OP_TAGN) { jc->pc += ptr_words; @@ -1715,7 +1715,7 @@ static void jitbytecode(jitcompiler *jc) { # 1132 "upb/pb/compile_decoder_x64.dasc" break; case OP_HALT: - assert(false); + UPB_ASSERT(false); } } diff --git a/upb/pb/decoder.c b/upb/pb/decoder.c index 8f4c867..182ecc9 100644 --- a/upb/pb/decoder.c +++ b/upb/pb/decoder.c @@ -117,7 +117,7 @@ void upb_pbdecoder_seterr(upb_pbdecoder *d, const char *msg) { /* How many bytes can be safely read from d->ptr without reading past end-of-buf * or past the current delimited end. */ static size_t curbufleft(const upb_pbdecoder *d) { - assert(d->data_end >= d->ptr); + UPB_ASSERT(d->data_end >= d->ptr); return d->data_end - d->ptr; } @@ -138,7 +138,7 @@ size_t delim_remaining(const upb_pbdecoder *d) { /* Advances d->ptr. */ static void advance(upb_pbdecoder *d, size_t len) { - assert(curbufleft(d) >= len); + UPB_ASSERT(curbufleft(d) >= len); d->ptr += len; } @@ -171,7 +171,7 @@ static void switchtobuf(upb_pbdecoder *d, const char *buf, const char *end) { } static void advancetobuf(upb_pbdecoder *d, const char *buf, size_t len) { - assert(curbufleft(d) == 0); + UPB_ASSERT(curbufleft(d) == 0); d->bufstart_ofs += (d->end - d->buf); switchtobuf(d, buf, buf + len); } @@ -180,7 +180,7 @@ static void checkpoint(upb_pbdecoder *d) { /* The assertion here is in the interests of efficiency, not correctness. * We are trying to ensure that we don't checkpoint() more often than * necessary. */ - assert(d->checkpoint != d->ptr); + UPB_ASSERT(d->checkpoint != d->ptr); d->checkpoint = d->ptr; } @@ -191,8 +191,8 @@ static void checkpoint(upb_pbdecoder *d) { * won't actually be read. */ static int32_t skip(upb_pbdecoder *d, size_t bytes) { - assert(!in_residual_buf(d, d->ptr) || d->size_param == 0); - assert(d->skip == 0); + UPB_ASSERT(!in_residual_buf(d, d->ptr) || d->size_param == 0); + UPB_ASSERT(d->skip == 0); if (bytes > delim_remaining(d)) { seterr(d, "Skipped value extended beyond enclosing submessage."); return upb_pbdecoder_suspend(d); @@ -220,7 +220,7 @@ int32_t upb_pbdecoder_resume(upb_pbdecoder *d, void *p, const char *buf, /* d->skip and d->residual_end could probably elegantly be represented * as a single variable, to more easily represent this invariant. */ - assert(!(d->skip && d->residual_end > d->residual)); + UPB_ASSERT(!(d->skip && d->residual_end > d->residual)); /* We need to remember the original size_param, so that the value we return * is relative to it, even if we do some skipping first. */ @@ -253,7 +253,7 @@ int32_t upb_pbdecoder_resume(upb_pbdecoder *d, void *p, const char *buf, if (d->residual_end > d->residual) { /* We have residual bytes from the last buffer. */ - assert(d->ptr == d->residual); + UPB_ASSERT(d->ptr == d->residual); } else { switchtobuf(d, buf, buf + size); } @@ -287,8 +287,8 @@ size_t upb_pbdecoder_suspend(upb_pbdecoder *d) { return 0; } else { size_t ret = d->size_param - (d->end - d->checkpoint); - assert(!in_residual_buf(d, d->checkpoint)); - assert(d->buf == d->buf_param || d->buf == &dummy_char); + UPB_ASSERT(!in_residual_buf(d, d->checkpoint)); + UPB_ASSERT(d->buf == d->buf_param || d->buf == &dummy_char); d->bufstart_ofs += (d->checkpoint - d->buf); d->residual_end = d->residual; @@ -308,7 +308,7 @@ static size_t suspend_save(upb_pbdecoder *d) { if (d->checkpoint == d->residual) { /* Checkpoint was in residual buf; append user byte(s) to residual buf. */ - assert((d->residual_end - d->residual) + d->size_param <= + UPB_ASSERT((d->residual_end - d->residual) + d->size_param <= sizeof(d->residual)); if (!in_residual_buf(d, d->ptr)) { d->bufstart_ofs -= (d->residual_end - d->residual); @@ -318,11 +318,11 @@ static size_t suspend_save(upb_pbdecoder *d) { } else { /* Checkpoint was in user buf; old residual bytes not needed. */ size_t save; - assert(!in_residual_buf(d, d->checkpoint)); + UPB_ASSERT(!in_residual_buf(d, d->checkpoint)); d->ptr = d->checkpoint; save = curbufleft(d); - assert(save <= sizeof(d->residual)); + UPB_ASSERT(save <= sizeof(d->residual)); memcpy(d->residual, d->ptr, save); d->residual_end = d->residual + save; d->bufstart_ofs = offset(d); @@ -336,7 +336,7 @@ static size_t suspend_save(upb_pbdecoder *d) { * Requires that this many bytes are available in the current buffer. */ UPB_FORCEINLINE static void consumebytes(upb_pbdecoder *d, void *buf, size_t bytes) { - assert(bytes <= curbufleft(d)); + UPB_ASSERT(bytes <= curbufleft(d)); memcpy(buf, d->ptr, bytes); advance(d, bytes); } @@ -349,7 +349,7 @@ UPB_NOINLINE static int32_t getbytes_slow(upb_pbdecoder *d, void *buf, const size_t avail = curbufleft(d); consumebytes(d, buf, avail); bytes -= avail; - assert(bytes > 0); + UPB_ASSERT(bytes > 0); if (in_residual_buf(d, d->ptr)) { advancetobuf(d, d->buf_param, d->size_param); } @@ -532,7 +532,7 @@ UPB_NOINLINE int32_t upb_pbdecoder_checktag_slow(upb_pbdecoder *d, if (read == bytes && data == expected) { /* Advance past matched bytes. */ int32_t ok = getbytes(d, &data, read); - UPB_ASSERT_VAR(ok, ok < 0); + UPB_ASSERT(ok < 0); return DECODE_OK; } else if (read < bytes && memcmp(&data, &expected, read) == 0) { return suspend_save(d); @@ -607,7 +607,7 @@ have_tag: static void goto_endmsg(upb_pbdecoder *d) { upb_value v; bool found = upb_inttable_lookup32(d->top->dispatch, DISPATCH_ENDMSG, &v); - UPB_ASSERT_VAR(found, found); + UPB_ASSERT(found); d->pc = d->top->base + upb_value_getuint64(v); } @@ -641,7 +641,7 @@ static int32_t dispatch(upb_pbdecoder *d) { } else if (wire_type == ((v >> 8) & 0xff)) { bool found = upb_inttable_lookup(dispatch, fieldnum + UPB_MAX_FIELDNUMBER, &val); - UPB_ASSERT_VAR(found, found); + UPB_ASSERT(found); d->pc = d->top->base + upb_value_getuint64(val); return DECODE_OK; } @@ -653,7 +653,7 @@ static int32_t dispatch(upb_pbdecoder *d) { * can re-check the delimited end. */ d->last--; /* Necessary if we get suspended */ d->pc = d->last; - assert(getop(*d->last) == OP_CHECKDELIM); + UPB_ASSERT(getop(*d->last) == OP_CHECKDELIM); /* Unknown field or ENDGROUP. */ retval = upb_pbdecoder_skipunknown(d, fieldnum, wire_type); @@ -671,7 +671,7 @@ static int32_t dispatch(upb_pbdecoder *d) { /* Callers know that the stack is more than one deep because the opcodes that * call this only occur after PUSH operations. */ upb_pbdecoder_frame *outer_frame(upb_pbdecoder *d) { - assert(d->top != d->stack); + UPB_ASSERT(d->top != d->stack); return d->top - 1; } @@ -703,7 +703,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group, op = getop(instruction); arg = instruction >> 8; longofs = arg; - assert(d->ptr != d->residual_end); + UPB_ASSERT(d->ptr != d->residual_end); UPB_UNUSED(group); #ifdef UPB_DUMP_BYTECODE fprintf(stderr, "s_ofs=%d buf_ofs=%d data_rem=%d buf_rem=%d delim_rem=%d " @@ -778,7 +778,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group, } else { int32_t ret = skip(d, n); /* This shouldn't return DECODE_OK, because n > len. */ - assert(ret >= 0); + UPB_ASSERT(ret >= 0); return ret; } } @@ -800,7 +800,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group, d->top->groupnum = *d->pc++; ) VMCASE(OP_POP, - assert(d->top > d->stack); + UPB_ASSERT(d->top > d->stack); decoder_pop(d); ) VMCASE(OP_PUSHLENDELIM, @@ -816,7 +816,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group, /* We are guaranteed of this assert because we never allow ourselves to * consume bytes beyond data_end, which covers delim_end when non-NULL. */ - assert(!(d->delim_end && d->ptr > d->delim_end)); + UPB_ASSERT(!(d->delim_end && d->ptr > d->delim_end)); if (d->ptr == d->delim_end) d->pc += longofs; ) @@ -825,7 +825,7 @@ size_t run_decoder_vm(upb_pbdecoder *d, const mgroup *group, d->pc += longofs; ) VMCASE(OP_RET, - assert(d->call_len > 0); + UPB_ASSERT(d->call_len > 0); d->pc = d->callstack[--d->call_len]; ) VMCASE(OP_BRANCH, @@ -952,7 +952,7 @@ bool upb_pbdecoder_end(void *closure, const void *handler_data) { if (p != method->code_base.ptr) p--; if (getop(*p) == OP_CHECKDELIM) { /* Rewind from OP_TAG* to OP_CHECKDELIM. */ - assert(getop(*d->pc) == OP_TAG1 || + UPB_ASSERT(getop(*d->pc) == OP_TAG1 || getop(*d->pc) == OP_TAG2 || getop(*d->pc) == OP_TAGN || getop(*d->pc) == OP_DISPATCH); @@ -1016,7 +1016,7 @@ upb_pbdecoder *upb_pbdecoder_create(upb_env *e, const upb_pbdecodermethod *m, upb_pbdecoder_reset(d); upb_bytessink_reset(&d->input_, &m->input_handler_, d); - assert(sink); + UPB_ASSERT(sink); if (d->method_->dest_handlers_) { if (sink->handlers != d->method_->dest_handlers_) return NULL; @@ -1024,7 +1024,8 @@ upb_pbdecoder *upb_pbdecoder_create(upb_env *e, const upb_pbdecodermethod *m, upb_sink_reset(&d->top->sink, sink->handlers, sink->closure); /* If this fails, increase the value in decoder.h. */ - assert(upb_env_bytesallocated(e) - size_before <= UPB_PB_DECODER_SIZE); + UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(e) - size_before <= + UPB_PB_DECODER_SIZE); return d; } @@ -1045,7 +1046,7 @@ size_t upb_pbdecoder_maxnesting(const upb_pbdecoder *d) { } bool upb_pbdecoder_setmaxnesting(upb_pbdecoder *d, size_t max) { - assert(d->top >= d->stack); + UPB_ASSERT(d->top >= d->stack); if (max < (size_t)(d->top - d->stack)) { /* Can't set a limit smaller than what we are currently at. */ diff --git a/upb/pb/encoder.c b/upb/pb/encoder.c index 8f974a3..780425d 100644 --- a/upb/pb/encoder.c +++ b/upb/pb/encoder.c @@ -128,7 +128,7 @@ struct upb_pb_encoder { /* TODO(haberman): handle pushback */ static void putbuf(upb_pb_encoder *e, const char *buf, size_t len) { size_t n = upb_bytessink_putbuf(e->output_, e->subc, buf, len, NULL); - UPB_ASSERT_VAR(n, n == len); + UPB_ASSERT(n == len); } static upb_pb_encoder_segment *top(upb_pb_encoder *e) { @@ -168,7 +168,7 @@ static bool reserve(upb_pb_encoder *e, size_t bytes) { /* Call when "bytes" bytes have been writte at e->ptr. The caller *must* have * previously called reserve() with at least this many bytes. */ static void encoder_advance(upb_pb_encoder *e, size_t bytes) { - assert((size_t)(e->limit - e->ptr) >= bytes); + UPB_ASSERT((size_t)(e->limit - e->ptr) >= bytes); e->ptr += bytes; } @@ -203,7 +203,7 @@ static bool encode_bytes(upb_pb_encoder *e, const void *data, size_t len) { * length. */ static void accumulate(upb_pb_encoder *e) { size_t run_len; - assert(e->ptr >= e->runbegin); + UPB_ASSERT(e->ptr >= e->runbegin); run_len = e->ptr - e->runbegin; e->segptr->seglen += run_len; top(e)->msglen += run_len; @@ -558,7 +558,8 @@ upb_pb_encoder *upb_pb_encoder_create(upb_env *env, const upb_handlers *h, e->ptr = e->buf; /* If this fails, increase the value in encoder.h. */ - assert(upb_env_bytesallocated(env) - size_before <= UPB_PB_ENCODER_SIZE); + UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(env) - size_before <= + UPB_PB_ENCODER_SIZE); return e; } diff --git a/upb/pb/textprinter.c b/upb/pb/textprinter.c index b9ff8d4..abfc2eb 100644 --- a/upb/pb/textprinter.c +++ b/upb/pb/textprinter.c @@ -112,7 +112,7 @@ bool putf(upb_textprinter *p, const char *fmt, ...) { if (!str) return false; written = vsprintf(str, fmt, args); va_end(args); - UPB_ASSERT_VAR(written, written == len); + UPB_ASSERT(written == len); ok = upb_bytessink_putbuf(p->output_, p->subc, str, len, NULL); upb_gfree(str); diff --git a/upb/pb/varint.int.h b/upb/pb/varint.int.h index 735bcbe..c8d4929 100644 --- a/upb/pb/varint.int.h +++ b/upb/pb/varint.int.h @@ -154,9 +154,9 @@ UPB_INLINE uint64_t upb_vencode32(uint32_t val) { char buf[UPB_PB_VARINT_MAX_LEN]; size_t bytes = upb_vencode64(val, buf); uint64_t ret = 0; - assert(bytes <= 5); + UPB_ASSERT(bytes <= 5); memcpy(&ret, buf, bytes); - assert(ret <= 0xffffffffffU); + UPB_ASSERT(ret <= 0xffffffffffU); return ret; } diff --git a/upb/refcounted.c b/upb/refcounted.c index ce06708..f00dbb7 100644 --- a/upb/refcounted.c +++ b/upb/refcounted.c @@ -134,7 +134,7 @@ static trackedref *trackedref_new(bool is_ref2) { static void track(const upb_refcounted *r, const void *owner, bool ref2) { upb_value v; - assert(owner); + UPB_ASSERT(owner); if (owner == UPB_UNTRACKED_REF) return; upb_lock(); @@ -145,8 +145,8 @@ static void track(const upb_refcounted *r, const void *owner, bool ref2) { * tracking behavior we get with regular refs. Since ref2s only happen * inside upb, we'll accept this limitation until/unless there is a really * difficult upb-internal bug that can't be figured out without it. */ - assert(ref2); - assert(ref->is_ref2); + UPB_ASSERT(ref2); + UPB_ASSERT(ref->is_ref2); ref->count++; } else { trackedref *ref = trackedref_new(ref2); @@ -156,7 +156,7 @@ static void track(const upb_refcounted *r, const void *owner, bool ref2) { /* We know this cast is safe when it is a ref2, because it's coming from * another refcounted object. */ const upb_refcounted *from = owner; - assert(!upb_inttable_lookupptr(from->ref2s, r, NULL)); + UPB_ASSERT(!upb_inttable_lookupptr(from->ref2s, r, NULL)); upb_inttable_insertptr2(from->ref2s, r, upb_value_ptr(NULL), &upb_alloc_debugrefs); } @@ -169,15 +169,15 @@ static void untrack(const upb_refcounted *r, const void *owner, bool ref2) { bool found; trackedref *ref; - assert(owner); + UPB_ASSERT(owner); if (owner == UPB_UNTRACKED_REF) return; upb_lock(); found = upb_inttable_lookupptr(r->refs, owner, &v); /* This assert will fail if an owner attempts to release a ref it didn't have. */ - UPB_ASSERT_VAR(found, found); + UPB_ASSERT(found); ref = upb_value_getptr(v); - assert(ref->is_ref2 == ref2); + UPB_ASSERT(ref->is_ref2 == ref2); if (--ref->count == 0) { free(ref); upb_inttable_removeptr(r->refs, owner, NULL); @@ -186,7 +186,7 @@ static void untrack(const upb_refcounted *r, const void *owner, bool ref2) { * another refcounted object. */ const upb_refcounted *from = owner; bool removed = upb_inttable_removeptr(from->ref2s, r, NULL); - assert(removed); + UPB_ASSERT(removed); } } upb_unlock(); @@ -199,9 +199,9 @@ static void checkref(const upb_refcounted *r, const void *owner, bool ref2) { upb_lock(); found = upb_inttable_lookupptr(r->refs, owner, &v); - UPB_ASSERT_VAR(found, found); + UPB_ASSERT(found); ref = upb_value_getptr(v); - assert(ref->is_ref2 == ref2); + UPB_ASSERT(ref->is_ref2 == ref2); upb_unlock(); } @@ -222,7 +222,7 @@ static void getref2s(const upb_refcounted *owner, upb_inttable *tab) { /* To get the count we need to look in the target's table. */ found = upb_inttable_lookupptr(to->refs, owner, &v); - assert(found); + UPB_ASSERT(found); ref = upb_value_getptr(v); count = upb_value_int32(ref->count); @@ -244,12 +244,12 @@ static void visit_check(const upb_refcounted *obj, const upb_refcounted *subobj, bool removed; int32_t newcount; - assert(obj == s->obj); - assert(subobj); + UPB_ASSERT(obj == s->obj); + UPB_ASSERT(subobj); removed = upb_inttable_removeptr(ref2, subobj, &v); /* The following assertion will fail if the visit() function visits a subobj * that it did not have a ref2 on, or visits the same subobj too many times. */ - assert(removed); + UPB_ASSERT(removed); newcount = upb_value_getint32(v) - 1; if (newcount > 0) { upb_inttable_insert2(ref2, (uintptr_t)subobj, upb_value_int32(newcount), @@ -271,7 +271,7 @@ static void visit(const upb_refcounted *r, upb_refcounted_visit *v, if (r->vtbl->visit) r->vtbl->visit(r, visit_check, &state); /* This assertion will fail if the visit() function missed any children. */ - assert(upb_inttable_count(&state.ref2) == 0); + UPB_ASSERT(upb_inttable_count(&state.ref2) == 0); upb_inttable_uninit2(&state.ref2, &upb_alloc_debugrefs); if (r->vtbl->visit) r->vtbl->visit(r, v, closure); } @@ -378,7 +378,7 @@ static uint64_t trygetattr(const tarjan *t, const upb_refcounted *r) { static uint64_t getattr(const tarjan *t, const upb_refcounted *r) { upb_value v; bool found = upb_inttable_lookupptr(&t->objattr, r, &v); - UPB_ASSERT_VAR(found, found); + UPB_ASSERT(found); return upb_value_getuint64(v); } @@ -392,13 +392,13 @@ static color_t color(tarjan *t, const upb_refcounted *r) { } static void set_gray(tarjan *t, const upb_refcounted *r) { - assert(color(t, r) == BLACK); + UPB_ASSERT(color(t, r) == BLACK); setattr(t, r, GRAY); } /* Pushes an obj onto the Tarjan stack and sets it to GREEN. */ static void push(tarjan *t, const upb_refcounted *r) { - assert(color(t, r) == BLACK || color(t, r) == GRAY); + UPB_ASSERT(color(t, r) == BLACK || color(t, r) == GRAY); /* This defines the attr layout for the GREEN state. "index" and "lowlink" * get 31 bits, which is plenty (limit of 2B objects frozen at a time). */ setattr(t, r, GREEN | (t->index << 2) | (t->index << 33)); @@ -413,7 +413,7 @@ static void push(tarjan *t, const upb_refcounted *r) { * SCC group. */ static upb_refcounted *pop(tarjan *t) { upb_refcounted *r = upb_value_getptr(upb_inttable_pop(&t->stack)); - assert(color(t, r) == GREEN); + UPB_ASSERT(color(t, r) == GREEN); /* This defines the attr layout for nodes in the WHITE state. * Top of group stack is [group, NULL]; we point at group. */ setattr(t, r, WHITE | (upb_inttable_count(&t->groups) - 2) << 8); @@ -433,7 +433,7 @@ static void tarjan_newgroup(tarjan *t) { } static uint32_t idx(tarjan *t, const upb_refcounted *r) { - assert(color(t, r) == GREEN); + UPB_ASSERT(color(t, r) == GREEN); return (getattr(t, r) >> 2) & 0x7FFFFFFF; } @@ -446,7 +446,7 @@ static uint32_t lowlink(tarjan *t, const upb_refcounted *r) { } static void set_lowlink(tarjan *t, const upb_refcounted *r, uint32_t lowlink) { - assert(color(t, r) == GREEN); + UPB_ASSERT(color(t, r) == GREEN); setattr(t, r, ((uint64_t)lowlink << 33) | (getattr(t, r) & 0x1FFFFFFFF)); } @@ -455,10 +455,10 @@ static uint32_t *group(tarjan *t, upb_refcounted *r) { upb_value v; bool found; - assert(color(t, r) == WHITE); + UPB_ASSERT(color(t, r) == WHITE); groupnum = getattr(t, r) >> 8; found = upb_inttable_lookup(&t->groups, groupnum, &v); - UPB_ASSERT_VAR(found, found); + UPB_ASSERT(found); return upb_value_getptr(v); } @@ -469,10 +469,10 @@ static upb_refcounted *groupleader(tarjan *t, upb_refcounted *r) { upb_value v; bool found; - assert(color(t, r) == WHITE); + UPB_ASSERT(color(t, r) == WHITE); leader_slot = (getattr(t, r) >> 8) + 1; found = upb_inttable_lookup(&t->groups, leader_slot, &v); - UPB_ASSERT_VAR(found, found); + UPB_ASSERT(found); if (upb_value_getptr(v)) { return upb_value_getptr(v); } else { @@ -532,7 +532,7 @@ static void do_tarjan(const upb_refcounted *obj, tarjan *t) { static void crossref(const upb_refcounted *r, const upb_refcounted *subobj, void *_t) { tarjan *t = _t; - assert(color(t, r) > BLACK); + UPB_ASSERT(color(t, r) > BLACK); if (color(t, subobj) > BLACK && r->group != subobj->group) { /* Previously this ref was not reflected in subobj->group because they * were in the same group; now that they are split a ref must be taken. */ @@ -600,13 +600,13 @@ static bool freeze(upb_refcounted *const*roots, int n, upb_status *s, upb_refcounted *move = obj->next; if (obj == move) { /* Removing the last object from a group. */ - assert(*obj->group == obj->individual_count); + UPB_ASSERT(*obj->group == obj->individual_count); upb_gfree(obj->group); } else { obj->next = move->next; /* This may decrease to zero; we'll collect GRAY objects (if any) that * remain in the group in the third pass. */ - assert(*move->group >= move->individual_count); + UPB_ASSERT(*move->group >= move->individual_count); *move->group -= move->individual_count; } @@ -619,7 +619,7 @@ static bool freeze(upb_refcounted *const*roots, int n, upb_status *s, *move->group = move->individual_count; } else { /* Group already has at least one object in it. */ - assert(leader->group == group(&t, move)); + UPB_ASSERT(leader->group == group(&t, move)); move->group = group(&t, move); move->next = leader->next; leader->next = move; @@ -726,7 +726,7 @@ static void release_ref2(const upb_refcounted *obj, UPB_UNUSED(closure); untrack(subobj, obj, true); if (!merged(obj, subobj)) { - assert(subobj->is_frozen); + UPB_ASSERT(subobj->is_frozen); unref(subobj); } } @@ -745,7 +745,7 @@ static void unref(const upb_refcounted *r) { o = r; do { const upb_refcounted *next = o->next; - assert(o->is_frozen || o->individual_count == 0); + UPB_ASSERT(o->is_frozen || o->individual_count == 0); freeobj((upb_refcounted*)o); o = next; } while(o != r); @@ -769,9 +769,9 @@ bool upb_refcounted_init(upb_refcounted *r, * basically every program using upb. */ const int x = 1; #ifdef UPB_BIG_ENDIAN - assert(*(char*)&x != 1); + UPB_ASSERT(*(char*)&x != 1); #else - assert(*(char*)&x == 1); + UPB_ASSERT(*(char*)&x == 1); #endif #endif @@ -806,7 +806,7 @@ void upb_refcounted_unref(const upb_refcounted *r, const void *owner) { } void upb_refcounted_ref2(const upb_refcounted *r, upb_refcounted *from) { - assert(!from->is_frozen); /* Non-const pointer implies this. */ + UPB_ASSERT(!from->is_frozen); /* Non-const pointer implies this. */ track(r, from, true); if (r->is_frozen) { refgroup(r->group); @@ -816,18 +816,18 @@ void upb_refcounted_ref2(const upb_refcounted *r, upb_refcounted *from) { } void upb_refcounted_unref2(const upb_refcounted *r, upb_refcounted *from) { - assert(!from->is_frozen); /* Non-const pointer implies this. */ + UPB_ASSERT(!from->is_frozen); /* Non-const pointer implies this. */ untrack(r, from, true); if (r->is_frozen) { unref(r); } else { - assert(merged(r, from)); + UPB_ASSERT(merged(r, from)); } } void upb_refcounted_donateref( const upb_refcounted *r, const void *from, const void *to) { - assert(from != to); + UPB_ASSERT(from != to); if (to != NULL) upb_refcounted_ref(r, to); if (from != NULL) @@ -843,9 +843,9 @@ bool upb_refcounted_freeze(upb_refcounted *const*roots, int n, upb_status *s, int i; bool ret; for (i = 0; i < n; i++) { - assert(!roots[i]->is_frozen); + UPB_ASSERT(!roots[i]->is_frozen); } ret = freeze(roots, n, s, maxdepth); - assert(!s || ret == upb_ok(s)); + UPB_ASSERT(!s || ret == upb_ok(s)); return ret; } diff --git a/upb/refcounted.h b/upb/refcounted.h index 115fc43..6698d38 100644 --- a/upb/refcounted.h +++ b/upb/refcounted.h @@ -258,7 +258,7 @@ template <class T> class upb::reffed_ptr { reffed_ptr(U* val, const void* ref_donor = NULL) : ptr_(upb::upcast(val)) { if (ref_donor) { - assert(ptr_); + UPB_ASSERT(ptr_); ptr_->DonateRef(ref_donor, this); } else if (ptr_) { ptr_->Ref(this); @@ -303,12 +303,12 @@ template <class T> class upb::reffed_ptr { } T& operator*() const { - assert(ptr_); + UPB_ASSERT(ptr_); return *ptr_; } T* operator->() const { - assert(ptr_); + UPB_ASSERT(ptr_); return ptr_; } diff --git a/upb/shim/shim.c b/upb/shim/shim.c index b8a43f5..1429332 100644 --- a/upb/shim/shim.c +++ b/upb/shim/shim.c @@ -50,7 +50,7 @@ bool upb_shim_set(upb_handlers *h, const upb_fielddef *f, size_t offset, TYPE(DOUBLE, double); TYPE(FLOAT, float); TYPE(BOOL, bool); - default: assert(false); break; + default: UPB_ASSERT(false); break; } #undef TYPE diff --git a/upb/symtab.c b/upb/symtab.c index 8b9e449..7d1aa76 100644 --- a/upb/symtab.c +++ b/upb/symtab.c @@ -33,13 +33,13 @@ void upb_symtab_freeze(upb_symtab *s) { upb_refcounted *r; bool ok; - assert(!upb_symtab_isfrozen(s)); + UPB_ASSERT(!upb_symtab_isfrozen(s)); r = upb_symtab_upcast_mutable(s); /* The symtab does not take ref2's (see refcounted.h) on the defs, because * defs cannot refer back to the table and therefore cannot create cycles. So * 0 will suffice for maxdepth here. */ ok = upb_refcounted_freeze(&r, 1, NULL, 0); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); } const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym) { @@ -77,7 +77,7 @@ static upb_def *upb_resolvename(const upb_strtable *t, /* Remove components from base until we find an entry or run out. * TODO: This branch is totally broken, but currently not used. */ (void)base; - assert(false); + UPB_ASSERT(false); return NULL; } } @@ -139,7 +139,7 @@ static bool upb_resolve_dfs(const upb_def *def, upb_strtable *addtab, upb_value v; const upb_msgdef *m; - assert(upb_def_isfrozen(def)); + UPB_ASSERT(upb_def_isfrozen(def)); if (def->type == UPB_DEF_FIELD) continue; if (upb_strtable_lookup(addtab, upb_def_fullname(def), &v)) { need_dup = true; @@ -214,7 +214,7 @@ static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n, return true; } - assert(!upb_symtab_isfrozen(s)); + UPB_ASSERT(!upb_symtab_isfrozen(s)); if (!upb_strtable_init(&addtab, UPB_CTYPE_PTR)) { upb_status_seterrmsg(status, "out of memory"); return false; @@ -230,7 +230,7 @@ static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n, upb_status_seterrmsg(status, "added defs must be mutable"); goto err; } - assert(!upb_def_isfrozen(def)); + UPB_ASSERT(!upb_def_isfrozen(def)); fullname = upb_def_fullname(def); if (!fullname) { upb_status_seterrmsg( @@ -274,7 +274,7 @@ static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n, if (!f) continue; msgname = upb_fielddef_containingtypename(f); /* We validated this earlier in this function. */ - assert(msgname); + UPB_ASSERT(msgname); /* If the extendee name is absolutely qualified, move past the initial ".". * TODO(haberman): it is not obvious what it would mean if this was not @@ -405,7 +405,7 @@ static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n, upb_def_unref(def, s); } success = upb_strtable_insert(&s->symtab, name, upb_value_ptr(def)); - UPB_ASSERT_VAR(success, success == true); + UPB_ASSERT(success == true); } upb_gfree(add_defs); return true; @@ -429,7 +429,7 @@ err: { } upb_strtable_uninit(&addtab); upb_gfree(add_defs); - assert(!upb_ok(status)); + UPB_ASSERT(!upb_ok(status)); return false; } diff --git a/upb/table.c b/upb/table.c index 53f757e..286e08f 100644 --- a/upb/table.c +++ b/upb/table.c @@ -14,16 +14,11 @@ #define ARRAY_SIZE(x) \ ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x]))))) -#ifdef NDEBUG static void upb_check_alloc(upb_table *t, upb_alloc *a) { UPB_UNUSED(t); UPB_UNUSED(a); + UPB_ASSERT_DEBUGVAR(t->alloc == a); } -#else -static void upb_check_alloc(upb_table *t, upb_alloc *a) { - assert(t->alloc == a); -} -#endif static const double MAX_LOAD = 0.85; @@ -132,7 +127,7 @@ static void uninit(upb_table *t, upb_alloc *a) { static upb_tabent *emptyent(upb_table *t) { upb_tabent *e = mutable_entries(t) + upb_table_size(t); - while (1) { if (upb_tabent_isempty(--e)) return e; assert(e > t->entries); } + while (1) { if (upb_tabent_isempty(--e)) return e; UPB_ASSERT(e > t->entries); } } static upb_tabent *getentry_mutable(upb_table *t, uint32_t hash) { @@ -177,10 +172,8 @@ static void insert(upb_table *t, lookupkey_t key, upb_tabkey tabkey, upb_tabent *mainpos_e; upb_tabent *our_e; - UPB_UNUSED(eql); - UPB_UNUSED(key); - assert(findentry(t, key, hash, eql) == NULL); - assert(val.ctype == t->ctype); + UPB_ASSERT(findentry(t, key, hash, eql) == NULL); + UPB_ASSERT_DEBUGVAR(val.ctype == t->ctype); t->count++; mainpos_e = getentry_mutable(t, hash); @@ -207,7 +200,7 @@ static void insert(upb_table *t, lookupkey_t key, upb_tabkey tabkey, *new_e = *mainpos_e; /* copies next. */ while (chain->next != mainpos_e) { chain = (upb_tabent*)chain->next; - assert(chain); + UPB_ASSERT(chain); } chain->next = new_e; our_e = mainpos_e; @@ -216,7 +209,7 @@ static void insert(upb_table *t, lookupkey_t key, upb_tabkey tabkey, } our_e->key = tabkey; our_e->val.val = val.val; - assert(findentry(t, key, hash, eql) == our_e); + UPB_ASSERT(findentry(t, key, hash, eql) == our_e); } static bool rm(upb_table *t, lookupkey_t key, upb_value *val, @@ -397,19 +390,19 @@ bool upb_strtable_done(const upb_strtable_iter *i) { } const char *upb_strtable_iter_key(const upb_strtable_iter *i) { - assert(!upb_strtable_done(i)); + UPB_ASSERT(!upb_strtable_done(i)); return upb_tabstr(str_tabent(i)->key, NULL); } size_t upb_strtable_iter_keylength(const upb_strtable_iter *i) { uint32_t len; - assert(!upb_strtable_done(i)); + UPB_ASSERT(!upb_strtable_done(i)); upb_tabstr(str_tabent(i)->key, &len); return len; } upb_value upb_strtable_iter_value(const upb_strtable_iter *i) { - assert(!upb_strtable_done(i)); + UPB_ASSERT(!upb_strtable_done(i)); return _upb_value_val(str_tabent(i)->val.val, i->t->t.ctype); } @@ -468,9 +461,9 @@ static void check(upb_inttable *t) { upb_inttable_iter i; upb_inttable_begin(&i, t); for(; !upb_inttable_done(&i); upb_inttable_next(&i), count++) { - assert(upb_inttable_lookup(t, upb_inttable_iter_key(&i), NULL)); + UPB_ASSERT(upb_inttable_lookup(t, upb_inttable_iter_key(&i), NULL)); } - assert(count == upb_inttable_count(t)); + UPB_ASSERT(count == upb_inttable_count(t)); } #endif } @@ -508,13 +501,12 @@ bool upb_inttable_insert2(upb_inttable *t, uintptr_t key, upb_value val, upb_alloc *a) { upb_tabval tabval; tabval.val = val.val; - UPB_UNUSED(tabval); - assert(upb_arrhas(tabval)); /* This will reject (uint64_t)-1. Fix this. */ + UPB_ASSERT(upb_arrhas(tabval)); /* This will reject (uint64_t)-1. Fix this. */ upb_check_alloc(&t->t, a); if (key < t->array_size) { - assert(!upb_arrhas(t->array[key])); + UPB_ASSERT(!upb_arrhas(t->array[key])); t->array_count++; mutable_array(t)[key].val = val.val; } else { @@ -537,7 +529,7 @@ bool upb_inttable_insert2(upb_inttable *t, uintptr_t key, upb_value val, insert(&new_table, intkey(e->key), e->key, v, hash, &inthash, &inteql); } - assert(t->t.count == new_table.count); + UPB_ASSERT(t->t.count == new_table.count); uninit(&t->t, a); t->t = new_table; @@ -593,7 +585,7 @@ bool upb_inttable_push2(upb_inttable *t, upb_value val, upb_alloc *a) { upb_value upb_inttable_pop(upb_inttable *t) { upb_value val; bool ok = upb_inttable_remove(t, upb_inttable_count(t) - 1, &val); - UPB_ASSERT_VAR(ok, ok); + UPB_ASSERT(ok); return val; } @@ -649,7 +641,7 @@ void upb_inttable_compact2(upb_inttable *t, upb_alloc *a) { arr_count -= counts[size_lg2]; } - assert(arr_count <= upb_inttable_count(t)); + UPB_ASSERT(arr_count <= upb_inttable_count(t)); { /* Insert all elements into new, perfectly-sized table. */ @@ -664,8 +656,8 @@ void upb_inttable_compact2(upb_inttable *t, upb_alloc *a) { uintptr_t k = upb_inttable_iter_key(&i); upb_inttable_insert2(&new_t, k, upb_inttable_iter_value(&i), a); } - assert(new_t.array_size == arr_size); - assert(new_t.t.size_lg2 == hashsize_lg2); + UPB_ASSERT(new_t.array_size == arr_size); + UPB_ASSERT(new_t.t.size_lg2 == hashsize_lg2); } upb_inttable_uninit2(t, a); *t = new_t; @@ -674,12 +666,12 @@ void upb_inttable_compact2(upb_inttable *t, upb_alloc *a) { /* Iteration. */ static const upb_tabent *int_tabent(const upb_inttable_iter *i) { - assert(!i->array_part); + UPB_ASSERT(!i->array_part); return &i->t->t.entries[i->index]; } static upb_tabval int_arrent(const upb_inttable_iter *i) { - assert(i->array_part); + UPB_ASSERT(i->array_part); return i->t->array[i->index]; } @@ -716,12 +708,12 @@ bool upb_inttable_done(const upb_inttable_iter *i) { } uintptr_t upb_inttable_iter_key(const upb_inttable_iter *i) { - assert(!upb_inttable_done(i)); + UPB_ASSERT(!upb_inttable_done(i)); return i->array_part ? i->index : int_tabent(i)->key; } upb_value upb_inttable_iter_value(const upb_inttable_iter *i) { - assert(!upb_inttable_done(i)); + UPB_ASSERT(!upb_inttable_done(i)); return _upb_value_val( i->array_part ? i->t->array[i->index].val : int_tabent(i)->val.val, i->t->t.ctype); diff --git a/upb/table.int.h b/upb/table.int.h index 131a74f..f0b395a 100644 --- a/upb/table.int.h +++ b/upb/table.int.h @@ -20,7 +20,6 @@ #ifndef UPB_TABLE_H_ #define UPB_TABLE_H_ -#include <assert.h> #include <stdint.h> #include <string.h> #include "upb/upb.h" @@ -103,7 +102,7 @@ UPB_INLINE upb_value _upb_value_val(uint64_t val, upb_ctype_t ctype) { return ret; \ } \ UPB_INLINE type_t upb_value_get ## name(upb_value val) { \ - assert(val.ctype == proto_type); \ + UPB_ASSERT_DEBUGVAR(val.ctype == proto_type); \ return (type_t)(converter)val.val; \ } @@ -21,7 +21,7 @@ bool upb_dumptostderr(void *closure, const upb_status* status) { static void nullz(upb_status *status) { const char *ellipsis = "..."; size_t len = strlen(ellipsis); - assert(sizeof(status->msg) > len); + UPB_ASSERT(sizeof(status->msg) > len); memcpy(status->msg + sizeof(status->msg) - len, ellipsis, len); } @@ -196,10 +196,17 @@ template <int N> class InlinedEnvironment; #define UPB_UNUSED(var) (void)var -/* For asserting something about a variable when the variable is not used for - * anything else. This prevents "unused variable" warnings when compiling in - * debug mode. */ -#define UPB_ASSERT_VAR(var, predicate) UPB_UNUSED(var); assert(predicate) +/* UPB_ASSERT(): in release mode, we use the expression without letting it be + * evaluated. This prevents "unused variable" warnings. */ +#ifdef NDEBUG +#define UPB_ASSERT(expr) do {} while (false && (expr)) +#else +#define UPB_ASSERT(expr) assert(expr) +#endif + +/* UPB_ASSERT_DEBUGVAR(): assert that uses functions or variables that only + * exist in debug mode. This turns into regular assert. */ +#define UPB_ASSERT_DEBUGVAR(expr) assert(expr) /* Generic function type. */ typedef void upb_func(); @@ -434,13 +441,13 @@ struct upb_alloc { }; UPB_INLINE void *upb_malloc(upb_alloc *alloc, size_t size) { - assert(size > 0); + UPB_ASSERT(size > 0); return alloc->func(alloc, NULL, 0, size); } UPB_INLINE void *upb_realloc(upb_alloc *alloc, void *ptr, size_t oldsize, size_t size) { - assert(size > 0); + UPB_ASSERT(size > 0); return alloc->func(alloc, ptr, oldsize, size); } |