update to 2021 edition
This commit is contained in:
parent
07100dee8e
commit
02e483c8cd
@ -2,7 +2,8 @@
|
|||||||
name = "rs-klamath"
|
name = "rs-klamath"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["jan <jan@mpxd.net>"]
|
authors = ["jan <jan@mpxd.net>"]
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
byteorder = "^1"
|
byteorder = "^1"
|
||||||
nom = "^7"
|
#nom = "^7"
|
||||||
|
@ -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.
|
|
||||||
*/
|
|
@ -3,16 +3,16 @@
|
|||||||
/// structure references) and associated properties.
|
/// 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,
|
DATATYPE, PATHTYPE, BOXTYPE, NODETYPE, TEXTTYPE,
|
||||||
LAYER, XY, WIDTH, COLROW, PRESENTATION, STRING,
|
LAYER, XY, WIDTH, COLROW, PRESENTATION, STRING,
|
||||||
STRANS, MAG, ANGLE, PROPATTR, PROPVALUE,
|
STRANS, MAG, ANGLE, PROPATTR, PROPVALUE,
|
||||||
ENDEL, BGNEXTN, ENDEXTN, SNAME,
|
ENDEL, BGNEXTN, ENDEXTN, SNAME,
|
||||||
};
|
};
|
||||||
|
|
||||||
use records;
|
use crate::records;
|
||||||
use record::{RecordHeader, Record};
|
use crate::record::{RecordHeader, Record};
|
||||||
use basic::{OResult, IResult, fail};
|
use crate::basic::{OResult, IResult, fail};
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
//#![feature(generic_associated_types)]
|
//#![feature(generic_associated_types)]
|
||||||
#![feature(destructuring_assignment)]
|
|
||||||
|
|
||||||
extern crate byteorder;
|
extern crate byteorder;
|
||||||
|
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use record;
|
use crate::record;
|
||||||
use record::{RecordHeader, Record};
|
use crate::record::{RecordHeader, Record};
|
||||||
use records;
|
use crate::records;
|
||||||
use elements;
|
use crate::elements;
|
||||||
use elements::{Element};
|
use crate::elements::{Element};
|
||||||
use basic::{IResult, OResult, take_bytes, fail};
|
use crate::basic::{IResult, OResult, take_bytes, fail};
|
||||||
|
|
||||||
|
|
||||||
const DEFAULT_DATE: [i16; 6] = [1900, 0, 0, 0, 0, 0];
|
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
|
/// Scan through a GDS file, building a table of instance counts
|
||||||
/// `{b'structure_name': {b'ref_name': count}}`.
|
/// `{b'structure_name': {b'ref_name': count}}`.
|
||||||
@ -304,8 +305,10 @@ impl Cell {
|
|||||||
pub fn scan_hierarchy(input: &[u8]) -> IResult<HashMap::<Vec<u8>, HashMap::<Vec<u8>, u32>>> {
|
pub fn scan_hierarchy(input: &[u8]) -> IResult<HashMap::<Vec<u8>, HashMap::<Vec<u8>, u32>>> {
|
||||||
let mut structures = HashMap::new();
|
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 input, mut header) = RecordHeader::read(input)?;
|
||||||
|
let mut cur_structure = HashMap::new();
|
||||||
while header.tag != records::RTAG_ENDLIB {
|
while header.tag != records::RTAG_ENDLIB {
|
||||||
match header.tag {
|
match header.tag {
|
||||||
records::RTAG_BGNSTR => {
|
records::RTAG_BGNSTR => {
|
||||||
@ -317,8 +320,6 @@ pub fn scan_hierarchy(input: &[u8]) -> IResult<HashMap::<Vec<u8>, HashMap::<Vec<
|
|||||||
return fail(input, format!("Duplicate structure name: {:?}", name));
|
return fail(input, format!("Duplicate structure name: {:?}", name));
|
||||||
}
|
}
|
||||||
let mut cur_structure = HashMap::new();
|
let mut cur_structure = HashMap::new();
|
||||||
let mut ref_name = None;
|
|
||||||
let mut ref_count = None;
|
|
||||||
structures.insert(name, cur_structure);
|
structures.insert(name, cur_structure);
|
||||||
ref_name = None;
|
ref_name = None;
|
||||||
ref_count = None;
|
ref_count = None;
|
||||||
@ -345,13 +346,12 @@ pub fn scan_hierarchy(input: &[u8]) -> IResult<HashMap::<Vec<u8>, HashMap::<Vec<
|
|||||||
}
|
}
|
||||||
Ok((input, structures))
|
Ok((input, structures))
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
while header.tag != records::RTAG_ENDLIB {
|
|
||||||
|
|
||||||
pub fn count_ref(input: &[u8]) -> IResult<Option((Vec<u8>, u32))> {
|
pub fn count_ref(input: &[u8]) -> IResult<Option((Vec<u8>, u32))> {
|
||||||
let (input, found_struc) = records::BGNSTR.skip_past(input)?;
|
let (input, found_struc) = records::BGNSTR.skip_past(input)?;
|
||||||
if not found_struc {
|
if !found_struc {
|
||||||
return Ok((input, None))
|
return Ok((input, None))
|
||||||
}
|
}
|
||||||
let mut cur_structure = HashMap::new();
|
let mut cur_structure = HashMap::new();
|
||||||
@ -390,3 +390,4 @@ pub fn count_ref(input: &[u8]) -> IResult<Option((Vec<u8>, u32))> {
|
|||||||
structures.insert(name, cur_structure);
|
structures.insert(name, cur_structure);
|
||||||
(input, header) = RecordHeader::read(input1)?;
|
(input, header) = RecordHeader::read(input1)?;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
@ -6,10 +6,10 @@ use std::convert::TryInto;
|
|||||||
use byteorder::{ByteOrder, BigEndian};
|
use byteorder::{ByteOrder, BigEndian};
|
||||||
|
|
||||||
|
|
||||||
use basic::{pack_datetime, pack_bitarray, pack_ascii, pack_int2, pack_int4, pack_real8}; #[warn(unused_imports)]
|
use crate::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 crate::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 crate::basic::{OResult, IResult, fail, parse_u16, take_bytes};
|
||||||
use records;
|
use crate::records;
|
||||||
|
|
||||||
|
|
||||||
//#[no_mangle]
|
//#[no_mangle]
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/// Record type and tag definitions
|
/// 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;
|
//use std::io::Write;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user