From 02e483c8cdaba081518076aeeecaba41265225f7 Mon Sep 17 00:00:00 2001 From: jan Date: Sun, 8 May 2022 16:41:43 -0700 Subject: [PATCH] update to 2021 edition --- Cargo.toml | 3 ++- src/__init__.rs | 29 ----------------------------- src/elements.rs | 8 ++++---- src/lib.rs | 1 - src/library.rs | 27 ++++++++++++++------------- src/record.rs | 8 ++++---- src/records.rs | 2 +- 7 files changed, 25 insertions(+), 53 deletions(-) delete mode 100644 src/__init__.rs diff --git a/Cargo.toml b/Cargo.toml index 414196a..01429e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,8 @@ name = "rs-klamath" version = "0.1.0" authors = ["jan "] +edition = "2021" [dependencies] byteorder = "^1" -nom = "^7" +#nom = "^7" diff --git a/src/__init__.rs b/src/__init__.rs deleted file mode 100644 index 44d6c6b..0000000 --- a/src/__init__.rs +++ /dev/null @@ -1,29 +0,0 @@ -/* - * `klamath` is a Python module for reading and writing to the GDSII file format. - * - * The goal is to keep this library simple: - * - Map data types directly wherever possible. - * * Presents an accurate representation of what is saved to the file. - * * Avoids excess copies / allocations for speed. - * * No "automatic" error checking, except when casting datatypes. - * If data integrity checks are provided at all, they must be - * explicitly run by the caller. - * - Low-level functionality is first-class. - * * Meant for use-cases where the caller wants to read or write - * individual GDS records. - * * Offers complete control over the written file. - * - Opinionated and limited high-level functionality. - * * Discards or ignores rarely-encountered data types. - * * Keeps functions simple and reusable. - * * Only de/encodes the file format, doesn't provide tools to modify - * the data itself. - * * Still requires explicit values for most fields. - * - No compilation - * * Uses `numpy` for speed, since it's commonly available / pre-built. - * * Building this library should not require a compiler. - * - * `klamath` was built to provide a fast and versatile GDS interface for - * [masque](https://mpxd.net/code/jan/masque), which provides higher-level - * tools for working with hierarchical design data and supports multiple - * file formats. - */ diff --git a/src/elements.rs b/src/elements.rs index 8c2e35b..516a622 100644 --- a/src/elements.rs +++ b/src/elements.rs @@ -3,16 +3,16 @@ /// structure references) and associated properties. /// -use records::{BOX, BOUNDARY, NODE, PATH, TEXT, SREF, AREF, +use crate::records::{BOX, BOUNDARY, NODE, PATH, TEXT, SREF, AREF, DATATYPE, PATHTYPE, BOXTYPE, NODETYPE, TEXTTYPE, LAYER, XY, WIDTH, COLROW, PRESENTATION, STRING, STRANS, MAG, ANGLE, PROPATTR, PROPVALUE, ENDEL, BGNEXTN, ENDEXTN, SNAME, }; -use records; -use record::{RecordHeader, Record}; -use basic::{OResult, IResult, fail}; +use crate::records; +use crate::record::{RecordHeader, Record}; +use crate::basic::{OResult, IResult, fail}; use std::collections::HashMap; use std::io::Write; diff --git a/src/lib.rs b/src/lib.rs index b17d455..dbaf483 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,4 @@ //#![feature(generic_associated_types)] -#![feature(destructuring_assignment)] extern crate byteorder; diff --git a/src/library.rs b/src/library.rs index 06ff7ba..84d74dc 100644 --- a/src/library.rs +++ b/src/library.rs @@ -5,12 +5,12 @@ use std::io::Write; use std::collections::HashMap; -use record; -use record::{RecordHeader, Record}; -use records; -use elements; -use elements::{Element}; -use basic::{IResult, OResult, take_bytes, fail}; +use crate::record; +use crate::record::{RecordHeader, Record}; +use crate::records; +use crate::elements; +use crate::elements::{Element}; +use crate::basic::{IResult, OResult, take_bytes, fail}; const DEFAULT_DATE: [i16; 6] = [1900, 0, 0, 0, 0, 0]; @@ -289,6 +289,7 @@ impl Cell { } +/* /// /// Scan through a GDS file, building a table of instance counts /// `{b'structure_name': {b'ref_name': count}}`. @@ -304,8 +305,10 @@ impl Cell { pub fn scan_hierarchy(input: &[u8]) -> IResult, HashMap::, u32>>> { let mut structures = HashMap::new(); - + let mut ref_name = None; + let mut ref_count = None; let (mut input, mut header) = RecordHeader::read(input)?; + let mut cur_structure = HashMap::new(); while header.tag != records::RTAG_ENDLIB { match header.tag { records::RTAG_BGNSTR => { @@ -317,8 +320,6 @@ pub fn scan_hierarchy(input: &[u8]) -> IResult, HashMap:: IResult, HashMap:: IResult, u32))> { let (input, found_struc) = records::BGNSTR.skip_past(input)?; - if not found_struc { + if !found_struc { return Ok((input, None)) } let mut cur_structure = HashMap::new(); @@ -390,3 +390,4 @@ pub fn count_ref(input: &[u8]) -> IResult, u32))> { structures.insert(name, cur_structure); (input, header) = RecordHeader::read(input1)?; } +*/ diff --git a/src/record.rs b/src/record.rs index 8d01c93..7d04085 100644 --- a/src/record.rs +++ b/src/record.rs @@ -6,10 +6,10 @@ use std::convert::TryInto; use byteorder::{ByteOrder, BigEndian}; -use basic::{pack_datetime, pack_bitarray, pack_ascii, pack_int2, pack_int4, pack_real8}; #[warn(unused_imports)] -use basic::{parse_datetime, parse_bitarray, parse_ascii, parse_int2, parse_int4, parse_real8}; #[warn(unused_imports)] -use basic::{OResult, IResult, fail, parse_u16, take_bytes}; -use records; +use crate::basic::{pack_datetime, pack_bitarray, pack_ascii, pack_int2, pack_int4, pack_real8}; #[warn(unused_imports)] +use crate::basic::{parse_datetime, parse_bitarray, parse_ascii, parse_int2, parse_int4, parse_real8}; #[warn(unused_imports)] +use crate::basic::{OResult, IResult, fail, parse_u16, take_bytes}; +use crate::records; //#[no_mangle] diff --git a/src/records.rs b/src/records.rs index 972cc78..21a5bb0 100644 --- a/src/records.rs +++ b/src/records.rs @@ -2,7 +2,7 @@ /// Record type and tag definitions /// -use record::{Record, Int2, Int4, Int2Array, Int4Array, Real8, Real8Pair, DateTimePair, BitArray, ASCII, Empty}; +use crate::record::{Record, Int2, Int4, Int2Array, Int4Array, Real8, Real8Pair, DateTimePair, BitArray, ASCII, Empty}; //use std::io::Write;