PortsRef -> Abstract

This commit is contained in:
Jan Petykiewicz 2023-01-23 22:34:31 -08:00
parent 326c9b9727
commit aff0df33cc
3 changed files with 9 additions and 10 deletions

View File

@ -35,7 +35,7 @@ from .pattern import Pattern
from .utils import layer_t, annotations_t from .utils import layer_t, annotations_t
from .library import Library, MutableLibrary, WrapROLibrary, WrapLibrary, LazyLibrary from .library import Library, MutableLibrary, WrapROLibrary, WrapLibrary, LazyLibrary
from .ports import Port, PortList from .ports import Port, PortList
from .builder import Builder, PortsRef, Tool from .builder import Builder, Abstract, Tool
__author__ = 'Jan Petykiewicz' __author__ = 'Jan Petykiewicz'

View File

@ -1,3 +1,3 @@
from .builder import Builder, PortsRef from .builder import Builder, Abstract
from .utils import ell from .utils import ell
from .tools import Tool from .tools import Tool

View File

@ -19,11 +19,10 @@ from .utils import ell
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
B = TypeVar('B', bound='Builder') BB = TypeVar('BB', bound='Builder')
PR = TypeVar('PR', bound='PortsRef')
class PortsRef(PortList): class Abstract(PortList):
__slots__ = ('name', 'ports') __slots__ = ('name', 'ports')
name: str name: str
@ -60,7 +59,7 @@ class PortsRef(PortList):
# TODO do we want to store a Ref instead of just a name? then we can translate/rotate/mirror... # TODO do we want to store a Ref instead of just a name? then we can translate/rotate/mirror...
def __repr__(self) -> str: def __repr__(self) -> str:
s = f'<PortsRef {self.name} [' s = f'<Abstract {self.name} ['
for name, port in self.ports.items(): for name, port in self.ports.items():
s += f'\n\t{name}: {port}' s += f'\n\t{name}: {port}'
s += ']>' s += ']>'
@ -280,7 +279,7 @@ class Builder(PortList):
def plug( def plug(
self: B, self: B,
other: PR, other: Abstract,
map_in: Dict[str, str], map_in: Dict[str, str],
map_out: Optional[Dict[str, Optional[str]]] = None, map_out: Optional[Dict[str, Optional[str]]] = None,
*, *,
@ -375,7 +374,7 @@ class Builder(PortList):
def place( def place(
self: B, self: B,
other: PR, other: Abstract,
*, *,
offset: ArrayLike = (0, 0), offset: ArrayLike = (0, 0),
rotation: float = 0, rotation: float = 0,
@ -554,7 +553,7 @@ class Builder(PortList):
pat = tool.path(ccw, length, in_ptype=in_ptype, port_names=tool_port_names, **kwargs) pat = tool.path(ccw, length, in_ptype=in_ptype, port_names=tool_port_names, **kwargs)
name = self.library.get_name(base_name) name = self.library.get_name(base_name)
self.library._set(name, pat) self.library._set(name, pat)
return self.plug(PortsRef(name, pat.ports), {portspec: tool_port_names[0]}) return self.plug(Abstract(name, pat.ports), {portspec: tool_port_names[0]})
def path_to( def path_to(
self: B, self: B,
@ -637,7 +636,7 @@ class Builder(PortList):
bld.path(port_name, ccw, length, tool_port_names=tool_port_names) bld.path(port_name, ccw, length, tool_port_names=tool_port_names)
name = self.library.get_name(base_name) name = self.library.get_name(base_name)
self.library._set(name, bld.pattern) self.library._set(name, bld.pattern)
return self.plug(PortsRef(name, bld.pattern.ports), {sp: 'in_' + sp for sp in ports.keys()}) # TODO safe to use 'in_'? return self.plug(Abstract(name, bld.pattern.ports), {sp: 'in_' + sp for sp in ports.keys()}) # TODO safe to use 'in_'?
# TODO def path_join() and def bus_join()? # TODO def path_join() and def bus_join()?