def _populate_field_defaults(self):
for namespace in self.api.namespaces.values():<EOL><INDENT>for data_type in namespace.data_types:<EOL><INDENT>if not isinstance(data_type, Struct):<EOL><INDENT>continue<EOL><DEDENT>for field in data_type.fields:<EOL><INDENT>if not field._ast_node.has_default:<EOL><INDENT>continue<EOL><DEDENT>if isinstance(field._ast_node.default, AstTagRef):<EOL><INDENT>default_value = TagRef(<EOL>field.data_type, field._ast_node.default.tag)<EOL><DEDENT>else:<EOL><INDENT>default_value = field._ast_node.default<EOL><DEDENT>if not (field._ast_node.type_ref.nullable and default_value is None):<EOL><INDENT>try:<EOL><INDENT>if field.data_type.name in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>default_value = float(default_value)<EOL><DEDENT>field.data_type.check(default_value)<EOL><DEDENT>except ValueError as e:<EOL><INDENT>raise InvalidSpec(<EOL>'<STR_LIT>' %<EOL>(quote(field._ast_node.name), e),<EOL>field._ast_node.lineno, field._ast_node.path)<EOL><DEDENT><DEDENT>field.set_default(default_value)<EOL><DEDENT><DEDENT><DEDENT>
Populate the defaults of each field. This is done in a separate pass
because defaults that specify a union tag require the union to have
been defined.