From 9d00e954576e240eb988332d6ccf91ff1155e926 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Sun, 16 Jun 2024 18:04:20 +0200 Subject: [PATCH] specctra: change "dsn" to "specctra" where it's about both DSN and SES --- Cargo.toml | 4 +- .../Cargo.toml | 2 +- .../src/lib.rs | 19 +--- .../src/read.rs | 0 .../src/write.rs | 35 +++---- src/bin/topola-egui/app.rs | 8 +- src/bin/topola-egui/top.rs | 4 +- src/bin/topola-egui/viewport.rs | 4 +- src/bin/topola-sdl2-demo/main.rs | 6 +- src/lib.rs | 2 +- src/{dsn => specctra}/common.rs | 0 src/{dsn => specctra}/de.rs | 0 src/{dsn => specctra}/design.rs | 42 ++++----- src/{dsn => specctra}/mesadata.rs | 24 ++--- src/{dsn => specctra}/mod.rs | 0 src/{dsn => specctra}/read.rs | 0 src/{dsn => specctra}/structure.rs | 94 +++++++++---------- src/{dsn => specctra}/write.rs | 26 ++--- tests/common/mod.rs | 8 +- 19 files changed, 128 insertions(+), 150 deletions(-) rename macro/{dsn_derive => specctra_derive}/Cargo.toml (84%) rename macro/{dsn_derive => specctra_derive}/src/lib.rs (64%) rename macro/{dsn_derive => specctra_derive}/src/read.rs (100%) rename macro/{dsn_derive => specctra_derive}/src/write.rs (74%) rename src/{dsn => specctra}/common.rs (100%) rename src/{dsn => specctra}/de.rs (100%) rename src/{dsn => specctra}/design.rs (96%) rename src/{dsn => specctra}/mesadata.rs (87%) rename src/{dsn => specctra}/mod.rs (100%) rename src/{dsn => specctra}/read.rs (100%) rename src/{dsn => specctra}/structure.rs (82%) rename src/{dsn => specctra}/write.rs (87%) diff --git a/Cargo.toml b/Cargo.toml index 8ea7461..88d9216 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,8 +34,8 @@ bimap = "0.6.3" log = "0.4" utf8-chars = "3.0.2" -[dependencies.dsn_derive] -path = "macro/dsn_derive" +[dependencies.specctra_derive] +path = "macro/specctra_derive" [dependencies.geo] version = "0.25.1" diff --git a/macro/dsn_derive/Cargo.toml b/macro/specctra_derive/Cargo.toml similarity index 84% rename from macro/dsn_derive/Cargo.toml rename to macro/specctra_derive/Cargo.toml index 0ee0688..e3d74b0 100644 --- a/macro/dsn_derive/Cargo.toml +++ b/macro/specctra_derive/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "dsn_derive" +name = "specctra_derive" version = "0.1.0" edition = "2021" diff --git a/macro/dsn_derive/src/lib.rs b/macro/specctra_derive/src/lib.rs similarity index 64% rename from macro/dsn_derive/src/lib.rs rename to macro/specctra_derive/src/lib.rs index 14915b2..a392091 100644 --- a/macro/dsn_derive/src/lib.rs +++ b/macro/specctra_derive/src/lib.rs @@ -1,21 +1,17 @@ use proc_macro::TokenStream; -use syn::{DeriveInput, Attribute, LitStr}; +use syn::{Attribute, DeriveInput, LitStr}; mod read; mod write; #[proc_macro_derive(ReadDsn, attributes(opt, anon, vec, anon_vec))] -pub fn derive_read(input: TokenStream) - -> TokenStream -{ +pub fn derive_read(input: TokenStream) -> TokenStream { let input = syn::parse_macro_input!(input as DeriveInput); read::impl_read(&input).into() } -#[proc_macro_derive(WriteDsn, attributes(anon))] -pub fn derive_write(input: TokenStream) - -> TokenStream -{ +#[proc_macro_derive(WriteSes, attributes(anon))] +pub fn derive_write(input: TokenStream) -> TokenStream { let input = syn::parse_macro_input!(input as DeriveInput); write::impl_write(&input).into() } @@ -31,10 +27,5 @@ fn attr_content(attrs: &Vec, name: &str) -> Option { attrs .iter() .find(|attr| attr.path().is_ident(name)) - .and_then(|attr| Some(attr - .parse_args::() - .expect("string literal") - .value() - )) + .and_then(|attr| Some(attr.parse_args::().expect("string literal").value())) } - diff --git a/macro/dsn_derive/src/read.rs b/macro/specctra_derive/src/read.rs similarity index 100% rename from macro/dsn_derive/src/read.rs rename to macro/specctra_derive/src/read.rs diff --git a/macro/dsn_derive/src/write.rs b/macro/specctra_derive/src/write.rs similarity index 74% rename from macro/dsn_derive/src/write.rs rename to macro/specctra_derive/src/write.rs index 6e9cf24..22db6ad 100644 --- a/macro/dsn_derive/src/write.rs +++ b/macro/specctra_derive/src/write.rs @@ -1,11 +1,11 @@ use proc_macro2::TokenStream; use quote::quote; -use syn::{Data, DeriveInput, Fields, Field}; -use syn::Type::Path; use syn::ext::IdentExt; +use syn::Type::Path; +use syn::{Data, DeriveInput, Field, Fields}; -use crate::attr_present; use crate::attr_content; +use crate::attr_present; pub fn impl_write(input: &DeriveInput) -> TokenStream { let name = &input.ident; @@ -13,7 +13,7 @@ pub fn impl_write(input: &DeriveInput) -> TokenStream { let body = impl_body(&input.data); quote! { - impl WriteDsn for #name { + impl WriteSes for #name { fn write_dsn(&self, writer: &mut ListWriter) -> std::io::Result<()> { @@ -25,23 +25,19 @@ pub fn impl_write(input: &DeriveInput) -> TokenStream { fn impl_body(data: &Data) -> TokenStream { match data { - Data::Struct(data) => { - match &data.fields { - Fields::Named(fields) => { - let fields = fields.named.iter().map(|field| { - impl_field(field) - }); + Data::Struct(data) => match &data.fields { + Fields::Named(fields) => { + let fields = fields.named.iter().map(|field| impl_field(field)); - quote! { - #(#fields)* + quote! { + #(#fields)* - Ok(()) - } + Ok(()) } - _ => unimplemented!() } - } - _ => unimplemented!() + _ => unimplemented!(), + }, + _ => unimplemented!(), } } @@ -61,7 +57,6 @@ fn impl_field(field: &Field) -> TokenStream { quote! { writer.write_array(&self.#name)?; } - } else { if let Path(type_path) = &field.ty { let segments = &type_path.path.segments; @@ -70,7 +65,7 @@ fn impl_field(field: &Field) -> TokenStream { if ident == "Option" { return quote! { writer.write_optional(stringify!(#name_str), &self.#name)?; - } + }; } } } @@ -80,5 +75,3 @@ fn impl_field(field: &Field) -> TokenStream { } } } - - diff --git a/src/bin/topola-egui/app.rs b/src/bin/topola-egui/app.rs index b62574c..30605a2 100644 --- a/src/bin/topola-egui/app.rs +++ b/src/bin/topola-egui/app.rs @@ -23,7 +23,6 @@ use topola::{ rules::RulesTrait, Drawing, Infringement, LayoutException, }, - dsn::{design::DsnDesign, mesadata::DsnMesadata}, geometry::{ compound::CompoundManagerTrait, primitive::{BendShape, DotShape, PrimitiveShape, PrimitiveShapeTrait, SegShape}, @@ -38,6 +37,7 @@ use topola::{ tracer::{Trace, Tracer}, EmptyRouterObserver, RouterObserverTrait, }, + specctra::{design::SpecctraDesign, mesadata::SpecctraMesadata}, }; use crate::{layers::Layers, overlay::Overlay, painter::Painter, top::Top, viewport::Viewport}; @@ -60,7 +60,7 @@ pub struct App { overlay: Option, #[serde(skip)] - invoker: Option>>>, + invoker: Option>>>, #[serde(skip)] shared_data: Arc>, @@ -164,7 +164,7 @@ impl eframe::App for App { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { if cfg!(target_arch = "wasm32") { if let Ok(file_contents) = self.text_channel.1.try_recv() { - let design = DsnDesign::load_from_string(file_contents).unwrap(); + let design = SpecctraDesign::load_from_string(file_contents).unwrap(); let board = design.make_board(); self.overlay = Some(Overlay::new(&board).unwrap()); self.layers = Some(Layers::new(&board)); @@ -174,7 +174,7 @@ impl eframe::App for App { } } else { if let Ok(path) = self.text_channel.1.try_recv() { - let design = DsnDesign::load_from_file(&path).unwrap(); + let design = SpecctraDesign::load_from_file(&path).unwrap(); let board = design.make_board(); self.overlay = Some(Overlay::new(&board).unwrap()); self.layers = Some(Layers::new(&board)); diff --git a/src/bin/topola-egui/top.rs b/src/bin/topola-egui/top.rs index 99292b7..c02b97b 100644 --- a/src/bin/topola-egui/top.rs +++ b/src/bin/topola-egui/top.rs @@ -5,7 +5,7 @@ use std::{ use topola::{ autorouter::invoker::{Command, Execute, Invoker, InvokerStatus}, - dsn::mesadata::DsnMesadata, + specctra::mesadata::SpecctraMesadata, }; use crate::{ @@ -31,7 +31,7 @@ impl Top { ctx: &egui::Context, shared_data: Arc>, sender: Sender, - maybe_invoker: &Option>>>, + maybe_invoker: &Option>>>, maybe_overlay: &Option, ) { egui::TopBottomPanel::top("top_panel").show(ctx, |ui| { diff --git a/src/bin/topola-egui/viewport.rs b/src/bin/topola-egui/viewport.rs index f44dc53..9008173 100644 --- a/src/bin/topola-egui/viewport.rs +++ b/src/bin/topola-egui/viewport.rs @@ -6,11 +6,11 @@ use topola::{ autorouter::invoker::{Command, Invoker}, board::mesadata::MesadataTrait, drawing::{graph::MakePrimitive, primitive::MakePrimitiveShape}, - dsn::mesadata::DsnMesadata, geometry::{shape::ShapeTrait, GenericNode}, layout::{via::ViaWeight, zone::MakePolyShape}, math::Circle, router::EmptyRouterObserver, + specctra::mesadata::SpecctraMesadata, }; use crate::{ @@ -37,7 +37,7 @@ impl Viewport { ctx: &egui::Context, top: &Top, shared_data: Arc>, - maybe_invoker: &Option>>>, + maybe_invoker: &Option>>>, maybe_overlay: &mut Option, maybe_layers: &Option, ) { diff --git a/src/bin/topola-sdl2-demo/main.rs b/src/bin/topola-sdl2-demo/main.rs index 6a4d9e6..f07c70a 100644 --- a/src/bin/topola-sdl2-demo/main.rs +++ b/src/bin/topola-sdl2-demo/main.rs @@ -20,8 +20,6 @@ use topola::drawing::primitive::MakePrimitiveShape; use topola::drawing::rules::{Conditions, RulesTrait}; use topola::drawing::seg::FixedSegWeight; use topola::drawing::{Infringement, LayoutException}; -use topola::dsn::design::DsnDesign; -use topola::dsn::mesadata::DsnMesadata; use topola::geometry::primitive::{PrimitiveShape, PrimitiveShapeTrait}; use topola::geometry::shape::ShapeTrait; use topola::layout::zone::MakePolyShape; @@ -30,6 +28,8 @@ use topola::router::draw::DrawException; use topola::router::navmesh::{Navmesh, NavmeshEdgeReference, NavvertexIndex}; use topola::router::tracer::{Trace, Tracer}; use topola::router::RouterObserverTrait; +use topola::specctra::design::SpecctraDesign; +use topola::specctra::mesadata::SpecctraMesadata; use sdl2::event::Event; use sdl2::keyboard::Keycode; @@ -246,7 +246,7 @@ fn main() -> Result<(), anyhow::Error> { ]), }));*/ - let design = DsnDesign::load_from_file( + let design = SpecctraDesign::load_from_file( "tests/data/de9_tht_female_to_tht_female/de9_tht_female_to_tht_female.dsn", )?; //let design = DsnDesign::load_from_file("tests/data/test/test.dsn")?; diff --git a/src/lib.rs b/src/lib.rs index 7e09708..6084948 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,9 +5,9 @@ pub mod graph; pub mod drawing; pub mod autorouter; pub mod board; -pub mod dsn; pub mod geometry; pub mod layout; pub mod math; pub mod router; +pub mod specctra; pub mod triangulation; diff --git a/src/dsn/common.rs b/src/specctra/common.rs similarity index 100% rename from src/dsn/common.rs rename to src/specctra/common.rs diff --git a/src/dsn/de.rs b/src/specctra/de.rs similarity index 100% rename from src/dsn/de.rs rename to src/specctra/de.rs diff --git a/src/dsn/design.rs b/src/specctra/design.rs similarity index 96% rename from src/dsn/design.rs rename to src/specctra/design.rs index c62d1f0..2321f85 100644 --- a/src/dsn/design.rs +++ b/src/specctra/design.rs @@ -6,13 +6,13 @@ use thiserror::Error; use crate::{ board::{mesadata::MesadataTrait, Board}, drawing::{dot::FixedDotWeight, seg::FixedSegWeight, Drawing}, - dsn::{ - de, - mesadata::DsnMesadata, - structure::{self, DsnFile, Layer, Pcb, Shape}, - }, layout::{zone::SolidZoneWeight, Layout}, math::Circle, + specctra::{ + de, + mesadata::SpecctraMesadata, + structure::{self, Layer, Pcb, Shape, SpecctraFile}, + }, }; #[derive(Error, Debug)] @@ -24,23 +24,18 @@ pub enum LoadingError { } #[derive(Debug)] -pub struct DsnDesign { +pub struct SpecctraDesign { pcb: Pcb, } -impl DsnDesign { +impl SpecctraDesign { pub fn load_from_file(filename: &str) -> Result { let file = std::fs::File::open(filename)?; let reader = std::io::BufReader::new(file); let mut list_reader = super::read::ListTokenizer::new(reader); - let dsn = list_reader.read_value::(); - - // TODO: make_board() still uses the old version of structure.rs - // so we can't pass the data to topola for real - - if let Ok(dsn) = dsn { - use super::structure::*; + if let Ok(file) = list_reader.read_value::() { + //use super::structure::*; // (this entire if let block does not belong here) @@ -107,9 +102,8 @@ impl DsnDesign { //println!("{:?}", list_writer.write_value(&ses)); - Ok(Self { pcb: dsn.pcb }) + Ok(Self { pcb: file.pcb }) } else { - dbg!(dsn); todo!(); } } @@ -121,15 +115,15 @@ impl DsnDesign { Ok(Self { pcb })*/ let mut list_reader = super::read::ListTokenizer::new(contents.as_bytes()); - let dsn = list_reader.read_value::(); + let dsn = list_reader.read_value::(); Ok(Self { pcb: dsn.unwrap().pcb, }) } - pub fn make_board(&self) -> Board { - let mesadata = DsnMesadata::from_pcb(&self.pcb); + pub fn make_board(&self) -> Board { + let mesadata = SpecctraMesadata::from_pcb(&self.pcb); let mut board = Board::new(Layout::new(Drawing::new( mesadata, self.pcb.structure.layers.len(), @@ -422,7 +416,7 @@ impl DsnDesign { } fn layer( - board: &Board, + board: &Board, layers: &Vec, layername: &str, front: bool, @@ -442,7 +436,7 @@ impl DsnDesign { } fn add_circle( - board: &mut Board, + board: &mut Board, place_pos: Point, place_rot: f64, pin_pos: Point, @@ -468,7 +462,7 @@ impl DsnDesign { } fn add_rect( - board: &mut Board, + board: &mut Board, place_pos: Point, place_rot: f64, pin_pos: Point, @@ -579,7 +573,7 @@ impl DsnDesign { } fn add_path( - board: &mut Board, + board: &mut Board, place_pos: Point, place_rot: f64, pin_pos: Point, @@ -656,7 +650,7 @@ impl DsnDesign { } fn add_polygon( - board: &mut Board, + board: &mut Board, place_pos: Point, place_rot: f64, pin_pos: Point, diff --git a/src/dsn/mesadata.rs b/src/specctra/mesadata.rs similarity index 87% rename from src/dsn/mesadata.rs rename to src/specctra/mesadata.rs index e31e42e..aa9f0f1 100644 --- a/src/dsn/mesadata.rs +++ b/src/specctra/mesadata.rs @@ -5,16 +5,16 @@ use bimap::BiHashMap; use crate::{ board::mesadata::MesadataTrait, drawing::rules::{Conditions, RulesTrait}, - dsn::structure::Pcb, + specctra::structure::Pcb, }; #[derive(Debug)] -pub struct DsnRule { +pub struct SpecctraRule { pub width: f64, pub clearance: f64, } -impl DsnRule { +impl SpecctraRule { fn from_dsn(rule: &super::structure::Rule) -> Self { Self { width: rule.width as f64, @@ -24,10 +24,10 @@ impl DsnRule { } #[derive(Debug)] -pub struct DsnMesadata { - structure_rule: DsnRule, +pub struct SpecctraMesadata { + structure_rule: SpecctraRule, // net class name -> rule - class_rules: HashMap, + class_rules: HashMap, // layername <-> layer for Layout pub layer_layername: BiHashMap, @@ -39,7 +39,7 @@ pub struct DsnMesadata { net_netclass: HashMap, } -impl DsnMesadata { +impl SpecctraMesadata { pub fn from_pcb(pcb: &Pcb) -> Self { let layer_layername = BiHashMap::from_iter( pcb.structure @@ -69,11 +69,11 @@ impl DsnMesadata { net_netclass.insert(*net, class.name.clone()); } }) - .map(|class| (class.name.clone(), DsnRule::from_dsn(&class.rule))), + .map(|class| (class.name.clone(), SpecctraRule::from_dsn(&class.rule))), ); Self { - structure_rule: DsnRule::from_dsn(&pcb.structure.rule), + structure_rule: SpecctraRule::from_dsn(&pcb.structure.rule), class_rules, layer_layername, net_netname, @@ -81,7 +81,7 @@ impl DsnMesadata { } } - pub fn get_rule(&self, net: usize) -> &DsnRule { + pub fn get_rule(&self, net: usize) -> &SpecctraRule { if let Some(netclass) = self.net_netclass.get(&net) { self.class_rules .get(netclass) @@ -92,7 +92,7 @@ impl DsnMesadata { } } -impl RulesTrait for DsnMesadata { +impl RulesTrait for SpecctraMesadata { fn clearance(&self, conditions1: &Conditions, conditions2: &Conditions) -> f64 { let (Some(net1), Some(net2)) = (conditions1.maybe_net, conditions2.maybe_net) else { return 0.0; @@ -121,7 +121,7 @@ impl RulesTrait for DsnMesadata { } } -impl MesadataTrait for DsnMesadata { +impl MesadataTrait for SpecctraMesadata { fn bename_layer(&mut self, layer: usize, layername: String) { self.layer_layername.insert(layer, layername); } diff --git a/src/dsn/mod.rs b/src/specctra/mod.rs similarity index 100% rename from src/dsn/mod.rs rename to src/specctra/mod.rs diff --git a/src/dsn/read.rs b/src/specctra/read.rs similarity index 100% rename from src/dsn/read.rs rename to src/specctra/read.rs diff --git a/src/dsn/structure.rs b/src/specctra/structure.rs similarity index 82% rename from src/dsn/structure.rs rename to src/specctra/structure.rs index eccc704..0714672 100644 --- a/src/dsn/structure.rs +++ b/src/specctra/structure.rs @@ -2,39 +2,39 @@ use super::common::ListToken; use super::read::ReadDsn; use super::read::{ListTokenizer, ParseError}; use super::write::ListWriter; -use super::write::WriteDsn; -use dsn_derive::ReadDsn; -use dsn_derive::WriteDsn; +use super::write::WriteSes; +use specctra_derive::ReadDsn; +use specctra_derive::WriteSes; -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Dummy {} -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct SesFile { pub session: Session, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Session { #[anon] pub id: String, pub routes: Routes, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Routes { pub resolution: Resolution, pub library_out: Library, pub network_out: NetworkOut, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct NetworkOut { #[vec("net")] pub net: Vec, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct NetOut { #[anon] pub name: String, @@ -44,12 +44,12 @@ pub struct NetOut { pub via: Vec, } -#[derive(ReadDsn, WriteDsn, Debug)] -pub struct DsnFile { +#[derive(ReadDsn, WriteSes, Debug)] +pub struct SpecctraFile { pub pcb: Pcb, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Pcb { #[anon] pub name: String, @@ -63,7 +63,7 @@ pub struct Pcb { pub wiring: Wiring, } -#[derive(WriteDsn, Debug)] +#[derive(WriteSes, Debug)] pub struct Parser { pub string_quote: Option, pub space_in_quoted_tokens: Option, @@ -71,7 +71,7 @@ pub struct Parser { pub host_version: Option, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Resolution { #[anon] pub unit: String, @@ -79,7 +79,7 @@ pub struct Resolution { pub value: f32, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Structure { #[vec("layer")] pub layers: Vec, @@ -90,7 +90,7 @@ pub struct Structure { pub rule: Rule, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Layer { #[anon] pub name: String, @@ -98,36 +98,36 @@ pub struct Layer { pub property: Property, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Property { pub index: usize, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Boundary { pub path: Path, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Plane { #[anon] pub net: String, pub polygon: Polygon, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct ViaNames { #[anon_vec] pub names: Vec, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Placement { #[vec("component")] pub components: Vec, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Component { #[anon] pub name: String, @@ -135,7 +135,7 @@ pub struct Component { pub places: Vec, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] #[allow(non_snake_case)] pub struct Place { #[anon] @@ -151,7 +151,7 @@ pub struct Place { pub PN: Option, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Library { #[vec("image")] pub images: Vec, @@ -159,7 +159,7 @@ pub struct Library { pub padstacks: Vec, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Image { #[anon] pub name: String, @@ -171,12 +171,12 @@ pub struct Image { pub keepouts: Vec, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Outline { pub path: Path, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Pin { #[anon] pub name: String, @@ -189,12 +189,12 @@ pub struct Pin { pub y: f32, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Rotate { pub angle: f32, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Keepout { #[anon] pub idk: String, @@ -202,7 +202,7 @@ pub struct Keepout { pub shape: Shape, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Padstack { #[anon] pub name: String, @@ -235,7 +235,7 @@ impl ReadDsn for Shape { } } -impl WriteDsn for Shape { +impl WriteSes for Shape { fn write_dsn(&self, writer: &mut ListWriter) -> Result<(), std::io::Error> { match self { Self::Circle(inner) => writer.write_named("circle", inner), @@ -246,7 +246,7 @@ impl WriteDsn for Shape { } } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Circle { #[anon] pub layer: String, @@ -256,7 +256,7 @@ pub struct Circle { pub offset: Option, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Network { #[vec("net")] pub nets: Vec, @@ -264,7 +264,7 @@ pub struct Network { pub classes: Vec, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] // dsn names this "net", but it's a structure unrelated to "net" in wiring or elsewhere pub struct NetPinAssignments { #[anon] @@ -272,13 +272,13 @@ pub struct NetPinAssignments { pub pins: Pins, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Pins { #[anon_vec] pub names: Vec, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Class { #[anon] pub name: String, @@ -288,12 +288,12 @@ pub struct Class { pub rule: Rule, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Circuit { pub use_via: String, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Wiring { #[vec("wire")] pub wires: Vec, @@ -301,7 +301,7 @@ pub struct Wiring { pub vias: Vec, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Wire { pub path: Path, pub net: String, @@ -355,7 +355,7 @@ impl ReadDsn for Option { } } -impl WriteDsn for Vec { +impl WriteSes for Vec { fn write_dsn(&self, writer: &mut ListWriter) -> Result<(), std::io::Error> { for elem in self { writer.write_value(&elem.x)?; @@ -365,7 +365,7 @@ impl WriteDsn for Vec { } } -impl WriteDsn for Option { +impl WriteSes for Option { fn write_dsn(&self, writer: &mut ListWriter) -> Result<(), std::io::Error> { if let Some(value) = self { writer.write_value(&value.x)?; @@ -375,7 +375,7 @@ impl WriteDsn for Option { } } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Polygon { #[anon] pub layer: String, @@ -385,7 +385,7 @@ pub struct Polygon { pub coords: Vec, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Path { #[anon] pub layer: String, @@ -395,7 +395,7 @@ pub struct Path { pub coords: Vec, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Rect { #[anon] pub layer: String, @@ -409,7 +409,7 @@ pub struct Rect { pub y2: f32, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Via { #[anon] pub name: String, @@ -421,14 +421,14 @@ pub struct Via { pub r#type: String, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Rule { pub width: f32, #[vec("clearance")] pub clearances: Vec, } -#[derive(ReadDsn, WriteDsn, Debug)] +#[derive(ReadDsn, WriteSes, Debug)] pub struct Clearance { #[anon] pub value: f32, diff --git a/src/dsn/write.rs b/src/specctra/write.rs similarity index 87% rename from src/dsn/write.rs rename to src/specctra/write.rs index f90a963..538f627 100644 --- a/src/dsn/write.rs +++ b/src/specctra/write.rs @@ -1,17 +1,17 @@ use super::common::ListToken; use std::io; -pub trait WriteDsn { +pub trait WriteSes { fn write_dsn(&self, writer: &mut ListWriter) -> Result<(), io::Error>; } -impl WriteDsn for char { +impl WriteSes for char { fn write_dsn(&self, writer: &mut ListWriter) -> Result<(), io::Error> { writer.write_leaf(self.to_string()) } } -impl WriteDsn for String { +impl WriteSes for String { fn write_dsn(&self, writer: &mut ListWriter) -> Result<(), io::Error> { let string = if self.len() == 0 { "\"\"".to_string() @@ -28,7 +28,7 @@ impl WriteDsn for String { } } -impl WriteDsn for bool { +impl WriteSes for bool { fn write_dsn(&self, writer: &mut ListWriter) -> Result<(), io::Error> { writer.write_leaf(match self { true => "on".to_string(), @@ -37,25 +37,25 @@ impl WriteDsn for bool { } } -impl WriteDsn for i32 { +impl WriteSes for i32 { fn write_dsn(&self, writer: &mut ListWriter) -> Result<(), io::Error> { writer.write_leaf(self.to_string()) } } -impl WriteDsn for u32 { +impl WriteSes for u32 { fn write_dsn(&self, writer: &mut ListWriter) -> Result<(), io::Error> { writer.write_leaf(self.to_string()) } } -impl WriteDsn for usize { +impl WriteSes for usize { fn write_dsn(&self, writer: &mut ListWriter) -> Result<(), io::Error> { writer.write_leaf(self.to_string()) } } -impl WriteDsn for f32 { +impl WriteSes for f32 { fn write_dsn(&self, writer: &mut ListWriter) -> Result<(), io::Error> { writer.write_leaf(self.to_string()) } @@ -116,11 +116,11 @@ impl ListWriter { self.write_token(ListToken::Leaf { value }) } - pub fn write_value>(&mut self, value: &T) -> Result<(), io::Error> { + pub fn write_value>(&mut self, value: &T) -> Result<(), io::Error> { value.write_dsn(self) } - pub fn write_named>( + pub fn write_named>( &mut self, name: &'static str, value: &T, @@ -134,7 +134,7 @@ impl ListWriter { Ok(()) } - pub fn write_optional>( + pub fn write_optional>( &mut self, name: &'static str, optional: &Option, @@ -146,7 +146,7 @@ impl ListWriter { Ok(()) } - pub fn write_array>(&mut self, array: &Vec) -> Result<(), io::Error> { + pub fn write_array>(&mut self, array: &Vec) -> Result<(), io::Error> { for elem in array { self.write_value(elem)?; } @@ -154,7 +154,7 @@ impl ListWriter { Ok(()) } - pub fn write_named_array>( + pub fn write_named_array>( &mut self, name: &'static str, array: &Vec, diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 390ec50..cdd27c8 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -9,12 +9,12 @@ use topola::{ }, board::{mesadata::MesadataTrait, Board}, drawing::graph::{GetLayer, GetMaybeNet}, - dsn::{design::DsnDesign, mesadata::DsnMesadata}, graph::GetNodeIndex, + specctra::{design::SpecctraDesign, mesadata::SpecctraMesadata}, }; -pub fn load_design_and_assert(filename: &str) -> Invoker { - let design = DsnDesign::load_from_file(filename).unwrap(); +pub fn load_design_and_assert(filename: &str) -> Invoker { + let design = SpecctraDesign::load_from_file(filename).unwrap(); let mut invoker = Invoker::new(Autorouter::new(design.make_board()).unwrap()); assert!(matches!( @@ -29,7 +29,7 @@ pub fn load_design_and_assert(filename: &str) -> Invoker { invoker } -pub fn replay_and_assert(invoker: &mut Invoker, filename: &str) { +pub fn replay_and_assert(invoker: &mut Invoker, filename: &str) { let file = File::open(filename).unwrap(); invoker.replay(serde_json::from_reader(file).unwrap());