Changeset 158
- Timestamp:
- 03/08/06 21:19:30 (3 years ago)
- Files:
-
- trunk/ddl/DDLException.d (modified) (1 diff)
- trunk/ddl/DDLReader.d (modified) (4 diffs)
- trunk/ddl/DDLWriter.d (modified) (1 diff)
- trunk/ddl/LoaderRegistry.d (modified) (3 diffs)
- trunk/ddl/ddl/DDLBinary.d (modified) (5 diffs)
- trunk/ddl/insitu/InSituMapBinary.d (modified) (1 diff)
- trunk/ddl/omf/OMFLibrary.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ddl/DDLException.d
r143 r158 41 41 public this(char[] fmt,TypeInfo[] arguments,void* argptr){ 42 42 ExtSprintClass sprint = new ExtSprintClass(fmt.length + 1024); 43 super( boilerplate(sprint(fmt,arguments,argptr)));43 super(sprint(fmt,arguments,argptr)); 44 44 } 45 45 46 public this(char[] message){ 47 super(boilerplate(message)); 46 public this(char[] fmt,...){ 47 ExtSprintClass sprint = new ExtSprintClass(fmt.length + 1024); 48 super(sprint(fmt,_arguments,_argptr)); 48 49 } 49 50 50 public char[] boilerplate(char[] message){51 public static char[] boilerplate(char[] message){ 51 52 return( 52 53 "[Exception] You have run into a condition not handled, or possibly incorrectly handled, by DDL.\n" ~ trunk/ddl/DDLReader.d
r143 r158 36 36 private import mango.io.model.IBuffer; 37 37 private import mango.io.model.IConduit; 38 39 private import mango.io.Stdout; 38 40 39 41 public class DDLReader : Reader{ … … 78 80 uint chunk = conduit.read(content[filled..$]); 79 81 if (chunk is conduit.Eof) 80 break; 81 82 break; 82 83 filled += chunk; 83 84 if (content.length - filled < 1024) … … 85 86 } 86 87 x ~= content [0..filled]; // add on additional data 88 89 Stdout.println("DDLReader.getAll: %d bytes read\n",x.length); 87 90 return this; 88 91 } … … 92 95 return result != null; 93 96 } 97 98 // perform a seek relative to the current buffer position and status using the conduit 99 // NOTE: this will clear out the current buffer 100 void seek(ulong offset, ISeekable.SeekAnchor anchor=ISeekable.SeekAnchor.Begin){ 101 ISeekable seekableConduit = cast(ISeekable)(getBuffer.getConduit); 102 assert(seekableConduit); 103 104 // seek and wipe out the buffer 105 switch(anchor){ 106 case ISeekable.SeekAnchor.Begin: 107 case ISeekable.SeekAnchor.End: 108 seekableConduit.seek(offset,anchor); 109 break; 110 case ISeekable.SeekAnchor.Current: 111 seekableConduit.seek(offset - getBuffer.readable,anchor); 112 break; 113 } 114 getBuffer.clear(); 115 } 116 117 // get the position relative to the current buffer position and status 118 ulong getPosition(){ 119 ISeekable seekableConduit = cast(ISeekable)(getBuffer.getConduit); 120 assert(seekableConduit); 121 return seekableConduit.getPosition() - getBuffer.readable; 122 } 94 123 } trunk/ddl/DDLWriter.d
r143 r158 44 44 super(conduit); 45 45 } 46 47 //TODO: add additional ddl specific methods 46 47 // perform a seek relative to the current buffer position and status using the conduit 48 // NOTE: this will flush the current buffer's contents 49 void seek(ulong offset, ISeekable.SeekAnchor anchor=ISeekable.SeekAnchor.Begin){ 50 ISeekable seekableConduit = cast(ISeekable)(getBuffer.getConduit); 51 assert(seekableConduit); 52 53 // seek and wipe out the buffer 54 ulong writable = getBuffer.writable; 55 getBuffer.flush(); 56 57 switch(anchor){ 58 case ISeekable.SeekAnchor.Begin: 59 case ISeekable.SeekAnchor.End: 60 seekableConduit.seek(offset,anchor); 61 break; 62 case ISeekable.SeekAnchor.Current: 63 seekableConduit.seek(offset - writable,anchor); 64 break; 65 } 66 } 67 68 // get the position relative to the current buffer position and status 69 ulong getPosition(){ 70 ISeekable seekableConduit = cast(ISeekable)(getBuffer.getConduit); 71 assert(seekableConduit); 72 return seekableConduit.getPosition() + getBuffer.writable; 73 } 48 74 } trunk/ddl/LoaderRegistry.d
r143 r158 77 77 } 78 78 79 80 79 /** 81 80 The LoaderRegistry fufills the role of controlling access to the loaders to be used for a … … 143 142 if(loader.canLoadLibrary(buffer)){ 144 143 lib = loader.load(this,buffer); 145 144 146 145 // check the version if needed 147 146 if(attrStdVersion.length > 0){ … … 152 151 throw new LibraryVersionException(buffer.getPath.toString(),attrStdVersion,*libraryStdVersion); 153 152 } 154 } 153 } 154 return lib; 155 155 } 156 156 } trunk/ddl/ddl/DDLBinary.d
r143 r158 31 31 private import mango.io.model.IConduit; 32 32 33 private import mango.io.Stdout; 34 33 35 /** 34 36 Provides support for loading and saving DDL files. … … 36 38 class DDLBinary{ 37 39 protected static const char[] MagicBytes = "DDL!"; 38 protected static const uint DDLVersion = 0x0001000 2;40 protected static const uint DDLVersion = 0x00010001; 39 41 protected static const uint BufferSize = 4096; 40 42 … … 96 98 reader.get(value); 97 99 attributes[name] = value; 98 } 99 ISeekable seekableConduit = cast(ISeekable)(reader.getBuffer.getConduit); 100 seekableConduit.seek(binaryStart); 101 reader.get(binaryData); 100 } 101 reader.seek(binaryStart); 102 103 void[] data; 104 reader.getAll(data); 105 binaryData = cast(ubyte[])data; 102 106 } 103 107 … … 139 143 writer.put(binaryData); 140 144 141 ISeekable seekableConduit = cast(ISeekable)(writer.getBuffer.getConduit); 142 uint binaryStart = seekableConduit.getPosition; 145 uint binaryStart = writer.getPosition(); 143 146 144 147 writer.put(binaryData); 145 148 146 seekableConduit.seek(8); // offset for binary start149 writer.seek(8); // offset for binary start 147 150 writer.put(binaryStart); 148 151 149 seekableConduit.seek(0,ISeekable.SeekAnchor.End); // be polite, and park at the end of the stream152 writer.seek(0,ISeekable.SeekAnchor.End); // be polite, and park at the end of the stream 150 153 } 151 154 } … … 155 158 header ::= magic version binaryOffset binaryType processorArch definedNamespaces importedModules attributes 156 159 magic ::= 'D' 'D' 'L' '!' 157 version ::= 0x0001000 2160 version ::= 0x00010001 158 161 159 162 binaryOffset ::= uint trunk/ddl/insitu/InSituMapBinary.d
r143 r158 32 32 private import mango.text.LineIterator; 33 33 34 private import mango.io.Stdout; 34 35 35 36 /* Binary 'file' for DMD map files */ trunk/ddl/omf/OMFLibrary.d
r143 r158 132 132 133 133 // skip the padding and proceed to the first page boundary 134 ISeekable seekableConduit = cast(ISeekable)(reader.getBuffer.getConduit); 135 seekableConduit.seek(pageSize); 134 reader.seek(pageSize); 136 135 137 136 // read in object files, and add them to the modules listing … … 144 143 145 144 // advance the remainder of a page 146 long delta = pageSize - (seekableConduit.getPosition % pageSize); 145 ulong position = reader.getPosition(); 146 ulong delta = pageSize - (position % pageSize); 147 147 if(delta != pageSize){ 148 seekableConduit.seek(seekableConduit.getPosition + delta);148 reader.seek(position + delta); 149 149 } 150 150
