Use consistent name for the "get item from untyped map iterator" thunk

It now uses the same prefix as other thunks needed for the proxied type,
so the RawMapThunk helper can be used for enums.

Calling it a "iter next" thunk is misleading.
It does not increment the iterator as "next" implies,
it only gets the current key/value the iterator points to.

PiperOrigin-RevId: 609527442
pull/15902/head
Alyssa Haroldsen 1 year ago committed by Copybara-Service
parent 5d876c9fec
commit dd27b6b877
  1. 4
      rust/cpp.rs
  2. 2
      rust/cpp_kernel/cpp_api.cc
  3. 14
      src/google/protobuf/compiler/rust/message.cc

@ -514,7 +514,7 @@ macro_rules! impl_ProxiedInMapValue_for_non_generated_value_types {
fn [< __rust_proto_thunk__Map_ $key_t _ $t _insert >](m: RawMap, key: $ffi_key_t, value: $ffi_t) -> bool;
fn [< __rust_proto_thunk__Map_ $key_t _ $t _get >](m: RawMap, key: $ffi_key_t, value: *mut $ffi_t) -> bool;
fn [< __rust_proto_thunk__Map_ $key_t _ $t _iter >](m: RawMap) -> UntypedMapIterator;
fn [< __rust_proto_thunk__MapIter_ $key_t _ $t _get >](iter: &mut UntypedMapIterator, key: *mut $ffi_key_t, value: *mut $ffi_t);
fn [< __rust_proto_thunk__Map_ $key_t _ $t _iter_get >](iter: &mut UntypedMapIterator, key: *mut $ffi_key_t, value: *mut $ffi_t);
fn [< __rust_proto_thunk__Map_ $key_t _ $t _remove >](m: RawMap, key: $ffi_key_t, value: *mut $ffi_t) -> bool;
}
@ -595,7 +595,7 @@ macro_rules! impl_ProxiedInMapValue_for_non_generated_value_types {
unsafe {
iter.as_raw_mut(Private).next_unchecked::<$key_t, Self, _, _>(
Private,
[< __rust_proto_thunk__MapIter_ $key_t _ $t _get >],
[< __rust_proto_thunk__Map_ $key_t _ $t _iter_get >],
$from_ffi_key,
$from_ffi_value,
)

@ -142,7 +142,7 @@ void __rust_proto_thunk__UntypedMapIterator_increment(
const google::protobuf::Map<key_ty, value_ty>* m) { \
return google::protobuf::internal::UntypedMapIterator::FromTyped(m->cbegin()); \
} \
void __rust_proto_thunk__MapIter_##rust_key_ty##_##rust_value_ty##_get( \
void __rust_proto_thunk__Map_##rust_key_ty##_##rust_value_ty##_iter_get( \
const google::protobuf::internal::UntypedMapIterator* iter, ffi_key_ty* key, \
ffi_value_ty* value) { \
auto typed_iter = \

@ -421,8 +421,8 @@ void MessageProxiedInMapValue(Context& ctx, const Descriptor& msg) {
{"map_remove_thunk",
RawMapThunk(ctx, msg, t.thunk_ident, "remove")},
{"map_iter_thunk", RawMapThunk(ctx, msg, t.thunk_ident, "iter")},
{"map_iter_next_thunk",
RawMapThunk(ctx, msg, t.thunk_ident, "iter_next")},
{"map_iter_get_thunk",
RawMapThunk(ctx, msg, t.thunk_ident, "iter_get")},
{"key_expr", t.rs_to_ffi_key_expr},
io::Printer::Sub("ffi_key_t", [&] { ctx.Emit(t.rs_ffi_key_t); })
.WithSuffix(""),
@ -441,7 +441,7 @@ void MessageProxiedInMapValue(Context& ctx, const Descriptor& msg) {
fn $map_get_thunk$(m: $pbi$::RawMap, key: $ffi_key_t$, value: *mut $pbi$::RawMessage) -> bool;
fn $map_remove_thunk$(m: $pbi$::RawMap, key: $ffi_key_t$, value: *mut $pbi$::RawMessage) -> bool;
fn $map_iter_thunk$(m: $pbi$::RawMap) -> $pbr$::UntypedMapIterator;
fn $map_iter_next_thunk$(iter: &mut $pbr$::UntypedMapIterator, key: *mut $ffi_key_t$, value: *mut $pbi$::RawMessage);
fn $map_iter_get_thunk$(iter: &mut $pbr$::UntypedMapIterator, key: *mut $ffi_key_t$, value: *mut $pbi$::RawMessage);
}
impl $pb$::ProxiedInMapValue<$key_t$> for $Msg$ {
fn map_new(_private: $pbi$::Private) -> $pb$::Map<$key_t$, Self> {
@ -508,7 +508,7 @@ void MessageProxiedInMapValue(Context& ctx, const Descriptor& msg) {
unsafe {
iter.as_raw_mut($pbi$::Private).next_unchecked::<$key_t$, Self, _, _>(
$pbi$::Private,
$map_iter_next_thunk$,
$map_iter_get_thunk$,
|ffi_key| $from_ffi_key_expr$,
|raw_msg| $Msg$View::new($pbi$::Private, raw_msg)
)
@ -1206,8 +1206,8 @@ void GenerateThunksCc(Context& ctx, const Descriptor& msg) {
{"map_remove_thunk",
RawMapThunk(ctx, msg, t.thunk_ident, "remove")},
{"map_iter_thunk", RawMapThunk(ctx, msg, t.thunk_ident, "iter")},
{"map_iter_next_thunk",
RawMapThunk(ctx, msg, t.thunk_ident, "iter_next")},
{"map_iter_get_thunk",
RawMapThunk(ctx, msg, t.thunk_ident, "iter_get")},
{"key_t", t.cc_key_t},
{"ffi_key_t", t.cc_ffi_key_t},
{"key_expr", t.cc_from_ffi_key_expr},
@ -1254,7 +1254,7 @@ void GenerateThunksCc(Context& ctx, const Descriptor& msg) {
const google::protobuf::Map<$key_t$, $pkg::Msg$>* m) {
return google::protobuf::internal::UntypedMapIterator::FromTyped(m->cbegin());
}
void $map_iter_next_thunk$(
void $map_iter_get_thunk$(
const google::protobuf::internal::UntypedMapIterator* iter,
$ffi_key_t$* key, const $pkg::Msg$** value) {
auto typed_iter = iter->ToTyped<

Loading…
Cancel
Save