Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /smlnj-lib/trunk/Controls/controls.sml
ViewVC logotype

Diff of /smlnj-lib/trunk/Controls/controls.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4195, Tue Oct 27 13:47:28 2015 UTC revision 4196, Wed Oct 28 13:52:51 2015 UTC
# Line 49  Line 49 
49      fun get (Ctl{get, ...}) = get()      fun get (Ctl{get, ...}) = get()
50      fun set (Ctl{set, ...}, v) = set (SOME v) ()      fun set (Ctl{set, ...}, v) = set (SOME v) ()
51      fun set' (Ctl{set, ...}, v) = set (SOME v)      fun set' (Ctl{set, ...}, v) = set (SOME v)
52        fun help (Ctl{help, ...}) = help
53      fun info (Ctl{priority, obscurity, help, ...}) =      fun info (Ctl{priority, obscurity, help, ...}) =
54          { priority = priority, obscurity = obscurity, help = help }          { priority = priority, obscurity = obscurity, help = help }
55    
56      (* package a boolean control as a GetOpt option descriptor (NoArg) *)
57        fun mkOptionFlag {ctl=Ctl{set, help, ...}, short, long} = {
58                short = short,
59                long = (case long of NONE => [] | SOME opt => [opt]),
60                desc = GetOpt.NoArg(set (SOME true)),
61                help = help
62              }
63    
64      (* package a string control as a GetOpt option descriptor with required argument (ReqArg)  *)
65        fun mkOptionReqArg {ctl=Ctl{set, help, ...}, arg, short, long} = {
66                short = short,
67                long = (case long of NONE => [] | SOME opt => [opt]),
68                desc = GetOpt.ReqArg(fn s => set (SOME s) (), arg),
69                help = help
70              }
71    
72      (* package a string control as a GetOpt option descriptor with an optional argument (OptArg) *)
73        fun mkOption {ctl=Ctl{set, help, ...}, arg, default, short, long} = {
74                short = short,
75                long = (case long of NONE => [] | SOME opt => [opt]),
76                desc = let
77                  fun setFn NONE = set (SOME default) ()
78                    | setFn someVal = set someVal ()
79                  in
80                    GetOpt.OptArg(setFn, arg)
81                  end,
82                help = help
83              }
84    
85      fun save'restore (Ctl{set,...}) = set NONE      fun save'restore (Ctl{set,...}) = set NONE
86    
87      fun compare (Ctl{priority=p1, ...}, Ctl{priority=p2, ...}) =      fun compare (Ctl{priority=p1, ...}, Ctl{priority=p2, ...}) =

Legend:
Removed from v.4195  
changed lines
  Added in v.4196

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0