Skip to content

Commit

Permalink
Remove old __setattr__ implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardt committed Nov 8, 2018
1 parent e4f9bfb commit 5308df7
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions magma/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,11 @@ def circuit_to_html(cls):

# create an attribute for each port
def setports(self, ports):
self.ports_set = False
#print('setports', ports)
for name, port in ports.items():
#print(self, port, type(port))
if isinstance(name, str):
setattr(self, name, port)
self.ports_set = True

#
# Metaclass for creating circuits
Expand Down Expand Up @@ -95,18 +93,6 @@ def __new__(metacls, name, bases, dct):

return cls

def __setattr__(cls, key, value):
# First check if interface has been set, since early in the metaclass
# pipeline we set attributes on the class, so we just use default
# semantics for those statements
if not getattr(cls, "ports_set", False) or key not in cls.interface:
super().__setattr__(key, value)
else:
port = cls.interface[key]
if port.isoutput():
raise TypeError(f"Cannot assign to input port of definition: {port.debug_name}")
port.wire(value)

def __call__(cls, *largs, **kwargs):
#print('CircuitKind call:', largs, kwargs)
debug_info = get_callee_frame_info()
Expand Down Expand Up @@ -221,20 +207,6 @@ def _repr_html_(self):
def __getitem__(self, key):
return self.interface[key]

def __setattr__(self, key, value):
# First check if interface has been set, since early in the metaclass
# pipeline we set attributes on the class, so we just use default
# semantics for those statements
if not getattr(self, "ports_set", False) or \
getattr(self, "interface", None) is None or \
key not in self.interface:
object.__setattr__(self, key, value)
else:
port = self.interface[key]
if port.isoutput():
raise TypeError(f"Cannot assign to output port of instance: {port.debug_name}")
port.wire(value)

# wire a list of outputs to the circuit's inputs
def wireoutputs(self, outputs, debug_info):
inputs = self.interface.inputs()
Expand Down

0 comments on commit 5308df7

Please sign in to comment.