Skip to content

Commit

Permalink
change from 'of_string' -> 'make_std'
Browse files Browse the repository at this point in the history
Signed-off-by: lubegasimon <lubegasimon73@gmail.com>
  • Loading branch information
lubegasimon committed Feb 19, 2021
1 parent 817de31 commit 0a44168
Show file tree
Hide file tree
Showing 20 changed files with 128 additions and 128 deletions.
16 changes: 8 additions & 8 deletions src/loader/cmi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ let read_value_description env parent id vd =
let read_label_declaration env parent ld =
let open TypeDecl.Field in
let name = Ident.name ld.ld_id in
let id = `Field(parent, Odoc_model.Names.FieldName.of_string name) in
let id = `Field(parent, Odoc_model.Names.FieldName.make_std name) in
let doc =
Doc_attr.attached
(parent :> Identifier.LabelParent.t) ld.ld_attributes
Expand All @@ -552,7 +552,7 @@ let read_constructor_declaration_arguments env parent arg =
let read_constructor_declaration env parent cd =
let open TypeDecl.Constructor in
let name = Ident.name cd.cd_id in
let id = `Constructor(parent, Odoc_model.Names.ConstructorName.of_string name) in
let id = `Constructor(parent, Odoc_model.Names.ConstructorName.make_std name) in
let container = (parent : Identifier.DataType.t :> Identifier.LabelParent.t) in
let doc = Doc_attr.attached container cd.cd_attributes in
let args =
Expand Down Expand Up @@ -642,7 +642,7 @@ let read_type_declaration env parent id decl =
let read_extension_constructor env parent id ext =
let open Extension.Constructor in
let name = Ident.name id in
let id = `Extension(parent, Odoc_model.Names.ExtensionName.of_string name) in
let id = `Extension(parent, Odoc_model.Names.ExtensionName.make_std name) in
let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in
let doc = Doc_attr.attached container ext.ext_attributes in
let args =
Expand Down Expand Up @@ -675,7 +675,7 @@ let read_type_extension env parent id ext rest =
let read_exception env parent id ext =
let open Exception in
let name = Ident.name id in
let id = `Exception(parent, Odoc_model.Names.ExceptionName.of_string name) in
let id = `Exception(parent, Odoc_model.Names.ExceptionName.make_std name) in
let container = (parent : Identifier.Signature.t :> Identifier.LabelParent.t) in
let doc = Doc_attr.attached container ext.ext_attributes in
mark_exception ext;
Expand All @@ -688,7 +688,7 @@ let read_exception env parent id ext =

let read_method env parent concrete (name, kind, typ) =
let open Method in
let id = `Method(parent, Odoc_model.Names.MethodName.of_string name) in
let id = `Method(parent, Odoc_model.Names.MethodName.make_std name) in
let doc = Doc_attr.empty in
let private_ = (Btype.field_kind_repr kind) <> Fpresent in
let virtual_ = not (Concr.mem name concrete) in
Expand All @@ -697,7 +697,7 @@ let read_method env parent concrete (name, kind, typ) =

let read_instance_variable env parent (name, mutable_, virtual_, typ) =
let open InstanceVariable in
let id = `InstanceVariable(parent, Odoc_model.Names.InstanceVariableName.of_string name) in
let id = `InstanceVariable(parent, Odoc_model.Names.InstanceVariableName.make_std name) in
let doc = Doc_attr.empty in
let mutable_ = (mutable_ = Mutable) in
let virtual_ = (virtual_ = Virtual) in
Expand Down Expand Up @@ -837,7 +837,7 @@ let rec read_module_type env parent (mty : Odoc_model.Compat.module_type) =
| Some id -> Ident.name id, Env.add_parameter parent id (ParameterName.of_ident id) env
| None -> "_", env
in
let id = `Parameter(parent, Odoc_model.Names.ParameterName.of_string name) in
let id = `Parameter(parent, Odoc_model.Names.ParameterName.make_std name) in
let arg = read_module_type env id arg in
Odoc_model.Lang.FunctorParameter.Named ({ FunctorParameter. id; expr = arg }), env
in
Expand Down Expand Up @@ -984,7 +984,7 @@ and read_signature env parent (items : Odoc_model.Compat.signature) =


let read_interface root name intf =
let id = `Root(root, Odoc_model.Names.ModuleName.of_string name) in
let id = `Root(root, Odoc_model.Names.ModuleName.make_std name) in
let doc = Doc_attr.empty in
let items = read_signature Env.empty id intf in
(id, doc, items)
12 changes: 6 additions & 6 deletions src/loader/cmt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ let rec read_class_type_field env parent ctf =
match ctf.ctf_desc with
| Tctf_val(name, mutable_, virtual_, typ) ->
let open InstanceVariable in
let id = `InstanceVariable(parent, InstanceVariableName.of_string name) in
let id = `InstanceVariable(parent, InstanceVariableName.make_std name) in
let mutable_ = (mutable_ = Mutable) in
let virtual_ = (virtual_ = Virtual) in
let type_ = read_core_type env typ in
Some (InstanceVariable {id; doc; mutable_; virtual_; type_})
| Tctf_method(name, private_, virtual_, typ) ->
let open Method in
let id = `Method(parent, MethodName.of_string name) in
let id = `Method(parent, MethodName.make_std name) in
let private_ = (private_ = Private) in
let virtual_ = (virtual_ = Virtual) in
let type_ = read_core_type env typ in
Expand Down Expand Up @@ -207,7 +207,7 @@ let rec read_class_field env parent cf =
match cf.cf_desc with
| Tcf_val({txt = name; _}, mutable_, _, kind, _) ->
let open InstanceVariable in
let id = `InstanceVariable(parent, InstanceVariableName.of_string name) in
let id = `InstanceVariable(parent, InstanceVariableName.make_std name) in
let mutable_ = (mutable_ = Mutable) in
let virtual_, type_ =
match kind with
Expand All @@ -219,7 +219,7 @@ let rec read_class_field env parent cf =
Some (InstanceVariable {id; doc; mutable_; virtual_; type_})
| Tcf_method({txt = name; _}, private_, kind) ->
let open Method in
let id = `Method(parent, MethodName.of_string name) in
let id = `Method(parent, MethodName.make_std name) in
let private_ = (private_ = Private) in
let virtual_, type_ =
match kind with
Expand Down Expand Up @@ -348,7 +348,7 @@ let rec read_module_expr env parent label_parent mexpr =
| Some id -> Ident.name id, Env.add_parameter parent id (ParameterName.of_ident id) env
| None -> "_", env
in
let id = `Parameter(parent, Odoc_model.Names.ParameterName.of_string name) in
let id = `Parameter(parent, Odoc_model.Names.ParameterName.make_std name) in
let arg = Cmti.read_module_type env id label_parent arg in

Named { id; expr=arg }, env
Expand Down Expand Up @@ -551,7 +551,7 @@ and read_structure env parent str =
{ items = List.rev items; compiled=false }

let read_implementation root name impl =
let id = `Root(root, Odoc_model.Names.ModuleName.of_string name) in
let id = `Root(root, Odoc_model.Names.ModuleName.make_std name) in
let sg = read_structure Env.empty id impl in
let doc, sg =
let open Signature in
Expand Down
18 changes: 9 additions & 9 deletions src/loader/cmti.ml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ let read_label_declaration env parent label_parent ld =
let open TypeDecl.Field in
let open Odoc_model.Names in
let name = Ident.name ld.ld_id in
let id = `Field(parent, FieldName.of_string name) in
let id = `Field(parent, FieldName.make_std name) in
let doc = Doc_attr.attached label_parent ld.ld_attributes in
let mutable_ = (ld.ld_mutable = Mutable) in
let type_ = read_core_type env label_parent ld.ld_type in
Expand All @@ -210,7 +210,7 @@ let read_constructor_declaration env parent cd =
let open TypeDecl.Constructor in
let open Odoc_model.Names in
let name = Ident.name cd.cd_id in
let id = `Constructor(parent, ConstructorName.of_string name) in
let id = `Constructor(parent, ConstructorName.make_std name) in
let container = (parent : Identifier.DataType.t :> Identifier.Parent.t) in
let label_container = (container :> Identifier.LabelParent.t) in
let doc = Doc_attr.attached label_container cd.cd_attributes in
Expand Down Expand Up @@ -283,7 +283,7 @@ let read_extension_constructor env parent ext =
let open Extension.Constructor in
let open Odoc_model.Names in
let name = Ident.name ext.ext_id in
let id = `Extension(parent, ExtensionName.of_string name) in
let id = `Extension(parent, ExtensionName.make_std name) in
let container = (parent : Identifier.Signature.t :> Identifier.Parent.t) in
let label_container = (container :> Identifier.LabelParent.t) in
let doc = Doc_attr.attached label_container ext.ext_attributes in
Expand Down Expand Up @@ -313,7 +313,7 @@ let read_exception env parent (ext : extension_constructor) =
let open Exception in
let open Odoc_model.Names in
let name = Ident.name ext.ext_id in
let id = `Exception(parent, ExceptionName.of_string name) in
let id = `Exception(parent, ExceptionName.make_std name) in
let container = (parent : Identifier.Signature.t :> Identifier.Parent.t) in
let label_container = (container :> Identifier.LabelParent.t) in
let doc = Doc_attr.attached label_container ext.ext_attributes in
Expand All @@ -336,14 +336,14 @@ let rec read_class_type_field env parent ctf =
match ctf.ctf_desc with
| Tctf_val(name, mutable_, virtual_, typ) ->
let open InstanceVariable in
let id = `InstanceVariable(parent, InstanceVariableName.of_string name) in
let id = `InstanceVariable(parent, InstanceVariableName.make_std name) in
let mutable_ = (mutable_ = Mutable) in
let virtual_ = (virtual_ = Virtual) in
let type_ = read_core_type env container typ in
Some (InstanceVariable {id; doc; mutable_; virtual_; type_})
| Tctf_method(name, private_, virtual_, typ) ->
let open Method in
let id = `Method(parent, MethodName.of_string name) in
let id = `Method(parent, MethodName.make_std name) in
let private_ = (private_ = Private) in
let virtual_ = (virtual_ = Virtual) in
let type_ = read_core_type env container typ in
Expand Down Expand Up @@ -487,7 +487,7 @@ and read_module_type env parent label_parent mty =
Ident.name id, Env.add_parameter parent id (ParameterName.of_ident id) env
| None -> "_", env
in
let id = `Parameter(parent, ParameterName.of_string name) in
let id = `Parameter(parent, ParameterName.make_std name) in
let arg = read_module_type env id label_parent arg in
Named { id; expr = arg; }, env
in
Expand All @@ -500,7 +500,7 @@ and read_module_type env parent label_parent mty =
| None -> Odoc_model.Lang.FunctorParameter.Unit
| Some arg ->
let name = Ident.name id in
let id = `Parameter(parent, Odoc_model.Names.ParameterName.of_string name) in
let id = `Parameter(parent, Odoc_model.Names.ParameterName.make_std name) in
let arg = read_module_type env id label_parent arg in
Named { FunctorParameter. id; expr = arg }
in
Expand Down Expand Up @@ -719,7 +719,7 @@ and read_signature env parent sg =
{ items = List.rev items; compiled=false }

let read_interface root name intf =
let id = `Root(root, Odoc_model.Names.ModuleName.of_string name) in
let id = `Root(root, Odoc_model.Names.ModuleName.make_std name) in
let sg = read_signature Env.empty id intf in
let doc, sg =
let open Signature in
Expand Down
4 changes: 2 additions & 2 deletions src/loader/odoc_loader.ml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ let read_cmt ~make_root ~parent ~filename () =
| Ok root -> root
| Error (`Msg m) -> error_msg filename m
in
let id = `Root(parent, Odoc_model.Names.ModuleName.of_string name) in
let id = `Root(parent, Odoc_model.Names.ModuleName.make_std name) in
let items =
List.map (fun file ->
let pref = Misc.chop_extensions file in
Expand All @@ -123,7 +123,7 @@ let read_cmt ~make_root ~parent ~filename () =
let items = List.sort String.compare items in
let items =
List.map (fun name ->
let id = `Module(id, Odoc_model.Names.ModuleName.of_string name) in
let id = `Module(id, Odoc_model.Names.ModuleName.make_std name) in
let path = `Root name in
{Odoc_model.Lang.Compilation_unit.Packed.id; path})
items
Expand Down
12 changes: 6 additions & 6 deletions src/model/ident_env.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ let env_of_items parent items env =
let identifier, shadowed =
if is_shadowed
then `Type(parent, TypeName.internal_of_string name), t :: env.shadowed
else `Type(parent, TypeName.of_string name), env.shadowed
else `Type(parent, TypeName.make_std name), env.shadowed
in
let types = Ident.add t identifier env.types in
inner rest { env with types; shadowed }
Expand All @@ -370,7 +370,7 @@ let env_of_items parent items env =
let identifier, shadowed =
if is_shadowed
then `Value(parent, ValueName.internal_of_string name), t :: env.shadowed
else `Value(parent, ValueName.of_string name), env.shadowed
else `Value(parent, ValueName.make_std name), env.shadowed
in
let values = Ident.add t identifier env.values in
inner rest { env with values; shadowed }
Expand All @@ -381,7 +381,7 @@ let env_of_items parent items env =
let identifier, shadowed =
if is_shadowed
then `ModuleType(parent, ModuleTypeName.internal_of_string name), t :: env.shadowed
else `ModuleType(parent, ModuleTypeName.of_string name), env.shadowed
else `ModuleType(parent, ModuleTypeName.make_std name), env.shadowed
in
let module_types = Ident.add t identifier env.module_types in
inner rest { env with module_types; shadowed }
Expand All @@ -391,7 +391,7 @@ let env_of_items parent items env =
let identifier, shadowed =
if is_shadowed
then `Module(parent, ModuleName.internal_of_string name), t :: env.shadowed
else `Module(parent, ModuleName.of_string name), env.shadowed
else `Module(parent, ModuleName.make_std name), env.shadowed
in
let path = `Identifier(identifier, is_shadowed) in
let modules = Ident.add t identifier env.modules in
Expand All @@ -403,7 +403,7 @@ let env_of_items parent items env =
let identifier, shadowed =
if is_shadowed
then `Class(parent, ClassName.internal_of_string name), t :: t2 :: t3 :: t4 :: env.shadowed
else `Class(parent, ClassName.of_string name), env.shadowed
else `Class(parent, ClassName.make_std name), env.shadowed
in
let classes =
List.fold_right (fun id classes -> Ident.add id identifier classes)
Expand All @@ -415,7 +415,7 @@ let env_of_items parent items env =
let identifier, shadowed =
if is_shadowed
then `ClassType(parent, ClassTypeName.internal_of_string name), t :: t2 :: t3 :: env.shadowed
else `ClassType(parent, ClassTypeName.of_string name), env.shadowed
else `ClassType(parent, ClassTypeName.make_std name), env.shadowed
in
let class_types =
List.fold_right (fun id class_types -> Ident.add id identifier class_types)
Expand Down
12 changes: 6 additions & 6 deletions src/model/names.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module type Name = sig

val to_string_unsafe : t -> string

val of_string : string -> t
val make_std : string -> t

val of_ident : Ident.t -> t

Expand Down Expand Up @@ -52,12 +52,12 @@ module Name : Name = struct

let to_string_unsafe = function Std s -> s | Internal (s, _i) -> s

let of_string s =
let make_std s =
let s = parenthesise s in
if String.length s > 0 && s.[0] = '{' then raise (Invalid_argument s)
else Std s

let of_ident id = of_string (Ident.name id)
let of_ident id = make_std (Ident.name id)

let internal_of_string id =
incr internal_counter;
Expand Down Expand Up @@ -95,7 +95,7 @@ module type SimpleName = sig

val to_string : t -> string

val of_string : string -> t
val make_std : string -> t

val of_ident : Ident.t -> t

Expand All @@ -113,9 +113,9 @@ module SimpleName : SimpleName = struct

let to_string s = s

let of_string s = s
let make_std s = s

let of_ident id = of_string (Ident.name id)
let of_ident id = make_std (Ident.name id)

let equal (x : t) (y : t) = x = y

Expand Down
4 changes: 2 additions & 2 deletions src/model/names.mli
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module type Name = sig
(** [to_string_unsafe] will allow even internal names to be turned into
strings. Use with caution. *)

val of_string : string -> t
val make_std : string -> t

val of_ident : Ident.t -> t

Expand Down Expand Up @@ -55,7 +55,7 @@ module type SimpleName = sig

val to_string : t -> string

val of_string : string -> t
val make_std : string -> t

val of_ident : Ident.t -> t

Expand Down
4 changes: 2 additions & 2 deletions src/model/paths.ml
Original file line number Diff line number Diff line change
Expand Up @@ -858,9 +858,9 @@ module Fragment = struct
| Resolved.Branch (base, m) -> Branch (base, `Resolved m) )
| `Dot (m, name) -> (
match split_parent m with
| Base None -> Branch (ModuleName.of_string name, `Root)
| Base None -> Branch (ModuleName.make_std name, `Root)
| Base (Some i) ->
Branch (ModuleName.of_string name, `Resolved (`Root i))
Branch (ModuleName.make_std name, `Resolved (`Root i))
| Branch (base, m) -> Branch (base, `Dot (m, name)) )

module Signature = struct
Expand Down
Loading

0 comments on commit 0a44168

Please sign in to comment.