Changeset 319

Show
Ignore:
Timestamp:
04/25/07 03:54:23 (2 years ago)
Author:
keinfarbton
Message:

BinToD fixed for windows

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bintod/bintod.d

    r308 r319  
    2727import             tango.text.convert.Utf; 
    2828import             tango.text.convert.UnicodeBom; 
    29 import             tango.text.Util : containsPattern; 
     29import             tango.text.Util : replace, containsPattern; 
    3030import             tango.text.stream.LineIterator; 
    3131 
     
    119119            } ); 
    120120 
     121    conduit.close(); 
    121122    return(config); 
    122123} 
     
    128129    } 
    129130    Config      config  = parserConfig(args[1]); 
    130     auto        cfgIter = new LineIterator!(char) (new FileConduit(args[1], FileConduit.ReadWriteCreate)); 
     131    auto        config_src = new FileConduit(args[1], FileConduit.ReadExisting ); 
     132    auto        cfgIter = new LineIterator!(char) ( config_src ); 
    131133 
    132134    FileConduit file = new FileConduit(config.mTargetFile, FileConduit.ReadWriteCreate); 
     
    142144        mWriter.formatln(cfgIter.get); 
    143145    } 
     146    config_src.close(); 
    144147    mWriter.formatln("module {0};", config.mTargetModule); 
    145148    mWriter.formatln(""); 
     
    160163    foreach (ResourceData res; config.mResources) { 
    161164        mWriter.formatln("version( {0} ){{", res.mVersion); 
    162         mWriter.formatln("    ubyte[] {0} = [ cast(ubyte)", res.mVarName); 
    163         FileConduit dataFc = new FileConduit(res.mFile, FileConduit.ReadWriteCreate); 
     165 
     166        version( Windows ){ 
     167            char[] fn = replace( res.mFile, '/', '\\' ); 
     168        } 
     169        else version( linux ){ 
     170            char[] fn = replace( res.mFile, '\\', '/' ); 
     171        } 
     172        auto path = new FilePath( fn ); 
     173        if( path.exists() ){ 
     174            Stdout.formatln( "processing file {}", fn ); 
     175        } 
     176        else{ 
     177            Stdout.formatln( "BINTOD Error: file {} does not exist.", fn ); 
     178        } 
     179        FileConduit dataFc = new FileConduit( fn, FileConduit.ReadExisting ); 
    164180        ubyte[]     data   = new ubyte[] (dataFc.length); 
    165181        dataFc.read(data); 
     182        dataFc.close(); 
    166183        char[]      showLine; 
    167184        const       LINE_ITEMCOUNT = 16; 
    168185        uint        lastIdx; 
    169         foreach (uint idx, ubyte d; data) { 
    170             lastIdx = idx; 
    171             if ((idx % LINE_ITEMCOUNT) == 0) { 
    172                 mWriter("        "); 
    173             } 
    174             mWriter.format("0x{0:X2}, ", d); 
    175             if (isAlphaNumeric(d) || .containsPattern(" []{};:'\"~`!@#$%^&*()_+=-/?.>,<\\|", [cast(char)d])) { 
    176                 showLine ~= d; 
    177             } 
    178             else { 
    179                 switch (d) { 
    180                 case '\n': 
    181                     showLine ~= "\u00b6"; 
    182                     break; 
    183  
    184                 case '\t': 
    185                     showLine ~= "\u00bb"; 
    186                     break; 
    187  
    188                 default: 
    189                     showLine ~= '.'; 
    190                     break; 
    191                 } 
    192             } 
    193             if ((idx % LINE_ITEMCOUNT) == LINE_ITEMCOUNT - 1) { 
    194                 mWriter.format(" // [0x{:X6}] {}", idx - (LINE_ITEMCOUNT - 1), showLine); 
    195                 showLine = null; 
     186        if( data.length == 0 ){ 
     187            mWriter.formatln("    ubyte[] {0};", res.mVarName); 
     188        } 
     189        else{ 
     190            mWriter.formatln("    ubyte[] {0} = [ cast(ubyte)", res.mVarName); 
     191            foreach (uint idx, ubyte d; data) { 
     192                lastIdx = idx; 
     193                if ((idx % LINE_ITEMCOUNT) == 0) { 
     194                    mWriter("        "); 
     195                } 
     196                mWriter.format("0x{0:X2}, ", d); 
     197                if (isAlphaNumeric(d) || .containsPattern(" []{};:'\"~`!@#$%^&*()_+=-/?.>,<\\|", [cast(char)d])) { 
     198                    showLine ~= d; 
     199                } 
     200                else { 
     201                    switch (d) { 
     202                    case '\n': 
     203                        showLine ~= "\u00b6"; 
     204                        break; 
     205 
     206                    case '\t': 
     207                        showLine ~= "\u00bb"; 
     208                        break; 
     209 
     210                    default: 
     211                        showLine ~= '.'; 
     212                        break; 
     213                    } 
     214                } 
     215                if ((idx % LINE_ITEMCOUNT) == LINE_ITEMCOUNT - 1) { 
     216                    mWriter.format(" // [0x{:X6}] {}", idx - (LINE_ITEMCOUNT - 1), showLine); 
     217                    showLine = null; 
     218                    mWriter.newline(); 
     219                } 
     220            } 
     221            mWriter.format("];"); 
     222            bool        printLastShowLine = false; 
     223            bool        firstFill         = true; 
     224            while ((lastIdx % LINE_ITEMCOUNT) != LINE_ITEMCOUNT - 1) { 
     225                if (!firstFill) { 
     226                    mWriter(" "); 
     227                } 
     228                mWriter("     "); 
     229                firstFill = false; 
     230                lastIdx++; 
     231                printLastShowLine = true; 
     232            } 
     233            if (printLastShowLine) { 
     234                mWriter.format("// [0x{:X6}] {}", lastIdx - (LINE_ITEMCOUNT - 1), showLine); 
    196235                mWriter.newline(); 
    197236            } 
    198         } 
    199         mWriter.format("];"); 
    200         bool        printLastShowLine = false; 
    201         bool        firstFill         = true; 
    202         while ((lastIdx % LINE_ITEMCOUNT) != LINE_ITEMCOUNT - 1) { 
    203             if (!firstFill) { 
    204                 mWriter(" "); 
    205             } 
    206             mWriter("     "); 
    207             firstFill = false; 
    208             lastIdx++; 
    209             printLastShowLine = true; 
    210         } 
    211         if (printLastShowLine) { 
    212             mWriter.format("// [0x{:X6}] {}", lastIdx - (LINE_ITEMCOUNT - 1), showLine); 
    213             mWriter.newline(); 
    214237        } 
    215238        mWriter.formatln("}"c); 
  • trunk/rakefile

    r318 r319  
    116116    file resources => [resources_cfg, BINTOD_CMD] do 
    117117        runInPath SWT_EXAMPLES do 
    118             puts "running bintod is disable, due to a bug on windows. Using the svn version of the #{resources}" 
    119             #sh P("../#{BINTOD_CMD} resources_#{t}.xml") 
     118            sh P("../#{BINTOD_CMD} resources_#{t}.xml") 
    120119        end 
    121120    end 
  • trunk/swt-3.2.1-examples/resources_addressbook.d

    • Property svn:eol-style set to native
  • trunk/swt-3.2.1-examples/resources_clipboard.d

    • Property svn:eol-style set to native
  • trunk/swt-3.2.1-examples/resources_control.d

    • Property svn:eol-style set to native
  • trunk/swt-3.2.1-examples/resources_dnd.d

    • Property svn:eol-style set to native
  • trunk/swt-3.2.1-examples/resources_graphics.d

    • Property svn:eol-style set to native
  • trunk/swt-3.2.1-examples/resources_helloworld1.d

    • Property svn:eol-style set to native
  • trunk/swt-3.2.1-examples/resources_helloworld2.d

    • Property svn:eol-style set to native
  • trunk/swt-3.2.1-examples/resources_helloworld3.d

    • Property svn:eol-style set to native
  • trunk/swt-3.2.1-examples/resources_helloworld4.d

    • Property svn:eol-style set to native
  • trunk/swt-3.2.1-examples/resources_helloworld5.d

    • Property svn:eol-style set to native
  • trunk/swt-3.2.1-examples/resources_hoverhelp.d

    • Property svn:eol-style set to native
  • trunk/swt-3.2.1-examples/resources_imageanalyzer.d

    • Property svn:eol-style set to native
  • trunk/swt-3.2.1-examples/resources_javaviewer.d

    • Property svn:eol-style set to native
  • trunk/swt-3.2.1-examples/resources_layoutexample.d

    • Property svn:eol-style set to native
  • trunk/swt-3.2.1-examples/resources_paint.d

    • Property svn:eol-style set to native
  • trunk/swt-3.2.1-examples/resources_wizard.d

    • Property svn:eol-style set to native