[
',\n{0:s} {1:s} = {2:s}'.format(
context.indent,
- name,
- default_value[type]
+ i[1].get_text(),
+ default_value[element.to_text(i[0])]
)
- for type, name in context.fields
+ for i in context.fields
]
),
context.indent,
[
',\n{0:s} {1:s}'.format(
context.indent,
- name
+ i[1].get_text()
)
- for type, name in context.fields[:n_base_fields]
+ for i in context.fields[:n_base_fields]
]
),
context.indent
)
)
- for type, name in context.fields[n_base_fields:]:
+ for i in context.fields[n_base_fields:]:
+ type = element.to_text(i[0])
+ name = i[1].get_text()
if type == 'ref' or type == 'list(ref)' or type == 'set(ref)' or type == 'str':
context.fout.write(
'''{0:s} self.{1:s} = {2:s}
{1:s} {2:s}.serialize(self, ref_list)
'''.format(context.indent, context.indent, full_base_class)
)
- for type, name in context.fields[n_base_fields:]:
+ for i in context.fields[n_base_fields:]:
+ type = element.to_text(i[0])
+ name = i[1].get_text()
if type[:5] == 'list(' and type[-1:] == ')':
subtype = type[5:-1]
context.fout.write(
{1:s} {2:s}.deserialize(self, ref_list)
'''.format(context.indent, context.indent, full_base_class)
)
- for type, name in context.fields[n_base_fields:]:
+ for i in context.fields[n_base_fields:]:
+ type = element.to_text(i[0])
+ name = i[1].get_text()
if type[:5] == 'list(' and type[-1:] == ')':
subtype = type[5:-1]
context.fout.write(
[
'\n{0:s} result.{1:s} = self.{2:s}'.format(
context.indent,
- name,
- name
+ i[1].get_text(),
+ i[1].get_text()
)
- for _, name in context.fields[n_base_fields:]
+ for i in context.fields[n_base_fields:]
]
),
context.indent
full_base_class
)
)
- for type, name in context.fields[n_base_fields:]:
+ for i in context.fields[n_base_fields:]:
+ type = element.to_text(i[0])
+ name = i[1].get_text()
if type[:5] == 'list(' and type[-1:] == ')':
subtype = type[5:-1]
context.fout.write(
return 'ast.AST.Section2.FieldDef({0:s})'.format(', '.join(params))
# GENERATE END
def generate_class_or_field_def(self, context):
- context.fields.append((element.to_text(self[0]), self[1].get_text()))
+ context.fields.append(self)
# GENERATE ELEMENT() BEGIN
def __init__(
self,