# HG changeset patch # User Frank Benoit # Date 1220830380 -7200 # Node ID 77fa7f3ab37e47f15ac82a0ebe8d7c3925b8dfa1 # Parent 7ca3f26319f1909f9801e0d7d16cd6088aef324d Additions for jface.text diff -r 7ca3f26319f1 -r 77fa7f3ab37e dwt/dwthelper/System.d --- a/dwt/dwthelper/System.d Tue Aug 26 02:47:19 2008 +0200 +++ b/dwt/dwthelper/System.d Mon Sep 08 01:33:00 2008 +0200 @@ -146,6 +146,13 @@ return (*cast(Object *)&x).toHash(); } + public static String getProperty( String key, String defval ){ + String res = getProperty(key); + if( res ){ + return res; + } + return defval; + } public static String getProperty( String key ){ /* Get values for local dwt specific keys */ String* p; @@ -176,13 +183,20 @@ } - class Output { + static class Output { public void println( String str ){ implMissing( __FILE__, __LINE__ ); } } - public static Output out__; + private static Output err__; + public static Output err(){ + if( err__ is null ){ + err__ = new Output(); + } + return err__; + } + private static Output out__; public static Output out_(){ if( out__ is null ){ out__ = new Output(); diff -r 7ca3f26319f1 -r 77fa7f3ab37e dwt/dwthelper/utils.d --- a/dwt/dwthelper/utils.d Tue Aug 26 02:47:19 2008 +0200 +++ b/dwt/dwthelper/utils.d Mon Sep 08 01:33:00 2008 +0200 @@ -14,6 +14,7 @@ static import tango.stdc.stringz; static import tango.text.Util; static import tango.text.Text; +static import tango.text.Ascii; import tango.text.Unicode; import tango.text.convert.Utf; import tango.core.Exception; @@ -21,11 +22,12 @@ import tango.util.log.Trace; import tango.text.UnicodeData; -static import tango.util.collection.model.Seq; alias char[] String; alias tango.text.Text.Text!(char) StringBuffer; +alias ArrayBoundsException ArrayIndexOutOfBoundsException; + void implMissing( String file, uint line ){ Stderr.formatln( "implementation missing in file {} line {}", file, line ); Stderr.formatln( "exiting ..." ); @@ -125,6 +127,9 @@ public static Boolean valueOf( bool b ){ return b ? TRUE : FALSE; } + public static bool getBoolean(String name){ + return tango.text.Ascii.icompare(System.getProperty(name, "false"), "true" ) is 0; + } } alias Boolean ValueWrapperBool; @@ -146,6 +151,11 @@ this( byte value ){ super( value ); } + + public static String toString( byte i ){ + return tango.text.convert.Integer.toString(i); + } + } alias Byte ValueWrapperByte; @@ -278,6 +288,10 @@ implMissing( __FILE__, __LINE__ ); return null; } + public static double parseDouble(String s){ + implMissing( __FILE__, __LINE__ ); + return 0.0; + } } class Float : ValueWrapperT!(float) { @@ -561,6 +575,10 @@ } return i; } +dchar getRelativeCodePoint( String str, int startIndex, int searchRelCp ){ + int dummy; + return getRelativeCodePoint( str, startIndex, dummy ); +} dchar getRelativeCodePoint( String str, int startIndex, int searchRelCp, out int relIndex ){ relIndex = getRelativeCodePointOffset( str, startIndex, searchRelCp ); int ignore; @@ -603,6 +621,84 @@ return res; } +class Character { + public static bool isUpperCase( dchar c ){ + implMissing( __FILE__, __LINE__); + return false; + } + public static dchar toUpperCase( dchar c ){ + dchar[] r = tango.text.Unicode.toUpper( [c] ); + return r[0]; + } + public static dchar toLowerCase( dchar c ){ + dchar[] r = tango.text.Unicode.toLower( [c] ); + return r[0]; + } + public static bool isWhitespace( dchar c ){ + return tango.text.Unicode.isWhitespace( c ); + } + public static bool isDigit( dchar c ){ + return tango.text.Unicode.isDigit( c ); + } + public static bool isLetterOrDigit( dchar c ){ + return isDigit(c) || isLetter(c); + } + public static bool isUnicodeIdentifierPart(char ch){ + implMissing( __FILE__, __LINE__); + return false; + } + public static bool isUnicodeIdentifierStart(char ch){ + implMissing( __FILE__, __LINE__); + return false; + } + public static bool isIdentifierIgnorable(char ch){ + implMissing( __FILE__, __LINE__); + return false; + } + public static bool isJavaIdentifierPart(char ch){ + implMissing( __FILE__, __LINE__); + return false; + } + + this( char c ){ + // must be correct for container storage + implMissing( __FILE__, __LINE__); + } +} + +String new_String( String cont, int offset, int len ){ + return cont[ offset .. offset+len ].dup; +} +String new_String( String cont ){ + return cont.dup; +} +String String_valueOf( bool v ){ + return v ? "true" : "false"; +} +String String_valueOf( int v ){ + return tango.text.convert.Integer.toString(v); +} +String String_valueOf( long v ){ + return tango.text.convert.Integer.toString(v); +} +String String_valueOf( float v ){ + return tango.text.convert.Float.toString(v); +} +String String_valueOf( double v ){ + return tango.text.convert.Float.toString(v); +} +String String_valueOf( dchar v ){ + return dcharToString(v); +} +String String_valueOf( char[] v ){ + return v.dup; +} +String String_valueOf( char[] v, int offset, int len ){ + return v[ offset .. offset+len ].dup; +} +String String_valueOf( Object v ){ + return v is null ? "null" : v.toString(); +} bool CharacterIsDefined( dchar ch ){ return (ch in tango.text.UnicodeData.unicodeData) !is null; } @@ -616,7 +712,9 @@ dchar[] r = tango.text.Unicode.toLower( buf ); return r[0]; } - +int length( String str ){ + return str.length; +} dchar CharacterToLower( dchar c ){ dchar[] r = tango.text.Unicode.toLower( [c] ); return r[0]; @@ -638,6 +736,11 @@ return tango.text.Unicode.toUpper( str ); } +public String replaceFirst( String str, String regex, String replacement ){ + implMissing(__FILE__,__LINE__); + return str; +} + public int indexOf( String str, char searched ){ int res = tango.text.Util.locate( str, searched ); if( res is str.length ) res = -1; @@ -677,6 +780,10 @@ return res; } +public String replaceAll( String str, String regex, String replacement ){ + implMissing(__FILE__,__LINE__); + return null; +} public String replace( String str, char from, char to ){ return tango.text.Util.replace( str.dup, from, to ); } @@ -705,8 +812,8 @@ dst[ dstBegin .. dstBegin + srcEnd - srcBegin ] = src[ srcBegin .. srcEnd ]; } -public wchar[] toCharArray( String str ){ - return toString16( str ); +public char[] toCharArray( String str ){ + return str; } public bool endsWith( String src, String pattern ){ @@ -862,6 +969,11 @@ super(e); } } +class ClassCastException : Exception { + this( String e = null ){ + super(e); + } +} interface Cloneable{ } @@ -927,7 +1039,42 @@ } } -interface Reader{ +class Reader{ + protected Object lock; + protected this(){ + implMissing(__FILE__,__LINE__); + } + protected this(Object lock){ + implMissing(__FILE__,__LINE__); + } + abstract void close(); + void mark(int readAheadLimit){ + implMissing(__FILE__,__LINE__); + } + bool markSupported(){ + implMissing(__FILE__,__LINE__); + return false; + } + int read(){ + implMissing(__FILE__,__LINE__); + return 0; + } + int read(char[] cbuf){ + implMissing(__FILE__,__LINE__); + return 0; + } + abstract int read(char[] cbuf, int off, int len); + bool ready(){ + implMissing(__FILE__,__LINE__); + return false; + } + void reset(){ + implMissing(__FILE__,__LINE__); + } + long skip(long n){ + implMissing(__FILE__,__LINE__); + return 0; + } } interface Writer{ } @@ -1045,7 +1192,7 @@ return true; } -int SeqIndexOf(T)( tango.util.collection.model.Seq.Seq!(T) s, T src ){ +/+int SeqIndexOf(T)( tango.util.collection.model.Seq.Seq!(T) s, T src ){ int idx; foreach( e; s ){ if( e == src ){ @@ -1054,7 +1201,8 @@ idx++; } return -1; -} +}+/ + int arrayIndexOf(T)( T[] arr, T v ){ int res = -1; int idx = 0; @@ -1068,18 +1216,18 @@ 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; -} +// 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( int deepth = 100, String prefix = "trc" ){ auto e = new Exception( null ); @@ -1110,9 +1258,29 @@ } interface CharSequence { - wchar charAt(int index); + char charAt(int index); int length(); CharSequence subSequence(int start, int end); String toString(); } +class StringCharSequence : CharSequence { + private String str; + this( String str ){ + this.str = str; + } + char charAt(int index){ + return str[index]; + } + int length(){ + return str.length; + } + CharSequence subSequence(int start, int end){ + return new StringCharSequence( str[ start .. end ]); + } + String toString(){ + return str; + } +} + +