def generate_data_type(self, data_type):
if isinstance(data_type, Struct):<EOL><INDENT>self.emit('<STR_LIT>')<EOL>self.emit('<STR_LIT>' % data_type.name)<EOL>with self.indent():<EOL><INDENT>if data_type.doc is not None:<EOL><INDENT>self.emit(self.format_string(data_type.doc))<EOL><DEDENT>for field in data_type.fields:<EOL><INDENT>type_repr = self.format_data_type(field.data_type)<EOL>if not field.has_default:<EOL><INDENT>self.emit('<STR_LIT>' % (field.name, type_repr))<EOL><DEDENT>else:<EOL><INDENT>self.emit('<STR_LIT>' %<EOL>(field.name, type_repr, self.format_value(field.default)))<EOL><DEDENT>if field.doc is not None:<EOL><INDENT>with self.indent():<EOL><INDENT>self.emit(self.format_value(field.doc))<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>elif isinstance(data_type, Union):<EOL><INDENT>self.emit('<STR_LIT>')<EOL>self.emit('<STR_LIT>' % data_type.name)<EOL>with self.indent():<EOL><INDENT>if data_type.doc is not None:<EOL><INDENT>self.emit(self.format_string(data_type.doc))<EOL><DEDENT>for field in data_type.fields:<EOL><INDENT>name = field.name<EOL>if field.catch_all or field is data_type.catch_all_field:<EOL><INDENT>name += '<STR_LIT:*>'<EOL><DEDENT>if isinstance(field.data_type, Void):<EOL><INDENT>self.emit('<STR_LIT:%s>' % (name))<EOL><DEDENT>else:<EOL><INDENT>type_repr = self.format_data_type(field.data_type)<EOL>self.emit('<STR_LIT>' % (name, type_repr))<EOL><DEDENT>if field.doc is not None:<EOL><INDENT>with self.indent():<EOL><INDENT>self.emit(self.format_value(field.doc))<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>self.emit('<STR_LIT>')<EOL>self.emit('<STR_LIT>' % repr(data_type))<EOL><DEDENT>
Output a data type definition (a struct or union).