Changeset 161
- Timestamp:
- 03/14/06 21:53:15 (3 years ago)
- Files:
-
- trunk/buildtest.bat (modified) (2 diffs)
- trunk/ddl/DDLReader.d (modified) (2 diffs)
- trunk/ddl/FileBuffer.d (modified) (3 diffs)
- trunk/ddl/LoaderRegistry.d (modified) (2 diffs)
- trunk/ddl/ddl/DDLBinary.d (modified) (3 diffs)
- trunk/ddl/insitu/InSituLibBinary.d (modified) (5 diffs)
- trunk/ddl/insitu/InSituMapBinary.d (modified) (4 diffs)
- trunk/ddoc/ddl.readme.txt (modified) (1 diff)
- trunk/ddoc/readme.txt (modified) (1 diff)
- trunk/utils/bless.d (modified) (6 diffs)
- trunk/utils/bless_bn.d (modified) (1 diff)
- trunk/utils/ddlinfo_bn.d (modified) (1 diff)
- trunk/utils/insitu.d (modified) (7 diffs)
- trunk/utils/insitu_bn.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/buildtest.bat
r101 r161 2 2 3 3 if "%1"=="" goto err 4 4 echo * Compiling Test Module 5 5 build -c test\testmodule.d %2 %3 %4 %5 %6 %7 %8 %9 6 6 7 echo * Building Test 7 8 build -full -L" -map" test\%1 %2 %3 %4 %5 %6 %7 %8 %9 8 9 copy %1.map test 10 11 echo * Creating in-situ module via insitu.exe 9 12 utils\insitu test\%1.map -ftest\%1.situ 13 14 echo * Creating ddl in-situ module via bless.exe 10 15 utils\bless test\%1.situ -ftest\%1.ddl 11 16 … … 17 22 18 23 :done 24 25 echo * Done trunk/ddl/DDLReader.d
r158 r161 41 41 public class DDLReader : Reader{ 42 42 public this(void[] data){ 43 super(new Buffer(data ));43 super(new Buffer(data,data.length)); 44 44 } 45 45 … … 87 87 x ~= content [0..filled]; // add on additional data 88 88 89 Stdout.println("DDLReader.getAll: %d bytes read\n",x.length);90 89 return this; 91 90 } trunk/ddl/FileBuffer.d
r143 r161 27 27 private import mango.io.Buffer; 28 28 private import mango.io.FileConduit; 29 30 private import mango.io.model.IBuffer; 29 31 private import mango.io.model.IConduit; 30 32 … … 36 38 FilePath path; 37 39 38 public this(char[] path ){40 public this(char[] path, FileStyle.Bits style = FileStyle.ReadExisting){ 39 41 this.path = new FilePath(path); 40 super(new FileConduit(this.path ));42 super(new FileConduit(this.path,style)); 41 43 } 42 44 43 public this(FilePath path ){44 super(new FileConduit(path ));45 public this(FilePath path, FileStyle.Bits style = FileStyle.ReadExisting){ 46 super(new FileConduit(path,style)); 45 47 this.path = path; 46 48 } … … 64 66 return path; 65 67 } 66 /*67 public void[] readAll(){68 ubyte[] content;69 68 70 auto conduit = this.getConduit(); 71 try{ 72 content = new ubyte[cast(int) conduit.length]; 73 74 // read the entire file into memory and return it 75 if (conduit.read (content) != content.length) 76 throw new IOException ("eof whilst reading"); 77 } 78 finally{ 79 conduit.close (); 80 } 81 return content; 82 }*/ 69 public IBuffer.Style getStyle(){ 70 return IBuffer.Mixed; 71 } 83 72 } trunk/ddl/LoaderRegistry.d
r158 r161 29 29 private import ddl.FileBuffer; 30 30 31 private import mango.io.Stdout; 32 31 33 /** 32 34 Exception class used exclusively by the Linker. … … 140 142 DynamicLibrary lib; 141 143 foreach(DynamicLibraryLoader loader;loaders){ 144 // Stdout.println("trying %s loader",loader.getLibraryType); 142 145 if(loader.canLoadLibrary(buffer)){ 146 //Stdout.println("loading... "); 143 147 lib = loader.load(this,buffer); 144 148 //Stdout.println("completed"); 145 149 // check the version if needed 146 150 if(attrStdVersion.length > 0){ trunk/ddl/ddl/DDLBinary.d
r158 r161 119 119 DDLWriter writer = new DDLWriter(fileBuffer); 120 120 121 writer. put(cast(ubyte[])MagicBytes);121 writer.getBuffer.append(cast(void[])MagicBytes); 122 122 writer.put(DDLVersion); 123 123 writer.put(cast(uint)0); // dummy write for binary start … … 140 140 writer.put(value); 141 141 } 142 143 writer.put(binaryData); 144 142 145 143 uint binaryStart = writer.getPosition(); 146 144 147 writer. put(binaryData);145 writer.getBuffer.append(cast(void[])binaryData); 148 146 149 147 writer.seek(8); // offset for binary start … … 174 172 count ::= uint 175 173 176 embeddedFile ::= ubyte( count)174 embeddedFile ::= ubyte(*) 177 175 +/ trunk/ddl/insitu/InSituLibBinary.d
r143 r161 34 34 35 35 private import mango.io.GrowBuffer; 36 private import mango.io.Stdout; 36 37 37 38 class InSituLibBinary : InSituBinary{ … … 74 75 reader.getAll(binaryData); 75 76 reader = new DDLReader(uncompress(binaryData)); 76 77 77 78 // read symbols 78 79 for(uint i=0; i<symbolCount; i++){ … … 82 83 reader.get(address); 83 84 reader.get(sym.name); 84 85 85 86 sym.address = cast(void*)address; 86 87 … … 101 102 // compress the data 102 103 ubyte[] binaryData = cast(ubyte[])compress(zipWriter.getBuffer.toString,compressionLevel); 103 104 104 105 // write the actual file 105 106 DDLWriter writer = new DDLWriter(file); 106 writer. put(cast(ubyte[])magicString);107 writer.getBuffer.append(cast(void[])magicString); 107 108 writer.put(InSituVersion); 108 109 writer.put(allSymbols.length); 109 writer. put(binaryData);110 writer.getBuffer.append(cast(void[])binaryData); 110 111 } 111 112 } … … 113 114 /+ 114 115 InSituLibBinary ::= header compressedData 115 header ::= fileVersion symbolCount116 header ::= magicString fileVersion symbolCount 116 117 fileVersion ::= uint 117 118 symbolCount ::= uint trunk/ddl/insitu/InSituMapBinary.d
r158 r161 29 29 private import ddl.insitu.InSituBinary; 30 30 31 private import mango.io.TextReader;32 31 private import mango.text.LineIterator; 33 32 … … 39 38 ExportSymbol[char[]] allSymbols; 40 39 40 // helper class 41 protected class ExtLineIteratorT(T) : LineIteratorT!(T){ 42 public this(){} 43 44 public this (IBuffer buffer){ 45 super (buffer); 46 } 47 48 public this (IConduit conduit){ 49 super (conduit); 50 } 51 52 this (T[] string){ 53 super (string); 54 } 55 56 public T[] getNext(){ 57 if(next) return get(); 58 else return (T[]).init; 59 } 60 } 61 62 alias ExtLineIteratorT!(char) ExtLineIterator; 63 41 64 public this(){ 42 65 //do nothing … … 44 67 45 68 public void load(FileBuffer file){ 46 TextReader reader = new TextReader(new LineIterator(file)); 47 parseSegmentDefinitions(reader); 48 parsePublicsByName(reader); 69 ExtLineIterator iter = new ExtLineIterator(file); 70 71 parseSegmentDefinitions(iter); 72 parsePublicsByName(iter); 49 73 // throw away the publics by address 50 74 } … … 58 82 } 59 83 60 protected void parseSegmentDefinitions( TextReader reader){84 protected void parseSegmentDefinitions(ExtLineIterator iter){ 61 85 char[] line; 62 reader.get(line); // throw away the first line (blank)63 reader.get(line); // throw away the second line (header)86 line = iter.getNext(); // throw away the first line (blank) 87 line = iter.getNext(); // throw away the second line (header) 64 88 65 89 // read until there's a blank line 66 90 while(true){ 67 reader.get(line);91 line = iter.getNext(); 68 92 if(line.length == 0) break; 69 93 } 70 94 } 71 95 72 protected void parsePublicsByName( TextReader reader){96 protected void parsePublicsByName(ExtLineIterator iter){ 73 97 char[] line; 74 reader.get(line); // throw away the first line (header)75 reader.get(line); // throw away the second line (blank)98 line = iter.getNext(); // throw away the first line (header) 99 line = iter.getNext(); // throw away the second line (blank) 76 100 77 101 // read until there's a blank line 78 102 while(true){ 79 reader.get(line);103 line = iter.getNext(); 80 104 if(line.length == 0) break; 81 105 trunk/ddoc/ddl.readme.txt
r62 r161 1 DDOC TOOL V1.0 FOR DDL2 ---------------3 4 By Eric Anderton (C) 20055 Contact: EricAnderton@yahoo.com6 7 This product is released under a modified BSD license -- see the section LICENSE for more information8 9 This tool has been modified explicitly for the DDL project.10 11 http://www.dsource.org/projects/ddl12 13 Please see the original readme.txt for more informationtrunk/ddoc/readme.txt
r62 r161 1 DDOC TOOL V1.02 ---------------3 4 By Eric Anderton (C) 20055 Contact: EricAnderton@yahoo.com6 7 This product is released under a modified BSD license -- see the section LICENSE for more information8 9 10 INTRODUCTION11 ------------12 13 The ddoc tool provides a means to manipulate XML data as generated by DMD's ddoc facility, into useful and cross-referenced documentation. It accomplishes this by using a XSLT processor, such as AltovaXML and a series of customizable stylesheets. The result is a very flexible system that can be molded to fit just about any html-based documentation layout imaginable.14 15 More information on DMD and ddoc can be found on the digitalmars.com website:16 http://www.digitalmars.com/d/ddoc.html17 18 19 PLATFORMS AND DEPENDENCIES20 --------------------------21 22 The tool is presently provided for use on win32 with the AltovaXML XSLT processor. If you are interested in using this tool with a different processor or a different operating system, please see the PORTING section below.23 24 AltovaXML may be acquired on their website. It is a free (as in beer) download that comes with a royalty-free use license.25 26 http://www.altova.com/altovaxml.html27 28 29 INSTALLATION30 ------------31 32 There are several steps to installation before you can get started with this utility.33 34 0) Extract the files from the provided .zip, making sure to preserve the directory structure. If you are reading this, then you've likely completed this step. The installed files can stay put: the installation tool takes care of moving things about from here on.35 36 1) If you plan on building your sourcecode using a tool like 'build', you may want to install the xml.ddoc file in the same directory as DMD, and add a reference to it in the sc.ini file:37 38 DDOCFILE=myproject.ddoc39 40 Otherwise, you can simply use the xml.ddoc file inline when you compile a file in DMD.41 42 dmd myfile.d xml.ddoc43 44 Since the ddoc tool can only work with what DMD outputs, it is only going to work as well as the quality of your code comments. If you're not already familiar with it, please review the documentation guidelines on the digitalmars.com website:45 46 http://www.digitalmars.com/d/ddoc.html47 48 2) Install ddoc for your D application of choice. Simply run the 'install' script in the directory where you extracted the files back in step #0. If you run it without any arguments, it'll prompt you in how to use it correctly.49 50 Usage: install.bat (source_path) (dest_path)51 52 Where the source path is the root-most directory where your sourcecode is kept, and the destination path is where you'd like your generated documentation to go.53 54 The source and destination paths must be fully-qualified. This is because the installation tool will install the scripts with those paths in mind, so you won't have to type them in after this step. If you decide to move your project directory, or its documentation directory, just re-run this step with the new paths. The installer is smart, and won't over-write any customized scripts you may have added in the interim.55 56 The installer will create a '_ddoc' sub-directory under your destination directory, and will copy all the needed XML, XSL and shell scripts there for use. When the installation process is complete, the installer will prompt you with the proper command-line for the next step. Feel free to place that in a shell script of your choosing for easy access later.57 58 3) Generate your documentation*. Simply run the 'compile' command that was given you by the installer; this will be in the form '(dest-path)\_ddoc\compile'.59 60 The 'compile' command will generate a cross-reference for your entire source tree, and then pass it to a series of transforms and child scripts. The process is very time-consuming, but is needed to generate some of the more complex pages in the documentation set.61 62 (*You'll of course want to have DMD generate the output .html (really XML data -- see step #1) files before you do this. Otherwise, you'll be very dissapointed at the output.)63 64 4) Once it is completed, you can aim your browser at (dest-path)/index.html to review the output. If at any time you update your code, and run it through DMD to get ddoc output, run the 'compile' script again from Step #3 to update your documentation.65 66 67 CUSTOMIZATION68 -------------69 70 There are several points for customization with this tool. These are located in the (dest-dir)\_ddoc directory after installation.71 72 - page.xsl - This transform is used for each and every page in the document. Modify the templates here if you want to change how all your pages look73 74 - pages.xml - This is used to describe all the non-module pages in the documentation output. If you want to suppress a given page, or to add your own, simply modify the file. The various XSL files indicated within pages.xml can also be modified, say if you want to change the title or enhance the content.75 76 Also, there is a logo.gif that is copied directly into the destination directory. As this is referenced in the page.xsl file (mentioned above), you may want to change this to your project's logo or get rid of it completely.77 78 If you are interested in porting the tool to another platform, please see the PORTING section.79 80 81 BUGS & ISSUES82 -------------83 84 - The xref is slow for big projects. Large D projects take a very long time to generate documentation -several minutes or more. This is a known issue, and a more scalable algorithm will be adopted for future releases.85 86 - Depending on your XSLT engine of choice, it may be difficult to debug custom scripts used with the tool. AltovaXML is notorious for quietly failing or giving minimal output on where your markup is invalid or if an XPATH expression is wrong.87 88 89 PORTING90 -------91 92 There are two files that need to be modified in order to get the tool to work with with a different scripting shell or XSLT engine, on your platform of choice.93 94 - install.bat - This script is inherently non-portable. It will require a complete re-write for porting to another operating system. Care has been taken to make it as short as possible, as to ease this transition. Note the behavior of xcopy, as it only overwrites files that are older than the ones from the /install sub-directory.95 96 - install/script.xsl - The system uses this transform to generate all of the scripts used after the inital install script. The files compile.xml, all-modules.xml and all-pages.xml are fed through this transform to generate shell scripts for later use. All of the productions in script.xsl will need to be modified to accomodate your command-shell and/or XSLT engine of choice.97 98 One caveat: the scripts for this tool require XSLT/XPATH 2.0 support. At the time of writing this document, there were exceptionally few such engine implementations out in the wild, with a very slim number of them available for free. It is technically possible to reduce the entire XSL set in the tool to XSLT/XPATH 1.0, but to do so would be quite an undertaking.99 100 101 LICENSE102 -------103 104 Copyright (c) 2005 Eric Anderton105 106 Permission is hereby granted, free of charge, to any person107 obtaining a copy of this software and associated documentation108 files (the "Software"), to deal in the Software without109 restriction, including without limitation the rights to use,110 copy, modify, merge, publish, distribute, sublicense, and/or111 sell copies of the Software, and to permit persons to whom the112 Software is furnished to do so, subject to the following113 conditions:114 115 The above copyright notice and this permission notice shall be116 included in all copies or substantial portions of the Software.117 118 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,119 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES120 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND121 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT122 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,123 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING124 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR125 OTHER DEALINGS IN THE SOFTWARE.trunk/utils/bless.d
r142 r161 30 30 private import ddl.all; 31 31 private import ddl.FileBuffer; 32 private import ddl.Attributes; 33 private import ddl.DDLException; 34 private import ddl.DDLReader; 35 32 36 private import ddl.ddl.DDLLoader; 33 37 private import ddl.ddl.DDLBinary; 34 38 35 private import mango.io.File;36 39 private import mango.io.FilePath; 40 private import mango.io.FileConduit; 41 42 private import mango.text.LineIterator; 37 43 38 44 private import utils.bless_bn; … … 95 101 96 102 // get the filename 97 File file = new File(args[1]); 98 99 char[] originalOutputFile = filePathPart(file.getPath,PathPart.Root | PathPart.Path | PathPart.Name | PathPart.Suffix); 100 103 101 104 // pick through the options (if any) 102 105 bit verbose = false; 103 106 bit extract = false; 104 107 bit noCreate = false; 105 char[] outputFileName = originalOutputFile; 106 char[][char[]] attributes; 107 108 // get dash prefixed args 109 ArgParser parser = new ArgParser(); 108 char[] outputFileName = ""; 109 char[] filename = ""; 110 Attributes attributes; 111 112 // configure the arg parser 113 ArgParser parser = new ArgParser(delegate uint(char[] value,uint ordinal){ 114 if(ordinal > 0) throw new DDLException("Invalid argument %s",value); 115 filename = value; 116 return value.length; 117 }); 110 118 111 119 parser.bind("-", "v",delegate void(){ … … 149 157 150 158 parser.bind("-", "p",delegate uint(char[] value){ 151 DDLFile file; 152 file.create(value); 153 if(file.exists){ 154 file.load(value); 155 ReadCursor cursor = new ReadCursor(file); 156 while(cursor.hasMore()){ 157 parseAttribute(cursor.readLine); 159 FileConduit file = new FileConduit(value); 160 //TODO: determine if file exists, or just let exception fall through? 161 //if(file.exists){ 162 LineIterator iter = new LineIterator(file); 163 while(iter.next){ 164 parseAttribute(iter.get); 158 165 } 159 166 return value.length; 160 } 161 else{ 162 throw new Exception("Cannot find properties file: '" ~ value ~ "'"); 163 } 164 }); 165 166 try{ 167 parser.parse(args[2..$]); 168 } 169 catch(Exception e){ 170 Stdout.println("%s",e.toString()); 171 return 1; 167 //} 168 //else{ 169 // throw new Exception("Cannot find properties file: '" ~ value ~ "'"); 170 //} 171 }); 172 173 // parse the arguments 174 parser.parse(args[1..$]); 175 176 if(filename == ""){ 177 throw new DDLException("No filename specified."); 178 } 179 180 // get the file 181 FileBuffer file = new FileBuffer(filename); 182 183 char[] originalOutputFile = filePathPart(file.getPath,PathPart.Root | PathPart.Path | PathPart.Name | PathPart.Suffix); 184 185 if(outputFileName == ""){ 186 outputFileName = originalOutputFile; 172 187 } 173 188 … … 191 206 // we load the entire file via its loader to ensure that it will work later. 192 207 DynamicLibrary lib = registry.load(file.getPath.toString()); 208 193 209 194 210 if(!lib){ … … 245 261 // create the file and save it 246 262 DDLBinary binary = new DDLBinary(); 263 DDLReader reader = new DDLReader(file); 264 void[] data; 247 265 248 266 // save the easy fields 249 267 binary.binaryType = lib.getType; 250 binary.binaryData = cast(ubyte[])file.read(); 251 binary.attributes = attributes; 252 268 binary.attributes = attributes; 269 270 reader.getAll(data); 271 binary.binaryData = cast(ubyte[])data; 272 253 273 if(!("std.filename" in attributes)){ 254 274 attributes["std.filename"] = file.getPath.getName ~ "." ~ file.getPath.getExtension; … … 282 302 283 303 if(!noCreate){ 284 binary.save(new FileBuffer(outputFileName)); 304 FileBuffer outputFile = new FileBuffer(outputFileName,FileStyle.ReadWriteCreate); 305 binary.save(outputFile); 306 307 outputFile.flush(); 308 outputFile.getConduit().close(); 309 285 310 if(verbose) Stdout.println("Created '%s'",outputFileName); 286 311 } trunk/utils/bless_bn.d
r159 r161 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 318;4 long auto_build_number = 407; trunk/utils/ddlinfo_bn.d
r159 r161 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 318;4 long auto_build_number = 407; trunk/utils/insitu.d
r159 r161 30 30 31 31 private import ddl.all; 32 private import ddl.DDLException; 32 33 private import ddl.FileBuffer; 33 34 private import ddl.insitu.all; … … 35 36 private import utils.insitu_bn; 36 37 private import utils.ArgParser; 38 39 private import mango.io.FileConduit; 37 40 38 41 char[] helpText = … … 70 73 } 71 74 72 // get the filename73 FileBuffer inputFile = new FileBuffer(args[1]);74 75 75 // determine the output file 76 char[] outputFilename = inputFile.getPath.toString; 77 bit filenameOverride = false; 76 char[] outputFilename = ""; 77 bool filenameOverride = false; 78 char[] filename = ""; 78 79 79 80 ubyte compressionLevel = 9; 80 81 81 // get dash prefixed args 82 ArgParser parser = new ArgParser(); 82 // Configure the parser and parse the command line 83 ArgParser parser = new ArgParser(delegate uint(char[] value,uint ordinal){ 84 if(ordinal > 0) throw new DDLException("Invalid argument %s",value); 85 filename = value; 86 return value.length; 87 }); 83 88 84 89 parser.bind("-", "f",delegate uint(char[] value){ … … 86 91 outputFilename = value; 87 92 return value.length; 88 }); 93 }); 89 94 90 95 parser.bind("-", "c",delegate uint(char[] value){ … … 96 101 return 1; 97 102 }); 98 99 103 100 parser.parse(args[2..$]); 104 parser.parse(args[1..$]); 105 106 if(filename == ""){ 107 throw new DDLException("No filename specified."); 108 } 109 110 // get the file 111 FileBuffer inputFile = new FileBuffer(filename); 112 113 if(outputFilename == ""){ 114 outputFilename = inputFile.getPath.toString; 115 } 101 116 102 117 // load the .map file and get what we need … … 111 126 } 112 127 113 FileBuffer outputFile = new FileBuffer(outputFilename );128 FileBuffer outputFile = new FileBuffer(outputFilename,FileStyle.ReadWriteCreate); 114 129 115 130 // commit the data to the lib-style binary … … 117 132 outputBinary.setAllSymbols(inputBinary.getAllSymbols()); 118 133 outputBinary.save(outputFile,compressionLevel); 134 135 outputFile.flush(); 136 outputFile.getConduit().close(); 119 137 120 138 return 0; trunk/utils/insitu_bn.d
r159 r161 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 318;4 long auto_build_number = 407;
