0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-12-23 15:50:11 -05:00
This commit is contained in:
Bert Belder 2019-10-08 02:50:18 +02:00
parent 12a439e55d
commit 20f5884b50
No known key found for this signature in database
GPG key ID: 7A77887B2E2ED461

View file

@ -38,28 +38,20 @@ mod channel {
}
}
pub struct ChannelDefaults;
impl ChannelDefaults {
pub fn method1(this: &mut Channel) {
unsafe { Channel__Channel__method1(this) }
}
}
pub trait ChannelOverrides: AsChannel {
fn extender(&self) -> &ChannelExtender;
fn extender_mut(&mut self) -> &mut ChannelExtender;
fn method1(&mut self) {
ChannelDefaults::method1(self.extender_mut().as_mut())
}
fn method2(&self) -> i32;
}
pub trait AsChannel {
fn as_channel(&self) -> &Channel;
fn as_channel_mut(&mut self) -> &mut Channel;
}
impl AsChannel for Channel {
fn as_channel(&self) -> &Channel {
self
}
fn as_channel_mut(&mut self) -> &mut Channel {
self
}
}
impl AsChannel for ChannelExtender {
fn as_channel(&self) -> &Channel {
&self.cxx_channel
@ -81,6 +73,23 @@ mod channel {
}
}
pub struct ChannelDefaults;
impl ChannelDefaults {
pub fn method1(channel: &mut Channel) {
unsafe { Channel__Channel__method1(channel) }
}
}
pub trait ChannelOverrides: AsChannel {
fn extender(&self) -> &ChannelExtender;
fn extender_mut(&mut self) -> &mut ChannelExtender;
fn method1(&mut self) {
ChannelDefaults::method1(self.as_channel_mut())
}
fn method2(&self) -> i32;
}
pub struct ChannelExtender {
cxx_channel: Channel,
extender_offset: usize,
@ -170,18 +179,6 @@ mod channel {
std::mem::transmute((embedder, vtable))
}
}
impl std::convert::AsRef<Channel> for ChannelExtender {
fn as_ref(&self) -> &Channel {
&self.cxx_channel
}
}
impl std::convert::AsMut<Channel> for ChannelExtender {
fn as_mut(&mut self) -> &mut Channel {
&mut self.cxx_channel
}
}
}
mod util {