# HG changeset patch # User Frank Benoit # Date 1218114412 -7200 # Node ID 4ec36c3a04a35721e6f7ee1672321558ae3c64cc # Parent 3f53ebb05b5ba8d6e2ee497287841217fc64c008 sync with dwt-linux diff -r 3f53ebb05b5b -r 4ec36c3a04a3 dwt/dwthelper/System.d --- a/dwt/dwthelper/System.d Tue Aug 05 01:07:44 2008 +0200 +++ b/dwt/dwthelper/System.d Thu Aug 07 15:06:52 2008 +0200 @@ -147,6 +147,7 @@ public static String getProperty( String key ){ switch( key ){ case "os.name": return "linux"; + case "file.separator" : return "."; default: return null; } } diff -r 3f53ebb05b5b -r 4ec36c3a04a3 dwt/dwthelper/WeakHashMap.d --- a/dwt/dwthelper/WeakHashMap.d Tue Aug 05 01:07:44 2008 +0200 +++ b/dwt/dwthelper/WeakHashMap.d Thu Aug 07 15:06:52 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){ + public void put (Object key, Object element){ auto k = new Ref(key); + rt_attachDisposeEvent(key, &unhook); data[ k ] = element; } - public void removeKey (Object key){ + public void remove (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 3f53ebb05b5b -r 4ec36c3a04a3 dwt/dwthelper/utils.d --- a/dwt/dwthelper/utils.d Tue Aug 05 01:07:44 2008 +0200 +++ b/dwt/dwthelper/utils.d Thu Aug 07 15:06:52 2008 +0200 @@ -845,12 +845,6 @@ } } -interface Enumeration { - public bool hasMoreElements(); - public Object nextElement(); -} - - template arraycast(T) { T[] arraycast(U) (U[] u) { static if ( @@ -894,6 +888,35 @@ return res; } +String[] stringArrayFromObject( Object obj ){ + if( auto wrapper = cast(ArrayWrapperString2)obj ){ + return wrapper.array; + } + if( auto wrapper = cast(ArrayWrapperObject)obj ){ + String[] res = new String[ wrapper.array.length ]; + foreach( idx, o; wrapper.array ){ + if( auto swrapper = cast(ArrayWrapperString) o ){ + res[idx] = swrapper.array; + } + } + return res; + } + assert( obj is null ); // if not null, it was the wrong type + return null; +} + +T[] arrayFromObject(T)( Object obj ){ + if( auto wrapper = cast(ArrayWrapperObject)obj ){ + T[] res = new T[ wrapper.array.length ]; + foreach( idx, o; wrapper.array ){ + res[idx] = cast(T)o; + } + return res; + } + assert( obj is null ); // if not null, it was the wrong type + return null; +} + bool ArrayEquals(T)( T[] a, T[] b ){ if( a.length !is b.length ){ @@ -921,24 +944,6 @@ return true; } -class Arrays{ - public static bool equals(Object[] a, Object[] b){ - if( a.length !is b.length ){ - return false; - } - for( int i = 0; i < a.length; i++ ){ - if( a[i] is null && b[i] is null ){ - continue; - } - if( a[i] !is null && b[i] !is null && a[i] == b[i] ){ - continue; - } - return false; - } - return true; - } -} - int SeqIndexOf(T)( tango.util.collection.model.Seq.Seq!(T) s, T src ){ int idx; foreach( e; s ){