mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-12-23 15:50:11 -05:00
update
This commit is contained in:
parent
12a439e55d
commit
20f5884b50
1 changed files with 26 additions and 29 deletions
55
src/main.rs
55
src/main.rs
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue