[multiple changes]
2003-09-26 Sascha Brawer <brawer@dandelis.ch> * java/awt/image/SinglePixelPackedSampleModel.java (createDataBuffer): Save space for some pixels at the buffer end. Added Javadoc. 2003-09-26 Tom Tromey <tromey@redhat.com> * java/io/ObjectOutputStream.java (writeFields): Fixed indentation. (putFields): Likewise. From-SVN: r71829
This commit is contained in:
parent
8aa43dd09b
commit
fc56f7acc1
@ -1,3 +1,14 @@
|
||||
2003-09-26 Sascha Brawer <brawer@dandelis.ch>
|
||||
|
||||
* java/awt/image/SinglePixelPackedSampleModel.java (createDataBuffer):
|
||||
Save space for some pixels at the buffer end. Added Javadoc.
|
||||
|
||||
2003-09-26 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
* java/io/ObjectOutputStream.java (writeFields): Fixed
|
||||
indentation.
|
||||
(putFields): Likewise.
|
||||
|
||||
2003-09-26 Michael Koch <konqueror@gmx.de>
|
||||
|
||||
* java/nio/ByteBufferHelper.java:
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2000, 2002 Free Software Foundation
|
||||
/* Copyright (C) 2000, 2002, 2003 Free Software Foundation
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@ -88,13 +88,25 @@ public class SinglePixelPackedSampleModel extends SampleModel
|
||||
return new SinglePixelPackedSampleModel(dataType, w, h, bitMasks);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a DataBuffer for holding pixel data in the format and
|
||||
* layout described by this SampleModel. The returned buffer will
|
||||
* consist of one single bank.
|
||||
*/
|
||||
public DataBuffer createDataBuffer()
|
||||
{
|
||||
// Important: use scanlineStride here, not width!
|
||||
int size = scanlineStride*height;
|
||||
int size;
|
||||
|
||||
// We can save (scanlineStride - width) pixels at the very end of
|
||||
// the buffer. The Sun reference implementation (J2SE 1.3.1 and
|
||||
// 1.4.1_01) seems to do this; tested with Mauve test code.
|
||||
size = scanlineStride * (height - 1) + width;
|
||||
|
||||
return Buffers.createBuffer(getDataType(), size);
|
||||
}
|
||||
|
||||
|
||||
public int[] getSampleSize()
|
||||
{
|
||||
return sampleSize;
|
||||
|
@ -868,140 +868,139 @@ public class ObjectOutputStream extends OutputStream
|
||||
{
|
||||
if (currentPutField == null)
|
||||
{
|
||||
currentPutField = new PutField ()
|
||||
{
|
||||
private byte[] prim_field_data
|
||||
= new byte[currentObjectStreamClass.primFieldSize];
|
||||
private Object[] objs
|
||||
= new Object[currentObjectStreamClass.objectFieldCount];
|
||||
currentPutField = new PutField ()
|
||||
{
|
||||
private byte[] prim_field_data =
|
||||
new byte[currentObjectStreamClass.primFieldSize];
|
||||
private Object[] objs =
|
||||
new Object[currentObjectStreamClass.objectFieldCount];
|
||||
|
||||
public void put (String name, boolean value)
|
||||
{
|
||||
ObjectStreamField field
|
||||
= currentObjectStreamClass.getField (name);
|
||||
checkType (field, 'Z');
|
||||
prim_field_data[field.getOffset ()] = (byte)(value ? 1 : 0);
|
||||
}
|
||||
public void put (String name, boolean value)
|
||||
{
|
||||
ObjectStreamField field
|
||||
= currentObjectStreamClass.getField (name);
|
||||
checkType (field, 'Z');
|
||||
prim_field_data[field.getOffset ()] = (byte)(value ? 1 : 0);
|
||||
}
|
||||
|
||||
public void put (String name, byte value)
|
||||
{
|
||||
ObjectStreamField field
|
||||
= currentObjectStreamClass.getField (name);
|
||||
checkType (field, 'B');
|
||||
prim_field_data[field.getOffset ()] = value;
|
||||
}
|
||||
public void put (String name, byte value)
|
||||
{
|
||||
ObjectStreamField field
|
||||
= currentObjectStreamClass.getField (name);
|
||||
checkType (field, 'B');
|
||||
prim_field_data[field.getOffset ()] = value;
|
||||
}
|
||||
|
||||
public void put (String name, char value)
|
||||
{
|
||||
ObjectStreamField field
|
||||
= currentObjectStreamClass.getField (name);
|
||||
checkType (field, 'C');
|
||||
int off = field.getOffset ();
|
||||
prim_field_data[off++] = (byte)(value >>> 8);
|
||||
prim_field_data[off] = (byte)value;
|
||||
}
|
||||
public void put (String name, char value)
|
||||
{
|
||||
ObjectStreamField field
|
||||
= currentObjectStreamClass.getField (name);
|
||||
checkType (field, 'C');
|
||||
int off = field.getOffset ();
|
||||
prim_field_data[off++] = (byte)(value >>> 8);
|
||||
prim_field_data[off] = (byte)value;
|
||||
}
|
||||
|
||||
public void put (String name, double value)
|
||||
{
|
||||
ObjectStreamField field
|
||||
= currentObjectStreamClass.getField (name);
|
||||
checkType (field, 'D');
|
||||
int off = field.getOffset ();
|
||||
long l_value = Double.doubleToLongBits (value);
|
||||
prim_field_data[off++] = (byte)(l_value >>> 52);
|
||||
prim_field_data[off++] = (byte)(l_value >>> 48);
|
||||
prim_field_data[off++] = (byte)(l_value >>> 40);
|
||||
prim_field_data[off++] = (byte)(l_value >>> 32);
|
||||
prim_field_data[off++] = (byte)(l_value >>> 24);
|
||||
prim_field_data[off++] = (byte)(l_value >>> 16);
|
||||
prim_field_data[off++] = (byte)(l_value >>> 8);
|
||||
prim_field_data[off] = (byte)l_value;
|
||||
}
|
||||
public void put (String name, double value)
|
||||
{
|
||||
ObjectStreamField field
|
||||
= currentObjectStreamClass.getField (name);
|
||||
checkType (field, 'D');
|
||||
int off = field.getOffset ();
|
||||
long l_value = Double.doubleToLongBits (value);
|
||||
prim_field_data[off++] = (byte)(l_value >>> 52);
|
||||
prim_field_data[off++] = (byte)(l_value >>> 48);
|
||||
prim_field_data[off++] = (byte)(l_value >>> 40);
|
||||
prim_field_data[off++] = (byte)(l_value >>> 32);
|
||||
prim_field_data[off++] = (byte)(l_value >>> 24);
|
||||
prim_field_data[off++] = (byte)(l_value >>> 16);
|
||||
prim_field_data[off++] = (byte)(l_value >>> 8);
|
||||
prim_field_data[off] = (byte)l_value;
|
||||
}
|
||||
|
||||
public void put (String name, float value)
|
||||
{
|
||||
ObjectStreamField field
|
||||
= currentObjectStreamClass.getField (name);
|
||||
checkType (field, 'F');
|
||||
int off = field.getOffset ();
|
||||
int i_value = Float.floatToIntBits (value);
|
||||
prim_field_data[off++] = (byte)(i_value >>> 24);
|
||||
prim_field_data[off++] = (byte)(i_value >>> 16);
|
||||
prim_field_data[off++] = (byte)(i_value >>> 8);
|
||||
prim_field_data[off] = (byte)i_value;
|
||||
}
|
||||
public void put (String name, float value)
|
||||
{
|
||||
ObjectStreamField field
|
||||
= currentObjectStreamClass.getField (name);
|
||||
checkType (field, 'F');
|
||||
int off = field.getOffset ();
|
||||
int i_value = Float.floatToIntBits (value);
|
||||
prim_field_data[off++] = (byte)(i_value >>> 24);
|
||||
prim_field_data[off++] = (byte)(i_value >>> 16);
|
||||
prim_field_data[off++] = (byte)(i_value >>> 8);
|
||||
prim_field_data[off] = (byte)i_value;
|
||||
}
|
||||
|
||||
public void put (String name, int value)
|
||||
{
|
||||
ObjectStreamField field
|
||||
= currentObjectStreamClass.getField (name);
|
||||
checkType (field, 'I');
|
||||
int off = field.getOffset ();
|
||||
prim_field_data[off++] = (byte)(value >>> 24);
|
||||
prim_field_data[off++] = (byte)(value >>> 16);
|
||||
prim_field_data[off++] = (byte)(value >>> 8);
|
||||
prim_field_data[off] = (byte)value;
|
||||
}
|
||||
public void put (String name, int value)
|
||||
{
|
||||
ObjectStreamField field
|
||||
= currentObjectStreamClass.getField (name);
|
||||
checkType (field, 'I');
|
||||
int off = field.getOffset ();
|
||||
prim_field_data[off++] = (byte)(value >>> 24);
|
||||
prim_field_data[off++] = (byte)(value >>> 16);
|
||||
prim_field_data[off++] = (byte)(value >>> 8);
|
||||
prim_field_data[off] = (byte)value;
|
||||
}
|
||||
|
||||
public void put (String name, long value)
|
||||
{
|
||||
ObjectStreamField field
|
||||
= currentObjectStreamClass.getField (name);
|
||||
checkType (field, 'J');
|
||||
int off = field.getOffset ();
|
||||
prim_field_data[off++] = (byte)(value >>> 52);
|
||||
prim_field_data[off++] = (byte)(value >>> 48);
|
||||
prim_field_data[off++] = (byte)(value >>> 40);
|
||||
prim_field_data[off++] = (byte)(value >>> 32);
|
||||
prim_field_data[off++] = (byte)(value >>> 24);
|
||||
prim_field_data[off++] = (byte)(value >>> 16);
|
||||
prim_field_data[off++] = (byte)(value >>> 8);
|
||||
prim_field_data[off] = (byte)value;
|
||||
}
|
||||
public void put (String name, long value)
|
||||
{
|
||||
ObjectStreamField field
|
||||
= currentObjectStreamClass.getField (name);
|
||||
checkType (field, 'J');
|
||||
int off = field.getOffset ();
|
||||
prim_field_data[off++] = (byte)(value >>> 52);
|
||||
prim_field_data[off++] = (byte)(value >>> 48);
|
||||
prim_field_data[off++] = (byte)(value >>> 40);
|
||||
prim_field_data[off++] = (byte)(value >>> 32);
|
||||
prim_field_data[off++] = (byte)(value >>> 24);
|
||||
prim_field_data[off++] = (byte)(value >>> 16);
|
||||
prim_field_data[off++] = (byte)(value >>> 8);
|
||||
prim_field_data[off] = (byte)value;
|
||||
}
|
||||
|
||||
public void put (String name, short value)
|
||||
{
|
||||
ObjectStreamField field
|
||||
= currentObjectStreamClass.getField (name);
|
||||
checkType (field, 'S');
|
||||
int off = field.getOffset ();
|
||||
prim_field_data[off++] = (byte)(value >>> 8);
|
||||
prim_field_data[off] = (byte)value;
|
||||
}
|
||||
public void put (String name, short value)
|
||||
{
|
||||
ObjectStreamField field
|
||||
= currentObjectStreamClass.getField (name);
|
||||
checkType (field, 'S');
|
||||
int off = field.getOffset ();
|
||||
prim_field_data[off++] = (byte)(value >>> 8);
|
||||
prim_field_data[off] = (byte)value;
|
||||
}
|
||||
|
||||
public void put (String name, Object value)
|
||||
{
|
||||
ObjectStreamField field
|
||||
= currentObjectStreamClass.getField (name);
|
||||
if (field == null)
|
||||
throw new IllegalArgumentException ();
|
||||
if (value != null &&
|
||||
! field.getType ().isAssignableFrom (value.getClass ()))
|
||||
throw new IllegalArgumentException ();
|
||||
objs[field.getOffset ()] = value;
|
||||
}
|
||||
public void put (String name, Object value)
|
||||
{
|
||||
ObjectStreamField field
|
||||
= currentObjectStreamClass.getField (name);
|
||||
if (field == null)
|
||||
throw new IllegalArgumentException ();
|
||||
if (value != null &&
|
||||
! field.getType ().isAssignableFrom (value.getClass ()))
|
||||
throw new IllegalArgumentException ();
|
||||
objs[field.getOffset ()] = value;
|
||||
}
|
||||
|
||||
public void write (ObjectOutput out) throws IOException
|
||||
{
|
||||
// Apparently Block data is not used with PutField as per
|
||||
// empirical evidence against JDK 1.2. Also see Mauve test
|
||||
// java.io.ObjectInputOutput.Test.GetPutField.
|
||||
boolean oldmode = setBlockDataMode (false);
|
||||
out.write (prim_field_data);
|
||||
for (int i = 0; i < objs.length; ++ i)
|
||||
out.writeObject (objs[i]);
|
||||
setBlockDataMode (oldmode);
|
||||
}
|
||||
public void write (ObjectOutput out) throws IOException
|
||||
{
|
||||
// Apparently Block data is not used with PutField as per
|
||||
// empirical evidence against JDK 1.2. Also see Mauve test
|
||||
// java.io.ObjectInputOutput.Test.GetPutField.
|
||||
boolean oldmode = setBlockDataMode (false);
|
||||
out.write (prim_field_data);
|
||||
for (int i = 0; i < objs.length; ++ i)
|
||||
out.writeObject (objs[i]);
|
||||
setBlockDataMode (oldmode);
|
||||
}
|
||||
|
||||
private void checkType (ObjectStreamField field, char type)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
if (TypeSignature.getEncodingOfClass (field.getType ()).charAt (0)
|
||||
!= type)
|
||||
throw new IllegalArgumentException ();
|
||||
}
|
||||
};
|
||||
// end PutFieldImpl
|
||||
private void checkType (ObjectStreamField field, char type)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
if (TypeSignature.getEncodingOfClass(field.getType ()).charAt(0)
|
||||
!= type)
|
||||
throw new IllegalArgumentException ();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return currentPutField;
|
||||
@ -1013,10 +1012,9 @@ public class ObjectOutputStream extends OutputStream
|
||||
if (currentPutField == null)
|
||||
throw new NotActiveException ("writeFields can only be called after putFields has been called");
|
||||
|
||||
// moved here from putFields since putFields
|
||||
// may be called more than once, but not writeFields
|
||||
markFieldsWritten();
|
||||
|
||||
// putFields may be called more than once, but not writeFields.
|
||||
markFieldsWritten();
|
||||
|
||||
currentPutField.write (this);
|
||||
currentPutField = null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user