Skip to content

Commit

Permalink
Fixed formatting and last crate uses
Browse files Browse the repository at this point in the history
  • Loading branch information
jaytaph committed Feb 20, 2024
1 parent 70962c0 commit 4bc481a
Show file tree
Hide file tree
Showing 76 changed files with 268 additions and 330 deletions.
31 changes: 10 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 0 additions & 24 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,38 +47,14 @@ gosub_css3 = { path = "./crates/gosub-css3", features = [] }
gosub_js = { path = "./crates/gosub-js", features = [] }
gosub_jsapi = { path = "./crates/gosub-jsapi", features = [] }
gosub_testing = { path = "./crates/gosub-testing", features = [] }
phf = { version = "0.11.2", features = ["macros"] }
derive_more = "0.99"
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
serde_derive = "1.0"
regex = "1"
lazy_static = "1.4"
#typed-arena = "2.0.2"
thiserror = "1.0.57"
ureq = "2.9.6"
anyhow = "1.0.79"
uuid = { version = "1.7.0", features = ["v4"] }
colored = "2.1.0"
walkdir = "2.3"
nom = "7.1.3"
nom_locate = "4.2.0"
sqlite = "0.33.0"
clap = { version = "4.5.0", features = ["derive"] }
log = "0.4.20"
#domain-lookup-tree = "0.1"
#hickory-resolver = "0.24.0"
simple_logger = "4.2.0"
#libc = "0.2"
#shared_singleton = "0.1.0"
testing_logger = "0.1.1"
cookie = { version = "0.18.0", features = ["secure", "private"] }
#http = "1.0.0"
url = "2.5.0"
v8 = "0.83.2"
#rand = "0.8.5"
#ouroboros = "0.18.3"
chardet = "0.2.4"

[dev-dependencies]
criterion = { version = "0.5", features = ["html_reports"] }
Expand Down
2 changes: 1 addition & 1 deletion benches/tokenizer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use criterion::{criterion_group, criterion_main, Criterion};
use gosub_engine::testing::tokenizer::{self, FixtureFile};
use gosub_testing::testing::tokenizer::{self, FixtureFile};

fn criterion_benchmark(c: &mut Criterion) {
// Criterion can report inconsistent results from run to run in some cases. We attempt to
Expand Down
4 changes: 2 additions & 2 deletions benches/tree_construction.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use criterion::{criterion_group, criterion_main, Criterion};
use gosub_engine::testing::tree_construction;
use gosub_engine::testing::tree_construction::Harness;
use gosub_testing::testing::tree_construction;
use gosub_testing::testing::tree_construction::Harness;

fn criterion_benchmark(c: &mut Criterion) {
let mut group = c.benchmark_group("Tree construction");
Expand Down
22 changes: 8 additions & 14 deletions benches/tree_iterator.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
use std::fs::File;

use criterion::{criterion_group, criterion_main, Criterion};
use gosub_engine::{
bytes::CharIterator,
html5::{
node::NodeId,
parser::{
document::{Document, DocumentBuilder, TreeIterator},
Html5Parser,
},
},
};
use gosub_html5::node::NodeId;
use gosub_html5::parser::document::{Document, DocumentBuilder, TreeIterator};
use gosub_html5::parser::Html5Parser;
use gosub_shared::bytes::CharIterator;

fn wikipedia_main_page(c: &mut Criterion) {
// Criterion can report inconsistent results from run to run in some cases. We attempt to
Expand All @@ -21,8 +15,8 @@ fn wikipedia_main_page(c: &mut Criterion) {

let html_file = File::open("tests/data/tree_iterator/wikipedia_main.html").unwrap();
let mut char_iter = CharIterator::new();
let _ = char_iter.read_from_file(html_file, Some(gosub_engine::bytes::Encoding::UTF8));
char_iter.set_confidence(gosub_engine::bytes::Confidence::Certain);
let _ = char_iter.read_from_file(html_file, Some(gosub_shared::bytes::Encoding::UTF8));
char_iter.set_confidence(gosub_shared::bytes::Confidence::Certain);

let main_document = DocumentBuilder::new_document();
let document = Document::clone(&main_document);
Expand All @@ -48,8 +42,8 @@ fn stackoverflow_home(c: &mut Criterion) {
// using the main page of (english) wikipedia as a rough estimate of traversing a decently sized website
let html_file = File::open("tests/data/tree_iterator/stackoverflow.html").unwrap();
let mut char_iter = CharIterator::new();
let _ = char_iter.read_from_file(html_file, Some(gosub_engine::bytes::Encoding::UTF8));
char_iter.set_confidence(gosub_engine::bytes::Confidence::Certain);
let _ = char_iter.read_from_file(html_file, Some(gosub_shared::bytes::Encoding::UTF8));
char_iter.set_confidence(gosub_shared::bytes::Confidence::Certain);

let main_document = DocumentBuilder::new_document();
let document = Document::clone(&main_document);
Expand Down
6 changes: 5 additions & 1 deletion crates/gosub-bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
name = "gosub-bindings"
version = "0.1.0"
edition = "2021"
authors = ["Gosub Community <[email protected]>"]
license = "MIT"

[dependencies]
gosub-engine = { path = "../../" }
gosub_shared = { path = "../gosub-shared" }
gosub_rendering = { path = "../gosub-rendering" }
gosub_html5 = { path = "../gosub-html5" }

[lib]
crate-type = ["staticlib"]
12 changes: 4 additions & 8 deletions crates/gosub-bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ use std::ptr;

pub mod wrapper;

use gosub_engine::{
bytes::{CharIterator, Confidence, Encoding},
html5::parser::{
document::{Document, DocumentBuilder},
Html5Parser,
},
render_tree::{Node, NodeType, RenderTree, TreeIterator},
};
use gosub_html5::parser::document::{Document, DocumentBuilder};
use gosub_html5::parser::Html5Parser;
use gosub_rendering::render_tree::{Node, NodeType, RenderTree, TreeIterator};
use gosub_shared::bytes::{CharIterator, Confidence, Encoding};
use wrapper::node::CNode;

/// Initialize a render tree and return an owning pointer to it.
Expand Down
4 changes: 2 additions & 2 deletions crates/gosub-bindings/src/wrapper/node.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use gosub_engine::render_tree::properties::{Position, Rectangle};
use gosub_engine::render_tree::{text::TextNode, Node};
use gosub_rendering::render_tree::properties::{Position, Rectangle};
use gosub_rendering::render_tree::{text::TextNode, Node};

use crate::wrapper::{text::CTextNode, CNodeType};

Expand Down
4 changes: 2 additions & 2 deletions crates/gosub-bindings/src/wrapper/text.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use gosub_engine::render_tree::text::TextNode;
use gosub_rendering::render_tree::text::TextNode;
use std::ffi::c_char;
use std::ffi::CString;

/// This is a C-friendly wrapper around gosub_engine::rendertree::text::TextNode
/// This is a C-friendly wrapper around gosub_rendering::rendertree::text::TextNode
/// that converts Rust Strings to owned pointers to pass to the C API.
#[repr(C)]
pub struct CTextNode {
Expand Down
2 changes: 1 addition & 1 deletion crates/gosub-config/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ pub enum Error {

#[error("there was a problem: {0}")]
Generic(String),
}
}
2 changes: 1 addition & 1 deletion crates/gosub-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ mod errors;
pub mod settings;
pub mod storage;

use gosub_shared::types::Result;
use crate::settings::{Setting, SettingInfo};
use crate::storage::MemoryStorageAdapter;
use gosub_shared::types::Result;
use lazy_static::lazy_static;
use log::warn;
use serde_derive::Deserialize;
Expand Down
2 changes: 1 addition & 1 deletion crates/gosub-config/src/storage/json.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use gosub_shared::types::Result;
use crate::settings::Setting;
use crate::StorageAdapter;
use gosub_shared::types::Result;
use log::warn;
use serde_json::Value;
use std::collections::HashMap;
Expand Down
2 changes: 1 addition & 1 deletion crates/gosub-config/src/storage/memory.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use gosub_shared::types::Result;
use crate::settings::Setting;
use crate::StorageAdapter;
use gosub_shared::types::Result;
use std::collections::HashMap;
use std::sync::Mutex;

Expand Down
2 changes: 1 addition & 1 deletion crates/gosub-config/src/storage/sqlite.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use gosub_shared::types::Result;
use crate::settings::Setting;
use crate::StorageAdapter;
use gosub_shared::types::Result;
use log::warn;
use std::collections::HashMap;
use std::str::FromStr;
Expand Down
2 changes: 2 additions & 0 deletions crates/gosub-css3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ license = "MIT"
gosub_shared = { path = "../gosub-shared", features = [] }
lazy_static = "1.4"
log = "0.4.20"
simple_logger = "4.2.0"

2 changes: 1 addition & 1 deletion crates/gosub-css3/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use gosub_shared::byte_stream::{ByteStream, Encoding, Stream};
use crate::location::Location;
use crate::node::Node;
use crate::parser_config::{Context, ParserConfig};
use crate::tokenizer::Tokenizer;
use gosub_shared::byte_stream::{ByteStream, Encoding, Stream};

pub mod location;
mod node;
Expand Down
9 changes: 4 additions & 5 deletions crates/gosub-css3/src/parser/anplusb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,15 @@ impl Css3<'_> {
#[cfg(test)]
mod test {
use super::*;
use crate::byte_stream::Stream;
use gosub_shared::byte_stream::{ByteStream, Encoding, Stream};

macro_rules! test {
($func:ident, $input:expr, $expected:expr) => {
let mut it = crate::css3::ByteStream::new();
it.read_from_str($input, Some(crate::byte_stream::Encoding::UTF8));
let mut it = ByteStream::new();
it.read_from_str($input, Some(Encoding::UTF8));
it.close();

// let mut tokenizer = crate::css3::tokenizer::Tokenizer::new(&mut it, crate::css3::Location::default());
let mut parser = crate::css3::Css3::new(&mut it);
let mut parser = crate::Css3::new(&mut it);
let result = parser.$func().unwrap();

assert_eq!(result.node_type, $expected);
Expand Down
5 changes: 2 additions & 3 deletions crates/gosub-css3/src/parser/at_rule/supports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ impl Css3<'_> {

#[cfg(test)]
mod tests {
use crate::byte_stream::{ByteStream, Encoding, Stream};
use crate::walker::Walker;
use crate::Css3;
use gosub_shared::byte_stream::{ByteStream, Encoding, Stream};

#[test]
fn test_parse_at_rule_supports_prelude() {
let mut it = ByteStream::new();
it.read_from_str("(display: flex)", Some(Encoding::UTF8));
it.close();
let mut parser = Css3::new(&mut it);
let mut parser = crate::Css3::new(&mut it);

let node = parser.parse_at_rule_supports_prelude().unwrap();

Expand Down
1 change: 1 addition & 0 deletions crates/gosub-css3/src/parser/calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl Css3<'_> {

#[cfg(test)]
mod tests {
#[test]
fn test_parse_calc() {
// test!(parse_calc, "calc(1px + 2px)", Box::new(NodeType::AnPlusB { a: "1".to_string(), b: "2".to_string() } ));
// test!(parse_calc, "calc(100px + (200px - 100px) * ((100vh - 500px) / (800 - 500)))", Box::new(NodeType::AnPlusB { a: "1".to_string(), b: "2".to_string() } ));
Expand Down
8 changes: 4 additions & 4 deletions crates/gosub-css3/src/parser/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ impl Css3<'_> {

#[cfg(test)]
mod tests {
use crate::byte_stream::Stream;
use crate::walker::Walker;
use gosub_shared::byte_stream::{ByteStream, Encoding, Stream};

macro_rules! test {
($func:ident, $input:expr, $expected:expr) => {
let mut it = crate::css3::ByteStream::new();
it.read_from_str($input, Some(crate::byte_stream::Encoding::UTF8));
let mut it = ByteStream::new();
it.read_from_str($input, Some(Encoding::UTF8));
it.close();

let mut parser = crate::css3::Css3::new(&mut it);
let mut parser = crate::Css3::new(&mut it);
let result = parser.$func().unwrap();

let w = Walker::new(&result);
Expand Down
Loading

0 comments on commit 4bc481a

Please sign in to comment.