def _generate_struct_class_reflection_attributes(self, ns, data_type):
class_name = class_name_for_data_type(data_type)<EOL>if data_type.parent_type:<EOL><INDENT>parent_type_class_name = class_name_for_data_type(<EOL>data_type.parent_type, ns)<EOL><DEDENT>else:<EOL><INDENT>parent_type_class_name = None<EOL><DEDENT>for field in data_type.fields:<EOL><INDENT>field_name = fmt_var(field.name)<EOL>validator_name = generate_validator_constructor(ns, field.data_type)<EOL>full_validator_name = '<STR_LIT>'.format(class_name, field_name)<EOL>self.emit('<STR_LIT>'.format(full_validator_name, validator_name))<EOL>if field.redactor:<EOL><INDENT>self._generate_redactor(full_validator_name, field.redactor)<EOL><DEDENT><DEDENT>child_omitted_callers = data_type.get_all_omitted_callers() | {None}<EOL>parent_omitted_callers = data_type.parent_type.get_all_omitted_callers() ifdata_type.parent_type else set([])<EOL>for omitted_caller in sorted(child_omitted_callers | parent_omitted_callers, key=str):<EOL><INDENT>is_public = omitted_caller is None<EOL>map_name_prefix = '<STR_LIT>' if is_public else '<STR_LIT>'.format(omitted_caller)<EOL>caller_in_parent = data_type.parent_type and (is_public or omitted_caller<EOL>in parent_omitted_callers)<EOL>names_map_name = '<STR_LIT>'.format(map_name_prefix)<EOL>all_names_map_name = '<STR_LIT>'.format(map_name_prefix)<EOL>if data_type.is_member_of_enumerated_subtypes_tree():<EOL><INDENT>if is_public or omitted_caller in child_omitted_callers:<EOL><INDENT>self.generate_multiline_list(<EOL>[<EOL>"<STR_LIT>" % field.name<EOL>for field in data_type.fields<EOL>if field.omitted_caller == omitted_caller<EOL>],<EOL>before='<STR_LIT>'.format(class_name, names_map_name),<EOL>after='<STR_LIT:)>',<EOL>delim=('<STR_LIT:[>', '<STR_LIT:]>'),<EOL>compact=False)<EOL><DEDENT>if caller_in_parent:<EOL><INDENT>self.emit('<STR_LIT>'<EOL>.format(class_name, parent_type_class_name, names_map_name,<EOL>all_names_map_name))<EOL><DEDENT>else:<EOL><INDENT>self.emit('<STR_LIT>'.format(class_name, names_map_name,<EOL>all_names_map_name))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if caller_in_parent:<EOL><INDENT>before = '<STR_LIT>'.format(class_name, all_names_map_name,<EOL>parent_type_class_name)<EOL>after = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>before = '<STR_LIT>'.format(class_name, all_names_map_name)<EOL>after = '<STR_LIT:)>'<EOL><DEDENT>items = [<EOL>"<STR_LIT>" % field.name<EOL>for field in data_type.fields<EOL>if field.omitted_caller == omitted_caller<EOL>]<EOL>self.generate_multiline_list(<EOL>items,<EOL>before=before,<EOL>after=after,<EOL>delim=('<STR_LIT:[>', '<STR_LIT:]>'),<EOL>compact=False)<EOL><DEDENT>fields_map_name = '<STR_LIT>'.format(map_name_prefix)<EOL>all_fields_map_name = '<STR_LIT>'.format(map_name_prefix)<EOL>if data_type.is_member_of_enumerated_subtypes_tree():<EOL><INDENT>items = []<EOL>for field in data_type.fields:<EOL><INDENT>if field.omitted_caller != omitted_caller:<EOL><INDENT>continue<EOL><DEDENT>var_name = fmt_var(field.name)<EOL>validator_name = '<STR_LIT>'.format(class_name,<EOL>var_name)<EOL>items.append("<STR_LIT>".format(var_name, validator_name))<EOL><DEDENT>self.generate_multiline_list(<EOL>items,<EOL>before='<STR_LIT>'.format(class_name, fields_map_name),<EOL>delim=('<STR_LIT:[>', '<STR_LIT:]>'),<EOL>compact=False,<EOL>)<EOL>if caller_in_parent:<EOL><INDENT>self.emit('<STR_LIT>'.format(<EOL>class_name, parent_type_class_name, fields_map_name, all_fields_map_name))<EOL><DEDENT>else:<EOL><INDENT>self.emit('<STR_LIT>'.format(<EOL>class_name, fields_map_name, all_fields_map_name))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if caller_in_parent:<EOL><INDENT>before = '<STR_LIT>'.format(<EOL>class_name, parent_type_class_name, all_fields_map_name)<EOL><DEDENT>else:<EOL><INDENT>before = '<STR_LIT>'.format(class_name, all_fields_map_name)<EOL><DEDENT>items = []<EOL>for field in data_type.fields:<EOL><INDENT>if field.omitted_caller != omitted_caller:<EOL><INDENT>continue<EOL><DEDENT>var_name = fmt_var(field.name)<EOL>validator_name = '<STR_LIT>'.format(<EOL>class_name, var_name)<EOL>items.append("<STR_LIT>".format(var_name, validator_name))<EOL><DEDENT>self.generate_multiline_list(<EOL>items, before=before, delim=('<STR_LIT:[>', '<STR_LIT:]>'), compact=False)<EOL><DEDENT><DEDENT>self.emit()<EOL>
Generates two class attributes:
  * _all_field_names_: Set of all field names including inherited fields.
  * _all_fields_: List of tuples, where each tuple is (name, validator).

If a struct has enumerated subtypes, then two additional attributes are
generated:
  * _field_names_: Set of all field names excluding inherited fields.
  * _fields: List of tuples, where each tuple is (name, validator), and
    excludes inherited fields.

These are needed because serializing a struct with enumerated subtypes
requires knowing the fields defined in each level of the hierarchy.