diff options
author | Maxence Guesdon <maxence.guesdon@inria.fr> | 2008-07-23 08:55:36 +0000 |
---|---|---|
committer | Maxence Guesdon <maxence.guesdon@inria.fr> | 2008-07-23 08:55:36 +0000 |
commit | a6ae8b88a50edf9a54eee11aa905aa20d2169601 (patch) | |
tree | a18d0f7defcb2421a0132bbe8d8c749cb9deb46d /ocamldoc/odoc_value.ml | |
parent | ff38e7832c1b9148c23c98b3f620608382de8d97 (diff) | |
download | ocaml-a6ae8b88a50edf9a54eee11aa905aa20d2169601.tar.gz |
fix bug #4585 and handle virtual flag for class value in all generators
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@8927 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'ocamldoc/odoc_value.ml')
-rw-r--r-- | ocamldoc/odoc_value.ml | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/ocamldoc/odoc_value.ml b/ocamldoc/odoc_value.ml index 62cf0ccf4f..1812068ae0 100644 --- a/ocamldoc/odoc_value.ml +++ b/ocamldoc/odoc_value.ml @@ -26,22 +26,23 @@ type t_value = { mutable val_parameters : Odoc_parameter.parameter list ; mutable val_code : string option ; mutable val_loc : Odoc_types.location ; - } + } (** Representation of a class attribute. *) type t_attribute = { att_value : t_value ; (** an attribute has almost all the same information as a value *) - att_mutable : bool ; - } + att_mutable : bool ; + att_virtual : bool ; + } (** Representation of a class method. *) type t_method = { met_value : t_value ; (** a method has almost all the same information as a value *) - met_private : bool ; + met_private : bool ; met_virtual : bool ; - } + } (** Functions *) @@ -60,27 +61,27 @@ let value_parameter_text_by_name v name = (** Update the parameters text of a t_value, according to the val_info field. *) let update_value_parameters_text v = - let f p = - Odoc_parameter.update_parameter_text (value_parameter_text_by_name v) p + let f p = + Odoc_parameter.update_parameter_text (value_parameter_text_by_name v) p in List.iter f v.val_parameters -(** Create a list of (parameter name, typ) from a type, according to the arrows. +(** Create a list of (parameter name, typ) from a type, according to the arrows. [parameter_list_from_arrows t = [ a ; b ]] if t = a -> b -> c.*) let parameter_list_from_arrows typ = - let rec iter t = + let rec iter t = match t.Types.desc with Types.Tarrow (l, t1, t2, _) -> (l, t1) :: (iter t2) - | Types.Tlink texp + | Types.Tlink texp | Types.Tsubst texp -> iter texp | Types.Tpoly (texp, _) -> iter texp | Types.Tvar - | Types.Ttuple _ - | Types.Tconstr _ + | Types.Ttuple _ + | Types.Tconstr _ | Types.Tobject _ - | Types.Tfield _ + | Types.Tfield _ | Types.Tnil | Types.Tunivar | Types.Tvariant _ -> @@ -88,16 +89,16 @@ let parameter_list_from_arrows typ = in iter typ -(** Create a list of parameters with dummy names "??" from a type list. +(** Create a list of parameters with dummy names "??" from a type list. Used when we want to merge the parameters of a value, from the .ml and the .mli file. In the .mli file we don't have parameter names so there is nothing to merge. With this dummy list we can merge the parameter names from the .ml and the type from the .mli file. *) let dummy_parameter_list typ = - let normal_name s = - match s with + let normal_name s = + match s with "" -> s - | _ -> + | _ -> match s.[0] with '?' -> String.sub s 1 ((String.length s) - 1) | _ -> s @@ -106,26 +107,26 @@ let dummy_parameter_list typ = let liste_param = parameter_list_from_arrows typ in let rec iter (label, t) = match t.Types.desc with - | Types.Ttuple l -> + | Types.Ttuple l -> if label = "" then - Odoc_parameter.Tuple + Odoc_parameter.Tuple (List.map (fun t2 -> iter ("", t2)) l, t) else (* if there is a label, then we don't want to decompose the tuple *) - Odoc_parameter.Simple_name + Odoc_parameter.Simple_name { Odoc_parameter.sn_name = normal_name label ; Odoc_parameter.sn_type = t ; Odoc_parameter.sn_text = None } - | Types.Tlink t2 + | Types.Tlink t2 | Types.Tsubst t2 -> (iter (label, t2)) | _ -> - Odoc_parameter.Simple_name + Odoc_parameter.Simple_name { Odoc_parameter.sn_name = normal_name label ; Odoc_parameter.sn_type = t ; Odoc_parameter.sn_text = None } - in + in List.map iter liste_param (** Return true if the value is a function, i.e. has a functional type.*) @@ -141,4 +142,4 @@ let is_function v = in f v.val_type - + |