Update from short forms to placeholders
This commit is contained in:
parent
eccff41397
commit
25ef728b80
|
@ -28,17 +28,18 @@ Observe = Record.makeConstructor('observe', 'specification')
|
||||||
Capture = Record.makeConstructor('capture', 'specification')
|
Capture = Record.makeConstructor('capture', 'specification')
|
||||||
Discard = Record.makeConstructor('discard', '')
|
Discard = Record.makeConstructor('discard', '')
|
||||||
|
|
||||||
|
_decode_placeholders = {
|
||||||
|
0: Discard.constructorInfo.key,
|
||||||
|
1: Capture.constructorInfo.key,
|
||||||
|
2: Observe.constructorInfo.key,
|
||||||
|
}
|
||||||
|
|
||||||
|
_encode_placeholders = dict(((v, k) for (k, v) in _decode_placeholders.items()))
|
||||||
|
|
||||||
class Decoder(preserves.Decoder):
|
class Decoder(preserves.Decoder):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Decoder, self).__init__(*args, **kwargs)
|
super(Decoder, self).__init__(*args, placeholders=_decode_placeholders, **kwargs)
|
||||||
_init_shortforms(self)
|
|
||||||
|
|
||||||
class Encoder(preserves.Encoder):
|
class Encoder(preserves.Encoder):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Encoder, self).__init__(*args, **kwargs)
|
super(Encoder, self).__init__(*args, placeholders=_encode_placeholders, **kwargs)
|
||||||
_init_shortforms(self)
|
|
||||||
|
|
||||||
def _init_shortforms(c):
|
|
||||||
c.set_shortform(0, Discard.constructorInfo.key)
|
|
||||||
c.set_shortform(1, Capture.constructorInfo.key)
|
|
||||||
c.set_shortform(2, Observe.constructorInfo.key)
|
|
||||||
|
|
Loading…
Reference in New Issue