From c223b2e1fa96feac05f275853e64a87993d557a2 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Wed, 4 Mar 2026 15:16:29 +0000 Subject: [PATCH] Auto-generate files after cl/878471014 --- php/ext/google/protobuf/php-upb.c | 56 +++++++++++++++++++++------ php/ext/google/protobuf/php-upb.h | 18 ++++++++- ruby/ext/google/protobuf_c/ruby-upb.c | 56 +++++++++++++++++++++------ ruby/ext/google/protobuf_c/ruby-upb.h | 18 ++++++++- 4 files changed, 122 insertions(+), 26 deletions(-) diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index 39450d4f5a..17e9bda33b 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -11763,7 +11763,7 @@ void _upb_DefPool_SetPlatform(upb_DefPool* s, upb_MiniTablePlatform platform) { const upb_MessageDef* upb_DefPool_FindMessageByName(const upb_DefPool* s, const char* sym) { - return _upb_DefPool_Unpack(s, sym, strlen(sym), UPB_DEFTYPE_MSG); + return upb_DefPool_FindMessageByNameWithSize(s, sym, strlen(sym)); } const upb_MessageDef* upb_DefPool_FindMessageByNameWithSize( @@ -11773,12 +11773,23 @@ const upb_MessageDef* upb_DefPool_FindMessageByNameWithSize( const upb_EnumDef* upb_DefPool_FindEnumByName(const upb_DefPool* s, const char* sym) { - return _upb_DefPool_Unpack(s, sym, strlen(sym), UPB_DEFTYPE_ENUM); + return upb_DefPool_FindEnumByNameWithSize(s, sym, strlen(sym)); } -const upb_EnumValueDef* upb_DefPool_FindEnumByNameval(const upb_DefPool* s, - const char* sym) { - return _upb_DefPool_Unpack(s, sym, strlen(sym), UPB_DEFTYPE_ENUMVAL); +const upb_EnumDef* upb_DefPool_FindEnumByNameWithSize(const upb_DefPool* s, + const char* sym, + size_t len) { + return _upb_DefPool_Unpack(s, sym, len, UPB_DEFTYPE_ENUM); +} + +const upb_EnumValueDef* upb_DefPool_FindEnumValueByName(const upb_DefPool* s, + const char* sym) { + return upb_DefPool_FindEnumValueByNameWithSize(s, sym, strlen(sym)); +} + +const upb_EnumValueDef* upb_DefPool_FindEnumValueByNameWithSize( + const upb_DefPool* s, const char* sym, size_t len) { + return _upb_DefPool_Unpack(s, sym, len, UPB_DEFTYPE_ENUMVAL); } const upb_FileDef* upb_DefPool_FindFileByName(const upb_DefPool* s, @@ -15691,6 +15702,7 @@ static void create_method(upb_DefBuilder* ctx, m->output_type = _upb_DefBuilder_Resolve( ctx, m->full_name, m->full_name, google_protobuf_MethodDescriptorProto_output_type(method_proto), UPB_DEFTYPE_MSG); + _upb_ServiceDef_InsertMethod(ctx, s, m); } // Allocate and initialize an array of |n| method defs belonging to |s|. @@ -15922,6 +15934,7 @@ struct upb_ServiceDef { upb_MethodDef* methods; int method_count; int index; + upb_strtable ntom; }; upb_ServiceDef* _upb_ServiceDef_At(const upb_ServiceDef* s, int index) { @@ -15966,13 +15979,18 @@ const upb_MethodDef* upb_ServiceDef_Method(const upb_ServiceDef* s, int i) { const upb_MethodDef* upb_ServiceDef_FindMethodByName(const upb_ServiceDef* s, const char* name) { - for (int i = 0; i < s->method_count; i++) { - const upb_MethodDef* m = _upb_MethodDef_At(s->methods, i); - if (strcmp(name, upb_MethodDef_Name(m)) == 0) { - return m; - } + return upb_ServiceDef_FindMethodByNameWithSize(s, name, strlen(name)); +} + +const upb_MethodDef* upb_ServiceDef_FindMethodByNameWithSize( + const upb_ServiceDef* s, const char* name, size_t len) { + upb_value val; + + if (!upb_strtable_lookup2(&s->ntom, name, len, &val)) { + return NULL; } - return NULL; + + return _upb_DefType_Unpack(val, UPB_DEFTYPE_METHOD); } static void create_service(upb_DefBuilder* ctx, @@ -15997,6 +16015,8 @@ static void create_service(upb_DefBuilder* ctx, const google_protobuf_MethodDescriptorProto* const* methods = google_protobuf_ServiceDescriptorProto_method(svc_proto, &n); s->method_count = n; + bool ok = upb_strtable_init(&s->ntom, n, ctx->arena); + if (!ok) _upb_DefBuilder_OomErr(ctx); s->methods = _upb_MethodDefs_New(ctx, n, methods, s->resolved_features, s); } @@ -16014,6 +16034,20 @@ upb_ServiceDef* _upb_ServiceDefs_New( return s; } +void _upb_ServiceDef_InsertMethod(upb_DefBuilder* ctx, upb_ServiceDef* s, + const upb_MethodDef* m) { + const char* shortname = upb_MethodDef_Name(m); + const size_t shortnamelen = strlen(shortname); + upb_value existing_v; + if (upb_strtable_lookup(&s->ntom, shortname, &existing_v)) { + _upb_DefBuilder_Errf(ctx, "duplicate method name (%s)", shortname); + } + const upb_value method_v = _upb_DefType_Pack(m, UPB_DEFTYPE_METHOD); + bool ok = upb_strtable_insert(&s->ntom, shortname, shortnamelen, method_v, + ctx->arena); + if (!ok) _upb_DefBuilder_OomErr(ctx); +} + #include #include diff --git a/php/ext/google/protobuf/php-upb.h b/php/ext/google/protobuf/php-upb.h index 585a0fa679..ef82bb72b7 100644 --- a/php/ext/google/protobuf/php-upb.h +++ b/php/ext/google/protobuf/php-upb.h @@ -14086,6 +14086,9 @@ typedef enum { // Only inside message table. UPB_DEFTYPE_FIELD = 0, UPB_DEFTYPE_ONEOF = 1, + + // Only inside service table. + UPB_DEFTYPE_METHOD = 0, } upb_deftype_t; #ifdef __cplusplus @@ -14144,8 +14147,14 @@ const upb_MessageDef* upb_DefPool_FindMessageByNameWithSize( UPB_API const upb_EnumDef* upb_DefPool_FindEnumByName(const upb_DefPool* s, const char* sym); -const upb_EnumValueDef* upb_DefPool_FindEnumByNameval(const upb_DefPool* s, - const char* sym); +UPB_API const upb_EnumDef* upb_DefPool_FindEnumByNameWithSize( + const upb_DefPool* s, const char* sym, size_t len); + +UPB_API const upb_EnumValueDef* upb_DefPool_FindEnumValueByName( + const upb_DefPool* s, const char* sym); + +UPB_API const upb_EnumValueDef* upb_DefPool_FindEnumValueByNameWithSize( + const upb_DefPool* s, const char* sym, size_t len); UPB_API const upb_FileDef* upb_DefPool_FindFileByName(const upb_DefPool* s, const char* name); @@ -14695,6 +14704,8 @@ extern "C" { UPB_API const upb_FileDef* upb_ServiceDef_File(const upb_ServiceDef* s); const upb_MethodDef* upb_ServiceDef_FindMethodByName(const upb_ServiceDef* s, const char* name); +const upb_MethodDef* upb_ServiceDef_FindMethodByNameWithSize( + const upb_ServiceDef* s, const char* name, size_t len); UPB_API const char* upb_ServiceDef_FullName(const upb_ServiceDef* s); bool upb_ServiceDef_HasOptions(const upb_ServiceDef* s); int upb_ServiceDef_Index(const upb_ServiceDef* s); @@ -17619,6 +17630,9 @@ upb_ServiceDef* _upb_ServiceDefs_New( const google_protobuf_ServiceDescriptorProto* const* protos, const google_protobuf_FeatureSet* parent_features); +void _upb_ServiceDef_InsertMethod(upb_DefBuilder* ctx, upb_ServiceDef* s, + const upb_MethodDef* m); + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index 33396acb4b..4cd305401f 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -10619,7 +10619,7 @@ void _upb_DefPool_SetPlatform(upb_DefPool* s, upb_MiniTablePlatform platform) { const upb_MessageDef* upb_DefPool_FindMessageByName(const upb_DefPool* s, const char* sym) { - return _upb_DefPool_Unpack(s, sym, strlen(sym), UPB_DEFTYPE_MSG); + return upb_DefPool_FindMessageByNameWithSize(s, sym, strlen(sym)); } const upb_MessageDef* upb_DefPool_FindMessageByNameWithSize( @@ -10629,12 +10629,23 @@ const upb_MessageDef* upb_DefPool_FindMessageByNameWithSize( const upb_EnumDef* upb_DefPool_FindEnumByName(const upb_DefPool* s, const char* sym) { - return _upb_DefPool_Unpack(s, sym, strlen(sym), UPB_DEFTYPE_ENUM); + return upb_DefPool_FindEnumByNameWithSize(s, sym, strlen(sym)); } -const upb_EnumValueDef* upb_DefPool_FindEnumByNameval(const upb_DefPool* s, - const char* sym) { - return _upb_DefPool_Unpack(s, sym, strlen(sym), UPB_DEFTYPE_ENUMVAL); +const upb_EnumDef* upb_DefPool_FindEnumByNameWithSize(const upb_DefPool* s, + const char* sym, + size_t len) { + return _upb_DefPool_Unpack(s, sym, len, UPB_DEFTYPE_ENUM); +} + +const upb_EnumValueDef* upb_DefPool_FindEnumValueByName(const upb_DefPool* s, + const char* sym) { + return upb_DefPool_FindEnumValueByNameWithSize(s, sym, strlen(sym)); +} + +const upb_EnumValueDef* upb_DefPool_FindEnumValueByNameWithSize( + const upb_DefPool* s, const char* sym, size_t len) { + return _upb_DefPool_Unpack(s, sym, len, UPB_DEFTYPE_ENUMVAL); } const upb_FileDef* upb_DefPool_FindFileByName(const upb_DefPool* s, @@ -14547,6 +14558,7 @@ static void create_method(upb_DefBuilder* ctx, m->output_type = _upb_DefBuilder_Resolve( ctx, m->full_name, m->full_name, google_protobuf_MethodDescriptorProto_output_type(method_proto), UPB_DEFTYPE_MSG); + _upb_ServiceDef_InsertMethod(ctx, s, m); } // Allocate and initialize an array of |n| method defs belonging to |s|. @@ -14778,6 +14790,7 @@ struct upb_ServiceDef { upb_MethodDef* methods; int method_count; int index; + upb_strtable ntom; }; upb_ServiceDef* _upb_ServiceDef_At(const upb_ServiceDef* s, int index) { @@ -14822,13 +14835,18 @@ const upb_MethodDef* upb_ServiceDef_Method(const upb_ServiceDef* s, int i) { const upb_MethodDef* upb_ServiceDef_FindMethodByName(const upb_ServiceDef* s, const char* name) { - for (int i = 0; i < s->method_count; i++) { - const upb_MethodDef* m = _upb_MethodDef_At(s->methods, i); - if (strcmp(name, upb_MethodDef_Name(m)) == 0) { - return m; - } + return upb_ServiceDef_FindMethodByNameWithSize(s, name, strlen(name)); +} + +const upb_MethodDef* upb_ServiceDef_FindMethodByNameWithSize( + const upb_ServiceDef* s, const char* name, size_t len) { + upb_value val; + + if (!upb_strtable_lookup2(&s->ntom, name, len, &val)) { + return NULL; } - return NULL; + + return _upb_DefType_Unpack(val, UPB_DEFTYPE_METHOD); } static void create_service(upb_DefBuilder* ctx, @@ -14853,6 +14871,8 @@ static void create_service(upb_DefBuilder* ctx, const google_protobuf_MethodDescriptorProto* const* methods = google_protobuf_ServiceDescriptorProto_method(svc_proto, &n); s->method_count = n; + bool ok = upb_strtable_init(&s->ntom, n, ctx->arena); + if (!ok) _upb_DefBuilder_OomErr(ctx); s->methods = _upb_MethodDefs_New(ctx, n, methods, s->resolved_features, s); } @@ -14870,6 +14890,20 @@ upb_ServiceDef* _upb_ServiceDefs_New( return s; } +void _upb_ServiceDef_InsertMethod(upb_DefBuilder* ctx, upb_ServiceDef* s, + const upb_MethodDef* m) { + const char* shortname = upb_MethodDef_Name(m); + const size_t shortnamelen = strlen(shortname); + upb_value existing_v; + if (upb_strtable_lookup(&s->ntom, shortname, &existing_v)) { + _upb_DefBuilder_Errf(ctx, "duplicate method name (%s)", shortname); + } + const upb_value method_v = _upb_DefType_Pack(m, UPB_DEFTYPE_METHOD); + bool ok = upb_strtable_insert(&s->ntom, shortname, shortnamelen, method_v, + ctx->arena); + if (!ok) _upb_DefBuilder_OomErr(ctx); +} + #include #include diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h index ecd2065102..b37b2c55a1 100755 --- a/ruby/ext/google/protobuf_c/ruby-upb.h +++ b/ruby/ext/google/protobuf_c/ruby-upb.h @@ -14123,6 +14123,9 @@ typedef enum { // Only inside message table. UPB_DEFTYPE_FIELD = 0, UPB_DEFTYPE_ONEOF = 1, + + // Only inside service table. + UPB_DEFTYPE_METHOD = 0, } upb_deftype_t; #ifdef __cplusplus @@ -14181,8 +14184,14 @@ const upb_MessageDef* upb_DefPool_FindMessageByNameWithSize( UPB_API const upb_EnumDef* upb_DefPool_FindEnumByName(const upb_DefPool* s, const char* sym); -const upb_EnumValueDef* upb_DefPool_FindEnumByNameval(const upb_DefPool* s, - const char* sym); +UPB_API const upb_EnumDef* upb_DefPool_FindEnumByNameWithSize( + const upb_DefPool* s, const char* sym, size_t len); + +UPB_API const upb_EnumValueDef* upb_DefPool_FindEnumValueByName( + const upb_DefPool* s, const char* sym); + +UPB_API const upb_EnumValueDef* upb_DefPool_FindEnumValueByNameWithSize( + const upb_DefPool* s, const char* sym, size_t len); UPB_API const upb_FileDef* upb_DefPool_FindFileByName(const upb_DefPool* s, const char* name); @@ -14732,6 +14741,8 @@ extern "C" { UPB_API const upb_FileDef* upb_ServiceDef_File(const upb_ServiceDef* s); const upb_MethodDef* upb_ServiceDef_FindMethodByName(const upb_ServiceDef* s, const char* name); +const upb_MethodDef* upb_ServiceDef_FindMethodByNameWithSize( + const upb_ServiceDef* s, const char* name, size_t len); UPB_API const char* upb_ServiceDef_FullName(const upb_ServiceDef* s); bool upb_ServiceDef_HasOptions(const upb_ServiceDef* s); int upb_ServiceDef_Index(const upb_ServiceDef* s); @@ -17421,6 +17432,9 @@ upb_ServiceDef* _upb_ServiceDefs_New( const google_protobuf_ServiceDescriptorProto* const* protos, const google_protobuf_FeatureSet* parent_features); +void _upb_ServiceDef_InsertMethod(upb_DefBuilder* ctx, upb_ServiceDef* s, + const upb_MethodDef* m); + #ifdef __cplusplus } /* extern "C" */ #endif