Home My Page Projects Code Snippets Project Openings 3D graphics for Standard ML
Summary Activity SCM

SCM Repository

[sml3d] Diff of /trunk/sml3d/gen/gen-from-xml/gldb/driver.sml
ViewVC logotype

Diff of /trunk/sml3d/gen/gen-from-xml/gldb/driver.sml

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

revision 1376, Wed Apr 2 17:51:39 2014 UTC revision 1377, Fri Apr 4 20:45:22 2014 UTC
# Line 7  Line 7 
7  structure Driver =  structure Driver =
8    struct    struct
9    
10      structure X = XMLRep      structure X = DBXMLRep
11    
12      fun err s = TextIO.output (TextIO.stdErr, s)      fun err s = TextIO.output (TextIO.stdErr, s)
13    
# Line 26  Line 26 
26            OS.Process.exit sts)            OS.Process.exit sts)
27    
28    (* create an initial (and empty) database file from command-line parameters *)    (* create an initial (and empty) database file from command-line parameters *)
29      fun initDB (db, specfile, api, profile, extensions) = let      fun initDB (db, regFile, api, profile, extensions) = let
30          (* first, check to make sure that the database file does not already exist *)          (* first, check to make sure that the database file does not already exist *)
31            val _ = if OS.FileSys.access(db, [])            val _ = if OS.FileSys.access(db, [])
32                      then (                      then (
# Line 39  Line 39 
39                    api = api,                    api = api,
40                    profile = profile,                    profile = profile,
41                    extensions = extensions,                    extensions = extensions,
                   constants = [],  
42                    types = [],                    types = [],
43                    functions = []                    enums = [],
44                      commands = [],
45                      groups = [],
46                      features = []
47                  }                  }
48          (* write out the database *)          (* write out the database *)
49            val outS = TextIO.openOut db            val outS = TextIO.openOut db
50            in            in
51              PrintXML.print (outS, xml);              DBXMLPrint.print (outS, xml);
52              TextIO.closeOut outS;              TextIO.closeOut outS;
53              OS.Process.success              OS.Process.success
54            end            end
# Line 54  Line 56 
56    (* check the specification files used to seed the database. *)    (* check the specification files used to seed the database. *)
57      fun checkSpecs db = let      fun checkSpecs db = let
58          (* first we load the database to get the paths the specifications *)          (* first we load the database to get the paths the specifications *)
59            val X.DB{specfile, ...} = XMLParser.parseFile db            val X.DB content = DBXMLParser.parseFile db
60            in            in
61            (* load and check specification *)            (* load and check specification *)
62              (DB.load db) handle Fail msg => ??             (DB.load {
63                    regFile = #registry content,
64                    api = #api content,
65                    profile = #profile content,
66                    extensions = #extensions content
67                  }) handle Fail msg => (
68                    TextIO.output (TextIO.stdErr, msg^"\n");
69                    OS.Process.exit OS.Process.failure);
70              OS.Process.success              OS.Process.success
71            end            end
72    
73      fun updateDB dbFile = let      fun updateDB dbFile = let
74          (* first we load the database to get the paths the specifications *)          (* first we load the database to get the paths the specifications *)
75            val db = DB.fromXML(XMLParser.parseFile dbFile)            val xmlDB as DBXMLRep.DB content = DBXMLParser.parseFile dbFile
76          (* clone the database and load the specifications *)            val db = DB.fromXML xmlDB
77            val newDB = DB.clone db          (* load the specifications into a new DB *)
78            val _ = DB.load newDB            val newDB = DB.load {
79                      regFile = #registry content,
80                      api = #api content,
81                      profile = #profile content,
82                      extensions = #extensions content
83                    }
84            in            in
85              DB.extend (db, newDB);              DB.extend (db, newDB);
86            (* we save the database by first writing it to a temp file and then renaming it *)            (* we save the database by first writing it to a temp file and then renaming it *)
# Line 74  Line 88 
88              val {file=tmpFile, ...} = OS.Path.splitDirFile (OS.FileSys.tmpName())              val {file=tmpFile, ...} = OS.Path.splitDirFile (OS.FileSys.tmpName())
89              val outS = TextIO.openOut tmpFile              val outS = TextIO.openOut tmpFile
90              fun atomicWrite () = (              fun atomicWrite () = (
91                    PrintXML.print(outS, DB.toXML db);                    DBXMLPrint.print(outS, DB.toXML db);
92                    TextIO.closeOut outS;                    TextIO.closeOut outS;
93                    OS.FileSys.rename {old = tmpFile, new = dbFile})                    OS.FileSys.rename {old = tmpFile, new = dbFile})
94              in              in

Legend:
Removed from v.1376  
changed lines
  Added in v.1377

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