Skip to content

Commit

Permalink
Separate protocols into submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
morr0ne committed Sep 14, 2024
1 parent 6679d19 commit 6462357
Show file tree
Hide file tree
Showing 22 changed files with 81,292 additions and 81,159 deletions.
11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ include = ["src/**/*.rs", "README.md", "LICENSE"]
[features]
client = []
server = []

# Various protocols
stable = []
staging = []
unstable = []
wlr = []
plasma = []
weston = []
cosmic = []

# Internal features
fuzz = ["dep:arbitrary"]

[dependencies]
Expand Down
7 changes: 4 additions & 3 deletions gen/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use crate::{
utils::{description_to_docs, find_enum, make_ident, write_enums},
};

pub fn generate_client_code(protocols: &[Protocol]) -> TokenStream {
pub fn generate_client_code(current: &[Protocol], protocols: &[Protocol]) -> TokenStream {
let mut modules = Vec::new();

for protocol in protocols {
for protocol in current {
debug!("Generating client code for \"{}\"", &protocol.name);

let mut inner_modules = Vec::new();
Expand All @@ -27,7 +27,7 @@ pub fn generate_client_code(protocols: &[Protocol]) -> TokenStream {

let enums = write_enums(&interface);

let requests = write_requests(&protocols, protocol, interface);
let requests = write_requests(current, protocols, protocol, interface);

inner_modules.push(quote! {
#(#docs)*
Expand Down Expand Up @@ -77,6 +77,7 @@ pub fn generate_client_code(protocols: &[Protocol]) -> TokenStream {
}

fn write_requests(
_current: &[Protocol],
protocols: &[Protocol],
protocol: &Protocol,
interface: &Interface,
Expand Down
320 changes: 195 additions & 125 deletions gen/src/main.rs

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions gen/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use crate::{
utils::{description_to_docs, find_enum, make_ident, write_enums},
};

pub fn generate_server_code(protocols: &[Protocol]) -> TokenStream {
pub fn generate_server_code(current: &[Protocol], protocols: &[Protocol]) -> TokenStream {
let mut modules = Vec::new();

for protocol in protocols {
for protocol in current {
debug!("Generating server code for \"{}\"", &protocol.name);

let mut inner_modules = Vec::new();
Expand All @@ -27,8 +27,8 @@ pub fn generate_server_code(protocols: &[Protocol]) -> TokenStream {
let version = &interface.version;

let dispatchers = write_dispatchers(&interface);
let requests = write_requests(&protocols, &protocol, &interface);
let events = write_events(&protocols, &protocol, &interface);
let requests = write_requests(protocols, &protocol, &interface);
let events = write_events(protocols, &protocol, &interface);
let enums = write_enums(&interface);

inner_modules.push(quote! {
Expand Down Expand Up @@ -184,7 +184,7 @@ fn write_events(

for arg in &event.args {
let mut ty =
arg.to_rust_type_token(arg.find_protocol(&protocols).as_ref().unwrap_or(protocol));
arg.to_rust_type_token(arg.find_protocol(protocols).as_ref().unwrap_or(protocol));

if arg.allow_null {
ty = quote! {Option<#ty>};
Expand Down
Loading

0 comments on commit 6462357

Please sign in to comment.