# HG changeset patch # User Frank Benoit # Date 1207929039 -7200 # Node ID 6da025bf255e6c20700c4edc71808daa5771a58e # Parent 5366f8db1eda7446031cb8420fc37487c3992ac2 some fixes diff -r 5366f8db1eda -r 6da025bf255e dwt/dwthelper/ResourceBundle.d --- a/dwt/dwthelper/ResourceBundle.d Fri Apr 11 01:26:04 2008 +0200 +++ b/dwt/dwthelper/ResourceBundle.d Fri Apr 11 17:50:39 2008 +0200 @@ -8,6 +8,7 @@ import dwt.DWT; import dwt.dwthelper.utils; +import tango.io.File; class ResourceBundle { @@ -60,10 +61,11 @@ if( esc ){ esc = false; switch( c ){ - case 't': c = '\t'; break; - case 'n': c = '\n'; break; + case 't' : c = '\t'; break; + case 'n' : c = '\n'; break; case '\\': c = '\\'; break; case '\"': c = '\"'; break; + //case ':' : c = ':' ; break; default: break; } } @@ -120,8 +122,18 @@ return map.keys; } + public static ResourceBundle getBundle( ImportData data ){ + return new ResourceBundle( cast(char[]) data.data ); + } public static ResourceBundle getBundle( char[] name ){ - return new ResourceBundle( null ); + try{ + scope f = new File(name); + return new ResourceBundle( cast(char[]) f.read() ); + } + catch( IOException e){ + e.msg ~= " file:" ~ name; + throw e; + } } public static ResourceBundle getBundleFromData( char[] data ){ return new ResourceBundle( data ); diff -r 5366f8db1eda -r 6da025bf255e dwt/dwthelper/WeakHashMap.d --- a/dwt/dwthelper/WeakHashMap.d Fri Apr 11 01:26:04 2008 +0200 +++ b/dwt/dwthelper/WeakHashMap.d Fri Apr 11 17:50:39 2008 +0200 @@ -1,6 +1,13 @@ module dwt.dwthelper.WeakHashMap; +private { + alias void delegate(Object) DisposeEvt; + extern (C) void rt_attachDisposeEvent( Object obj, DisposeEvt evt ); + extern (C) void rt_detachDisposeEvent( Object obj, DisposeEvt evt ); +} + + /+ Is not yet 'weak' +/ @@ -11,17 +18,45 @@ this(Object k){ ptr = cast(size_t)cast(void*)k; } + override hash_t toHash(){ + return cast(hash_t)ptr; + } + override int opEquals( Object o ){ + if( auto other = cast(Ref)o ){ + return ptr is other.ptr; + } + return false; + } + } + + private Ref unhookKey; + + private void unhook(Object o) { + unhookKey.ptr = cast(size_t)cast(void*)o; + if( auto p = unhookKey in data ){ + rt_detachDisposeEvent(o, &unhook); + data.remove( unhookKey ); + } } Object[ Ref ] data; + ClassInfo gcLock; + this(){ + unhookKey = new Ref(null); + gcLock = ClassInfo.find( "gcx.GCLock" ); + } public void add (Object key, Object element){ auto k = new Ref(key); + rt_attachDisposeEvent(key, &unhook); data[ k ] = element; } public void removeKey (Object key){ scope k = new Ref(key); - data.remove( k ); + if( auto p = k in data ){ + data.remove( k ); + rt_detachDisposeEvent(key, &unhook); + } } public Object get(Object key){ scope k = new Ref(key); diff -r 5366f8db1eda -r 6da025bf255e dwt/dwthelper/utils.d --- a/dwt/dwthelper/utils.d Fri Apr 11 01:26:04 2008 +0200 +++ b/dwt/dwthelper/utils.d Fri Apr 11 17:50:39 2008 +0200 @@ -72,6 +72,11 @@ class Boolean : ValueWrapperT!(bool) { public static Boolean TRUE; public static Boolean FALSE; + + static this(){ + TRUE = new Boolean(true); + FALSE = new Boolean(false); + } public this( bool v ){ super(v); } @@ -125,8 +130,7 @@ } public this ( char[] s ){ - implMissing( __FILE__, __LINE__ ); - super(0); + super(parseInt(s)); } public static char[] toString( int i, int radix ){ @@ -185,13 +189,11 @@ } public static Integer valueOf( char[] s ){ - implMissing( __FILE__, __LINE__ ); - return null; + return valueOf( parseInt(s)); } public static Integer valueOf( int i ){ - implMissing( __FILE__, __LINE__ ); - return null; + return new Integer(i); } public byte byteValue(){ @@ -844,6 +846,7 @@ } } } + return true; } class Arrays{