refactor: split cargo workspace
This commit is contained in:
parent
5db14936e7
commit
1c21bd1259
695 changed files with 32023 additions and 44964 deletions
129
build/enums.rs
129
build/enums.rs
|
|
@ -4,18 +4,27 @@ use {
|
|||
std::{env, io::Write},
|
||||
};
|
||||
|
||||
#[expect(unused_macros)]
|
||||
#[macro_use]
|
||||
#[path = "../src/macros.rs"]
|
||||
mod macros;
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! cenum {
|
||||
($name:ident, $uc:ident; $($name2:ident = $val:expr,)*) => {
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub struct $name(pub i32);
|
||||
|
||||
#[path = "../src/libinput/consts.rs"]
|
||||
mod libinput;
|
||||
impl $name {
|
||||
pub fn raw(self) -> i32 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[path = "../src/pango/consts.rs"]
|
||||
mod pango;
|
||||
pub const $uc: &[i32] = &[$($val,)*];
|
||||
|
||||
#[path = "../src/fontconfig/consts.rs"]
|
||||
$(
|
||||
pub const $name2: $name = $name($val);
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
||||
#[path = "fontconfig_consts.rs"]
|
||||
mod fontconfig;
|
||||
|
||||
fn get_target() -> repc::Target {
|
||||
|
|
@ -49,108 +58,6 @@ fn write_ty<W: Write>(f: &mut W, vals: &[i32], ty: &str) -> anyhow::Result<()> {
|
|||
}
|
||||
|
||||
pub fn main() -> anyhow::Result<()> {
|
||||
let mut f = open("libinput_tys.rs")?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
libinput::LIBINPUT_LOG_PRIORITY,
|
||||
"libinput_log_priority",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
libinput::LIBINPUT_DEVICE_CAPABILITY,
|
||||
"libinput_device_capability",
|
||||
)?;
|
||||
write_ty(&mut f, libinput::LIBINPUT_KEY_STATE, "libinput_key_state")?;
|
||||
write_ty(&mut f, libinput::LIBINPUT_LED, "libinput_led")?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
libinput::LIBINPUT_BUTTON_STATE,
|
||||
"libinput_button_state",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
libinput::LIBINPUT_POINTER_AXIS,
|
||||
"libinput_pointer_axis",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
libinput::LIBINPUT_POINTER_AXIS_SOURCE,
|
||||
"libinput_pointer_axis_source",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
libinput::LIBINPUT_TABLET_PAD_RING_AXIS_SOURCE,
|
||||
"libinput_tablet_pad_ring_axis_source",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
libinput::LIBINPUT_TABLET_PAD_STRIP_AXIS_SOURCE,
|
||||
"libinput_tablet_pad_strip_axis_source",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
libinput::LIBINPUT_TABLET_TOOL_TYPE,
|
||||
"libinput_tablet_tool_type",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
libinput::LIBINPUT_TABLET_TOOL_PROXIMITY_STATE,
|
||||
"libinput_tablet_tool_proximity_state",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
libinput::LIBINPUT_TABLET_TOOL_TIP_STATE,
|
||||
"libinput_tablet_tool_tip_state",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
libinput::LIBINPUT_SWITCH_STATE,
|
||||
"libinput_switch_state",
|
||||
)?;
|
||||
write_ty(&mut f, libinput::LIBINPUT_SWITCH, "libinput_switch")?;
|
||||
write_ty(&mut f, libinput::LIBINPUT_EVENT_TYPE, "libinput_event_type")?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
libinput::LIBINPUT_CONFIG_STATUS,
|
||||
"libinput_config_status",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
libinput::LIBINPUT_CONFIG_ACCEL_PROFILE,
|
||||
"libinput_config_accel_profile",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
libinput::LIBINPUT_CONFIG_TAP_STATE,
|
||||
"libinput_config_tap_state",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
libinput::LIBINPUT_CONFIG_DRAG_STATE,
|
||||
"libinput_config_drag_state",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
libinput::LIBINPUT_CONFIG_DRAG_LOCK_STATE,
|
||||
"libinput_config_drag_lock_state",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
libinput::LIBINPUT_CONFIG_CLICK_METHOD,
|
||||
"libinput_config_click_method",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
libinput::LIBINPUT_CONFIG_MIDDLE_EMULATION_STATE,
|
||||
"libinput_config_middle_emulation_state",
|
||||
)?;
|
||||
|
||||
let mut f = open("pango_tys.rs")?;
|
||||
write_ty(&mut f, pango::CAIRO_FORMATS, "cairo_format_t")?;
|
||||
write_ty(&mut f, pango::CAIRO_STATUSES, "cairo_status_t")?;
|
||||
write_ty(&mut f, pango::CAIRO_OPERATORS, "cairo_operator_t")?;
|
||||
write_ty(&mut f, pango::PANGO_ELLIPSIZE_MODES, "PangoEllipsizeMode_")?;
|
||||
|
||||
let mut f = open("fontconfig_tys.rs")?;
|
||||
write_ty(&mut f, fontconfig::FC_MATCH_KINDS, "FcMatchKind")?;
|
||||
write_ty(&mut f, fontconfig::FC_RESULTS, "FcResult")?;
|
||||
|
|
|
|||
20
build/fontconfig_consts.rs
Normal file
20
build/fontconfig_consts.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
cenum! {
|
||||
_FcMatchKind, FC_MATCH_KINDS;
|
||||
|
||||
FC_MATCH_PATTERN = 0,
|
||||
FC_MATCH_FONT = 1,
|
||||
FC_MATCH_SCAN = 2,
|
||||
FC_MATCH_KIND_END = 3,
|
||||
}
|
||||
|
||||
cenum! {
|
||||
_FcResult, FC_RESULTS;
|
||||
|
||||
FC_RESULT_MATCH = 0,
|
||||
FC_RESULT_NO_MATCH = 1,
|
||||
FC_RESULT_TYPE_MISMATCH = 2,
|
||||
FC_RESULT_NO_ID = 3,
|
||||
FC_RESULT_OUT_OF_MEMORY = 4,
|
||||
}
|
||||
|
|
@ -274,47 +274,15 @@ 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}{camel_direction}Handler: {parent} + Sized {{"
|
||||
" pub trait {camel_obj_name}RequestHandler: crate::object::Object + Sized {{"
|
||||
)?;
|
||||
writeln!(f, " type Error: std::error::Error;")?;
|
||||
for message in messages {
|
||||
|
|
@ -326,24 +294,24 @@ fn write_request_handler<W: Write>(
|
|||
writeln!(f)?;
|
||||
writeln!(
|
||||
f,
|
||||
" fn {}(&self, {param}: {}{lt}, _slf: &Rc<Self>) -> Result<(), Self::Error>;",
|
||||
" fn {}(&self, req: {}{lt}, _slf: &Rc<Self>) -> Result<(), Self::Error>;",
|
||||
msg.safe_name, msg.camel_name
|
||||
)?;
|
||||
}
|
||||
writeln!(f)?;
|
||||
writeln!(f, " #[inline(always)]")?;
|
||||
writeln!(f, " fn handle_{snake_direction}_impl(")?;
|
||||
writeln!(f, " fn handle_request_impl(")?;
|
||||
writeln!(f, " self: Rc<Self>,")?;
|
||||
writeln!(f, " client: &{parser},")?;
|
||||
writeln!(f, " client: &crate::client::Client,")?;
|
||||
writeln!(f, " req: u32,")?;
|
||||
writeln!(
|
||||
f,
|
||||
" parser: crate::utils::buffd::MsgParser<'_, '_>,"
|
||||
)?;
|
||||
writeln!(f, " ) -> Result<(), {error}> {{")?;
|
||||
writeln!(f, " ) -> Result<(), crate::client::ClientError> {{")?;
|
||||
if messages.is_empty() {
|
||||
writeln!(f, " #![allow(unused_variables)]")?;
|
||||
writeln!(f, " Err({error}::InvalidMethod)")?;
|
||||
writeln!(f, " Err(crate::client::ClientError::InvalidMethod)")?;
|
||||
} else {
|
||||
writeln!(f, " let method;")?;
|
||||
writeln!(
|
||||
|
|
@ -379,10 +347,10 @@ fn write_request_handler<W: Write>(
|
|||
}
|
||||
writeln!(
|
||||
f,
|
||||
" _ => return Err({error}::InvalidMethod),"
|
||||
" _ => return Err(crate::client::ClientError::InvalidMethod),"
|
||||
)?;
|
||||
writeln!(f, " }};")?;
|
||||
writeln!(f, " Err({error}::MethodError {{")?;
|
||||
writeln!(f, " Err(crate::client::ClientError::MethodError {{")?;
|
||||
writeln!(f, " interface: {camel_obj_name},")?;
|
||||
writeln!(f, " id: self.id(),")?;
|
||||
writeln!(f, " method,")?;
|
||||
|
|
@ -417,6 +385,7 @@ fn write_file<W: Write>(
|
|||
let messages = parse_messages(&contents)?;
|
||||
writeln!(f)?;
|
||||
writeln!(f, "pub mod {} {{", obj_name)?;
|
||||
writeln!(f, " #![allow(dead_code)]")?;
|
||||
writeln!(f, " use super::*;")?;
|
||||
for message in messages.requests.iter().chain(messages.events.iter()) {
|
||||
write_message(f, &camel_obj_name, &message.val)?;
|
||||
|
|
@ -425,13 +394,6 @@ 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