Changeset 145

Show
Ignore:
Timestamp:
02/23/06 12:44:47 (3 years ago)
Author:
larsivi
Message:

Merging in pragmas refactorings.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/larsivi-elf/utils/ArgParser.d

    r133 r145  
    168168                    else { 
    169169                        argData = argData[prefix.length..$]; 
    170                     } 
     170                    }  
    171171                    foreach (PrefixCallback cb; bindings[prefix]) { 
    172172                        if (argData.length < cb.id.length) continue; 
  • branches/larsivi-elf/utils/bless.d

    r127 r145  
    2929 
    3030private import ddl.all; 
     31private import ddl.FileBuffer; 
    3132private import ddl.ddl.DDLLoader; 
    3233private import ddl.ddl.DDLBinary; 
    3334 
     35private import mango.io.File; 
     36private import mango.io.FilePath; 
     37 
    3438private import utils.bless_bn; 
    3539private import utils.ArgParser; 
    3640 
     41enum PathPart{ 
     42    Ext = 1, 
     43    Name = 2, 
     44    Path = 4, 
     45    Root = 8, 
     46    Suffix = 16 
     47} 
     48 
     49char[] filePathPart(FilePath path,PathPart parts){ 
     50    char[] result; 
     51     
     52    if(parts | PathPart.Root) result ~= path.getRoot; 
     53    if(parts | PathPart.Path) result ~= path.getPath; 
     54    if(parts | PathPart.Name) result ~= path.getName; 
     55    if(parts | PathPart.Suffix) result ~= path.getSuffix; 
     56    if(parts | PathPart.Ext) result ~= path.getExtension; 
     57     
     58    return result;   
     59} 
     60 
    3761 
    3862char[] helpText =  
    3963"Bless - DDL wrapper utility - V1.2 Build %d 
    40 Copyright (C) 2005 Eric Anderton 
     64Copyright (C) 2005,2006 Eric Anderton 
    4165Documentation: http://www.dsource.org/projects/ddl 
    4266 
     
    7195         
    7296    // get the filename 
    73     DDLFile file; 
    74     file.create(args[1]); 
    75          
    76     char[] originalOutputFile = file.getName ~ ".ddl"; 
     97    File file = new File(args[1]); 
     98         
     99    char[] originalOutputFile = filePathPart(file.getPath,PathPart.Root | PathPart.Path | PathPart.Name | PathPart.Suffix); 
    77100     
    78101    // pick through the options (if any) 
     
    157180     
    158181    // validate a few things 
     182    /* 
    159183    if(!file.exists){ 
    160184        Stdout.println("File '%s' does not exist.",file.filename); 
    161185        return 1; 
    162186    } 
     187    */ 
    163188     
    164189    // load it up! 
    165190    //NOTE: rather than just be satisfied with what loader likes this file 
    166191    // we load the entire file via its loader to ensure that it will work later. 
    167     file.load();     
    168     DynamicLibrary lib = registry.load(file); 
     192    DynamicLibrary lib = registry.load(file.getPath.toString()); 
    169193     
    170194    if(!lib){ 
    171         Stdout.println("Cannot load '%s'",file.filename); 
     195        Stdout.println("Cannot load '%s'",file.getPath); 
    172196        return 1; 
    173197    } 
     
    175199    // output 
    176200    if(verbose){ 
    177         Stdout.println("filename: '%s'",file.filename); 
     201        Stdout.println("filename: '%s'",file.getPath); 
    178202        Stdout.println("type: '%s'",lib.getType); 
    179203    }    
     
    181205    if(extract){ 
    182206        if(lib.getType != DDLLoader.typeName){ 
    183             Stdout.println("cannot extract from a non-ddl file ('%s').",file.filename); 
     207            Stdout.println("cannot extract from a non-ddl file ('%s').",file.getPath); 
    184208            return 1; 
    185209        } 
    186210    }    
    187211    else if(lib.getType == DDLLoader.typeName){ 
    188         Stdout.println("'%s' already appears to be a ddl file.",file.filename); 
     212        Stdout.println("'%s' already appears to be a ddl file.",file.getPath); 
    189213        return 1; 
    190214    } 
     
    192216    if(extract){ 
    193217        // coerce complete load of the ddl binary file 
    194         DDLBinary binary = new DDLBinary(file.buffer); 
     218        DDLBinary binary = new DDLBinary(); 
     219        binary.load(new FileBuffer(file.getPath)); 
    195220         
    196221        // save to output file 
     
    223248        // save the easy fields  
    224249        binary.binaryType = lib.getType; 
    225         binary.binaryData = file.buffer
     250        binary.binaryData = cast(ubyte[])file.read()
    226251        binary.attributes = attributes; 
    227252         
    228253        if(!("std.filename" in attributes)){ 
    229             attributes["std.filename"] = file.getName ~ "." ~ file.getExtension; 
     254            attributes["std.filename"] = file.getPath.getName ~ "." ~ file.getPath.getExtension; 
    230255        } 
    231256 
     
    257282                 
    258283        if(!noCreate){ 
    259             binary.save(outputFileName); 
     284            binary.save(new FileBuffer(outputFileName)); 
    260285            if(verbose) Stdout.println("Created '%s'",outputFileName); 
    261286        } 
  • branches/larsivi-elf/utils/bless_bn.d

    r117 r145  
    22// This file is automatically maintained by the BUILD utility, 
    33// Please refrain from manually editing it. 
    4 long auto_build_number = 199
     4long auto_build_number = 254
  • branches/larsivi-elf/utils/ddlinfo.d

    r127 r145  
    3030private import utils.ddlinfo_bn; 
    3131private import ddl.all; 
     32private import ddl.FileBuffer; 
    3233private import utils.ArgParser; 
    3334 
     
    6162         
    6263    // get the filename 
    63     DDLFile file; 
    64     file.load(args[1]); 
     64    FileBuffer file = new FileBuffer(args[1]); 
    6565                 
    6666    // pick through the options (if any) 
     
    9292                 
    9393    // validate a few things 
    94   if(!file.exists){ 
     94/*    if(!file.exists){ 
    9595        Stdout.println("file '%s' does not exist.",file.filename); 
    9696        return 1; 
    9797    } 
    98      
    99     //TODO: make sure the file is supported 
    100     file.load(); 
    101      
     98*/       
    10299    // (attempt to) load the binary file 
    103100    DynamicLibrary lib = regsitry.load(file); 
    104101     
    105102    if(!lib){ 
    106         Stdout.println("file '%s' is not supported.",file.filename); 
     103        Stdout.println("file '%s' is not supported.",file.getPath); 
    107104        return 1; 
    108105    } 
    109106 
    110     Stdout.println("filename: '%s'",file.filename); 
     107    Stdout.println("filename: '%s'",file.getPath); 
    111108    Stdout.println("type: '%s'",lib.getType); 
    112109     
  • branches/larsivi-elf/utils/ddlinfo_bn.d

    r117 r145  
    22// This file is automatically maintained by the BUILD utility, 
    33// Please refrain from manually editing it. 
    4 long auto_build_number = 199
     4long auto_build_number = 254
  • branches/larsivi-elf/utils/insitu.d

    r127 r145  
    3030 
    3131private import ddl.all; 
    32 private import ddl.Utils
     32private import ddl.FileBuffer
    3333private import ddl.insitu.all; 
    3434 
     
    5656  by DMD. 
    5757"; 
    58 // -d   Create a .d file with a SituLibrary class instead 
    59 //With the -d switch, <filename>_InSitu.d will be used instead. 
    6058 
    6159int main(char[][] args){ 
     
    7371             
    7472    // get the filename 
    75     DDLFile inputFile; 
    76     inputFile.create(args[1]); 
     73    FileBuffer inputFile = new FileBuffer(args[1]); 
    7774     
    7875    // determine the output file 
    79     char[] outputFilename = inputFile.getName; 
    80     bit dOutput = false; 
     76    char[] outputFilename = inputFile.getPath.toString; 
    8177    bit filenameOverride = false; 
    8278     
     
    10197    }); 
    10298             
    103 //  parser.bind("d",delegate void(){ 
    104 //      dOutput = true; 
    105 //  }); 
    10699     
    107100    parser.parse(args[2..$]); 
    108101     
    109102    // load the .map file and get what we need 
    110     inputFile.load(); 
    111103    InSituMapBinary inputBinary = new InSituMapBinary(); 
    112104    inputBinary.load(inputFile); 
    113105     
    114     debugLog("%d bytes loaded",inputFile.buffer.length); 
    115      
    116     debugLog("%d exports total",inputBinary.getAllSymbols().values.length); 
     106    //debugLog("%d bytes loaded",inputFile.buffer.length); 
     107    //debugLog("%d exports total",inputBinary.getAllSymbols().values.length); 
    117108 
    118     DDLFile outputFile; 
    119     outputFile.create(outputFilename);   
     109    FileBuffer outputFile = new FileBuffer(outputFilename); 
    120110         
    121 //  if(!dOutput){ 
    122         if(!filenameOverride) outputFile.filename ~= ".situ"; 
    123         // commit the data to the lib-style binary 
    124         InSituLibBinary outputBinary = new InSituLibBinary(); 
    125         outputBinary.setAllSymbols(inputBinary.getAllSymbols()); 
    126         outputBinary.save(outputFile,compressionLevel); 
    127 /*  } 
    128     else{ 
    129         // create .d sourcecode to use instead 
    130         WriteCursor cursor = new WriteCursor(); 
    131                  
    132         cursor.writeText( 
    133 "//Auto-generated by the DDL In-Situ tool 
    134 import ddl.insitu.InSituStubLibrary; 
    135 import ddl.ExportSymbol; 
     111    if(!filenameOverride) outputFile.filename ~= ".situ"; 
     112    // commit the data to the lib-style binary 
     113    InSituLibBinary outputBinary = new InSituLibBinary(); 
     114    outputBinary.setAllSymbols(inputBinary.getAllSymbols()); 
     115    outputBinary.save(outputFile,compressionLevel); 
    136116 
    137 const ExportSymbol[char[]] symbols=[" 
    138         ); 
    139          
    140         // create buffers 
    141         foreach(ExportSymbol exp; inputBinary.getAllSymbols()){ 
    142             cursor.writeText("\n\t\t\"" ~ exp.name ~ "\" : {cast(void*)" ~ uintToString(cast(uint)exp.address) ~ ",\"" ~ exp.name ~ "\"},"); 
    143         } 
    144         cursor.writeText( 
    145 " 
    146 ]; 
    147  
    148 class InSituLibrary : InSituStubLibrary{ 
    149     public this(){ 
    150         super(symbols); 
    151     } 
    152 }" 
    153         ); 
    154         if(!filenameOverride) outputFile.filename ~= "_InSitu.d"; 
    155         outputFile.save(cursor.getData()); 
    156     } */ 
    157117    return 0; 
    158118} 
  • branches/larsivi-elf/utils/insitu_bn.d

    r117 r145  
    22// This file is automatically maintained by the BUILD utility, 
    33// Please refrain from manually editing it. 
    4 long auto_build_number = 199
     4long auto_build_number = 254