Changeset 226:6da025bf255e

Show
Ignore:
Timestamp:
04/11/08 11:50:39 (5 months ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

some fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/dwthelper/ResourceBundle.d

    r219 r226  
    99import dwt.DWT; 
    1010import dwt.dwthelper.utils; 
     11import tango.io.File; 
    1112 
    1213class ResourceBundle { 
     
    6162                    esc = false; 
    6263                    switch( c ){ 
    63                     case 't': c = '\t'; break; 
    64                     case 'n': c = '\n'; break; 
     64                    case 't' : c = '\t'; break; 
     65                    case 'n' : c = '\n'; break; 
    6566                    case '\\': c = '\\'; break; 
    6667                    case '\"': c = '\"'; break; 
     68                    //case ':' : c = ':' ; break; 
    6769                    default: break; 
    6870                    } 
     
    121123    } 
    122124 
     125    public static ResourceBundle getBundle( ImportData data ){ 
     126        return new ResourceBundle( cast(char[]) data.data ); 
     127    } 
    123128    public static ResourceBundle getBundle( char[] name ){ 
    124         return new ResourceBundle( null ); 
     129        try{ 
     130            scope f = new File(name); 
     131            return new ResourceBundle( cast(char[]) f.read() ); 
     132        } 
     133        catch( IOException e){ 
     134            e.msg ~= " file:" ~ name; 
     135            throw e; 
     136        } 
    125137    } 
    126138    public static ResourceBundle getBundleFromData( char[] data ){ 
  • dwt/dwthelper/WeakHashMap.d

    r223 r226  
    11module dwt.dwthelper.WeakHashMap; 
     2 
     3 
     4private { 
     5    alias void delegate(Object) DisposeEvt; 
     6    extern (C) void  rt_attachDisposeEvent( Object obj, DisposeEvt evt ); 
     7    extern (C) void  rt_detachDisposeEvent( Object obj, DisposeEvt evt ); 
     8} 
    29 
    310 
     
    1219            ptr = cast(size_t)cast(void*)k; 
    1320        } 
     21        override hash_t toHash(){ 
     22            return cast(hash_t)ptr; 
     23        } 
     24        override int opEquals( Object o ){ 
     25            if( auto other = cast(Ref)o ){ 
     26                return ptr is other.ptr; 
     27            } 
     28            return false; 
     29        } 
     30    } 
     31 
     32    private Ref unhookKey; 
     33 
     34    private void unhook(Object o) { 
     35        unhookKey.ptr = cast(size_t)cast(void*)o; 
     36        if( auto p = unhookKey in data ){ 
     37            rt_detachDisposeEvent(o, &unhook); 
     38            data.remove( unhookKey ); 
     39        } 
    1440    } 
    1541 
    1642    Object[ Ref ] data; 
     43    ClassInfo gcLock; 
     44    this(){ 
     45        unhookKey = new Ref(null); 
     46        gcLock = ClassInfo.find( "gcx.GCLock" ); 
     47    } 
    1748 
    1849    public void add (Object key, Object element){ 
    1950        auto k = new Ref(key); 
     51        rt_attachDisposeEvent(key, &unhook); 
    2052        data[ k ] = element; 
    2153    } 
    2254    public void removeKey (Object key){ 
    2355        scope k = new Ref(key); 
    24         data.remove( k ); 
     56        if( auto p = k in data ){ 
     57            data.remove( k ); 
     58            rt_detachDisposeEvent(key, &unhook); 
     59        } 
    2560    } 
    2661    public Object get(Object key){ 
  • dwt/dwthelper/utils.d

    r225 r226  
    7373    public static Boolean TRUE; 
    7474    public static Boolean FALSE; 
     75 
     76    static this(){ 
     77        TRUE  = new Boolean(true); 
     78        FALSE = new Boolean(false); 
     79    } 
    7580    public this( bool v ){ 
    7681        super(v); 
     
    126131 
    127132    public this ( char[] s ){ 
    128             implMissing( __FILE__, __LINE__ ); 
    129             super(0); 
     133        super(parseInt(s)); 
    130134    } 
    131135 
     
    186190 
    187191    public static Integer valueOf( char[] s ){ 
    188         implMissing( __FILE__, __LINE__ ); 
    189         return null; 
     192        return valueOf( parseInt(s)); 
    190193    } 
    191194 
    192195    public static Integer valueOf( int i ){ 
    193         implMissing( __FILE__, __LINE__ ); 
    194         return null; 
     196        return new Integer(i); 
    195197    } 
    196198 
     
    845847        } 
    846848    } 
     849    return true; 
    847850} 
    848851