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 /sml/trunk/src/cm/main/filename-policy.sml
ViewVC logotype

Diff of /sml/trunk/src/cm/main/filename-policy.sml

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

revision 297, Thu May 27 08:29:19 1999 UTC revision 357, Mon Jun 28 08:46:30 1999 UTC
# Line 1  Line 1 
 (* just a placeholder so far *)  
   
1  (*  (*
2   * A type representing different choices for file naming conventions.   * A type representing different choices for file naming conventions.
3   *   *
# Line 10  Line 8 
8  signature FILENAMEPOLICY = sig  signature FILENAMEPOLICY = sig
9    
10      type policy      type policy
11        type policyMaker = { arch: string, os: SMLofNJ.SysInfo.os_kind } -> policy
12    
13        val colocate : policyMaker
14        val separate : { bindir: string, bootdir: string } -> policyMaker
15    
16      val default : policy      val mkBinName : policy -> SrcPath.t -> string
17        val mkSkelName : policy -> SrcPath.t -> string
18        val mkStableName : policy -> SrcPath.t -> string
19    
20      val mkBinPath : policy -> AbsPath.t -> AbsPath.t      val kind2name : SMLofNJ.SysInfo.os_kind -> string
     val mkSkelPath : policy -> AbsPath.t -> AbsPath.t  
     val mkStablePath : policy -> AbsPath.t -> AbsPath.t  
21  end  end
22    
23  structure FilenamePolicy :> FILENAMEPOLICY = struct  functor FilenamePolicyFn (val cmdir : string
24                              val skeldir : string) :> FILENAMEPOLICY = struct
25    
26      type policy = Dummy.t      type converter = SrcPath.t -> string
27    
28      val default = Dummy.v      type policy = { bin: converter, skel: converter, stable: converter }
29        type policyMaker = { arch: string, os: SMLofNJ.SysInfo.os_kind } -> policy
30    
31      fun cmpath (d, s) = let      fun kind2name SMLofNJ.SysInfo.BEOS = "beos"
32          val { dir = d0, file = f } = AbsPath.splitDirFile s        | kind2name SMLofNJ.SysInfo.MACOS = "macos"
33          val d1 = AbsPath.joinDirFile { dir = d0, file = "CM" }        | kind2name SMLofNJ.SysInfo.OS2 = "os2"
34          val d2 = AbsPath.joinDirFile { dir = d1, file = d }        | kind2name SMLofNJ.SysInfo.UNIX = "unix"
35          | kind2name SMLofNJ.SysInfo.WIN32 = "win32"
36    
37        fun mkPolicy (shiftbin, shiftstable) { arch, os } = let
38            fun cmname d s = let
39                val { dir = d0, file = f } = OS.Path.splitDirFile s
40                val d1 = OS.Path.joinDirFile { dir = d0, file = cmdir }
41                val d2 = OS.Path.joinDirFile { dir = d1, file = d }
42      in      in
43          AbsPath.joinDirFile { dir = d2, file = f }              OS.Path.joinDirFile { dir = d2, file = f }
44      end      end
45            val archos = concat [arch, "-", kind2name os]
46        in
47            { skel = cmname skeldir o SrcPath.osstring,
48              bin = cmname archos o shiftbin,
49              stable = cmname archos o shiftstable }
50        end
51    
52        val colocate = mkPolicy (SrcPath.osstring, SrcPath.osstring)
53    
54      fun mkBinPath _ s = cmpath ("bin", s)      fun separate { bindir, bootdir } = let
55      fun mkSkelPath _ s = cmpath ("SKEL", s)          fun shiftname root p =
56      fun mkStablePath _ s = cmpath ("bin", s)              case SrcPath.reAnchoredName (p, root) of
57                    SOME s => s
58                  | NONE => (Say.say ["Failure: ", SrcPath.descr p,
59                                      " is not an anchored path!\n"];
60                             raise Fail "bad path")
61        in
62            mkPolicy (shiftname bindir, shiftname bootdir)
63        end
64    
65        fun mkBinName (p: policy) s = #bin p s
66        fun mkSkelName (p: policy) s = #skel p s
67        fun mkStableName (p: policy) s = #stable p s
68  end  end
69    
70    structure FilenamePolicy =
71        FilenamePolicyFn (val cmdir = "NEWCM" val skeldir = "SKEL")

Legend:
Removed from v.297  
changed lines
  Added in v.357

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