def _generate_struct_deserializer(self, struct):
struct_name = fmt_class_prefix(struct)<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(struct_name),<EOL>class_func=True):<EOL><INDENT>if not struct.all_fields and not struct.has_enumerated_subtypes():<EOL><INDENT>self.emit('<STR_LIT>')<EOL><DEDENT>def emit_struct_deserialize_logic(struct):<EOL><INDENT>for field in struct.all_fields:<EOL><INDENT>data_type, nullable = unwrap_nullable(field.data_type)<EOL>input_value = '<STR_LIT>'.format(field.name)<EOL>if is_primitive_type(data_type):<EOL><INDENT>deserialize_call = input_value<EOL><DEDENT>else:<EOL><INDENT>deserialize_call = self._fmt_serialization_call(<EOL>field.data_type, input_value, False)<EOL><DEDENT>if nullable or field.has_default:<EOL><INDENT>default_value = fmt_default_value(<EOL>field) if field.has_default else '<STR_LIT>'<EOL>if is_primitive_type(data_type):<EOL><INDENT>deserialize_call = '<STR_LIT>'.format(<EOL>input_value, default_value)<EOL><DEDENT>else:<EOL><INDENT>deserialize_call = '<STR_LIT>'.format(<EOL>input_value, deserialize_call, default_value)<EOL><DEDENT><DEDENT>self.emit('<STR_LIT>'.format(<EOL>fmt_type(field.data_type),<EOL>fmt_var(field.name), deserialize_call))<EOL><DEDENT>self.emit()<EOL>deserialized_obj_args = [(fmt_var(f.name), fmt_var(f.name))<EOL>for f in struct.all_fields]<EOL>init_call = fmt_func_call(<EOL>caller=fmt_alloc_call(caller=struct_name),<EOL>callee=self._cstor_name_from_fields(struct.all_fields),<EOL>args=fmt_func_args(deserialized_obj_args))<EOL>self.emit('<STR_LIT>'.format(init_call))<EOL><DEDENT>if not struct.has_enumerated_subtypes():<EOL><INDENT>emit_struct_deserialize_logic(struct)<EOL><DEDENT>else:<EOL><INDENT>for tags, subtype in struct.get_all_subtypes_with_tags():<EOL><INDENT>assert len(tags) == <NUM_LIT:1>, tags<EOL>tag = tags[<NUM_LIT:0>]<EOL>base_string = '<STR_LIT>'<EOL>with self.block(base_string.format(tag)):<EOL><INDENT>caller = fmt_serial_class(fmt_class_prefix(subtype))<EOL>args = fmt_func_args([('<STR_LIT:value>', '<STR_LIT>')])<EOL>deserialize_call = fmt_func_call(<EOL>caller=caller, callee='<STR_LIT>', args=args)<EOL>self.emit('<STR_LIT>'.format(deserialize_call))<EOL><DEDENT><DEDENT>self.emit()<EOL>if struct.is_catch_all():<EOL><INDENT>emit_struct_deserialize_logic(struct)<EOL><DEDENT>else:<EOL><INDENT>description_str = (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>self._generate_throw_error('<STR_LIT>', description_str)<EOL><DEDENT><DEDENT><DEDENT>self.emit()<EOL>
Emits the deserialize method for the serialization object for the given struct.