|
|
@ -80,7 +80,7 @@ void MessageSerialize(Context& ctx, const Descriptor& msg) { |
|
|
|
// SAFETY: `MINI_TABLE` is the one associated with `self.raw_msg()`.
|
|
|
|
// SAFETY: `MINI_TABLE` is the one associated with `self.raw_msg()`.
|
|
|
|
let encoded = unsafe { |
|
|
|
let encoded = unsafe { |
|
|
|
$pbr$::wire::encode(self.raw_msg(), |
|
|
|
$pbr$::wire::encode(self.raw_msg(), |
|
|
|
<Self as $pbr$::AssociatedMiniTable>::MINI_TABLE) |
|
|
|
<Self as $pbr$::AssociatedMiniTable>::mini_table()) |
|
|
|
}; |
|
|
|
}; |
|
|
|
//~ TODO: This discards the info we have about the reason
|
|
|
|
//~ TODO: This discards the info we have about the reason
|
|
|
|
//~ of the failure, we should try to keep it instead.
|
|
|
|
//~ of the failure, we should try to keep it instead.
|
|
|
@ -102,12 +102,11 @@ void MessageMutClear(Context& ctx, const Descriptor& msg) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
case Kernel::kUpb: |
|
|
|
case Kernel::kUpb: |
|
|
|
ctx.Emit( |
|
|
|
ctx.Emit( |
|
|
|
{ |
|
|
|
|
|
|
|
{"minitable", UpbMinitableName(msg)}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
R"rs( |
|
|
|
R"rs( |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
$pbr$::upb_Message_Clear(self.raw_msg(), $std$::ptr::addr_of!($minitable$)) |
|
|
|
$pbr$::upb_Message_Clear( |
|
|
|
|
|
|
|
self.raw_msg(), |
|
|
|
|
|
|
|
<Self as $pbr$::AssociatedMiniTable>::mini_table()) |
|
|
|
} |
|
|
|
} |
|
|
|
)rs"); |
|
|
|
)rs"); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -148,7 +147,7 @@ void MessageClearAndParse(Context& ctx, const Descriptor& msg) { |
|
|
|
$pbr$::wire::decode( |
|
|
|
$pbr$::wire::decode( |
|
|
|
data, |
|
|
|
data, |
|
|
|
msg.raw_msg(), |
|
|
|
msg.raw_msg(), |
|
|
|
<Self as $pbr$::AssociatedMiniTable>::MINI_TABLE, |
|
|
|
<Self as $pbr$::AssociatedMiniTable>::mini_table(), |
|
|
|
msg.arena()) |
|
|
|
msg.arena()) |
|
|
|
}; |
|
|
|
}; |
|
|
|
match status { |
|
|
|
match status { |
|
|
@ -183,7 +182,7 @@ void MessageDebug(Context& ctx, const Descriptor& msg) { |
|
|
|
let string = unsafe { |
|
|
|
let string = unsafe { |
|
|
|
$pbr$::debug_string( |
|
|
|
$pbr$::debug_string( |
|
|
|
self.raw_msg(), |
|
|
|
self.raw_msg(), |
|
|
|
<Self as $pbr$::AssociatedMiniTable>::MINI_TABLE |
|
|
|
<Self as $pbr$::AssociatedMiniTable>::mini_table() |
|
|
|
) |
|
|
|
) |
|
|
|
}; |
|
|
|
}; |
|
|
|
write!(f, "{}", string) |
|
|
|
write!(f, "{}", string) |
|
|
@ -297,7 +296,7 @@ void IntoProxiedForMessage(Context& ctx, const Descriptor& msg) { |
|
|
|
unsafe { $pbr$::upb_Message_DeepCopy( |
|
|
|
unsafe { $pbr$::upb_Message_DeepCopy( |
|
|
|
dst.inner.msg, |
|
|
|
dst.inner.msg, |
|
|
|
self.msg, |
|
|
|
self.msg, |
|
|
|
<Self as $pbr$::AssociatedMiniTable>::MINI_TABLE, |
|
|
|
<Self as $pbr$::AssociatedMiniTable>::mini_table(), |
|
|
|
dst.inner.arena.raw(), |
|
|
|
dst.inner.arena.raw(), |
|
|
|
) }; |
|
|
|
) }; |
|
|
|
dst |
|
|
|
dst |
|
|
@ -319,16 +318,25 @@ void IntoProxiedForMessage(Context& ctx, const Descriptor& msg) { |
|
|
|
void UpbGeneratedMessageTraitImpls(Context& ctx, const Descriptor& msg) { |
|
|
|
void UpbGeneratedMessageTraitImpls(Context& ctx, const Descriptor& msg) { |
|
|
|
if (ctx.opts().kernel == Kernel::kUpb) { |
|
|
|
if (ctx.opts().kernel == Kernel::kUpb) { |
|
|
|
ctx.Emit({{"minitable", UpbMinitableName(msg)}}, R"rs( |
|
|
|
ctx.Emit({{"minitable", UpbMinitableName(msg)}}, R"rs( |
|
|
|
unsafe impl $pbr$::AssociatedMiniTable for $Msg$ { |
|
|
|
impl $pbr$::AssociatedMiniTable for $Msg$ { |
|
|
|
const MINI_TABLE: *const $pbr$::upb_MiniTable = unsafe { $std$::ptr::addr_of!($minitable$) }; |
|
|
|
#[inline(always)] |
|
|
|
|
|
|
|
unsafe fn mini_table() -> *const $pbr$::upb_MiniTable { |
|
|
|
|
|
|
|
$std$::ptr::addr_of!($minitable$) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
unsafe impl $pbr$::AssociatedMiniTable for $Msg$View<'_> { |
|
|
|
impl $pbr$::AssociatedMiniTable for $Msg$View<'_> { |
|
|
|
const MINI_TABLE: *const $pbr$::upb_MiniTable = unsafe { $std$::ptr::addr_of!($minitable$) }; |
|
|
|
#[inline(always)] |
|
|
|
|
|
|
|
unsafe fn mini_table() -> *const $pbr$::upb_MiniTable { |
|
|
|
|
|
|
|
$std$::ptr::addr_of!($minitable$) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
unsafe impl $pbr$::AssociatedMiniTable for $Msg$Mut<'_> { |
|
|
|
impl $pbr$::AssociatedMiniTable for $Msg$Mut<'_> { |
|
|
|
const MINI_TABLE: *const $pbr$::upb_MiniTable = unsafe { $std$::ptr::addr_of!($minitable$) }; |
|
|
|
#[inline(always)] |
|
|
|
|
|
|
|
unsafe fn mini_table() -> *const $pbr$::upb_MiniTable { |
|
|
|
|
|
|
|
$std$::ptr::addr_of!($minitable$) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
)rs"); |
|
|
|
)rs"); |
|
|
|
} |
|
|
|
} |
|
|
@ -362,7 +370,7 @@ void MessageMutMergeFrom(Context& ctx, const Descriptor& msg) { |
|
|
|
assert!( |
|
|
|
assert!( |
|
|
|
$pbr$::upb_Message_MergeFrom(self.raw_msg(), |
|
|
|
$pbr$::upb_Message_MergeFrom(self.raw_msg(), |
|
|
|
src.as_view().raw_msg(), |
|
|
|
src.as_view().raw_msg(), |
|
|
|
<Self as $pbr$::AssociatedMiniTable>::MINI_TABLE, |
|
|
|
<Self as $pbr$::AssociatedMiniTable>::mini_table(), |
|
|
|
// Use a nullptr for the ExtensionRegistry.
|
|
|
|
// Use a nullptr for the ExtensionRegistry.
|
|
|
|
$std$::ptr::null(), |
|
|
|
$std$::ptr::null(), |
|
|
|
self.arena().raw()) |
|
|
|
self.arena().raw()) |
|
|
@ -568,7 +576,7 @@ void MessageProxiedInRepeated(Context& ctx, const Descriptor& msg) { |
|
|
|
// SAFETY:
|
|
|
|
// SAFETY:
|
|
|
|
// - Elements of `src` and `dest` have message minitable `MINI_TABLE`.
|
|
|
|
// - Elements of `src` and `dest` have message minitable `MINI_TABLE`.
|
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
$pbr$::repeated_message_copy_from(src, dest, <Self as $pbr$::AssociatedMiniTable>::MINI_TABLE); |
|
|
|
$pbr$::repeated_message_copy_from(src, dest, <Self as $pbr$::AssociatedMiniTable>::mini_table()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|