Changeset 158

Show
Ignore:
Timestamp:
03/08/06 21:19:30 (3 years ago)
Author:
pragma
Message:

- Fixed some bugs with .ddl parsing and handling
- Improved Exception clasess
- Bugfixes with omf, coff, ar and situ still pending

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ddl/DDLException.d

    r143 r158  
    4141    public this(char[] fmt,TypeInfo[] arguments,void* argptr){ 
    4242        ExtSprintClass sprint = new ExtSprintClass(fmt.length + 1024); 
    43         super(boilerplate(sprint(fmt,arguments,argptr))); 
     43        super(sprint(fmt,arguments,argptr)); 
    4444    } 
    4545     
    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)); 
    4849    } 
    4950     
    50     public char[] boilerplate(char[] message){ 
     51    public static char[] boilerplate(char[] message){ 
    5152        return( 
    5253            "[Exception] You have run into a condition not handled, or possibly incorrectly handled, by DDL.\n" ~ 
  • trunk/ddl/DDLReader.d

    r143 r158  
    3636private import mango.io.model.IBuffer; 
    3737private import mango.io.model.IConduit; 
     38 
     39private import mango.io.Stdout; 
    3840 
    3941public class DDLReader : Reader{ 
     
    7880            uint chunk = conduit.read(content[filled..$]); 
    7981            if (chunk is conduit.Eof) 
    80                 break; 
    81          
     82                break;       
    8283            filled += chunk; 
    8384            if (content.length - filled < 1024) 
     
    8586        } 
    8687        x ~= content [0..filled]; // add on additional data 
     88         
     89        Stdout.println("DDLReader.getAll: %d bytes read\n",x.length); 
    8790        return this; 
    8891    } 
     
    9295        return result != null; 
    9396    } 
     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    } 
    94123} 
  • trunk/ddl/DDLWriter.d

    r143 r158  
    4444        super(conduit); 
    4545    } 
    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    } 
    4874} 
  • trunk/ddl/LoaderRegistry.d

    r143 r158  
    7777} 
    7878 
    79  
    8079/** 
    8180    The LoaderRegistry fufills the role of controlling access to the loaders to be used for a 
     
    143142            if(loader.canLoadLibrary(buffer)){ 
    144143                lib = loader.load(this,buffer); 
    145                  
     144 
    146145                // check the version if needed 
    147146                if(attrStdVersion.length > 0){ 
     
    152151                        throw new LibraryVersionException(buffer.getPath.toString(),attrStdVersion,*libraryStdVersion); 
    153152                    } 
    154                 }        
     153                } 
     154                return lib; 
    155155            } 
    156156        } 
  • trunk/ddl/ddl/DDLBinary.d

    r143 r158  
    3131private import mango.io.model.IConduit; 
    3232 
     33private import mango.io.Stdout; 
     34 
    3335/** 
    3436    Provides support for loading and saving DDL files. 
     
    3638class DDLBinary{ 
    3739    protected static const char[] MagicBytes = "DDL!"; 
    38     protected static const uint DDLVersion = 0x00010002
     40    protected static const uint DDLVersion = 0x00010001
    3941    protected static const uint BufferSize = 4096; 
    4042     
     
    9698            reader.get(value); 
    9799            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; 
    102106    } 
    103107             
     
    139143        writer.put(binaryData); 
    140144         
    141         ISeekable seekableConduit = cast(ISeekable)(writer.getBuffer.getConduit); 
    142         uint binaryStart = seekableConduit.getPosition; 
     145        uint binaryStart = writer.getPosition(); 
    143146         
    144147        writer.put(binaryData); 
    145148         
    146         seekableConduit.seek(8); // offset for binary start 
     149        writer.seek(8); // offset for binary start 
    147150        writer.put(binaryStart); 
    148151         
    149         seekableConduit.seek(0,ISeekable.SeekAnchor.End); // be polite, and park at the end of the stream 
     152        writer.seek(0,ISeekable.SeekAnchor.End); // be polite, and park at the end of the stream 
    150153    } 
    151154} 
     
    155158header ::= magic version binaryOffset binaryType processorArch definedNamespaces importedModules attributes 
    156159magic ::= 'D' 'D' 'L' '!' 
    157 version ::= 0x00010002 
     160version ::= 0x00010001 
    158161 
    159162binaryOffset ::= uint 
  • trunk/ddl/insitu/InSituMapBinary.d

    r143 r158  
    3232private import mango.text.LineIterator; 
    3333 
     34private import mango.io.Stdout; 
    3435 
    3536/* Binary 'file' for DMD map files */ 
  • trunk/ddl/omf/OMFLibrary.d

    r143 r158  
    132132                 
    133133        // 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); 
    136135         
    137136        // read in object files, and add them to the modules listing 
     
    144143                 
    145144            // advance the remainder of a page 
    146             long delta = pageSize - (seekableConduit.getPosition % pageSize); 
     145            ulong position = reader.getPosition(); 
     146            ulong delta = pageSize - (position % pageSize); 
    147147            if(delta != pageSize){ 
    148                 seekableConduit.seek(seekableConduit.getPosition + delta); 
     148                reader.seek(position + delta); 
    149149            } 
    150150