Commit 5841c9a9 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Made python remember seen signatures.

parent 9cacaaf1
...@@ -691,6 +691,8 @@ class Codec(object): ...@@ -691,6 +691,8 @@ class Codec(object):
def add_decl(self, decl, index=0): def add_decl(self, decl, index=0):
if index == 0: if index == 0:
if decl in self.decl_to_index:
return False
index = self.decl_index index = self.decl_index
self.decl_index += 1 self.decl_index += 1
self.index_to_decl[index] = decl self.index_to_decl[index] = decl
...@@ -699,9 +701,12 @@ class Codec(object): ...@@ -699,9 +701,12 @@ class Codec(object):
self.name_to_decl[decl.name] = decl self.name_to_decl[decl.name] = decl
except: except:
pass pass
return True
def add_ref(self, ref, index=0): def add_ref(self, ref, index=0):
if index == 0: if index == 0:
if ref.sample in self.ref_to_index:
return False
index = self.ref_index index = self.ref_index
self.ref_index += 1 self.ref_index += 1
self.index_to_ref[index] = ref.sample self.index_to_ref[index] = ref.sample
...@@ -710,7 +715,8 @@ class Codec(object): ...@@ -710,7 +715,8 @@ class Codec(object):
self.name_to_ref[ref.sample.name] = ref.sample self.name_to_ref[ref.sample.name] = ref.sample
except: except:
pass pass
return True
def add_binding(self, name, decl): def add_binding(self, name, decl):
self.type_to_name[decl] = name self.type_to_name[decl] = name
self.name_to_type[name] = decl self.name_to_type[name] = decl
...@@ -744,15 +750,13 @@ class Encoder(Codec): ...@@ -744,15 +750,13 @@ 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):
super(Encoder, self).add_decl(decl, index) if super(Encoder, self).add_decl(decl, index) and index == 0:
if index == 0:
decl.encode_decl(self) decl.encode_decl(self)
self.writer.mark() self.writer.mark()
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)
super(Encoder, self).add_ref(ref, index) if super(Encoder, self).add_ref(ref, index) and index == 0:
if index == 0:
ref.encode_decl(self) ref.encode_decl(self)
self.writer.mark() self.writer.mark()
......
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