mirror of https://codeberg.org/topola/topola.git
specctra: change "dsn" to "specctra" where it's about both DSN and SES
This commit is contained in:
parent
96ad809a83
commit
9d00e95457
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "dsn_derive"
|
||||
name = "specctra_derive"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
|
|
@ -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<Attribute>, name: &str) -> Option<String> {
|
|||
attrs
|
||||
.iter()
|
||||
.find(|attr| attr.path().is_ident(name))
|
||||
.and_then(|attr| Some(attr
|
||||
.parse_args::<LitStr>()
|
||||
.expect("string literal")
|
||||
.value()
|
||||
))
|
||||
.and_then(|attr| Some(attr.parse_args::<LitStr>().expect("string literal").value()))
|
||||
}
|
||||
|
||||
|
|
@ -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<W: std::io::Write> WriteDsn<W> for #name {
|
||||
impl<W: std::io::Write> WriteSes<W> for #name {
|
||||
fn write_dsn(&self, writer: &mut ListWriter<W>)
|
||||
-> std::io::Result<()>
|
||||
{
|
||||
|
|
@ -25,12 +25,9 @@ pub fn impl_write(input: &DeriveInput) -> TokenStream {
|
|||
|
||||
fn impl_body(data: &Data) -> TokenStream {
|
||||
match data {
|
||||
Data::Struct(data) => {
|
||||
match &data.fields {
|
||||
Data::Struct(data) => match &data.fields {
|
||||
Fields::Named(fields) => {
|
||||
let fields = fields.named.iter().map(|field| {
|
||||
impl_field(field)
|
||||
});
|
||||
let fields = fields.named.iter().map(|field| impl_field(field));
|
||||
|
||||
quote! {
|
||||
#(#fields)*
|
||||
|
|
@ -38,10 +35,9 @@ fn impl_body(data: &Data) -> TokenStream {
|
|||
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 {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -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<Overlay>,
|
||||
|
||||
#[serde(skip)]
|
||||
invoker: Option<Arc<Mutex<Invoker<DsnMesadata>>>>,
|
||||
invoker: Option<Arc<Mutex<Invoker<SpecctraMesadata>>>>,
|
||||
|
||||
#[serde(skip)]
|
||||
shared_data: Arc<Mutex<SharedData>>,
|
||||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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<Mutex<SharedData>>,
|
||||
sender: Sender<String>,
|
||||
maybe_invoker: &Option<Arc<Mutex<Invoker<DsnMesadata>>>>,
|
||||
maybe_invoker: &Option<Arc<Mutex<Invoker<SpecctraMesadata>>>>,
|
||||
maybe_overlay: &Option<Overlay>,
|
||||
) {
|
||||
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
|
||||
|
|
|
|||
|
|
@ -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<Mutex<SharedData>>,
|
||||
maybe_invoker: &Option<Arc<Mutex<Invoker<DsnMesadata>>>>,
|
||||
maybe_invoker: &Option<Arc<Mutex<Invoker<SpecctraMesadata>>>>,
|
||||
maybe_overlay: &mut Option<Overlay>,
|
||||
maybe_layers: &Option<Layers>,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -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")?;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<Self, LoadingError> {
|
||||
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::<super::structure::DsnFile>();
|
||||
|
||||
// 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::<super::structure::SpecctraFile>() {
|
||||
//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::<super::structure::DsnFile>();
|
||||
let dsn = list_reader.read_value::<super::structure::SpecctraFile>();
|
||||
|
||||
Ok(Self {
|
||||
pcb: dsn.unwrap().pcb,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn make_board(&self) -> Board<DsnMesadata> {
|
||||
let mesadata = DsnMesadata::from_pcb(&self.pcb);
|
||||
pub fn make_board(&self) -> Board<SpecctraMesadata> {
|
||||
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<DsnMesadata>,
|
||||
board: &Board<SpecctraMesadata>,
|
||||
layers: &Vec<Layer>,
|
||||
layername: &str,
|
||||
front: bool,
|
||||
|
|
@ -442,7 +436,7 @@ impl DsnDesign {
|
|||
}
|
||||
|
||||
fn add_circle(
|
||||
board: &mut Board<DsnMesadata>,
|
||||
board: &mut Board<SpecctraMesadata>,
|
||||
place_pos: Point,
|
||||
place_rot: f64,
|
||||
pin_pos: Point,
|
||||
|
|
@ -468,7 +462,7 @@ impl DsnDesign {
|
|||
}
|
||||
|
||||
fn add_rect(
|
||||
board: &mut Board<DsnMesadata>,
|
||||
board: &mut Board<SpecctraMesadata>,
|
||||
place_pos: Point,
|
||||
place_rot: f64,
|
||||
pin_pos: Point,
|
||||
|
|
@ -579,7 +573,7 @@ impl DsnDesign {
|
|||
}
|
||||
|
||||
fn add_path(
|
||||
board: &mut Board<DsnMesadata>,
|
||||
board: &mut Board<SpecctraMesadata>,
|
||||
place_pos: Point,
|
||||
place_rot: f64,
|
||||
pin_pos: Point,
|
||||
|
|
@ -656,7 +650,7 @@ impl DsnDesign {
|
|||
}
|
||||
|
||||
fn add_polygon(
|
||||
board: &mut Board<DsnMesadata>,
|
||||
board: &mut Board<SpecctraMesadata>,
|
||||
place_pos: Point,
|
||||
place_rot: f64,
|
||||
pin_pos: Point,
|
||||
|
|
@ -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<String, DsnRule>,
|
||||
class_rules: HashMap<String, SpecctraRule>,
|
||||
|
||||
// layername <-> layer for Layout
|
||||
pub layer_layername: BiHashMap<usize, String>,
|
||||
|
|
@ -39,7 +39,7 @@ pub struct DsnMesadata {
|
|||
net_netclass: HashMap<usize, String>,
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
@ -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<NetOut>,
|
||||
}
|
||||
|
||||
#[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<Via>,
|
||||
}
|
||||
|
||||
#[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<char>,
|
||||
pub space_in_quoted_tokens: Option<bool>,
|
||||
|
|
@ -71,7 +71,7 @@ pub struct Parser {
|
|||
pub host_version: Option<String>,
|
||||
}
|
||||
|
||||
#[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<Layer>,
|
||||
|
|
@ -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<String>,
|
||||
}
|
||||
|
||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
||||
#[derive(ReadDsn, WriteSes, Debug)]
|
||||
pub struct Placement {
|
||||
#[vec("component")]
|
||||
pub components: Vec<Component>,
|
||||
}
|
||||
|
||||
#[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<Place>,
|
||||
}
|
||||
|
||||
#[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<String>,
|
||||
}
|
||||
|
||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
||||
#[derive(ReadDsn, WriteSes, Debug)]
|
||||
pub struct Library {
|
||||
#[vec("image")]
|
||||
pub images: Vec<Image>,
|
||||
|
|
@ -159,7 +159,7 @@ pub struct Library {
|
|||
pub padstacks: Vec<Padstack>,
|
||||
}
|
||||
|
||||
#[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<Keepout>,
|
||||
}
|
||||
|
||||
#[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<R: std::io::BufRead> ReadDsn<R> for Shape {
|
|||
}
|
||||
}
|
||||
|
||||
impl<W: std::io::Write> WriteDsn<W> for Shape {
|
||||
impl<W: std::io::Write> WriteSes<W> for Shape {
|
||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), std::io::Error> {
|
||||
match self {
|
||||
Self::Circle(inner) => writer.write_named("circle", inner),
|
||||
|
|
@ -246,7 +246,7 @@ impl<W: std::io::Write> WriteDsn<W> 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<Point>,
|
||||
}
|
||||
|
||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
||||
#[derive(ReadDsn, WriteSes, Debug)]
|
||||
pub struct Network {
|
||||
#[vec("net")]
|
||||
pub nets: Vec<NetPinAssignments>,
|
||||
|
|
@ -264,7 +264,7 @@ pub struct Network {
|
|||
pub classes: Vec<Class>,
|
||||
}
|
||||
|
||||
#[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<String>,
|
||||
}
|
||||
|
||||
#[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<Wire>,
|
||||
|
|
@ -301,7 +301,7 @@ pub struct Wiring {
|
|||
pub vias: Vec<Via>,
|
||||
}
|
||||
|
||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
||||
#[derive(ReadDsn, WriteSes, Debug)]
|
||||
pub struct Wire {
|
||||
pub path: Path,
|
||||
pub net: String,
|
||||
|
|
@ -355,7 +355,7 @@ impl<R: std::io::BufRead> ReadDsn<R> for Option<Point> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<W: std::io::Write> WriteDsn<W> for Vec<Point> {
|
||||
impl<W: std::io::Write> WriteSes<W> for Vec<Point> {
|
||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), std::io::Error> {
|
||||
for elem in self {
|
||||
writer.write_value(&elem.x)?;
|
||||
|
|
@ -365,7 +365,7 @@ impl<W: std::io::Write> WriteDsn<W> for Vec<Point> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<W: std::io::Write> WriteDsn<W> for Option<Point> {
|
||||
impl<W: std::io::Write> WriteSes<W> for Option<Point> {
|
||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), std::io::Error> {
|
||||
if let Some(value) = self {
|
||||
writer.write_value(&value.x)?;
|
||||
|
|
@ -375,7 +375,7 @@ impl<W: std::io::Write> WriteDsn<W> for Option<Point> {
|
|||
}
|
||||
}
|
||||
|
||||
#[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<Point>,
|
||||
}
|
||||
|
||||
#[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<Point>,
|
||||
}
|
||||
|
||||
#[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<Clearance>,
|
||||
}
|
||||
|
||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
||||
#[derive(ReadDsn, WriteSes, Debug)]
|
||||
pub struct Clearance {
|
||||
#[anon]
|
||||
pub value: f32,
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
use super::common::ListToken;
|
||||
use std::io;
|
||||
|
||||
pub trait WriteDsn<W: io::Write> {
|
||||
pub trait WriteSes<W: io::Write> {
|
||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error>;
|
||||
}
|
||||
|
||||
impl<W: io::Write> WriteDsn<W> for char {
|
||||
impl<W: io::Write> WriteSes<W> for char {
|
||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
||||
writer.write_leaf(self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl<W: io::Write> WriteDsn<W> for String {
|
||||
impl<W: io::Write> WriteSes<W> for String {
|
||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
||||
let string = if self.len() == 0 {
|
||||
"\"\"".to_string()
|
||||
|
|
@ -28,7 +28,7 @@ impl<W: io::Write> WriteDsn<W> for String {
|
|||
}
|
||||
}
|
||||
|
||||
impl<W: io::Write> WriteDsn<W> for bool {
|
||||
impl<W: io::Write> WriteSes<W> for bool {
|
||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
||||
writer.write_leaf(match self {
|
||||
true => "on".to_string(),
|
||||
|
|
@ -37,25 +37,25 @@ impl<W: io::Write> WriteDsn<W> for bool {
|
|||
}
|
||||
}
|
||||
|
||||
impl<W: io::Write> WriteDsn<W> for i32 {
|
||||
impl<W: io::Write> WriteSes<W> for i32 {
|
||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
||||
writer.write_leaf(self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl<W: io::Write> WriteDsn<W> for u32 {
|
||||
impl<W: io::Write> WriteSes<W> for u32 {
|
||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
||||
writer.write_leaf(self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl<W: io::Write> WriteDsn<W> for usize {
|
||||
impl<W: io::Write> WriteSes<W> for usize {
|
||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
||||
writer.write_leaf(self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl<W: io::Write> WriteDsn<W> for f32 {
|
||||
impl<W: io::Write> WriteSes<W> for f32 {
|
||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
||||
writer.write_leaf(self.to_string())
|
||||
}
|
||||
|
|
@ -116,11 +116,11 @@ impl<W: io::Write> ListWriter<W> {
|
|||
self.write_token(ListToken::Leaf { value })
|
||||
}
|
||||
|
||||
pub fn write_value<T: WriteDsn<W>>(&mut self, value: &T) -> Result<(), io::Error> {
|
||||
pub fn write_value<T: WriteSes<W>>(&mut self, value: &T) -> Result<(), io::Error> {
|
||||
value.write_dsn(self)
|
||||
}
|
||||
|
||||
pub fn write_named<T: WriteDsn<W>>(
|
||||
pub fn write_named<T: WriteSes<W>>(
|
||||
&mut self,
|
||||
name: &'static str,
|
||||
value: &T,
|
||||
|
|
@ -134,7 +134,7 @@ impl<W: io::Write> ListWriter<W> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn write_optional<T: WriteDsn<W>>(
|
||||
pub fn write_optional<T: WriteSes<W>>(
|
||||
&mut self,
|
||||
name: &'static str,
|
||||
optional: &Option<T>,
|
||||
|
|
@ -146,7 +146,7 @@ impl<W: io::Write> ListWriter<W> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn write_array<T: WriteDsn<W>>(&mut self, array: &Vec<T>) -> Result<(), io::Error> {
|
||||
pub fn write_array<T: WriteSes<W>>(&mut self, array: &Vec<T>) -> Result<(), io::Error> {
|
||||
for elem in array {
|
||||
self.write_value(elem)?;
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ impl<W: io::Write> ListWriter<W> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn write_named_array<T: WriteDsn<W>>(
|
||||
pub fn write_named_array<T: WriteSes<W>>(
|
||||
&mut self,
|
||||
name: &'static str,
|
||||
array: &Vec<T>,
|
||||
|
|
@ -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<DsnMesadata> {
|
||||
let design = DsnDesign::load_from_file(filename).unwrap();
|
||||
pub fn load_design_and_assert(filename: &str) -> Invoker<SpecctraMesadata> {
|
||||
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<DsnMesadata> {
|
|||
invoker
|
||||
}
|
||||
|
||||
pub fn replay_and_assert(invoker: &mut Invoker<DsnMesadata>, filename: &str) {
|
||||
pub fn replay_and_assert(invoker: &mut Invoker<SpecctraMesadata>, filename: &str) {
|
||||
let file = File::open(filename).unwrap();
|
||||
invoker.replay(serde_json::from_reader(file).unwrap());
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue