Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file internal.ml
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970openTypes(** {6 Misc functions } *)letlist_filter_mapfxs=List.fold_right(funxst->matchfxwith|None->st|Somev->v::st)xs[]letlist_mapifxs=letrecmapifpos=function|[]->[]|x::xs->fposx::mapif(pos+1)xsinmapif0xslet(~?)=function|Sometrace->trace|None->[](** {6 Error decoders } *)lettuple_arity_errorexp_lenact_len?(trace=[])v=Error(`Wrong_arity(exp_len,act_len,None),v,trace)letvariant_arity_errortype_nameconstructor_nameexp_lenact_len?(trace=[])v=Error(`Wrong_arity(exp_len,act_len,Some(type_name,constructor_name)),v,trace)letvariant_unknown_tag_errortype_nametag_name?(trace=[])v=Error(`Unknown_tag(type_name,tag_name),v,trace)letprimitive_decoding_failuremes?(trace=[])v=Error(`Primitive_decoding_failuremes,v,trace)letsub_decoders_failed_for_one_ofname?(trace=[])v=Error(`Sub_decoders_failed_for_one_ofname,v,trace)(** {6 Tools used by generated code } *)letfield_assoc_exnnamekeyalist(throw:'targetError.t->'host)(decode_exn:('host,'target)Decoder.t_exn):('host,'target)Decoder.t_exn=fun?(trace=[])v->matchList.assockeyalistwith|v'->lettrace=`Fieldkey::`Nodev::traceindecode_exn?trace:(Sometrace)v'|exceptionNot_found->throw(`Required_field_not_found(name,key),v,trace)letfield_assoc_optional_exn_namekeyalistdecode_exn?(trace=[])v=matchList.assockeyalistwith|v'->lettrace=`Fieldkey::`Nodev::traceinSome(decode_exn?trace:(Sometrace)v')|exceptionNot_found->Noneletfilter_fieldstype_systemactual=List.partition(fun(f,_)->List.memftype_system)actualletembeded_decoding_helpersecondary_fieldsv=function|Okv->Ok(v,[])(* Having this function in Internal is mainly to avoid seeing
bunch of Warnings 4 due to the next line, if it would be inlined
in the generalted code. *)|Error(`Unknown_fields(_,keys,o),v',_)whenv==v'->(* extract the accepted fields and the decoded value, and rest fields
- Obj.magic
- inefficient
*)letsecondary_fields=List.filter(fun(k,_)->List.memkkeys)secondary_fieldsinOk(Obj.objo,secondary_fields)|Errore->Errore