Commit 84f40041 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Added mark_begin and changed mark to mark_end to python writer

parent db87060a
...@@ -759,24 +759,29 @@ class Encoder(Codec): ...@@ -759,24 +759,29 @@ class Encoder(Codec):
self.writer.write(packer.pack(format, *args)) self.writer.write(packer.pack(format, *args))
def add_decl(self, decl, index=0): def add_decl(self, decl, index=0):
if super(Encoder, self).add_decl(decl, index) and index == 0: if index == 0:
self.writer.mark_begin(decl, None)
if super(Encoder, self).add_decl(decl, index):
decl.encode_decl(self) decl.encode_decl(self)
self.writer.mark() self.writer.mark_end(decl, None)
def add_ref(self, decl, index=0): def add_ref(self, decl, index=0):
ref = sample_ref(name=decl.name, decl=decl.decl, sample=decl) ref = sample_ref(name=decl.name, decl=decl.decl, sample=decl)
if super(Encoder, self).add_ref(ref, index) and index == 0: if index == 0:
self.writer.mark_begin(decl, None)
if super(Encoder, self).add_ref(ref, index):
ref.encode_decl(self) ref.encode_decl(self)
self.writer.mark() self.writer.mark_end(decl, None)
def encode(self, object, decl=None): def encode(self, object, decl=None):
if decl == None: if decl == None:
name = self.type_to_name[object.__class__] name = self.type_to_name[object.__class__]
decl = self.name_to_decl[name] decl = self.name_to_decl[name]
self.writer.mark_begin(decl, object)
self.encode_type_number(decl) self.encode_type_number(decl)
with length_encoder(self) as e: with length_encoder(self) as e:
decl.encode(e, object) decl.encode(e, object)
self.writer.mark() self.writer.mark_end(decl, object)
def encode_type_number(self, decl): def encode_type_number(self, decl):
try: try:
......
...@@ -10,7 +10,10 @@ class StreamWriter: ...@@ -10,7 +10,10 @@ class StreamWriter:
self.stream.write(data) self.stream.write(data)
pass pass
def mark(self): def mark_begin(self, decl, value):
pass
def mark_end(self, decl, value):
self.stream.flush() self.stream.flush()
pass pass
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment