# HG changeset patch # User Frank Benoit # Date 1207819189 -7200 # Node ID 184ab53b7785617a83c56d6187acc02f9c498c27 # Parent 1e7701c27c03e0e56e3b8e1ae4beb67afd01048c Changes and fixes for jface diff -r 1e7701c27c03 -r 184ab53b7785 dwt/custom/BusyIndicator.d --- a/dwt/custom/BusyIndicator.d Mon Apr 07 13:08:57 2008 +0200 +++ b/dwt/custom/BusyIndicator.d Thu Apr 10 11:19:49 2008 +0200 @@ -18,7 +18,7 @@ import dwt.graphics.Cursor; import dwt.widgets.Display; import dwt.widgets.Shell; -import dwt.dwthelper.Integer; +import dwt.dwthelper.utils; import dwt.dwthelper.Runnable; /** diff -r 1e7701c27c03 -r 184ab53b7785 dwt/custom/CTabFolder.d --- a/dwt/custom/CTabFolder.d Mon Apr 07 13:08:57 2008 +0200 +++ b/dwt/custom/CTabFolder.d Thu Apr 10 11:19:49 2008 +0200 @@ -49,7 +49,6 @@ import dwt.custom.CTabFolderEvent; import dwt.dwthelper.utils; -import dwt.dwthelper.Integer; import tango.util.Convert; static import tango.text.convert.Utf; diff -r 1e7701c27c03 -r 184ab53b7785 dwt/custom/StyledText.d --- a/dwt/custom/StyledText.d Mon Apr 07 13:08:57 2008 +0200 +++ b/dwt/custom/StyledText.d Thu Apr 10 11:19:49 2008 +0200 @@ -465,7 +465,7 @@ printerRenderer = null; } } - void init() { + void init_() { Rectangle trim = printer.computeTrim(0, 0, 0, 0); Point dpi = printer.getDPI(); @@ -694,7 +694,7 @@ jobName = "Printing"; } if (printer.startJob(jobName)) { - init(); + init_(); print(); dispose(); printer.endJob(); diff -r 1e7701c27c03 -r 184ab53b7785 dwt/dnd/HTMLTransfer.d --- a/dwt/dnd/HTMLTransfer.d Mon Apr 07 13:08:57 2008 +0200 +++ b/dwt/dnd/HTMLTransfer.d Thu Apr 10 11:19:49 2008 +0200 @@ -20,7 +20,6 @@ import dwt.dnd.TransferData; import dwt.dnd.DND; -import dwt.dwthelper.Integer; import dwt.dwthelper.utils; static import tango.text.Text; alias tango.text.Text.Text!(char) StringBuffer; diff -r 1e7701c27c03 -r 184ab53b7785 dwt/dnd/RTFTransfer.d --- a/dwt/dnd/RTFTransfer.d Mon Apr 07 13:08:57 2008 +0200 +++ b/dwt/dnd/RTFTransfer.d Thu Apr 10 11:19:49 2008 +0200 @@ -20,7 +20,6 @@ import dwt.dnd.TransferData; import dwt.dnd.DND; -import dwt.dwthelper.Integer; import dwt.dwthelper.utils; static import tango.text.Text; alias tango.text.Text.Text!(char) StringBuffer; diff -r 1e7701c27c03 -r 184ab53b7785 dwt/dnd/TextTransfer.d --- a/dwt/dnd/TextTransfer.d Mon Apr 07 13:08:57 2008 +0200 +++ b/dwt/dnd/TextTransfer.d Thu Apr 10 11:19:49 2008 +0200 @@ -20,7 +20,6 @@ import dwt.dnd.TransferData; import dwt.dnd.DND; -import dwt.dwthelper.Integer; import dwt.dwthelper.utils; static import tango.text.Text; alias tango.text.Text.Text!(char) StringBuffer; diff -r 1e7701c27c03 -r 184ab53b7785 dwt/dnd/URLTransfer.d --- a/dwt/dnd/URLTransfer.d Mon Apr 07 13:08:57 2008 +0200 +++ b/dwt/dnd/URLTransfer.d Thu Apr 10 11:19:49 2008 +0200 @@ -22,7 +22,6 @@ import dwt.dnd.TransferData; import dwt.dnd.DND; -import dwt.dwthelper.Integer; import dwt.dwthelper.utils; static import tango.text.Text; alias tango.text.Text.Text!(char) StringBuffer; diff -r 1e7701c27c03 -r 184ab53b7785 dwt/dwthelper/BufferedInputStream.d --- a/dwt/dwthelper/BufferedInputStream.d Mon Apr 07 13:08:57 2008 +0200 +++ b/dwt/dwthelper/BufferedInputStream.d Thu Apr 10 11:19:49 2008 +0200 @@ -50,7 +50,7 @@ assert( pos == count ); pos = 0; count = 0; - int count = getAndCheckIstr().read( buf ); + count = getAndCheckIstr().read( buf ); if( count < 0 ){ count = 0; istr = null; diff -r 1e7701c27c03 -r 184ab53b7785 dwt/dwthelper/Float.d --- a/dwt/dwthelper/Float.d Mon Apr 07 13:08:57 2008 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,149 +0,0 @@ -module dwt.dwthelper.Float; - -import dwt.dwthelper.utils; -static import tango.text.convert.Float; -import tango.core.Exception; - -public final class Float { - - public static float POSITIVE_INFINITY = (1.0f / 0.0f); - public static float NEGATIVE_INFINITY = ((-1.0f) / 0.0f); - public static float NaN = (0.0f / 0.0f); - public static float MAX_VALUE = 3.4028235e+38f; - public static float MIN_VALUE = 1.4e-45f; - public static int SIZE = 32; - public this ( float value ){ - implMissing( __FILE__, __LINE__ ); - } - - public this ( double value ){ - implMissing( __FILE__, __LINE__ ); - } - - public this ( char[] s ){ - implMissing( __FILE__, __LINE__ ); - } - - public static char[] toString( float f ){ - implMissing( __FILE__, __LINE__ ); - return null; - } - - public static char[] toHexString( float f ){ - implMissing( __FILE__, __LINE__ ); - return null; - } - - public static Float valueOf( char[] s ){ - implMissing( __FILE__, __LINE__ ); - return null; - } - - public static Float valueOf( float f ){ - implMissing( __FILE__, __LINE__ ); - return null; - } - - public static float parseFloat( char[] s ){ - try{ - return tango.text.convert.Float.toFloat( s ); - } - catch( IllegalArgumentException e ){ - throw new NumberFormatException( e ); - } - } - - public static bool isNaN( float v ){ - implMissing( __FILE__, __LINE__ ); - return false; - } - - public static bool isInfinite( float v ){ - implMissing( __FILE__, __LINE__ ); - return false; - } - - public bool isNaN(){ - implMissing( __FILE__, __LINE__ ); - return false; - } - - public bool isInfinite(){ - implMissing( __FILE__, __LINE__ ); - return false; - } - - public char[] toString(){ - implMissing( __FILE__, __LINE__ ); - return null; - } - - public byte byteValue(){ - implMissing( __FILE__, __LINE__ ); - return 0; - } - - public short shortValue(){ - implMissing( __FILE__, __LINE__ ); - return 0; - } - - public int intValue(){ - implMissing( __FILE__, __LINE__ ); - return 0; - } - - public long longValue(){ - implMissing( __FILE__, __LINE__ ); - return 0L; - } - - public float floatValue(){ - implMissing( __FILE__, __LINE__ ); - return 0.0f; - } - - public double doubleValue(){ - implMissing( __FILE__, __LINE__ ); - return 0.0; - } - - public hash_t toHash(){ - implMissing( __FILE__, __LINE__ ); - return 0; - } - - public int opEquals( Object obj ){ - implMissing( __FILE__, __LINE__ ); - return false; - } - - public static int floatToIntBits( float value ){ - implMissing( __FILE__, __LINE__ ); - return 0; - } - - public static int floatToRawIntBits( float value ){ - implMissing( __FILE__, __LINE__ ); - return 0; - } - - public static float intBitsToFloat( int bits ){ - implMissing( __FILE__, __LINE__ ); - return 0.0f; - } - - public int compareTo( Object anotherByte ){ - implMissing( __FILE__, __LINE__ ); - return 0; - } - - public static int compare( float f1, float f2 ){ - implMissing( __FILE__, __LINE__ ); - return 0; - } - - -} - - diff -r 1e7701c27c03 -r 184ab53b7785 dwt/dwthelper/Integer.d --- a/dwt/dwthelper/Integer.d Mon Apr 07 13:08:57 2008 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,143 +0,0 @@ -/** - * Authors: Frank Benoit - */ - -module dwt.dwthelper.Integer; - -import dwt.dwthelper.utils; - -static import tango.text.convert.Integer; -private import tango.core.Exception; - -public final class Byte { - public static byte parseByte( char[] s ){ - try{ - int res = tango.text.convert.Integer.parse( s ); - if( res < byte.min || res > byte.max ){ - throw new NumberFormatException( "out of range" ); - } - return res; - } - catch( IllegalArgumentException e ){ - throw new NumberFormatException( e ); - } - } -} -public final class Integer { - - public static int MIN_VALUE = 0x80000000; - public static int MAX_VALUE = 0x7fffffff; - public static int SIZE = 32; - - public int value; - public this ( int value ){ - this.value = value; - } - - public this ( char[] s ){ - } - - public static char[] toString( int i, int radix ){ - switch( radix ){ - case 2: - return toBinaryString(i); - case 8: - return toOctalString(i); - case 10: - return toString(i); - case 16: - return toHexString(i); - default: - implMissing( __FILE__, __LINE__ ); - return null; - } - } - - public static char[] toHexString( int i ){ - return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Hex ); - } - - public static char[] toOctalString( int i ){ - return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Octal ); - } - - public static char[] toBinaryString( int i ){ - return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Binary ); - } - - public static char[] toString( int i ){ - return tango.text.convert.Integer.toString(i); - } - - public static int parseInt( char[] s, int radix ){ - try{ - return tango.text.convert.Integer.parse( s, cast(uint)radix ); - } - catch( IllegalArgumentException e ){ - throw new NumberFormatException( e ); - } - } - - public static int parseInt( char[] s ){ - try{ - return tango.text.convert.Integer.parse( s ); - } - catch( IllegalArgumentException e ){ - throw new NumberFormatException( e ); - } - } - - public static Integer valueOf( char[] s, int radix ){ - implMissing( __FILE__, __LINE__ ); - return null; - } - - public static Integer valueOf( char[] s ){ - implMissing( __FILE__, __LINE__ ); - return null; - } - - public static Integer valueOf( int i ){ - implMissing( __FILE__, __LINE__ ); - return null; - } - - public byte byteValue(){ - return cast(byte)value; - } - - public short shortValue(){ - return cast(short)value; - } - - public int intValue(){ - return value; - } - - public long longValue(){ - return cast(long)value; - } - - public float floatValue(){ - return cast(float)value; - } - - public double doubleValue(){ - return cast(double)value; - } - - public override hash_t toHash(){ - return intValue(); - } - - public override int opEquals( Object obj ){ - implMissing( __FILE__, __LINE__ ); - return false; - } - - public override char[] toString(){ - return tango.text.convert.Integer.toString( value ); - } -} - - diff -r 1e7701c27c03 -r 184ab53b7785 dwt/dwthelper/ResourceBundle.d --- a/dwt/dwthelper/ResourceBundle.d Mon Apr 07 13:08:57 2008 +0200 +++ b/dwt/dwthelper/ResourceBundle.d Thu Apr 10 11:19:49 2008 +0200 @@ -6,6 +6,8 @@ import tango.text.Util; import tango.io.Stdout; +import dwt.DWT; +import dwt.dwthelper.utils; class ResourceBundle { @@ -34,7 +36,7 @@ while( dataIndex < data.length ){ //tango.io.Stdout.Stdout.formatln( "properties put {} startline", __LINE__ ); readLine(); - line = line.trim(); + line = dwt.dwthelper.utils.trim(line); if( line.length is 0 ){ //tango.io.Stdout.Stdout.formatln( "properties put {} was 0 length", __LINE__ ); continue; @@ -61,6 +63,7 @@ case 't': c = '\t'; break; case 'n': c = '\n'; break; case '\\': c = '\\'; break; + case '\"': c = '\"'; break; default: break; } } @@ -89,11 +92,12 @@ } } if( iskeypart ){ - //tango.io.Stdout.Stdout.formatln( "dwt.dwthelper.ResourceBundle ctor cannot find '='." ); + // Cannot find '=' in record + DWT.error( __FILE__, __LINE__, DWT.ERROR_INVALID_ARGUMENT ); continue; } - key = key.trim(); - value = value.trim(); + key = dwt.dwthelper.utils.trim(key); + value = dwt.dwthelper.utils.trim(value); //tango.io.Stdout.Stdout.formatln( "properties put {}=>{}", key, value ); map[ key.dup ] = value.dup; @@ -109,7 +113,11 @@ if( auto v = key in map ){ return (*v).dup; } - return key; + throw new MissingResourceException( "key not found", this.classinfo.name, key ); + } + + public char[][] getKeys(){ + return map.keys; } public static ResourceBundle getBundle( char[] name ){ diff -r 1e7701c27c03 -r 184ab53b7785 dwt/dwthelper/System.d --- a/dwt/dwthelper/System.d Mon Apr 07 13:08:57 2008 +0200 +++ b/dwt/dwthelper/System.d Thu Apr 10 11:19:49 2008 +0200 @@ -128,6 +128,18 @@ static void exit( int code ){ .exit(code); } + public static int identityHashCode(Object x){ + if( x is null ){ + return 0; + } + return (*cast(Object *)&x).toHash(); + } + public static char[] getProperty( char[] key ){ + switch( key ){ + case "os.name": return "windows"; + default: return null; + } + } } diff -r 1e7701c27c03 -r 184ab53b7785 dwt/dwthelper/utils.d --- a/dwt/dwthelper/utils.d Mon Apr 07 13:08:57 2008 +0200 +++ b/dwt/dwthelper/utils.d Thu Apr 10 11:19:49 2008 +0200 @@ -9,14 +9,31 @@ public import tango.core.Exception : IllegalArgumentException, IOException; import tango.io.Stdout; +import tango.io.Print; import tango.stdc.stringz; static import tango.text.Util; +static import tango.text.Text; import tango.text.Unicode; import tango.text.convert.Utf; import tango.core.Exception; import tango.stdc.stdlib : exit; import tango.util.log.Trace; +import tango.text.UnicodeData; +static import tango.util.collection.model.Seq; +// static import tango.util.collection.ArraySeq; +// static import tango.util.collection.LinkSeq; +// static import tango.util.collection.model.Map; +// static import tango.util.collection.HashMap; +// +// alias tango.util.collection.model.Seq.Seq!(Object) List; +// alias tango.util.collection.ArraySeq.ArraySeq!(Object) ArrayList; +// alias tango.util.collection.LinkSeq.LinkSeq!(Object) LinkList; +// alias tango.util.collection.model.Map.Map!(Object,Object) Map; +// alias tango.util.collection.HashMap.HashMap!(Object,Object) HashMap; + +alias char[] String; +alias tango.text.Text.Text!(char) StringBuffer; void implMissing( char[] file, uint line ){ Stderr.formatln( "implementation missing in file {} line {}", file, line ); @@ -41,17 +58,264 @@ public this( T data ){ value = data; } + public int opEquals( T other ){ + return value == other; + } + public int opEquals( Object other ){ + if( auto o = cast(ValueWrapperT!(T))other ){ + return value == o.value; + } + return false; + } +} + +class Boolean : ValueWrapperT!(bool) { + public static Boolean TRUE; + public static Boolean FALSE; + public this( bool v ){ + super(v); + } + + alias ValueWrapperT!(bool).opEquals opEquals; + public int opEquals( int other ){ + return value == ( other !is 0 ); + } + public int opEquals( Object other ){ + if( auto o = cast(Boolean)other ){ + return value == o.value; + } + return false; + } + public bool booleanValue(){ + return value; + } } -alias ValueWrapperT!(bool) ValueWrapperBool; -alias ValueWrapperT!(int) ValueWrapperInt; -alias ValueWrapperT!(long) ValueWrapperLong; +alias Boolean ValueWrapperBool; + + +class Byte : ValueWrapperT!(byte) { + public static byte parseByte( char[] s ){ + try{ + int res = tango.text.convert.Integer.parse( s ); + if( res < byte.min || res > byte.max ){ + throw new NumberFormatException( "out of range" ); + } + return res; + } + catch( IllegalArgumentException e ){ + throw new NumberFormatException( e ); + } + } + this( byte value ){ + super( value ); + } +} +alias Byte ValueWrapperByte; + + +class Integer : ValueWrapperT!(int) { + + public static int MIN_VALUE = 0x80000000; + public static int MAX_VALUE = 0x7fffffff; + public static int SIZE = 32; + + public this ( int value ){ + super( value ); + } + + public this ( char[] s ){ + implMissing( __FILE__, __LINE__ ); + super(0); + } + + public static char[] toString( int i, int radix ){ + switch( radix ){ + case 2: + return toBinaryString(i); + case 8: + return toOctalString(i); + case 10: + return toString(i); + case 16: + return toHexString(i); + default: + implMissing( __FILE__, __LINE__ ); + return null; + } + } + + public static char[] toHexString( int i ){ + return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Hex ); + } + + public static char[] toOctalString( int i ){ + return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Octal ); + } + + public static char[] toBinaryString( int i ){ + return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Binary ); + } + + public static char[] toString( int i ){ + return tango.text.convert.Integer.toString(i); + } + + public static int parseInt( char[] s, int radix ){ + try{ + return tango.text.convert.Integer.parse( s, cast(uint)radix ); + } + catch( IllegalArgumentException e ){ + throw new NumberFormatException( e ); + } + } + + public static int parseInt( char[] s ){ + try{ + return tango.text.convert.Integer.parse( s ); + } + catch( IllegalArgumentException e ){ + throw new NumberFormatException( e ); + } + } + + public static Integer valueOf( char[] s, int radix ){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public static Integer valueOf( char[] s ){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public static Integer valueOf( int i ){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + public byte byteValue(){ + return cast(byte)value; + } + + public short shortValue(){ + return cast(short)value; + } + + public int intValue(){ + return value; + } + + public long longValue(){ + return cast(long)value; + } + + public float floatValue(){ + return cast(float)value; + } + + public double doubleValue(){ + return cast(double)value; + } + + public override hash_t toHash(){ + return intValue(); + } + + public override char[] toString(){ + return tango.text.convert.Integer.toString( value ); + } +} +alias Integer ValueWrapperInt; + +class Double : ValueWrapperT!(double) { + this( double value ){ + super(value); + } + this( char[] str ){ + implMissing( __FILE__, __LINE__ ); + super(0.0); + } + public double doubleValue(){ + return value; + } + public static char[] toString( double value ){ + implMissing( __FILE__, __LINE__ ); + return null; + } +} + +class Float : ValueWrapperT!(float) { + + public static float POSITIVE_INFINITY = (1.0f / 0.0f); + public static float NEGATIVE_INFINITY = ((-1.0f) / 0.0f); + public static float NaN = (0.0f / 0.0f); + public static float MAX_VALUE = 3.4028235e+38f; + public static float MIN_VALUE = 1.4e-45f; + public static int SIZE = 32; + + this( float value ){ + super(value); + } + this( char[] str ){ + implMissing( __FILE__, __LINE__ ); + super(0.0); + } + public float floatValue(){ + return value; + } + public static char[] toString( float value ){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public static float parseFloat( char[] s ){ + try{ + return tango.text.convert.Float.toFloat( s ); + } + catch( IllegalArgumentException e ){ + throw new NumberFormatException( e ); + } + } + +} +class Long : ValueWrapperT!(long) { + this( long value ){ + super(value); + } + this( char[] str ){ + implMissing( __FILE__, __LINE__ ); + super(0); + } + public long longValue(){ + return value; + } + public static long parseLong(char[] s){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public static char[] toString( double value ){ + implMissing( __FILE__, __LINE__ ); + return null; + } +} +alias Long ValueWrapperLong; + + +// alias ValueWrapperT!(int) ValueWrapperInt; + alias ArrayWrapperT!(byte) ArrayWrapperByte; alias ArrayWrapperT!(int) ArrayWrapperInt; alias ArrayWrapperT!(Object) ArrayWrapperObject; alias ArrayWrapperT!(char) ArrayWrapperString; alias ArrayWrapperT!(char[]) ArrayWrapperString2; +Object[] StringArrayToObjectArray( String[] strs ){ + Object[] res = new Object[strs.length]; + foreach( idx, str; strs ){ + res[idx] = new ArrayWrapperString(str); + } + return res; +} int codepointIndexToIndex( char[] str, int cpIndex ){ int cps = cpIndex; int res = 0; @@ -203,6 +467,9 @@ return offset; } +bool CharacterIsDefined( dchar ch ){ + return (ch in tango.text.UnicodeData.unicodeData) !is null; +} dchar CharacterFirstToLower( char[] str ){ int consumed; return CharacterFirstToLower( str, consumed ); @@ -228,6 +495,12 @@ bool CharacterIsDigit( dchar c ){ return tango.text.Unicode.isDigit( c ); } +bool CharacterIsLetter( dchar c ){ + return tango.text.Unicode.isLetter( c ); +} +public char[] toUpperCase( char[] str ){ + return tango.text.Unicode.toUpper( str ); +} public int indexOf( char[] str, char searched ){ int res = tango.text.Util.locate( str, searched ); @@ -259,6 +532,14 @@ if( res is str.length ) res = -1; return res; } +public int lastIndexOf(char[] str, char[] ch ){ + return lastIndexOf( str, ch, str.length ); +} +public int lastIndexOf(char[] str, char[] ch, int start ){ + int res = tango.text.Util.locatePatternPrior( str, ch, start ); + if( res is str.length ) res = -1; + return res; +} public char[] replace( char[] str, char from, char to ){ return tango.text.Util.replace( str.dup, from, to ); @@ -313,6 +594,7 @@ } return src[ 0 .. pattern.length ] == pattern; } + public char[] toLowerCase( char[] src ){ return tango.text.Unicode.toLower( src ); } @@ -324,6 +606,9 @@ public char[] trim( char[] str ){ return tango.text.Util.trim( str ).dup; } +public char[] intern( char[] str ){ + return str; +} public char* toStringzValidPtr( char[] src ){ if( src ){ @@ -346,6 +631,28 @@ ); } +class RuntimeException : Exception { + this( char[] e = null){ + super(e); + } + this( Exception e ){ + super(e.toString); + } +} +class IndexOutOfBoundsException : Exception { + this( char[] e = null){ + super(e); + } +} + +class UnsupportedOperationException : RuntimeException { + this( char[] e = null){ + super(e); + } + this( Exception e ){ + super(e.toString); + } +} class NumberFormatException : IllegalArgumentException { this( char[] e ){ super(e); @@ -354,6 +661,86 @@ super(e.toString); } } +class NullPointerException : Exception { + this( char[] e = null ){ + super(e); + } + this( Exception e ){ + super(e.toString); + } +} +class IllegalStateException : Exception { + this( char[] e = null ){ + super(e); + } + this( Exception e ){ + super(e.toString); + } +} +class InterruptedException : Exception { + this( char[] e = null ){ + super(e); + } + this( Exception e ){ + super(e.toString); + } +} +class InvocationTargetException : Exception { + Exception cause; + this( Exception e = null, char[] msg = null ){ + super(msg); + cause = e; + } + + alias getCause getTargetException; + Exception getCause(){ + return cause; + } +} +class MissingResourceException : Exception { + char[] classname; + char[] key; + this( char[] msg, char[] classname, char[] key ){ + super(msg); + this.classname = classname; + this.key = key; + } +} +class ParseException : Exception { + this( char[] e = null ){ + super(e); + } +} + +interface Cloneable{ +} + +interface Comparable { + int compareTo(Object o); +} +interface Comparator { + int compare(Object o1, Object o2); +} +interface EventListener{ +} + +class EventObject { + protected Object source; + + public this(Object source) { + if (source is null) + throw new IllegalArgumentException( "null arg" ); + this.source = source; + } + + public Object getSource() { + return source; + } + + public override char[] toString() { + return this.classinfo.name ~ "[source=" ~ source.toString() ~ "]"; + } +} private struct GCStats { size_t poolsize; // total size of pool @@ -370,5 +757,184 @@ } +void ExceptionPrintStackTrace( Exception e ){ + ExceptionPrintStackTrace( e, Stderr ); +} +void ExceptionPrintStackTrace( Exception e, Print!(char) print ){ + print.formatln( "Exception in {}({}): {}", e.file, e.line, e.msg ); +} + +interface Reader{ +} +interface Writer{ +} + + +class Collator : Comparator { + public static Collator getInstance(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + private this(){ + } + int compare(Object o1, Object o2){ + implMissing( __FILE__, __LINE__ ); + return 0; + } +} + +interface Enumeration { + public bool hasMoreElements(); + public Object nextElement(); +} + + +template arraycast(T) { + T[] arraycast(U) (U[] u) { + static if ( + (is (T == interface ) && is (U == interface )) || + (is (T == class ) && is (U == class ))) { + return(cast(T[])u); + } + else { + int l = u.length; + T[] res; + res.length = l; + for (int i = 0; i < l; i++) { + res[i] = cast(T)u[i]; + } + return(res); + } + } +} + +char[] stringcast( Object o ){ + if( auto str = cast(ArrayWrapperString) o ){ + return str.array; + } + return null; +} +char[][] stringcast( Object[] objs ){ + char[][] res = new char[][](objs.length); + foreach( idx, obj; objs ){ + res[idx] = stringcast(obj); + } + return res; +} +ArrayWrapperString stringcast( char[] str ){ + return new ArrayWrapperString( str ); +} +ArrayWrapperString[] stringcast( char[][] strs ){ + ArrayWrapperString[] res = new ArrayWrapperString[ strs.length ]; + foreach( idx, str; strs ){ + res[idx] = stringcast(str); + } + return res; +} +bool ArrayEquals(T)( T[] a, T[] b ){ + if( a.length !is b.length ){ + return false; + } + for( int i = 0; i < a.length; i++ ){ + static if( is( T==class) || is(T==interface)){ + if( a[i] !is null && b[i] !is null ){ + if( a[i] != b[i] ){ + return false; + } + } + else if( a[i] is null && b[i] is null ){ + } + else{ + return false; + } + } + else{ + if( a[i] != b[i] ){ + return false; + } + } + } +} + +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 ){ + if( e == src ){ + return idx; + } + idx++; + } + return -1; +} +int arrayIndexOf(T)( T[] arr, T v ){ + int res = -1; + int idx = 0; + foreach( p; arr ){ + if( p == v){ + res = idx; + break; + } + idx++; + } + return res; +} + +int seqIndexOf( tango.util.collection.model.Seq.Seq!(Object) seq, Object v ){ + int res = -1; + int idx = 0; + foreach( p; seq ){ + if( p == v){ + res = idx; + break; + } + idx++; + } + return res; +} + +void PrintStackTrace(){ + try{ + throw new Exception( null ); + } + catch( Exception e ){ + foreach( msg; e.info ){ + Trace.formatln( "trc: {}", msg ); + } + } +} + +struct ImportData{ + void[] data; + char[] name; + + public static ImportData opCall( void[] data, char[] name ){ + ImportData res; + res.data = data; + res.name = name; + return res; + } +} + +template getImportData(char[] name ){ + const ImportData getImportData = ImportData( import(name), name ); +} \ No newline at end of file diff -r 1e7701c27c03 -r 184ab53b7785 dwt/graphics/Color.d --- a/dwt/graphics/Color.d Mon Apr 07 13:08:57 2008 +0200 +++ b/dwt/graphics/Color.d Thu Apr 10 11:19:49 2008 +0200 @@ -12,7 +12,6 @@ *******************************************************************************/ module dwt.graphics.Color; - import dwt.DWT; import dwt.DWTException; import dwt.internal.win32.OS; @@ -85,7 +84,7 @@ public this (Device device, int red, int green, int blue) { if (device is null) device = Device.getDevice(); if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); - init(device, red, green, blue); + init_(device, red, green, blue); if (device.tracking) device.new_Object(this); } @@ -115,7 +114,7 @@ if (device is null) device = Device.getDevice(); if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (rgb is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); - init(device, rgb.red, rgb.green, rgb.blue); + init_(device, rgb.red, rgb.green, rgb.blue); if (device.tracking) device.new_Object(this); } @@ -249,7 +248,7 @@ * * @see #dispose */ -void init(Device device, int red, int green, int blue) { +void init_(Device device, int red, int green, int blue) { if (red > 255 || red < 0 || green > 255 || green < 0 || blue > 255 || blue < 0) { DWT.error(DWT.ERROR_INVALID_ARGUMENT); } diff -r 1e7701c27c03 -r 184ab53b7785 dwt/graphics/Cursor.d --- a/dwt/graphics/Cursor.d Mon Apr 07 13:08:57 2008 +0200 +++ b/dwt/graphics/Cursor.d Thu Apr 10 11:19:49 2008 +0200 @@ -347,7 +347,7 @@ DWT.error(DWT.ERROR_INVALID_ARGUMENT); } ImageData mask = source.getTransparencyMask(); - int[] result = Image.init(device, null, source, mask); + int[] result = Image.init_(device, null, source, mask); auto hBitmap = cast(HBITMAP)result[0]; auto hMask = cast(HBITMAP)result[1]; /* Create the icon */ diff -r 1e7701c27c03 -r 184ab53b7785 dwt/graphics/Device.d --- a/dwt/graphics/Device.d Mon Apr 07 13:08:57 2008 +0200 +++ b/dwt/graphics/Device.d Thu Apr 10 11:19:49 2008 +0200 @@ -142,7 +142,7 @@ tracking = data.tracking; } create (data); - init (); + init_ (); if (tracking) { errors = new Exception [128]; objects = new Object [128]; @@ -655,7 +655,7 @@ * * @see #create */ -protected void init () { +protected void init_ () { if (debug_) { static if (!OS.IsWinCE) OS.GdiSetBatchLimit(1); } diff -r 1e7701c27c03 -r 184ab53b7785 dwt/graphics/Font.d --- a/dwt/graphics/Font.d Mon Apr 07 13:08:57 2008 +0200 +++ b/dwt/graphics/Font.d Thu Apr 10 11:19:49 2008 +0200 @@ -80,7 +80,7 @@ public this(Device device, FontData fd) { if (device is null) device = Device.getDevice(); if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); - init(device, fd); + init_(device, fd); if (device.tracking) device.new_Object(this); } @@ -115,7 +115,7 @@ for (int i=0; i