Skip to content

Commit

Permalink
extract wayrs-proto-parser from wayrs-scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxVerevkin committed Jan 9, 2024
1 parent 3c69f10 commit b71c569
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 10 deletions.
9 changes: 8 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
[workspace]
members = ["wayrs-client", "wayrs-scanner", "wayrs-protocols", "wayrs-utils", "wayrs-egl"]
members = [
"wayrs-client",
"wayrs-scanner",
"wayrs-protocols",
"wayrs-utils",
"wayrs-egl",
"wayrs-proto-parser",
]
resolver = "2"

[workspace.package]
Expand Down
14 changes: 14 additions & 0 deletions wayrs-proto-parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "wayrs-proto-parser"
version = "1.0.0"
description = "Parser for wayland protocol xml files"
authors = ["MaxVerevkin <[email protected]>"]
keywords = ["wayland", "protocol", "parser", "xml"]
repository.workspace = true
readme.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true

[dependencies]
quick-xml = "0.31"
10 changes: 10 additions & 0 deletions wayrs-proto-parser/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//! Parser for wayland protocol xml files
mod parser;
mod types;

pub use types::*;

pub fn parse_protocol(text: &str) -> Protocol<'_> {
parser::Parser::new(text).get_grotocol()
}
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion wayrs-scanner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ license.workspace = true
proc-macro = true

[dependencies]
wayrs-proto-parser = { version = "1.0", path = "../wayrs-proto-parser" }
proc-macro2 = "1.0"
proc-macro-crate = "2"
quick-xml = "0.31"
quote = "1.0"

[dependencies.syn]
Expand Down
11 changes: 3 additions & 8 deletions wayrs-scanner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@
//!
//! **Do not use directly in your projcets. Call `wayrs_client::generate!()` instead.**
mod parser;
mod types;
mod utils;

use std::path::PathBuf;

use proc_macro2::{Span, TokenStream};
use proc_macro_crate::{crate_name, FoundCrate};
use quote::{format_ident, quote};
use wayrs_proto_parser::*;

use crate::parser::Parser;
use crate::types::*;
mod utils;
use crate::utils::*;

/// These interfaces are frozen at version 1 and will not introduce new events or requests.
Expand Down Expand Up @@ -44,8 +40,7 @@ pub fn generate(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
};

let file = std::fs::read_to_string(path).expect("could not read the file");
let parser = Parser::new(&file);
let protocol = parser.get_grotocol();
let protocol = parse_protocol(&file);

let wayrs_client_path = wayrs_client_path();
let modules = protocol
Expand Down

0 comments on commit b71c569

Please sign in to comment.