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 331, Sat Jun 12 15:04:53 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 default : policy      val colocate : policyMaker
14        val separate :
15            { root: AbsPath.t, parentArc: string, absArc: string } -> policyMaker
16    
17      val mkBinPath : policy -> AbsPath.t -> AbsPath.t      val mkBinPath : policy -> AbsPath.t -> AbsPath.t
18      val mkSkelPath : policy -> AbsPath.t -> AbsPath.t      val mkSkelPath : policy -> AbsPath.t -> AbsPath.t
19      val mkStablePath : policy -> AbsPath.t -> AbsPath.t      val mkStablePath : policy -> AbsPath.t -> AbsPath.t
20  end  end
21    
22  structure FilenamePolicy :> FILENAMEPOLICY = struct  functor FilenamePolicyFn (val cmdir : string
23                              val skeldir : string) :> FILENAMEPOLICY = struct
24    
25        type converter = AbsPath.t -> AbsPath.t
26    
27      type policy = Dummy.t      type policy = { bin: converter, skel: converter, stable: converter }
28        type policyMaker = { arch: string, os: SMLofNJ.SysInfo.os_kind } -> policy
29    
30      val default = Dummy.v      fun kind2name SMLofNJ.SysInfo.BEOS = "beos"
31          | kind2name SMLofNJ.SysInfo.MACOS = "macos"
32          | kind2name SMLofNJ.SysInfo.OS2 = "os2"
33          | kind2name SMLofNJ.SysInfo.UNIX = "unix"
34          | kind2name SMLofNJ.SysInfo.WIN32 = "win32"
35    
36      fun cmpath (d, s) = let      fun mkPolicy shift { arch, os } = let
37            fun cmpath d s = let
38          val { dir = d0, file = f } = AbsPath.splitDirFile s          val { dir = d0, file = f } = AbsPath.splitDirFile s
39          val d1 = AbsPath.joinDirFile { dir = d0, file = "CM" }              val d1 = AbsPath.joinDirFile { dir = d0, file = cmdir }
40          val d2 = AbsPath.joinDirFile { dir = d1, file = d }          val d2 = AbsPath.joinDirFile { dir = d1, file = d }
41      in      in
42          AbsPath.joinDirFile { dir = d2, file = f }          AbsPath.joinDirFile { dir = d2, file = f }
43      end      end
44            val archos = concat [arch, "-", kind2name os]
45            val archosdep = cmpath archos o shift
46        in
47            { skel = cmpath skeldir, bin = archosdep, stable = archosdep }
48        end
49    
50        val colocate = mkPolicy (fn s => s)
51    
52      fun mkBinPath _ s = cmpath ("bin", s)      fun separate { root, parentArc, absArc } = let
53      fun mkSkelPath _ s = cmpath ("SKEL", s)          val root = AbsPath.relativeContext root
54      fun mkStablePath _ s = cmpath ("bin", s)          fun shift p = let
55                val s = AbsPath.name p
56                fun cvt arc = if arc = OS.Path.parentArc then parentArc else arc
57            in
58                case OS.Path.fromString s of
59                    { isAbs = false, vol = "", arcs } =>
60                        AbsPath.native { context = root,
61                                         spec = OS.Path.toString
62                                             { isAbs = false, vol = "",
63                                               arcs = map cvt arcs } }
64                  | _ => AbsPath.native
65                        { context = root,
66                          spec = OS.Path.joinDirFile { dir = absArc,
67                                                       file = AbsPath.file p } }
68  end  end
69        in
70            mkPolicy shift
71        end
72    
73        fun mkBinPath (p: policy) s = #bin p s
74        fun mkSkelPath (p: policy) s = #skel p s
75        fun mkStablePath (p: policy) s = #stable p s
76    end
77    
78    structure FilenamePolicy =
79        FilenamePolicyFn (val cmdir = "NEWCM" val skeldir = "SKEL")

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

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