From: Fredrik Tolf Date: Tue, 11 Jan 2022 18:30:12 +0000 (+0100) Subject: Move namedtype from bin to data. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=8dc0c47abac97c689406a014945e5f605dd762e1;p=coe.git Move namedtype from bin to data. --- diff --git a/coe/bin.py b/coe/bin.py index 395a209..de3d6fa 100644 --- a/coe/bin.py +++ b/coe/bin.py @@ -152,12 +152,6 @@ class referror(fmterror): def __init__(self): super().__init__("bad backref") -class namedtype(type): - def __new__(cls, *args, typename=None, **kwargs): - self = super().__new__(cls, *args, **kwargs) - self.typename = typename - return self - class decoder(object): def __init__(self): self.reftab = [] @@ -229,7 +223,7 @@ class decoder(object): buf[key] = self.loadtagged(fp, tag) def makeobjtype(self, nm): - return namedtype(str(nm), (data.obj, object), {}, typename=nm) + return data.namedtype(str(nm), (data.obj, object), {}, typename=nm) def loadobj(self, fp, ref=False): if ref: diff --git a/coe/data.py b/coe/data.py index 05e129b..b65dbae 100644 --- a/coe/data.py +++ b/coe/data.py @@ -64,6 +64,12 @@ class nssymbol(symbol): self.name = name self.ns = ns +class namedtype(type): + def __new__(cls, *args, typename=None, **kwargs): + self = super().__new__(cls, *args, **kwargs) + self.typename = typename + return self + class obj(object): def __getitem__(self, key): return self.__dict__[key]