csn1: fix handling of nested undefinitely repeated objects

This commit is contained in:
mitshell 2017-09-07 00:28:05 +02:00
parent 92ba213d0f
commit 5e2f16e915
2 changed files with 6 additions and 7 deletions

View File

@ -196,7 +196,7 @@ class CSN1Obj(Element):
self._val = val
elif self._num == -1:
val = []
while True:
while char.len_bit():
try:
char_cur = char._cur
self._from_char_obj(char)
@ -709,14 +709,14 @@ class CSN1Ref(CSN1Obj):
def _from_char_obj(self, char):
obj_val = self._obj._val
self._obj._from_char_obj(char)
self._obj._from_char(char)
self._val = self._obj._val
self._obj._val = obj_val
def _to_pack_obj(self):
obj_val = self._obj._val
self._obj._val = self._val
ret = self._obj._to_pack_obj()
ret = self._obj._to_pack()
self._obj._val = obj_val
return ret

View File

@ -517,7 +517,7 @@ def translate_text(text=u'', **kwargs):
#
# 3) return python source
return Objs, '# code automatically generated by pycrate_csn1\n' + \
'# change object type with type=T_BYTES\n' + \
'# change object type with type=CSN1T_BSTR (default type is CSN1T_UINT)\n' + \
'# add dict for value interpretation with dict={...}\n\n' + \
'from pycrate_csn1.csnobj import *\n' + \
gen_predefined_objects() + \
@ -570,14 +570,13 @@ def translate_object(Obj):
def translate_ref(Obj):
global obj_name
name = pythonize_name(Obj._name)
name, args = pythonize_name(Obj._name), []
if name == obj_name:
# self reference
cla = 'CSN1SelfRef'
args = []
else:
cla = 'CSN1Ref'
args = ['obj=%s' % pythonize_name(Obj._name)]
args.append( 'obj=%s' % name )
if hasattr(Obj, '_root') and Obj._root:
args.append( 'root=True' )
if Obj._num != 1: