From d21425d334f965650c3c66362b0d827797f059db Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Tue, 30 Jan 2024 01:25:51 -0800 Subject: [PATCH] Use consistent thunk prefix between generator and cpp.rs PiperOrigin-RevId: 602644203 --- rust/cpp.rs | 28 ++++++++++++++-------------- rust/cpp_kernel/cpp_api.cc | 14 +++++++------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/rust/cpp.rs b/rust/cpp.rs index 35ee4afe6d..e79c9ba902 100644 --- a/rust/cpp.rs +++ b/rust/cpp.rs @@ -411,13 +411,13 @@ macro_rules! impl_ProxiedInMapValue_for_non_generated_value_types { ($key_t:ty, $ffi_key_t:ty, $to_ffi_key:expr, for $($t:ty, $ffi_t:ty, $to_ffi_value:expr, $from_ffi_value:expr, $zero_val:literal;)*) => { paste! { $( extern "C" { - fn [< __pb_rust_Map_ $key_t _ $t _new >]() -> RawMap; - fn [< __pb_rust_Map_ $key_t _ $t _free >](m: RawMap); - fn [< __pb_rust_Map_ $key_t _ $t _clear >](m: RawMap); - fn [< __pb_rust_Map_ $key_t _ $t _size >](m: RawMap) -> usize; - fn [< __pb_rust_Map_ $key_t _ $t _insert >](m: RawMap, key: $ffi_key_t, value: $ffi_t); - fn [< __pb_rust_Map_ $key_t _ $t _get >](m: RawMap, key: $ffi_key_t, value: *mut $ffi_t) -> bool; - fn [< __pb_rust_Map_ $key_t _ $t _remove >](m: RawMap, key: $ffi_key_t, value: *mut $ffi_t) -> bool; + fn [< __rust_proto_thunk__Map_ $key_t _ $t _new >]() -> RawMap; + fn [< __rust_proto_thunk__Map_ $key_t _ $t _free >](m: RawMap); + fn [< __rust_proto_thunk__Map_ $key_t _ $t _clear >](m: RawMap); + fn [< __rust_proto_thunk__Map_ $key_t _ $t _size >](m: RawMap) -> usize; + fn [< __rust_proto_thunk__Map_ $key_t _ $t _insert >](m: RawMap, key: $ffi_key_t, value: $ffi_t); + 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 _remove >](m: RawMap, key: $ffi_key_t, value: *mut $ffi_t) -> bool; } impl ProxiedInMapValue<$key_t> for $t { @@ -426,7 +426,7 @@ macro_rules! impl_ProxiedInMapValue_for_non_generated_value_types { Map::from_inner( Private, InnerMapMut { - raw: [< __pb_rust_Map_ $key_t _ $t _new >](), + raw: [< __rust_proto_thunk__Map_ $key_t _ $t _new >](), _phantom: PhantomData } ) @@ -437,29 +437,29 @@ macro_rules! impl_ProxiedInMapValue_for_non_generated_value_types { // SAFETY: // - `map.inner.raw` is a live `RawMap` // - This function is only called once for `map` in `Drop`. - unsafe { [< __pb_rust_Map_ $key_t _ $t _free >](map.inner.raw); } + unsafe { [< __rust_proto_thunk__Map_ $key_t _ $t _free >](map.inner.raw); } } fn map_clear(map: Mut<'_, Map<$key_t, Self>>) { - unsafe { [< __pb_rust_Map_ $key_t _ $t _clear >](map.inner.raw); } + unsafe { [< __rust_proto_thunk__Map_ $key_t _ $t _clear >](map.inner.raw); } } fn map_len(map: View<'_, Map<$key_t, Self>>) -> usize { - unsafe { [< __pb_rust_Map_ $key_t _ $t _size >](map.raw) } + unsafe { [< __rust_proto_thunk__Map_ $key_t _ $t _size >](map.raw) } } fn map_insert(map: Mut<'_, Map<$key_t, Self>>, key: View<'_, $key_t>, value: View<'_, Self>) -> bool { let ffi_key = $to_ffi_key(key); let ffi_value = $to_ffi_value(value); - unsafe { [< __pb_rust_Map_ $key_t _ $t _insert >](map.inner.raw, ffi_key, ffi_value) } + unsafe { [< __rust_proto_thunk__Map_ $key_t _ $t _insert >](map.inner.raw, ffi_key, ffi_value) } true } fn map_get<'a>(map: View<'a, Map<$key_t, Self>>, key: View<'_, $key_t>) -> Option> { let ffi_key = $to_ffi_key(key); let mut ffi_value = $to_ffi_value($zero_val); - let found = unsafe { [< __pb_rust_Map_ $key_t _ $t _get >](map.raw, ffi_key, &mut ffi_value) }; + let found = unsafe { [< __rust_proto_thunk__Map_ $key_t _ $t _get >](map.raw, ffi_key, &mut ffi_value) }; if !found { return None; } @@ -469,7 +469,7 @@ macro_rules! impl_ProxiedInMapValue_for_non_generated_value_types { fn map_remove(map: Mut<'_, Map<$key_t, Self>>, key: View<'_, $key_t>) -> bool { let ffi_key = $to_ffi_key(key); let mut ffi_value = $to_ffi_value($zero_val); - unsafe { [< __pb_rust_Map_ $key_t _ $t _remove >](map.inner.raw, ffi_key, &mut ffi_value) } + unsafe { [< __rust_proto_thunk__Map_ $key_t _ $t _remove >](map.inner.raw, ffi_key, &mut ffi_value) } } } )* } diff --git a/rust/cpp_kernel/cpp_api.cc b/rust/cpp_kernel/cpp_api.cc index cb20fc9087..404f6f60a6 100644 --- a/rust/cpp_kernel/cpp_api.cc +++ b/rust/cpp_kernel/cpp_api.cc @@ -100,28 +100,28 @@ expose_repeated_ptr_field_methods(Bytes); value_ty, rust_value_ty, ffi_value_ty, \ to_cpp_value, to_ffi_value) \ google::protobuf::Map* \ - __pb_rust_Map_##rust_key_ty##_##rust_value_ty##_new() { \ + __rust_proto_thunk__Map_##rust_key_ty##_##rust_value_ty##_new() { \ return new google::protobuf::Map(); \ } \ - void __pb_rust_Map_##rust_key_ty##_##rust_value_ty##_free( \ + void __rust_proto_thunk__Map_##rust_key_ty##_##rust_value_ty##_free( \ google::protobuf::Map* m) { \ delete m; \ } \ - void __pb_rust_Map_##rust_key_ty##_##rust_value_ty##_clear( \ + void __rust_proto_thunk__Map_##rust_key_ty##_##rust_value_ty##_clear( \ google::protobuf::Map* m) { \ m->clear(); \ } \ - size_t __pb_rust_Map_##rust_key_ty##_##rust_value_ty##_size( \ + size_t __rust_proto_thunk__Map_##rust_key_ty##_##rust_value_ty##_size( \ const google::protobuf::Map* m) { \ return m->size(); \ } \ - void __pb_rust_Map_##rust_key_ty##_##rust_value_ty##_insert( \ + void __rust_proto_thunk__Map_##rust_key_ty##_##rust_value_ty##_insert( \ google::protobuf::Map* m, ffi_key_ty key, ffi_value_ty value) { \ auto cpp_key = to_cpp_key; \ auto cpp_value = to_cpp_value; \ (*m)[cpp_key] = cpp_value; \ } \ - bool __pb_rust_Map_##rust_key_ty##_##rust_value_ty##_get( \ + bool __rust_proto_thunk__Map_##rust_key_ty##_##rust_value_ty##_get( \ const google::protobuf::Map* m, ffi_key_ty key, \ ffi_value_ty* value) { \ auto cpp_key = to_cpp_key; \ @@ -133,7 +133,7 @@ expose_repeated_ptr_field_methods(Bytes); *value = to_ffi_value; \ return true; \ } \ - bool __pb_rust_Map_##rust_key_ty##_##rust_value_ty##_remove( \ + bool __rust_proto_thunk__Map_##rust_key_ty##_##rust_value_ty##_remove( \ google::protobuf::Map* m, ffi_key_ty key, ffi_value_ty* value) { \ auto cpp_key = to_cpp_key; \ auto num_removed = m->erase(cpp_key); \