123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194open!Baseopen!Ppxlibletdefault=Attribute.declare"yojson.default"Attribute.Context.label_declarationAst_pattern.(pstr(pstr_eval__nil^::nil))(funx->x);;letdrop_default=Attribute.declare"yojson.yojson_drop_default"Attribute.Context.label_declarationAst_pattern.(pstr(alt_option(pstr_eval__nil^::nil)nil))(funx->x);;letdrop_default_equal=Attribute.declare"yojson.@yojson_drop_default.equal"Attribute.Context.label_declarationAst_pattern.(pstrnil)();;letdrop_default_compare=Attribute.declare"yojson.@yojson_drop_default.compare"Attribute.Context.label_declarationAst_pattern.(pstrnil)();;letdrop_default_yojson=Attribute.declare"yojson.@yojson_drop_default.yojson"Attribute.Context.label_declarationAst_pattern.(pstrnil)();;letdrop_if=Attribute.declare"yojson.yojson_drop_if"Attribute.Context.label_declarationAst_pattern.(pstr(pstr_eval__nil^::nil))(funx->x);;letopaque=Attribute.declare"yojson.opaque"Attribute.Context.core_typeAst_pattern.(pstrnil)();;letoption=Attribute.declare"yojson.option"Attribute.Context.label_declarationAst_pattern.(pstrnil)();;letallow_extra_fields_td=Attribute.declare"yojson.allow_extra_fields"Attribute.Context.type_declarationAst_pattern.(pstrnil)();;letallow_extra_fields_cd=Attribute.declare"yojson.allow_extra_fields"Attribute.Context.constructor_declarationAst_pattern.(pstrnil)();;letyojson_key=Attribute.declare"yojson.key"Attribute.Context.label_declarationAst_pattern.(pstr(pstr_eval(estring__)nil^::nil))(funx->x);;letyojson_name=Attribute.declare"yojson.name"Attribute.Context.constructor_declarationAst_pattern.(pstr(pstr_eval(estring__)nil^::nil))(funx->x);;letinvalid_attribute~locattrdescription=Location.raise_errorf~loc"ppx_yojson_conv: [@%s] is only allowed on type [%s]."(Attribute.nameattr)description;;letfail_if_allow_extra_field_cd~locx=ifOption.is_some(Attribute.getallow_extra_fields_cdx)thenLocation.raise_errorf~loc"ppx_yojson_conv: [@@allow_extra_fields] is only allowed on inline records.";;letfail_if_allow_extra_field_td~locx=ifOption.is_some(Attribute.getallow_extra_fields_tdx)then(matchx.ptype_kindwith|Ptype_variantcdswhenList.existscds~f:(funcd->matchcd.pcd_argswith|Pcstr_record_->true|_->false)->Location.raise_errorf~loc"ppx_yojson_conv: [@@@@allow_extra_fields] only works on records. For inline \
records, do: type t = A of { a : int } [@@allow_extra_fields] | B \
[@@@@deriving yojson]"|_->Location.raise_errorf~loc"ppx_yojson_conv: [@@@@allow_extra_fields] is only allowed on records.");;moduleRecord_field_handler=structtypecommon=[`yojson_optionofcore_type]letget_attributeattrld~f=Option.map(Attribute.getattrld)~f:(funx->fx,Attribute.nameattr);;letcreate~locgettersld=letcommon_getters=[(funld->matchAttribute.getoptionldwith|Some()->(matchld.pld_typewith|[%type:[%t?ty]option]->Some(`yojson_optionty,"[@yojson.option]")|_->invalid_attribute~locoption"_ option")|None->None)]inmatchList.filter_map(getters@common_getters)~f:(funf->fld)with|[]->None|[(v,_)]->Somev|_::_::_asattributes->Location.raise_errorf~loc"The following elements are mutually exclusive: %s"(String.concat~sep:" "(List.mapattributes~f:snd));;moduleOf_yojson=structtypet=[common|`defaultofexpression]letcreate~locld=create~loc[get_attributedefault~f:(fundefault->`defaultdefault)]ld;;endmoduleYojson_of=structtypet=[common|`drop_defaultof[`no_arg|`compare|`equal|`yojson|`funcofexpression]|`drop_ifofexpression|`keep]letcreate~locld=create~loc[get_attributedrop_default~f:(function|None->`drop_default`no_arg|Somee->`drop_default(`funce));get_attributedrop_default_equal~f:(fun()->`drop_default`equal);get_attributedrop_default_compare~f:(fun()->`drop_default`compare);get_attributedrop_default_yojson~f:(fun()->`drop_default`yojson);get_attributedrop_if~f:(funx->`drop_ifx)]ld|>Option.value~default:`keep;;endend