Mercurial > projects > dwt2
changeset 84:fcf926c91ca4
Added base classes
line wrap: on
line diff
--- a/base/src/java/lang/Boolean.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/lang/Boolean.d Sat Apr 18 09:25:29 2009 +0200 @@ -49,6 +49,15 @@ return std.string.icmp(System.getProperty(name, "false"), "true" ) is 0; } } + + private static TypeInfo TYPE_; + public static TypeInfo TYPE(){ + if( TYPE_ is null ){ + TYPE_ = typeid(bool); + } + return TYPE_; + } + } alias Boolean ValueWrapperBool;
--- a/base/src/java/lang/Byte.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/lang/Byte.d Sat Apr 18 09:25:29 2009 +0200 @@ -2,12 +2,17 @@ import java.lang.util; import java.lang.exceptions; +import java.lang.Number; version(Tango){ static import tango.text.convert.Integer; } else { // Phobos } -class Byte : ValueWrapperT!(byte) { +class Byte : Number { + public static const byte MIN_VALUE = byte.min; + public static const byte MAX_VALUE = byte.max; + private byte value; + public static byte parseByte( String s ){ version(Tango){ try{ @@ -26,13 +31,29 @@ } } this( byte value ){ - super( value ); + super(); + this.value = value; } public static String toString( byte i ){ return String_valueOf(i); } + private static TypeInfo TYPE_; + public static TypeInfo TYPE(){ + if( TYPE_ is null ){ + TYPE_ = typeid(byte); + } + return TYPE_; + } + + byte byteValue(){ return value; } + double doubleValue(){ return value; } + float floatValue(){ return value; } + int intValue(){ return value; } + long longValue(){ return value; } + short shortValue(){ return value; } } alias Byte ValueWrapperByte; +
--- a/base/src/java/lang/Character.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/lang/Character.d Sat Apr 18 09:25:29 2009 +0200 @@ -124,6 +124,19 @@ // must be correct for container storage implMissing( __FILE__, __LINE__); } + + private static TypeInfo TYPE_; + public static TypeInfo TYPE(){ + if( TYPE_ is null ){ + TYPE_ = typeid(char); + } + return TYPE_; + } + + public dchar charValue(){ + implMissing( __FILE__, __LINE__); + return ' '; + } } bool CharacterIsDefined( dchar ch ){ @@ -195,3 +208,4 @@ } } +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base/src/java/lang/Class.d Sat Apr 18 09:25:29 2009 +0200 @@ -0,0 +1,158 @@ +module java.lang.Class; + +import java.lang.util; +import java.lang.reflect.Method; +import java.lang.reflect.Field; +import java.lang.reflect.Package; +import java.lang.reflect.Constructor; + +class Class { + bool desiredAssertionStatus(){ + implMissing(__FILE__, __LINE__ ); + return false; + } + static Class forName(String className){ + implMissing(__FILE__, __LINE__ ); + return null; + } + //static Class forName(String name, bool initialize, ClassLoader loader){ + // implMissing(__FILE__, __LINE__ ); + // return null; + //} + Class[] getClasses(){ + implMissing(__FILE__, __LINE__ ); + return null; + } + //ClassLoader getClassLoader(){ + // implMissing(__FILE__, __LINE__ ); + // return null; + //} + Class getComponentType(){ + implMissing(__FILE__, __LINE__ ); + return null; + } + Constructor getConstructor(Class parameterTypes...){ + implMissing(__FILE__, __LINE__ ); + return null; + } + Constructor[] getConstructors(){ + implMissing(__FILE__, __LINE__ ); + return null; + } + Class[] getDeclaredClasses(){ + implMissing(__FILE__, __LINE__ ); + return null; + } + Constructor getDeclaredConstructor(Class parameterTypes...){ + implMissing(__FILE__, __LINE__ ); + return null; + } + Constructor[] getDeclaredConstructors(){ + implMissing(__FILE__, __LINE__ ); + return null; + } + Field getDeclaredField(String name){ + implMissing(__FILE__, __LINE__ ); + return null; + } + Field[] getDeclaredFields(){ + implMissing(__FILE__, __LINE__ ); + return null; + } + Method getDeclaredMethod(String name, Class parameterTypes...){ + implMissing(__FILE__, __LINE__ ); + return null; + } + Method[] getDeclaredMethods(){ + implMissing(__FILE__, __LINE__ ); + return null; + } + Class getDeclaringClass(){ + implMissing(__FILE__, __LINE__ ); + return null; + } + Field getField(String name){ + implMissing(__FILE__, __LINE__ ); + return null; + } + Field[] getFields(){ + implMissing(__FILE__, __LINE__ ); + return null; + } + Class[] getInterfaces(){ + implMissing(__FILE__, __LINE__ ); + return null; + } + Method getMethod(String name, Class parameterTypes...){ + implMissing(__FILE__, __LINE__ ); + return null; + } + Method[] getMethods(){ + implMissing(__FILE__, __LINE__ ); + return null; + } + int getModifiers(){ + implMissing(__FILE__, __LINE__ ); + return 0; + } + String getName(){ + implMissing(__FILE__, __LINE__ ); + return null; + } + Package getPackage(){ + implMissing(__FILE__, __LINE__ ); + return null; + } + //ProtectionDomain getProtectionDomain(){ + // implMissing(__FILE__, __LINE__ ); + // return null; + //} + //URL getResource(String name){ + // implMissing(__FILE__, __LINE__ ); + // return null; + //} + //InputStream getResourceAsStream(String name){ + // implMissing(__FILE__, __LINE__ ); + // return null; + //} + //Object[] getSigners(){ + // implMissing(__FILE__, __LINE__ ); + // return null; + //} + String getSimpleName(){ + implMissing(__FILE__, __LINE__ ); + return null; + } + Class getSuperclass(){ + implMissing(__FILE__, __LINE__ ); + return null; + } + bool isArray(){ + implMissing(__FILE__, __LINE__ ); + return false; + } + bool isAssignableFrom(Class cls){ + implMissing(__FILE__, __LINE__ ); + return false; + } + bool isInstance(Object obj){ + implMissing(__FILE__, __LINE__ ); + return false; + } + bool isInterface(){ + implMissing(__FILE__, __LINE__ ); + return false; + } + bool isPrimitive(){ + implMissing(__FILE__, __LINE__ ); + return false; + } + Object newInstance(){ + implMissing(__FILE__, __LINE__ ); + return null; + } + String toString(){ + implMissing(__FILE__, __LINE__ ); + return null; + } +}
--- a/base/src/java/lang/Double.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/lang/Double.d Sat Apr 18 09:25:29 2009 +0200 @@ -1,19 +1,21 @@ module java.lang.Double; import java.lang.util; +import java.lang.Number; -class Double : ValueWrapperT!(double) { +class Double : Number { + public static double POSITIVE_INFINITY = double.infinity; + public static double NEGATIVE_INFINITY = -double.infinity; public static double MAX_VALUE = double.max; public static double MIN_VALUE = double.min; + private double value; this( double value ){ - super(value); + super(); + this.value = value; } this( String str ){ implMissing( __FILE__, __LINE__ ); - super(0.0); - } - public double doubleValue(){ - return value; + super(); } public static String toString( double value ){ implMissing( __FILE__, __LINE__ ); @@ -23,4 +25,38 @@ implMissing( __FILE__, __LINE__ ); return 0.0; } + + private static TypeInfo TYPE_; + public static TypeInfo TYPE(){ + if( TYPE_ is null ){ + TYPE_ = typeid(double); + } + return TYPE_; + } + + public byte byteValue(){ + return cast(byte)value; + } + + public short shortValue(){ + return cast(short)value; + } + + public int intValue(){ + return cast(int)value; + } + + public long longValue(){ + return cast(long)value; + } + + public float floatValue(){ + return cast(float)value; + } + + public double doubleValue(){ + return cast(double)value; + } } + +
--- a/base/src/java/lang/Float.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/lang/Float.d Sat Apr 18 09:25:29 2009 +0200 @@ -2,8 +2,9 @@ import java.lang.util; import java.lang.exceptions; +import java.lang.Number; -class Float : ValueWrapperT!(float) { +class Float : Number { public static float POSITIVE_INFINITY = (1.0f / 0.0f); public static float NEGATIVE_INFINITY = ((-1.0f) / 0.0f); @@ -11,16 +12,15 @@ public static float MAX_VALUE = 3.4028235e+38f; public static float MIN_VALUE = 1.4e-45f; public static int SIZE = 32; + private float value; this( float value ){ - super(value); + super(); + this.value = value; } this( String str ){ implMissing( __FILE__, __LINE__ ); - super(0.0); - } - public float floatValue(){ - return value; + super(); } public static String toString( float value ){ implMissing( __FILE__, __LINE__ ); @@ -40,4 +40,37 @@ } } + private static TypeInfo TYPE_; + public static TypeInfo TYPE(){ + if( TYPE_ is null ){ + TYPE_ = typeid(float); + } + return TYPE_; + } + + public byte byteValue(){ + return cast(byte)value; + } + + public short shortValue(){ + return cast(short)value; + } + + public int intValue(){ + return cast(int)value; + } + + public long longValue(){ + return cast(long)value; + } + + public float floatValue(){ + return cast(float)value; + } + + public double doubleValue(){ + return cast(double)value; + } } + +
--- a/base/src/java/lang/Integer.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/lang/Integer.d Sat Apr 18 09:25:29 2009 +0200 @@ -2,6 +2,7 @@ import java.lang.util; import java.lang.exceptions; +import java.lang.Number; version(Tango){ } else { // Phobos @@ -12,21 +13,25 @@ } -class Integer : ValueWrapperT!(int) { +class Integer : Number { public static const int MIN_VALUE = 0x80000000; public static const int MAX_VALUE = 0x7fffffff; public static const int SIZE = 32; + private int value; public this ( void* value ){ - super( cast(int)value ); + super(); + this.value = cast(int)value; } public this ( int value ){ - super( value ); + super(); + this.value = value; } public this ( String s ){ - super(parseInt(s)); + super(); + this.value = parseInt(s); } public static String toString( int i, int radix ){ @@ -142,6 +147,15 @@ return std.string.toString(value); } } + + private static TypeInfo TYPE_; + public static TypeInfo TYPE(){ + if( TYPE_ is null ){ + TYPE_ = typeid(int); + } + return TYPE_; + } + } alias Integer ValueWrapperInt;
--- a/base/src/java/lang/Long.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/lang/Long.d Sat Apr 18 09:25:29 2009 +0200 @@ -1,20 +1,43 @@ module java.lang.Long; import java.lang.util; +import java.lang.Number; -class Long : ValueWrapperT!(long) { +class Long : Number { public static const long MIN_VALUE = long.min; public static const long MAX_VALUE = long.max; + private long value; this( long value ){ - super(value); + super(); + this.value = value; } this( String str ){ implMissing( __FILE__, __LINE__ ); - super(0); + super(); + } + public byte byteValue(){ + return cast(byte)value; } + + public short shortValue(){ + return cast(short)value; + } + + public int intValue(){ + return cast(int)value; + } + public long longValue(){ return value; } + + public float floatValue(){ + return cast(float)value; + } + + public double doubleValue(){ + return cast(double)value; + } public static long parseLong(String s){ implMissing( __FILE__, __LINE__ ); return 0; @@ -23,6 +46,14 @@ implMissing( __FILE__, __LINE__ ); return null; } + private static TypeInfo TYPE_; + public static TypeInfo TYPE(){ + if( TYPE_ is null ){ + TYPE_ = typeid(long); + } + return TYPE_; + } + } alias Long ValueWrapperLong;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base/src/java/lang/Short.d Sat Apr 18 09:25:29 2009 +0200 @@ -0,0 +1,57 @@ +module java.lang.Short; + +import java.lang.util; +import java.lang.exceptions; +import java.lang.Number; + +version(Tango){ + static import tango.text.convert.Integer; +} else { // Phobos +} +class Short : Number { + public static const short MIN_VALUE = short.min; + public static const short MAX_VALUE = short.max; + private short value; + public static byte parseShort( String s ){ + version(Tango){ + 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 ); + } + } else { // Phobos + implMissing( __FILE__, __LINE__); + return 0; + } + } + this( short value ){ + super(); + this.value = value; + } + + public static String toString( short i ){ + return String_valueOf(i); + } + + private static TypeInfo TYPE_; + public static TypeInfo TYPE(){ + if( TYPE_ is null ){ + TYPE_ = typeid(short); + } + return TYPE_; + } + + byte byteValue(){ return cast(byte)value; } + double doubleValue(){ return value; } + float floatValue(){ return value; } + int intValue(){ return value; } + long longValue(){ return value; } + short shortValue(){ return value; } +} +alias Short ValueWrapperShort; +
--- a/base/src/java/lang/String.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/lang/String.d Sat Apr 18 09:25:29 2009 +0200 @@ -696,6 +696,7 @@ public hash_t toHash( CString src ){ return typeid(String).getHash(&src); } +public alias toHash String_toHash; /// Extension to String public String trim( CString str ){ @@ -786,5 +787,15 @@ } } +class StringCls { + private static TypeInfo TYPE_; + public static TypeInfo TYPE(){ + if( TYPE_ is null ){ + TYPE_ = typeid(char[]); + } + return TYPE_; + } + +}
--- a/base/src/java/lang/StringBuffer.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/lang/StringBuffer.d Sat Apr 18 09:25:29 2009 +0200 @@ -120,6 +120,10 @@ return append( arr ); } + StringBuffer append( bool i ){ + return append( String_valueOf(i) ); + } + StringBuffer append( int i ){ return append( String_valueOf(i) ); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base/src/java/lang/ThreadLocal.d Sat Apr 18 09:25:29 2009 +0200 @@ -0,0 +1,20 @@ +module java.lang.ThreadLocal; +import java.lang.util; + +class ThreadLocal{ + this(){ + implMissing(__FILE__, __LINE__); + } + Object get(){ + implMissing(__FILE__, __LINE__); + return null; + } + protected Object initialValue(){ + implMissing(__FILE__, __LINE__); + return null; + } + void set(Object value){ + implMissing(__FILE__, __LINE__); + } +} +
--- a/base/src/java/lang/all.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/lang/all.d Sat Apr 18 09:25:29 2009 +0200 @@ -5,6 +5,7 @@ public import java.lang.Boolean; public import java.lang.Byte; public import java.lang.Character; +public import java.lang.Class; public import java.lang.Double; public import java.lang.Float; public import java.lang.Integer; @@ -13,8 +14,11 @@ public import java.lang.Number; public import java.lang.Runnable; public import java.lang.String; +public import java.lang.Short; public import java.lang.StringBuffer; public import java.lang.System; +public import java.lang.Thread; +public import java.lang.ThreadLocal; public import java.lang.util; public import java.lang.exceptions;
--- a/base/src/java/lang/exceptions.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/lang/exceptions.d Sat Apr 18 09:25:29 2009 +0200 @@ -101,6 +101,9 @@ this( Exception e ){ super(e.toString); } + public String getMessage(){ + return msg; + } } class RuntimeException : Exception { @@ -114,6 +117,9 @@ super(e.toString); next = e; } + public String getMessage(){ + return msg; + } public Throwable getCause() { return next; // D2 has next of type Throwable }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base/src/java/lang/reflect/AccessibleObject.d Sat Apr 18 09:25:29 2009 +0200 @@ -0,0 +1,19 @@ +module java.lang.reflect.AccessibleObject; + +import java.lang.all; + +class AccessibleObject { + protected this(){ + implMissing(__FILE__,__LINE__); + } + bool isAccessible(){ + implMissing(__FILE__,__LINE__); + return false; + } + static void setAccessible(AccessibleObject[] array, bool flag){ + implMissing(__FILE__,__LINE__); + } + void setAccessible(bool flag){ + implMissing(__FILE__,__LINE__); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base/src/java/lang/reflect/Array.d Sat Apr 18 09:25:29 2009 +0200 @@ -0,0 +1,83 @@ +module java.lang.reflect.Array; + +import java.lang.all; + +class Array { + static Object get(Object array, int index){ + implMissing(__FILE__, __LINE__); + return null; + } + static bool getBoolean(Object array, int index){ + implMissing(__FILE__, __LINE__); + return false; + } + static byte getByte(Object array, int index){ + implMissing(__FILE__, __LINE__); + return 0; + } + static char getChar(Object array, int index){ + implMissing(__FILE__, __LINE__); + return 0; + } + static double getDouble(Object array, int index){ + implMissing(__FILE__, __LINE__); + return 0; + } + static float getFloat(Object array, int index){ + implMissing(__FILE__, __LINE__); + return 0; + } + static int getInt(Object array, int index){ + implMissing(__FILE__, __LINE__); + return 0; + } + static int getLength(Object array){ + implMissing(__FILE__, __LINE__); + return 0; + } + static long getLong(Object array, int index){ + implMissing(__FILE__, __LINE__); + return 0; + } + static short getShort(Object array, int index){ + implMissing(__FILE__, __LINE__); + return 0; + } + static Object newInstance(Class componentType, int length){ + implMissing(__FILE__, __LINE__); + return null; + } + static Object newInstance(Class componentType, int[] dimensions){ + implMissing(__FILE__, __LINE__); + return null; + } + static void set(Object array, int index, Object value){ + implMissing(__FILE__, __LINE__); + } + static void setBoolean(Object array, int index, bool z){ + implMissing(__FILE__, __LINE__); + } + static void setByte(Object array, int index, byte b){ + implMissing(__FILE__, __LINE__); + } + static void setChar(Object array, int index, char c){ + implMissing(__FILE__, __LINE__); + } + static void setDouble(Object array, int index, double d){ + implMissing(__FILE__, __LINE__); + } + static void setFloat(Object array, int index, float f){ + implMissing(__FILE__, __LINE__); + } + static void setInt(Object array, int index, int i){ + implMissing(__FILE__, __LINE__); + } + static void setLong(Object array, int index, long l){ + implMissing(__FILE__, __LINE__); + } + static void setShort(Object array, int index, short s){ + implMissing(__FILE__, __LINE__); + } +} + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base/src/java/lang/reflect/Constructor.d Sat Apr 18 09:25:29 2009 +0200 @@ -0,0 +1,44 @@ +module java.lang.reflect.Constructor; + +import java.lang.all; +import java.lang.Class; +import java.lang.String; + +class Constructor { + public override equals_t opEquals(Object obj){ + implMissing(__FILE__,__LINE__); + return false; + } + Class getDeclaringClass(){ + implMissing(__FILE__,__LINE__); + return null; + } + Class[] getExceptionTypes(){ + implMissing(__FILE__,__LINE__); + return null; + } + int getModifiers(){ + implMissing(__FILE__,__LINE__); + return 0; + } + String getName(){ + implMissing(__FILE__,__LINE__); + return null; + } + Class[] getParameterTypes(){ + implMissing(__FILE__,__LINE__); + return null; + } + public override hash_t toHash(){ + implMissing(__FILE__,__LINE__); + return 0; + } + Object newInstance(Object[] initargs){ + implMissing(__FILE__,__LINE__); + return null; + } + String toString(){ + implMissing(__FILE__,__LINE__); + return null; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base/src/java/lang/reflect/Field.d Sat Apr 18 09:25:29 2009 +0200 @@ -0,0 +1,99 @@ +module java.lang.reflect.Field; + +import java.lang.all; +import java.lang.Class; +import java.lang.String; + +class Field { + public override equals_t opEquals(Object obj){ + implMissing(__FILE__,__LINE__); + return false; + } + Object get(Object obj){ + implMissing(__FILE__,__LINE__); + return null; + } + bool getBoolean(Object obj){ + implMissing(__FILE__,__LINE__); + return false; + } + byte getByte(Object obj){ + implMissing(__FILE__,__LINE__); + return 0; + } + char getChar(Object obj){ + implMissing(__FILE__,__LINE__); + return 0; + } + Class getDeclaringClass(){ + implMissing(__FILE__,__LINE__); + return null; + } + double getDouble(Object obj){ + implMissing(__FILE__,__LINE__); + return 0; + } + float getFloat(Object obj){ + implMissing(__FILE__,__LINE__); + return 0; + } + int getInt(Object obj){ + implMissing(__FILE__,__LINE__); + return 0; + } + long getLong(Object obj){ + implMissing(__FILE__,__LINE__); + return 0; + } + int getModifiers(){ + implMissing(__FILE__,__LINE__); + return 0; + } + String getName(){ + implMissing(__FILE__,__LINE__); + return null; + } + short getShort(Object obj){ + implMissing(__FILE__,__LINE__); + return 0; + } + Class getType(){ + implMissing(__FILE__,__LINE__); + return null; + } + public override hash_t toHash(){ + implMissing(__FILE__,__LINE__); + return 0; + } + void set(Object obj, Object value){ + implMissing(__FILE__,__LINE__); + } + void setBoolean(Object obj, bool z){ + implMissing(__FILE__,__LINE__); + } + void setByte(Object obj, byte b){ + implMissing(__FILE__,__LINE__); + } + void setChar(Object obj, char c){ + implMissing(__FILE__,__LINE__); + } + void setDouble(Object obj, double d){ + implMissing(__FILE__,__LINE__); + } + void setFloat(Object obj, float f){ + implMissing(__FILE__,__LINE__); + } + void setInt(Object obj, int i){ + implMissing(__FILE__,__LINE__); + } + void setLong(Object obj, long l){ + implMissing(__FILE__,__LINE__); + } + void setShort(Object obj, short s){ + implMissing(__FILE__,__LINE__); + } + public override String toString(){ + implMissing(__FILE__,__LINE__); + return null; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base/src/java/lang/reflect/Method.d Sat Apr 18 09:25:29 2009 +0200 @@ -0,0 +1,48 @@ +module java.lang.reflect.Method; + +import java.lang.all; +import java.lang.Class; +import java.lang.String; + +class Method { + public override equals_t opEquals(Object obj){ + implMissing(__FILE__,__LINE__); + return false; + } + Class getDeclaringClass(){ + implMissing(__FILE__,__LINE__); + return null; + } + Class[] getExceptionTypes(){ + implMissing(__FILE__,__LINE__); + return null; + } + int getModifiers(){ + implMissing(__FILE__,__LINE__); + return 0; + } + String getName(){ + implMissing(__FILE__,__LINE__); + return null; + } + Class[] getParameterTypes(){ + implMissing(__FILE__,__LINE__); + return null; + } + Class getReturnType(){ + implMissing(__FILE__,__LINE__); + return null; + } + public override hash_t toHash(){ + implMissing(__FILE__,__LINE__); + return 0; + } + Object invoke(Object obj, Object[] args){ + implMissing(__FILE__,__LINE__); + return null; + } + public override String toString(){ + implMissing(__FILE__,__LINE__); + return null; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base/src/java/lang/reflect/Package.d Sat Apr 18 09:25:29 2009 +0200 @@ -0,0 +1,64 @@ +module java.lang.reflect.Package; + +import java.lang.all; +import java.lang.Class; +import java.lang.String; + +class Package { + String getImplementationTitle(){ + implMissing(__FILE__,__LINE__); + return null; + } + String getImplementationVendor(){ + implMissing(__FILE__,__LINE__); + return null; + } + String getImplementationVersion(){ + implMissing(__FILE__,__LINE__); + return null; + } + String getName(){ + implMissing(__FILE__,__LINE__); + return null; + } + static Package getPackage(String name){ + implMissing(__FILE__,__LINE__); + return null; + } + static Package[] getPackages(){ + implMissing(__FILE__,__LINE__); + return null; + } + String getSpecificationTitle(){ + implMissing(__FILE__,__LINE__); + return null; + } + String getSpecificationVendor(){ + implMissing(__FILE__,__LINE__); + return null; + } + String getSpecificationVersion(){ + implMissing(__FILE__,__LINE__); + return null; + } + public override hash_t toHash(){ + implMissing(__FILE__,__LINE__); + return 0; + } + bool isCompatibleWith(String desired){ + implMissing(__FILE__,__LINE__); + return false; + } + //bool isSealed(){ + // implMissing(__FILE__,__LINE__); + // return false; + //} + //bool isSealed(URL url){ + // implMissing(__FILE__,__LINE__); + // return false; + //} + String toString(){ + implMissing(__FILE__,__LINE__); + return null; + } +}
--- a/base/src/java/lang/wrappers.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/lang/wrappers.d Sat Apr 18 09:25:29 2009 +0200 @@ -140,3 +140,4 @@ return null; } +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base/src/java/nonstandard/RuntimeTraits.d Sat Apr 18 09:25:29 2009 +0200 @@ -0,0 +1,609 @@ +/** + * Provides runtime traits, which provide much of the functionality of tango.core.Traits and + * is-expressions, as well as some functionality that is only available at runtime, using + * runtime type information. + * + * Authors: Chris Wright (dhasenan) <dhasenan@gmail.com> + * License: tango license, apache 2.0 + * Copyright (c) 2009, CHRISTOPHER WRIGHT + */ +module java.nonstandard.RuntimeTraits; +import java.lang.all; +// Only DWT +public bool isJavaPrimitive( TypeInfo type ){ + return isBool(type) || isInteger(type) || isCharacter(type) || isFloat(type); +} + +public TypeInfo_Class getTypeInfo( ClassInfo ci ){ + return null; +} + +public TypeInfo_Class getSuperclass( ClassInfo ci ){ + return getSuperclass(getTypeInfo(ci)); +} +public TypeInfo_Class getSuperclass( TypeInfo ti ){ + return null; +} + +public TypeInfo_Interface[] getInterfaces( ClassInfo ci ){ + return getInterfaces(getTypeInfo(ci)); +} +public TypeInfo_Interface[] getInterfaces( TypeInfo ti ){ + return null; +} + +public String getName( ClassInfo ci ){ + return ci.name; +} +public String getName( TypeInfo ti ){ + if( isClass(ti) ){ + return getName( asClass(ti)); + } + return null; +} + +// End DWT. Start Tango... +/// If the given type represents a typedef, return the actual type. +TypeInfo realType (TypeInfo type) +{ + // TypeInfo_Typedef.next() doesn't return the actual type. + // I think it returns TypeInfo_Typedef.base.next(). + // So, a slightly different method. + auto def = cast(TypeInfo_Typedef) type; + if (def !is null) + { + return def.base; + } + return type; +} + +/// If the given type represents a class, return its ClassInfo; else return null; +ClassInfo asClass (TypeInfo type) +{ + if (isInterface (type)) + { + auto klass = cast(TypeInfo_Interface) type; + return klass.info; + } + if (isClass (type)) + { + auto klass = cast(TypeInfo_Class) type; + return klass.info; + } + return null; +} + +/** Returns true iff one type is an ancestor of the other, or if the types are the same. + * If either is null, returns false. */ +bool isDerived (ClassInfo derived, ClassInfo base) +{ + if (derived is null || base is null) + return false; + do + if (derived is base) + return true; + while ((derived = derived.base) !is null) + return false; +} + +/** Returns true iff implementor implements the interface described + * by iface. This is an expensive operation (linear in the number of + * interfaces and base classes). + */ +bool implements (ClassInfo implementor, ClassInfo iface) +{ + foreach (info; applyInterfaces (implementor)) + { + if (iface is info) + return true; + } + return false; +} + +/** Returns true iff an instance of class test is implicitly castable to target. + * This is an expensive operation (isDerived + implements). */ +bool isImplicitly (ClassInfo test, ClassInfo target) +{ + // Keep isDerived first. + // isDerived will be much faster than implements. + return (isDerived (test, target) || implements (test, target)); +} + +/** Returns true iff an instance of type test is implicitly castable to target. + * If the types describe classes or interfaces, this is an expensive operation. */ +bool isImplicitly (TypeInfo test, TypeInfo target) +{ + // A lot of special cases. This is ugly. + if (test is target) + return true; + if (isStaticArray (test) && isDynamicArray (target) && valueType (test) is valueType (target)) + { + // you can implicitly cast static to dynamic (currently) if they + // have the same value type. Other casts should be forbidden. + return true; + } + auto klass1 = asClass (test); + auto klass2 = asClass (target); + if (isClass (test) && isClass (target)) + { + return isDerived (klass1, klass2); + } + if (isInterface (test) && isInterface (target)) + { + return isDerived (klass1, klass2); + } + if (klass1 && klass2) + { + return isImplicitly (klass1, klass2); + } + if (klass1 || klass2) + { + // no casts from class to non-class + return false; + } + if ((isSignedInteger (test) && isSignedInteger (target)) || (isUnsignedInteger (test) && isUnsignedInteger (target)) || (isFloat ( + test) && isFloat (target)) || (isCharacter (test) && isCharacter (target))) + { + return test.tsize () <= target.tsize (); + } + if (isSignedInteger (test) && isUnsignedInteger (target)) + { + // potential loss of data + return false; + } + if (isUnsignedInteger (test) && isSignedInteger (target)) + { + // if the sizes are the same, you could be losing data + // the upper half of the range wraps around to negatives + // if the target type is larger, you can safely hold it + return test.tsize () < target.tsize (); + } + // delegates and functions: no can do + // pointers: no + // structs: no + return false; +} + +/// +ClassInfo[] baseClasses (ClassInfo type) +{ + if (type is null) + return null; + ClassInfo[] types; + while ((type = type.base) !is null) + types ~= type; + return types; +} + +/** Returns a list of all interfaces that this type implements, directly + * or indirectly. This includes base interfaces of types the class implements, + * and interfaces that base classes implement, and base interfaces of interfaces + * that base classes implement. This is an expensive operation. */ +ClassInfo[] baseInterfaces (ClassInfo type) +{ + if (type is null) + return null; + ClassInfo[] types = directInterfaces (type); + while ((type = type.base) !is null) + { + types ~= interfaceGraph (type); + } + return types; +} + +/** Returns all the interfaces that this type directly implements, including + * inherited interfaces. This is an expensive operation. + * + * Examples: + * --- + * interface I1 {} + * interface I2 : I1 {} + * class A : I2 {} + * + * auto interfaces = interfaceGraph (A.classinfo); + * // interfaces = [I1.classinfo, I2.classinfo] + * --- + * + * --- + * interface I1 {} + * interface I2 {} + * class A : I1 {} + * class B : A, I2 {} + * + * auto interfaces = interfaceGraph (B.classinfo); + * // interfaces = [I2.classinfo] + * --- + */ +ClassInfo[] interfaceGraph (ClassInfo type) +{ + ClassInfo[] info; + foreach (iface; type.interfaces) + { + info ~= iface.classinfo; + info ~= interfaceGraph (iface.classinfo); + } + return info; +} + +/** Iterate through all interfaces that type implements, directly or indirectly, including base interfaces. */ +struct applyInterfaces +{ + /// + static applyInterfaces opCall (ClassInfo type) + { + applyInterfaces apply; + apply.type = type; + return apply; + } + + /// + int opApply (int delegate (ref ClassInfo) dg) + { + int result = 0; + for (; type; type = type.base) + { + foreach (iface; type.interfaces) + { + result = dg (iface.classinfo); + if (result) + return result; + result = applyInterfaces (iface.classinfo).opApply (dg); + if (result) + return result; + } + } + return result; + } + + ClassInfo type; +} + +/// +ClassInfo[] baseTypes (ClassInfo type) +{ + if (type is null) + return null; + return baseClasses (type) ~ baseInterfaces (type); +} + +/// +ModuleInfo moduleOf (ClassInfo type) +{ + foreach (modula; ModuleInfo) + foreach (klass; modula.localClasses) + if (klass is type) + return modula; + return null; +} + +/// Returns a list of interfaces that this class directly implements. +ClassInfo[] directInterfaces (ClassInfo type) +{ + ClassInfo[] types; + foreach (iface; type.interfaces) + types ~= iface.classinfo; + return types; +} + +/** Returns a list of all types that are derived from the given type. This does not + * count interfaces; that is, if type is an interface, you will only get derived + * interfaces back. It is an expensive operations. */ +ClassInfo[] derivedTypes (ClassInfo type) +{ + ClassInfo[] types; + foreach (modula; ModuleInfo) + foreach (klass; modula.localClasses) + if (isDerived (klass, type) && (klass !is type)) + types ~= klass; + return types; +} + +/// +bool isDynamicArray (TypeInfo type) +{ + // This implementation is evil. + // Array typeinfos are named TypeInfo_A?, and defined individually for each + // possible type aside from structs. For example, typeinfo for int[] is + // TypeInfo_Ai; for uint[], TypeInfo_Ak. + // So any TypeInfo with length 11 and starting with TypeInfo_A is an array + // type. + // Also, TypeInfo_Array is an array type. + type = realType (type); + return ((type.classinfo.name[9] == 'A') && (type.classinfo.name.length == 11)) || ((cast(TypeInfo_Array) type) !is null); +} + +/// +bool isStaticArray (TypeInfo type) +{ + type = realType (type); + return (cast(TypeInfo_StaticArray) type) !is null; +} + +/** Returns true iff the given type is a dynamic or static array (false for associative + * arrays and non-arrays). */ +bool isArray (TypeInfo type) +{ + type = realType (type); + return isDynamicArray (type) || isStaticArray (type); +} + +/// +bool isAssociativeArray (TypeInfo type) +{ + type = realType (type); + return (cast(TypeInfo_AssociativeArray) type) !is null; +} + +/// +bool isCharacter (TypeInfo type) +{ + type = realType (type); + return (type is typeid(char) || type is typeid(wchar) || type is typeid(dchar)); +} + +/// +bool isString (TypeInfo type) +{ + type = realType (type); + return isArray (type) && isCharacter (valueType (type)); +} + +/// +bool isUnsignedInteger (TypeInfo type) +{ + type = realType (type); + return (type is typeid(uint) || type is typeid(ulong) || type is typeid(ushort) || type is typeid(ubyte)); +} + +/// +bool isSignedInteger (TypeInfo type) +{ + type = realType (type); + return (type is typeid(int) || type is typeid(long) || type is typeid(short) || type is typeid(byte)); +} + +/// +bool isInteger (TypeInfo type) +{ + type = realType (type); + return isSignedInteger (type) || isUnsignedInteger (type); +} + +/// +bool isBool (TypeInfo type) +{ + type = realType (type); + return (type is typeid(bool)); +} + +/// +bool isFloat (TypeInfo type) +{ + type = realType (type); + return (type is typeid(float) || type is typeid(double) || type is typeid(real)); +} + +/// +bool isPrimitive (TypeInfo type) +{ + type = realType (type); + return (isArray (type) || isAssociativeArray (type) || isCharacter (type) || isFloat (type) || isInteger (type)); +} + +/// Returns true iff the given type represents an interface. +bool isInterface (TypeInfo type) +{ + return (cast(TypeInfo_Interface) type) !is null; +} + +/// +bool isPointer (TypeInfo type) +{ + type = realType (type); + return (cast(TypeInfo_Pointer) type) !is null; +} + +/// Returns true iff the type represents a class (false for interfaces). +bool isClass (TypeInfo type) +{ + type = realType (type); + return (cast(TypeInfo_Class) type) !is null; +} + +/// +bool isStruct (TypeInfo type) +{ + type = realType (type); + return (cast(TypeInfo_Struct) type) !is null; +} + +/// +bool isFunction (TypeInfo type) +{ + type = realType (type); + return ((cast(TypeInfo_Function) type) !is null) || ((cast(TypeInfo_Delegate) type) !is null); +} + +/** Returns true iff the given type is a reference type. */ +bool isReferenceType (TypeInfo type) +{ + return isClass (type) || isPointer (type) || isDynamicArray (type); +} + +/** Returns true iff the given type represents a user-defined type. + * This does not include functions, delegates, aliases, or typedefs. */ +bool isUserDefined (TypeInfo type) +{ + return isClass (type) || isStruct (type); +} + +/** Returns true for all value types, false for all reference types. + * For functions and delegates, returns false (is this the way it should be?). */ +bool isValueType (TypeInfo type) +{ + return !(isDynamicArray (type) || isAssociativeArray (type) || isPointer (type) || isClass (type) || isFunction ( + type)); +} + +/** The key type of the given type. For an array, size_t; for an associative + * array T[U], U. */ +TypeInfo keyType (TypeInfo type) +{ + type = realType (type); + auto assocArray = cast(TypeInfo_AssociativeArray) type; + if (assocArray) + return assocArray.key; + if (isArray (type)) + return typeid(size_t); + return null; +} + +/** The value type of the given type -- given T[] or T[n], T; given T[U], + * T; given T*, T; anything else, null. */ +TypeInfo valueType (TypeInfo type) +{ + type = realType (type); + if (isArray (type)) + return type.next; + auto assocArray = cast(TypeInfo_AssociativeArray) type; + if (assocArray) + return assocArray.value; + auto pointer = cast(TypeInfo_Pointer) type; + if (pointer) + return pointer.m_next; + return null; +} + +/** If the given type represents a delegate or function, the return type + * of that function. Otherwise, null. */ +TypeInfo returnType (TypeInfo type) +{ + type = realType (type); + auto delegat = cast(TypeInfo_Delegate) type; + if (delegat) + return delegat.next; + auto func = cast(TypeInfo_Function) type; + if (func) + return func.next; + return null; +} + +debug (UnitTest) +{ + + interface I1 + { + } + + interface I2 + { + } + + interface I3 + { + } + + interface I4 + { + } + + class A + { + } + + class B : A, I1 + { + } + + class C : B, I2, I3 + { + } + + class D : A, I1 + { + int foo (int i) + { + return i; + } + } + + struct S1 + { + } + + unittest { + // Struct-related stuff. + auto type = typeid(S1); + assert (isStruct (type)); + assert (isValueType (type)); + assert (isUserDefined (type)); + assert (!isClass (type)); + assert (!isPointer (type)); + assert (null is returnType (type)); + assert (!isPrimitive (type)); + assert (valueType (type) is null); + } + + unittest { + auto type = A.classinfo; + assert (baseTypes (type) == [Object.classinfo]); + assert (baseClasses (type) == [Object.classinfo]); + assert (baseInterfaces (type).length == 0); + type = C.classinfo; + assert (baseClasses (type) == [B.classinfo, A.classinfo, Object.classinfo]); + assert (baseInterfaces (type) == [I2.classinfo, I3.classinfo, I1.classinfo]); + assert (baseTypes (type) == [B.classinfo, A.classinfo, Object.classinfo, I2.classinfo, I3.classinfo, + I1.classinfo]); + } + + unittest { + assert (isPointer (typeid(S1*))); + assert (isArray (typeid(S1[]))); + assert (valueType (typeid(S1*)) is typeid(S1)); + auto d = new D; + assert (returnType (typeid(typeof(&d.foo))) is typeid(int)); + assert (isFloat (typeid(real))); + assert (isFloat (typeid(double))); + assert (isFloat (typeid(float))); + assert (!isFloat (typeid(creal))); + assert (!isFloat (typeid(cdouble))); + assert (!isInteger (typeid(float))); + assert (!isInteger (typeid(creal))); + assert (isInteger (typeid(ulong))); + assert (isInteger (typeid(ubyte))); + assert (isCharacter (typeid(char))); + assert (isCharacter (typeid(wchar))); + assert (isCharacter (typeid(dchar))); + assert (!isCharacter (typeid(ubyte))); + assert (isArray (typeid(typeof("hello")))); + assert (isCharacter (typeid(typeof("hello"[0])))); + assert (valueType (typeid(typeof("hello"))) is typeid(typeof('h'))); + assert (isString (typeid(typeof("hello"))), typeof("hello").stringof); + auto staticString = typeid(typeof("hello"d)); + auto dynamicString = typeid(typeof("hello"d[0 .. $])); + assert (isString (staticString)); + assert (isStaticArray (staticString)); + assert (isDynamicArray (dynamicString), dynamicString.toString () ~ dynamicString.classinfo.name); + assert (isString (dynamicString)); + + auto type = typeid(int[char[]]); + assert (valueType (type) is typeid(int), valueType (type).toString ()); + assert (keyType (type) is typeid(char[]), keyType (type).toString ()); + void delegate (int) dg = (int i) + { + }; + assert (returnType (typeid(typeof(dg))) is typeid(void)); + assert (returnType (typeid(int delegate (int))) is typeid(int)); + + assert (!isDynamicArray (typeid(int[4]))); + assert (isStaticArray (typeid(int[4]))); + } + + unittest { + typedef int myint; + assert (typeid(myint) !is null, "null typeid(myint)"); + assert (isInteger (typeid(myint))); + } + +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base/src/java/text/ParsePosition.d Sat Apr 18 09:25:29 2009 +0200 @@ -0,0 +1,36 @@ +module java.text.ParsePosition; + +import java.lang.all; +import java.util.Date; + +class ParsePosition{ + this(int index){ + implMissing(__FILE__, __LINE__); + } + bool equals(Object obj){ + implMissing(__FILE__, __LINE__); + return 0; + } + int getErrorIndex(){ + implMissing(__FILE__, __LINE__); + return 0; + } + int getIndex(){ + implMissing(__FILE__, __LINE__); + return 0; + } + int hashCode(){ + implMissing(__FILE__, __LINE__); + return 0; + } + void setErrorIndex(int ei){ + implMissing(__FILE__, __LINE__); + } + void setIndex(int index){ + implMissing(__FILE__, __LINE__); + } + String toString(){ + implMissing(__FILE__, __LINE__); + return null; + } +}
--- a/base/src/java/util/AbstractCollection.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/util/AbstractCollection.d Sat Apr 18 09:25:29 2009 +0200 @@ -43,8 +43,7 @@ return 0; } bool remove(Object o){ - implMissing( __FILE__, __LINE__ ); - return false; + throw new UnsupportedOperationException(); } bool remove(String o){ return remove(stringcast(o)); @@ -70,6 +69,10 @@ implMissing( __FILE__, __LINE__ ); return null; } + String[] toArray(String[] a){ + implMissing( __FILE__, __LINE__ ); + return null; + } String toString(){ implMissing( __FILE__, __LINE__ ); return null;
--- a/base/src/java/util/AbstractList.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/util/AbstractList.d Sat Apr 18 09:25:29 2009 +0200 @@ -11,18 +11,61 @@ this(){ } - public abstract void add(int index, Object element); - public abstract bool add(Object o); - public abstract bool addAll(Collection c); - public abstract bool addAll(int index, Collection c); - public abstract void clear(); - public abstract bool contains(Object o); - public bool contains(String str){ - return contains(stringcast(str)); + public void add(int index, Object element){ + throw new UnsupportedOperationException(); + } + public bool add(String o){ + return add(stringcast(o)); + } + public bool add(Object o){ + add(size(), o); + return true; + } + public bool addAll(Collection c){ + throw new UnsupportedOperationException(); + } + public bool addAll(int index, Collection c){ + throw new UnsupportedOperationException(); + } + public void clear(){ + throw new UnsupportedOperationException(); } - public abstract bool containsAll(Collection c); - public abstract equals_t opEquals(Object o); - public abstract Object get(int index); + public bool contains(Object o){ return super.contains(o); } + public bool contains(String str){ return contains(stringcast(str)); } + public bool containsAll(Collection c){ return super.containsAll(c); } + public equals_t opEquals(Object o){ + if( auto other = cast(List)o ){ + if( other is cast(List)this ){ + return true; + } + auto it1 = this.iterator(); + auto it2 = other.iterator(); + while(true){ + bool n1 = it1.hasNext(); + bool n2 = it2.hasNext(); + if( !n1 && !n2 ) return true; + if( (n1 && !n2) || (!n1 && n2 )) return false; + Object o1 = it1.next(); + Object o2 = it2.next(); + if( o1 is null ){ + if( o2 !is null ){ + return false; + } + } + else{ + if( o2 is null ){ + return false; + } + if( o1 != o2 ){ + return false; + } + } + } + } + return false; + } + + public abstract Object get(int index); public hash_t toHash(){ // http://java.sun.com/j2se/1.4.2/docs/api/java/util/List.html#hashCode() @@ -35,22 +78,63 @@ return hashCode; } - public abstract int indexOf(Object o); - public abstract bool isEmpty(); - public abstract Iterator iterator(); - public abstract int lastIndexOf(Object o); - public abstract ListIterator listIterator(); - public abstract ListIterator listIterator(int index); - public abstract Object remove(int index); - protected abstract void removeRange(int fromIndex, int toIndex); - public abstract bool remove(Object o); - public abstract bool remove(String o); - public abstract bool removeAll(Collection c); - public abstract bool retainAll(Collection c); - public abstract Object set(int index, Object element); - public abstract List subList(int fromIndex, int toIndex); - public abstract Object[] toArray(); - public abstract Object[] toArray(Object[] a); + public int indexOf(Object o){ + auto it = listIterator(); + int idx = 0; + while(it.hasNext()){ + auto t = it.next(); + if( t is null ? o is null : t == o){ + return idx; + } + idx++; + } + return -1; + } + public bool isEmpty(){ + return super.isEmpty(); + } + public Iterator iterator(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public int lastIndexOf(Object o){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public ListIterator listIterator(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public ListIterator listIterator(int index){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public Object remove(int index){ + throw new UnsupportedOperationException(); + } + protected void removeRange(int fromIndex, int toIndex){ + } + public bool remove(Object o){ return super.remove(o); } + public bool remove(String o){ return super.remove(o); } + public bool removeAll(Collection c){ return super.removeAll(c); } + public bool retainAll(Collection c){ return super.retainAll(c); } + public Object set(int index, Object element){ + throw new UnsupportedOperationException(); + } + public List subList(int fromIndex, int toIndex){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public Object[] toArray(){ return super.toArray(); } + public Object[] toArray(Object[] a){ return super.toArray(a); } + public String[] toArray(String[] a){ return super.toArray(a); } + public int opApply (int delegate(ref Object value) dg){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public String toString(){ + return super.toString(); + } }
--- a/base/src/java/util/AbstractSet.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/util/AbstractSet.d Sat Apr 18 09:25:29 2009 +0200 @@ -17,32 +17,27 @@ implMissing( __FILE__, __LINE__ ); return 0; } - bool removeAll(Collection c){ - return super.removeAll(c); - } - public abstract bool add(Object o); - public abstract bool add(String o); - public abstract bool addAll(Collection c); - public abstract void clear(); - public abstract bool contains(Object o); - public abstract bool contains(String o); - public abstract bool containsAll(Collection c); + public bool add(Object o){ return super.add(o); } + public bool add(String o){ return super.add(stringcast(o)); } + public bool addAll(Collection c){ return super.addAll(c); } + public void clear(){ super.clear(); } + public bool contains(Object o){ return super.contains(o); } + public bool contains(String o){ return super.contains(stringcast(o)); } + public bool containsAll(Collection c){ return super.containsAll(c); } - public abstract bool isEmpty(); - public abstract Iterator iterator(); - public abstract bool remove(Object o); - public abstract bool remove(String o); - public abstract bool removeAll(Collection c); - public abstract bool retainAll(Collection c); - public abstract int size(); - public abstract Object[] toArray(); - public abstract Object[] toArray(Object[] a); - public abstract String toString(){ - return super.toString(); - } + public bool isEmpty(){ return super.isEmpty(); } + public Iterator iterator(){ return super.iterator(); } + public bool remove(Object o){ return super.remove(o); } + public bool remove(String o){ return super.remove(o); } + public bool removeAll(Collection c){ return super.removeAll(c); } + public bool retainAll(Collection c){ return super.retainAll(c); } + public int size(){ return super.size(); } + public Object[] toArray(){ return super.toArray(); } + public Object[] toArray(Object[] a){ return super.toArray(a); } + public String toString(){ return super.toString(); } // only for D - public abstract int opApply (int delegate(ref Object value) dg); + public int opApply (int delegate(ref Object value) dg){ return super.opApply(dg); } }
--- a/base/src/java/util/ArrayList.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/util/ArrayList.d Sat Apr 18 09:25:29 2009 +0200 @@ -172,7 +172,7 @@ public void add(Object o){ implMissing( __FILE__, __LINE__ ); } - public bool add(String o){ + public void add(String o){ implMissing( __FILE__, __LINE__ ); return false; } @@ -266,6 +266,22 @@ } return a; } + String[] toArray(String[] a){ + version(Tango){ + auto res = a; + if( res.length < data.length ){ + res.length = data.length; + } + int idx = 0; + foreach( o; data ){ + res[idx] = stringcast(o); + } + return res; + } else { // Phobos + implMissing( __FILE__, __LINE__ ); + return null; + } + } // only for D public int opApply (int delegate(ref Object value) dg){ @@ -275,5 +291,8 @@ } return 0; } + public String toString(){ + return super.toString(); + } }
--- a/base/src/java/util/Arrays.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/util/Arrays.d Sat Apr 18 09:25:29 2009 +0200 @@ -4,6 +4,10 @@ import java.util.List; import java.util.ArrayList; import java.util.Collections; +version(Tango){ + static import tango.core.Array; +} else { // Phobos +} class Arrays { public static bool equals(T)(T[] a, T[] b){ @@ -37,6 +41,17 @@ return true; } +/ + static int binarySearch( T )( T[] a, T b ){ + if( tango.core.Array.bsearch( a, b )){ + tango.core.Array.lbound( a, b ); + } + else{ + return -(tango.core.Array.lbound( a, b ))-1; + } + } + static void sort( T )( T[] a ){ + tango.core.Array.sort( a ); + } static void sort( T )( T[] a, Comparator c ){ static if( is( T : char[] )){ bool isLess( String o1, String o2 ){ @@ -50,11 +65,12 @@ } tango.core.Array.sort( a, &isLess ); } - static List asList(Object[] a) { + static List asList(T)(T[] a) { + static assert( is(T==interface) || is(T==class)); if( a.length is 0 ) return Collections.EMPTY_LIST; ArrayList res = new ArrayList( a.length ); foreach( o; a ){ - res.add(o); + res.add( cast(Object)o); } return res; }
--- a/base/src/java/util/Collections.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/util/Collections.d Sat Apr 18 09:25:29 2009 +0200 @@ -73,7 +73,7 @@ public void add(Object o){ unsupported(); } - public bool add(String o){ + public void add(String o){ unsupported(); return false; // make compiler happy } @@ -202,6 +202,9 @@ public Object[] toArray(Object[] a){ return list.toArray(a); } + public String[] toArray(String[] a){ + return list.toArray(a); + } public int opApply (int delegate(ref Object value) dg){ implMissing(__FILE__, __LINE__ ); return 0; @@ -210,6 +213,9 @@ implMissing(__FILE__, __LINE__ ); return 0; } + public String toString(){ + return list.toString(); + } } static int binarySearch(List list, Object key){ implMissing( __FILE__, __LINE__ ); @@ -230,6 +236,10 @@ implMissing( __FILE__, __LINE__ ); return null; } + public static List singletonList( Object o ){ + implMissing( __FILE__, __LINE__ ); + return null; + } public static Set singleton( Object o ){ TreeSet res = new TreeSet(); res.add(o); @@ -280,6 +290,8 @@ public List subList(int fromIndex, int toIndex){ synchronized(this){ return this.list.subList(fromIndex,toIndex); } } public Object[] toArray(){ synchronized(this){ return this.list.toArray(); } } public Object[] toArray(Object[] a){ synchronized(this){ return this.list.toArray(a); } } + public String[] toArray(String[] a){ synchronized(this){ return this.list.toArray(a); } } + public String toString(){ synchronized(this){ return this.list.toString(); } } } static List synchronizedList(List list){ return new SynchronizedList(list);
--- a/base/src/java/util/Date.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/util/Date.d Sat Apr 18 09:25:29 2009 +0200 @@ -3,6 +3,12 @@ import java.lang.all; class Date { + public this(){ + implMissing(__FILE__,__LINE__); + } + public this( long millis ){ + implMissing(__FILE__,__LINE__); + } long getTime(){ implMissing(__FILE__,__LINE__); return 0;
--- a/base/src/java/util/LinkedList.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/util/LinkedList.d Sat Apr 18 09:25:29 2009 +0200 @@ -289,7 +289,6 @@ } Object[] toArray(){ version(Tango){ - if( list.size() is 0 ) return null; // workaround tango ticket 1237 return list.toArray(); } else { // Phobos implMissing( __FILE__, __LINE__ ); @@ -298,13 +297,28 @@ } Object[] toArray(Object[] a){ version(Tango){ - if( list.size() is 0 ) return a[0 .. 0]; // workaround tango ticket 1237 return list.toArray( a ); } else { // Phobos implMissing( __FILE__, __LINE__ ); return null; } } + String[] toArray(String[] a){ + version(Tango){ + auto res = a; + if( res.length < list.size() ){ + res.length = list.size(); + } + int idx = 0; + foreach( o; list ){ + res[idx] = stringcast(o); + } + return res; + } else { // Phobos + implMissing( __FILE__, __LINE__ ); + return null; + } + } String toString(){ implMissing( __FILE__, __LINE__ ); return null;
--- a/base/src/java/util/List.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/util/List.d Sat Apr 18 09:25:29 2009 +0200 @@ -34,5 +34,7 @@ public List subList(int fromIndex, int toIndex); public Object[] toArray(); public Object[] toArray(Object[] a); + public String[] toArray(String[] a); + public String toString(); }
--- a/base/src/java/util/ListIterator.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/util/ListIterator.d Sat Apr 18 09:25:29 2009 +0200 @@ -5,7 +5,7 @@ interface ListIterator : Iterator { public void add(Object o); - public bool add(String o); + public void add(String o); public bool hasNext(); public bool hasPrevious(); public Object next();
--- a/base/src/java/util/Stack.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/util/Stack.d Sat Apr 18 09:25:29 2009 +0200 @@ -178,6 +178,10 @@ implMissing( __FILE__, __LINE__ ); return null; } + String[] toArray(String[] a){ + implMissing( __FILE__, __LINE__ ); + return null; + } // from Stack String toString(){
--- a/base/src/java/util/Vector.d Tue Apr 14 13:22:56 2009 +0200 +++ b/base/src/java/util/Vector.d Sat Apr 18 09:25:29 2009 +0200 @@ -197,6 +197,10 @@ implMissing( __FILE__, __LINE__ ); return null; } + String[] toArray(String[] a){ + implMissing( __FILE__, __LINE__ ); + return null; + } public String toString(){ implMissing( __FILE__, __LINE__ ); return null;