diff options
| author | Pierre-Marie Pédrot | 2014-01-19 17:20:58 +0100 |
|---|---|---|
| committer | Pierre-Marie Pédrot | 2014-01-19 17:35:59 +0100 |
| commit | a532777dcfc59128be2daa7cc74c7881a06f8cb3 (patch) | |
| tree | 97cde2983485df683a6a82780f1365c47aacadf7 /lib/genarg.ml | |
| parent | 7e6e533b148c9d57251388e9f1646a6829d10bfb (diff) | |
Adding a default object to generic argument registering mechanism.
Diffstat (limited to 'lib/genarg.ml')
| -rw-r--r-- | lib/genarg.ml | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/genarg.ml b/lib/genarg.ml index 3fb8155106..58dfbc91a1 100644 --- a/lib/genarg.ml +++ b/lib/genarg.ml @@ -194,6 +194,7 @@ module type GenObj = sig type ('raw, 'glb, 'top) obj val name : string + val default : ('raw, 'glb, 'top) genarg_type -> ('raw, 'glb, 'top) obj option end module Register (M : GenObj) = @@ -213,7 +214,10 @@ struct let get_obj0 name = try String.Map.find name !arg0_map with Not_found -> - Errors.anomaly (str M.name ++ str " function not found: " ++ str name) + match M.default (ExtraArgType name) with + | None -> + Errors.anomaly (str M.name ++ str " function not found: " ++ str name) + | Some obj -> obj (** For now, the following function is quite dummy and should only be applied to an extra argument type, otherwise, it will badly fail. *) |
