all: bring back xdg portals
This commit is contained in:
parent
d920e554cf
commit
e61f042d8b
107 changed files with 14293 additions and 55 deletions
|
|
@ -274,15 +274,47 @@ fn write_message<W: Write>(f: &mut W, obj: &str, message: &Message) -> Result<()
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
enum RequestHandlerDirection {
|
||||
Request,
|
||||
Event,
|
||||
}
|
||||
|
||||
fn write_request_handler<W: Write>(
|
||||
f: &mut W,
|
||||
camel_obj_name: &str,
|
||||
messages: &[Lined<Message>],
|
||||
direction: RequestHandlerDirection,
|
||||
) -> Result<()> {
|
||||
let snake_direction;
|
||||
let camel_direction;
|
||||
let parent;
|
||||
let parser;
|
||||
let error;
|
||||
let param;
|
||||
writeln!(f)?;
|
||||
match direction {
|
||||
RequestHandlerDirection::Request => {
|
||||
snake_direction = "request";
|
||||
camel_direction = "Request";
|
||||
parent = "crate::object::Object";
|
||||
parser = "crate::client::Client";
|
||||
error = "crate::client::ClientError";
|
||||
param = "req";
|
||||
}
|
||||
RequestHandlerDirection::Event => {
|
||||
snake_direction = "event";
|
||||
camel_direction = "Event";
|
||||
parent = "crate::wl_usr::usr_object::UsrObject";
|
||||
parser = "crate::wl_usr::UsrCon";
|
||||
error = "crate::wl_usr::UsrConError";
|
||||
param = "ev";
|
||||
writeln!(f, " #[allow(clippy::allow_attributes, dead_code)]")?;
|
||||
}
|
||||
}
|
||||
writeln!(
|
||||
f,
|
||||
" pub trait {camel_obj_name}RequestHandler: crate::object::Object + Sized {{"
|
||||
" pub trait {camel_obj_name}{camel_direction}Handler: {parent} + Sized {{"
|
||||
)?;
|
||||
writeln!(f, " type Error: std::error::Error;")?;
|
||||
for message in messages {
|
||||
|
|
@ -294,24 +326,24 @@ fn write_request_handler<W: Write>(
|
|||
writeln!(f)?;
|
||||
writeln!(
|
||||
f,
|
||||
" fn {}(&self, req: {}{lt}, _slf: &Rc<Self>) -> Result<(), Self::Error>;",
|
||||
" fn {}(&self, {param}: {}{lt}, _slf: &Rc<Self>) -> Result<(), Self::Error>;",
|
||||
msg.safe_name, msg.camel_name
|
||||
)?;
|
||||
}
|
||||
writeln!(f)?;
|
||||
writeln!(f, " #[inline(always)]")?;
|
||||
writeln!(f, " fn handle_request_impl(")?;
|
||||
writeln!(f, " fn handle_{snake_direction}_impl(")?;
|
||||
writeln!(f, " self: Rc<Self>,")?;
|
||||
writeln!(f, " client: &crate::client::Client,")?;
|
||||
writeln!(f, " client: &{parser},")?;
|
||||
writeln!(f, " req: u32,")?;
|
||||
writeln!(
|
||||
f,
|
||||
" parser: crate::utils::buffd::MsgParser<'_, '_>,"
|
||||
)?;
|
||||
writeln!(f, " ) -> Result<(), crate::client::ClientError> {{")?;
|
||||
writeln!(f, " ) -> Result<(), {error}> {{")?;
|
||||
if messages.is_empty() {
|
||||
writeln!(f, " #![allow(unused_variables)]")?;
|
||||
writeln!(f, " Err(crate::client::ClientError::InvalidMethod)")?;
|
||||
writeln!(f, " Err({error}::InvalidMethod)")?;
|
||||
} else {
|
||||
writeln!(f, " let method;")?;
|
||||
writeln!(
|
||||
|
|
@ -347,10 +379,10 @@ fn write_request_handler<W: Write>(
|
|||
}
|
||||
writeln!(
|
||||
f,
|
||||
" _ => return Err(crate::client::ClientError::InvalidMethod),"
|
||||
" _ => return Err({error}::InvalidMethod),"
|
||||
)?;
|
||||
writeln!(f, " }};")?;
|
||||
writeln!(f, " Err(crate::client::ClientError::MethodError {{")?;
|
||||
writeln!(f, " Err({error}::MethodError {{")?;
|
||||
writeln!(f, " interface: {camel_obj_name},")?;
|
||||
writeln!(f, " id: self.id(),")?;
|
||||
writeln!(f, " method,")?;
|
||||
|
|
@ -394,6 +426,13 @@ fn write_file<W: Write>(
|
|||
f,
|
||||
&camel_obj_name,
|
||||
&messages.requests,
|
||||
RequestHandlerDirection::Request,
|
||||
)?;
|
||||
write_request_handler(
|
||||
f,
|
||||
&camel_obj_name,
|
||||
&messages.events,
|
||||
RequestHandlerDirection::Event,
|
||||
)?;
|
||||
writeln!(f, "}}")?;
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue