|
|
@@ -824,15 +824,35 @@ module Printer = struct
|
|
|
| CTExtend (tl, fl) -> "{> " ^ String.concat " >, " (List.map (s_complex_type_path tabs) tl) ^ ", " ^ String.concat ", " (List.map (s_class_field tabs) fl) ^ " }"
|
|
|
| CTIntersection tl -> String.concat "&" (List.map (fun (t,_) -> s_complex_type tabs t) tl)
|
|
|
and s_class_field tabs f =
|
|
|
- match f.cff_doc with
|
|
|
- | Some d -> "/**\n\t" ^ tabs ^ (gen_doc_text d) ^ "\n**/\n"
|
|
|
- | None -> "" ^
|
|
|
- if List.length f.cff_meta > 0 then String.concat ("\n" ^ tabs) (List.map (s_metadata tabs) f.cff_meta) else "" ^
|
|
|
- if List.length f.cff_access > 0 then String.concat " " (List.map s_placed_access f.cff_access) else "" ^
|
|
|
- match f.cff_kind with
|
|
|
- | FVar (t,e) -> "var " ^ (fst f.cff_name) ^ s_opt_type_hint tabs t " : " ^ s_opt_expr tabs e " = "
|
|
|
- | FProp ((get,_),(set,_),t,e) -> "var " ^ (fst f.cff_name) ^ "(" ^ get ^ "," ^ set ^ ")" ^ s_opt_type_hint tabs t " : " ^ s_opt_expr tabs e " = "
|
|
|
- | FFun func -> "function " ^ (fst f.cff_name) ^ s_func tabs func
|
|
|
+ let doc = match f.cff_doc with
|
|
|
+ | Some d -> "/**\n\t" ^ tabs ^ (gen_doc_text d) ^ "\n**/\n"
|
|
|
+ | None -> ""
|
|
|
+ in
|
|
|
+ let s_separated f sep list =
|
|
|
+ if list <> [] then ((String.concat sep (List.map f list)) ^ sep) else ""
|
|
|
+ in
|
|
|
+ let s_meta = s_separated (s_metadata tabs) ("\n" ^ tabs) in
|
|
|
+ let s_access = s_separated s_placed_access " " in
|
|
|
+ (match f.cff_kind with
|
|
|
+ | FVar (t,e) ->
|
|
|
+ doc ^
|
|
|
+ let keyword = ref "var " in
|
|
|
+ let question = ref "" in
|
|
|
+ let access = List.filter (fun (a,_) -> if a = AFinal then (keyword := "final "; false) else true) f.cff_access in
|
|
|
+ let meta = List.filter (fun (m,_,_) -> if m = Meta.Optional then (question := "?"; false) else true) f.cff_meta in
|
|
|
+ s_meta meta ^
|
|
|
+ s_access access ^
|
|
|
+ !keyword ^ !question ^ (fst f.cff_name) ^ s_opt_type_hint tabs t " : " ^ s_opt_expr tabs e " = "
|
|
|
+ | FProp ((get,_),(set,_),t,e) ->
|
|
|
+ doc ^
|
|
|
+ s_meta f.cff_meta ^
|
|
|
+ s_access f.cff_access ^
|
|
|
+ "var " ^ (fst f.cff_name) ^ "(" ^ get ^ "," ^ set ^ ")" ^ s_opt_type_hint tabs t " : " ^ s_opt_expr tabs e " = "
|
|
|
+ | FFun func ->
|
|
|
+ doc ^
|
|
|
+ s_meta f.cff_meta ^
|
|
|
+ s_access f.cff_access ^
|
|
|
+ "function " ^ (fst f.cff_name) ^ s_func tabs func)
|
|
|
and s_metadata tabs (s,e,_) =
|
|
|
"@" ^ Meta.to_string s ^ if List.length e > 0 then "(" ^ s_expr_list tabs e ", " ^ ")" else ""
|
|
|
and s_opt_expr tabs e pre =
|