Commits

camlspotter committed 5e24bb9

{caml_x=v} => x and CAML_x v => x

  • Participants
  • Parent commits 705d3ae

Comments (0)

Files changed (1)

File json-tc/sources/ocaml-json-tc/lib/pa_json_tc.ml

     | <:ctyp< $lid:id$ : $t$ >> ->  fnt ~mut:false ~id ~t
     | other -> type_fail other "process_fields: unexpected AST"
   and fnt ~mut ~id ~t =
-    let field_json_name = if id.[String.length id-1] = '_' then String.sub id 0 (String.length id - 1) else id in
+    let field_json_name = if try String.sub id 0 5 = "caml_" with _ -> false then String.sub id 5 (String.length id - 5) else id in
     [ { field_caml_name = id; field_json_name;
         field_type = (_loc, process_td _loc t);
         field_caml_loc = _loc; field_json_loc = _loc;
   List.map (function
     | <:ctyp< `$uid:id$ of $t$ >> 
     | <:ctyp< $uid:id$ of $t$ >> ->
+       
        let cons_args = List.map (fun x -> _loc, process_td _loc x) (Ast.list_of_ctyp t []) in
-       { cons_caml_name=id; cons_json_name=id; cons_caml_loc=_loc;
+       let cons_json_name = if try String.sub id 0 5 = "CAML_" with _ -> false then String.sub id 5 (String.length id - 5) else id in
+       { cons_caml_name=id; cons_json_name; cons_caml_loc=_loc;
          cons_json_loc=_loc; cons_args=cons_args }
     | <:ctyp< `$uid:id$ >> 
     | <:ctyp< $uid:id$ >> ->
-       { cons_caml_name=id; cons_json_name=id; cons_caml_loc=_loc;
+       let cons_json_name = if try String.sub id 0 5 = "CAML_" with _ -> false then String.sub id 5 (String.length id - 5) else id in
+       { cons_caml_name=id; cons_json_name; cons_caml_loc=_loc;
          cons_json_loc=_loc; cons_args=[] }
     | other -> type_fail other "process_constructor: unexpected AST"
   ) (Ast.list_of_ctyp rf [])