def _generate_union_deserializer(self, union):
union_name = fmt_class_prefix(union)<EOL>with self.block_func(<EOL>func='<STR_LIT>',<EOL>args=fmt_func_args_declaration([('<STR_LIT>',<EOL>'<STR_LIT>')]),<EOL>return_type='<STR_LIT>'.format(union_name),<EOL>class_func=True):<EOL><INDENT>if not union.all_fields:<EOL><INDENT>self.emit('<STR_LIT>')<EOL><DEDENT>self.emit('<STR_LIT>')<EOL>self.emit()<EOL>first_block = True<EOL>for field in union.all_fields:<EOL><INDENT>base_cond = '<STR_LIT>'<EOL>with self.block(<EOL>base_cond.format('<STR_LIT>' if first_block else '<STR_LIT>',<EOL>field.name)):<EOL><INDENT>if first_block:<EOL><INDENT>first_block = False<EOL><DEDENT>if not is_void_type(field.data_type):<EOL><INDENT>data_type, nullable = unwrap_nullable(field.data_type)<EOL>if is_struct_type(<EOL>data_type<EOL>) and not data_type.has_enumerated_subtypes():<EOL><INDENT>input_value = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>input_value = '<STR_LIT>'.format(field.name)<EOL><DEDENT>if is_primitive_type(data_type):<EOL><INDENT>deserialize_call = input_value<EOL><DEDENT>else:<EOL><INDENT>deserialize_call = self._fmt_serialization_call(<EOL>data_type, input_value, False)<EOL><DEDENT>if nullable:<EOL><INDENT>deserialize_call = '<STR_LIT>'.format(<EOL>input_value, deserialize_call)<EOL><DEDENT>self.emit('<STR_LIT>'.format(<EOL>fmt_type(field.data_type),<EOL>fmt_var(field.name), deserialize_call))<EOL>deserialized_obj_args = [(fmt_var(field.name),<EOL>fmt_var(field.name))]<EOL><DEDENT>else:<EOL><INDENT>deserialized_obj_args = []<EOL><DEDENT>args = fmt_func_args(deserialized_obj_args)<EOL>callee = self._cstor_name_from_field(field)<EOL>self.emit('<STR_LIT>'.format(<EOL>fmt_func_call(<EOL>caller=fmt_alloc_call(union_name),<EOL>callee=callee,<EOL>args=args)))<EOL><DEDENT><DEDENT>with self.block('<STR_LIT>'):<EOL><INDENT>if not union.closed:<EOL><INDENT>callee = '<STR_LIT>'<EOL>self.emit('<STR_LIT>'.format(<EOL>fmt_func_call(<EOL>caller=fmt_alloc_call(union_name), callee=callee)))<EOL><DEDENT>else:<EOL><INDENT>reason = (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>self._generate_throw_error('<STR_LIT>', reason)<EOL><DEDENT><DEDENT><DEDENT>self.emit()<EOL>
Emits the deserialize method for the serialization object for the given union.