Use consistent thunk prefix between generator and cpp.rs

PiperOrigin-RevId: 602644203
pull/15642/head
Marcel Hlopko 10 months ago committed by Copybara-Service
parent a019e8d9e1
commit d21425d334
  1. 28
      rust/cpp.rs
  2. 14
      rust/cpp_kernel/cpp_api.cc

@ -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<View<'a, Self>> {
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) }
}
}
)* }

@ -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<key_ty, value_ty>* \
__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<key_ty, value_ty>(); \
} \
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<key_ty, value_ty>* 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<key_ty, value_ty>* 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<key_ty, value_ty>* 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<key_ty, value_ty>* 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<key_ty, value_ty>* 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<key_ty, value_ty>* m, ffi_key_ty key, ffi_value_ty* value) { \
auto cpp_key = to_cpp_key; \
auto num_removed = m->erase(cpp_key); \

Loading…
Cancel
Save