Re: [cp-patches] Patch: BorderLayout fix

2006-02-13 Thread Roman Kennke
Hi Lillian,

Am Montag, den 13.02.2006, 12:30 -0500 schrieb Lillian Angel:
> Some of the problems I have had with Panels stemmed from BorderLayout.
> Many things were not being painted because the size was set incorrectly.

Is it possible to add Mauve tests for your changes? LayoutManagers are
usually relativly easy to test and tend to cause regressions quite
often.

/Roman



signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


Re: [cp-patches] bootstrap, System.loadLibrary() and Math

2006-02-13 Thread Tom Tromey
> "Mark" == Mark Wielaard <[EMAIL PROTECTED]> writes:

Mark> For now to get things working I just reintroduced the loadLibrary() call
Mark> in the Math static initializer. This should work as before the
Mark> Math/VMMath split even though it is a little ugly.

I'm glad you fixed this immediately; it was blocking some work.

However it would be preferable in the long run for this to be a
defined part of our VM interface.  Relying on Math being initialized
at a "good" moment during VM bootstrap seems fragile.

Tom



[cp-patches] Patch: FYI: minor javadoc fixes

2006-02-13 Thread Tom Tromey
I'm checking this in.

This fixes a couple javadoc warnings in java.lang.reflect.

Tom

2006-02-13  Tom Tromey  <[EMAIL PROTECTED]>

* vm/reference/java/lang/reflect/Method.java: Javadoc fix.
* vm/reference/java/lang/reflect/Constructor.java: Javadoc fix.

Index: vm/reference/java/lang/reflect/Constructor.java
===
RCS file: 
/cvsroot/classpath/classpath/vm/reference/java/lang/reflect/Constructor.java,v
retrieving revision 1.13
diff -u -r1.13 Constructor.java
--- vm/reference/java/lang/reflect/Constructor.java 2 Jul 2005 20:33:08 
-   1.13
+++ vm/reference/java/lang/reflect/Constructor.java 13 Feb 2006 23:26:56 
-
@@ -66,8 +66,8 @@
  * @author Eric Blake <[EMAIL PROTECTED]>
  * @see Member
  * @see Class
- * @see java.lang.Class#getConstructor(Object[])
- * @see java.lang.Class#getDeclaredConstructor(Object[])
+ * @see java.lang.Class#getConstructor(Class[])
+ * @see java.lang.Class#getDeclaredConstructor(Class[])
  * @see java.lang.Class#getConstructors()
  * @see java.lang.Class#getDeclaredConstructors()
  * @since 1.1
Index: vm/reference/java/lang/reflect/Method.java
===
RCS file: 
/cvsroot/classpath/classpath/vm/reference/java/lang/reflect/Method.java,v
retrieving revision 1.14
diff -u -r1.14 Method.java
--- vm/reference/java/lang/reflect/Method.java  2 Jul 2005 20:33:08 -   
1.14
+++ vm/reference/java/lang/reflect/Method.java  13 Feb 2006 23:26:56 -
@@ -66,8 +66,8 @@
  * @author Eric Blake <[EMAIL PROTECTED]>
  * @see Member
  * @see Class
- * @see java.lang.Class#getMethod(String,Object[])
- * @see java.lang.Class#getDeclaredMethod(String,Object[])
+ * @see java.lang.Class#getMethod(String,Class[])
+ * @see java.lang.Class#getDeclaredMethod(String,Class[])
  * @see java.lang.Class#getMethods()
  * @see java.lang.Class#getDeclaredMethods()
  * @since 1.1



[cp-patches] FYI: Real double buffering for Swing

2006-02-13 Thread Roman Kennke
I implemented real double buffering for Swing. What does that mean? Up
until now implemented double buffering like this: When painting for a
component starts, it fetches an offscreen image from the RepaintManager,
paints the component to (0,0) and when this is done, the painted area is
copied onto the screen. The next component that is painted does the same
etc. The RepaintManager has exactly one offscreen image available that
is used by all componenents. While this allows for smooth drawing, it
can be done better. Now the RepaintManager manages exactly one offscreen
buffer for each top level window (Window or Applet instance). When a
component fetches the offscreen buffer, it will always get the offscreen
buffer from its toplevel window. Then it draws itself, not to (0,0) but
instead to its real location. When this is done, the other components
also draw themselves in the same manner. When all components are done,
the (updated area of the) offscreen buffer is blitted to the screen all
at once.

This has the following immediate advantage:
- painting operations seem more atomic, each work request in the
RepaintManager performs at most 1 blitting operation per toplevel window
- performance is most likely increased because we need only one blit and
not several (looking at GtkImage.c I would think that we can even
optimize this a little more)

However, there are more advantages:
- Components can now assume that the offscreen buffer still has the state
from the last painting operation. This will allow to optimize JViewport
for example, where we manage an additional back buffer ATM to do double
buffered scrolling. This can now be implemented to directly blit inside
the offscreen buffer from the RepaintManager thus reducing memory
consumption and saving 1 unnecessary blitting operation.
- Uncovering a Window with Swing in it normally triggers an expensive
repaint operation, during which the uncovered Window remains gray. This
can be implemented to blit the offscreen buffer to screen before
starting the repaint (if that is necessary at all then), thus making the
GUI more responsive.

BTW: AFAIK, this feature ('real doublebuffering') will ship with JDK6
for the first time in Sun's JDK. The above mentioned optimization in
JViewport has been solved a little differently in the JDK (they directly
blit from the screen into the Swing backbuffer).

If somebody sees any regressions with that optimization, please ping me.

2006-02-13  Roman Kennke  <[EMAIL PROTECTED]>

* javax/swing/RepaintManager.java
(offscreenBuffers): New field.
(doubleBuffer): Removed field.
(repaintUnderway): New field.
(commitRequests): New field.
(RepaintManager): Initialize new fields.
(paintDirtyRegions): Handle repaintUnderway flag. Commit
buffers when done.
(getOffscreenBuffer): Returns the offscreen buffer for the
corresponding root component.
(commitBuffer): New method.
(commitRemainingBuffers): New method.
* javax/swing/JComponent.java
(paint): Call paintDoubleBuffered with the current clip.
(paintImmediately2): Don't paint on screen here.
(paintDoubleBuffered): Rewritten for real double buffering.
(paintSimple): Draw to screen in this method.

/Roman
Index: javax/swing/JComponent.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v
retrieving revision 1.98
diff -u -r1.98 JComponent.java
--- javax/swing/JComponent.java	6 Feb 2006 13:32:03 -	1.98
+++ javax/swing/JComponent.java	13 Feb 2006 22:28:21 -
@@ -1549,7 +1549,10 @@
 // screen.
 if (!isPaintingDoubleBuffered && isDoubleBuffered()
 && rm.isDoubleBufferingEnabled())
-  paintDoubleBuffered(g);
+  {
+Rectangle clip = g.getClipBounds();
+paintDoubleBuffered(clip);
+  }
 else
   {
 if (g.getClip() == null)
@@ -1750,33 +1753,29 @@
   void paintImmediately2(Rectangle r)
   {
 RepaintManager rm = RepaintManager.currentManager(this);
-Graphics g = getGraphics();
-g.setClip(r.x, r.y, r.width, r.height);
 if (rm.isDoubleBufferingEnabled() && isDoubleBuffered())
-  paintDoubleBuffered(g);
+  paintDoubleBuffered(r);
 else
-  paintSimple(g);
-g.dispose();
+  paintSimple(r);
   }
 
   /**
* Performs double buffered repainting.
-   *
-   * @param g the graphics context to paint to
*/
-  void paintDoubleBuffered(Graphics g)
+  private void paintDoubleBuffered(Rectangle r)
   {
-
-Rectangle r = g.getClipBounds();
-if (r == null)
-  r = new Rectangle(0, 0, getWidth(), getHeight());
 RepaintManager rm = RepaintManager.currentManager(this);
 
 // Paint on the offscreen buffer.
-Image buffer = rm.getOffscreenBuffer(this, getWidth(), getHeight());
+Component root = SwingUtilities.getRoot(this);
+Image buffer = rm.getOffscreenBuffer(this, ro

[cp-patches] FYI: JRootPane fixlet

2006-02-13 Thread Roman Kennke
The JRootPane in Sun's implementation is opaque, so should we do. This
allows for some nice painting optimization (if the root pane isn't
opaque, the painting goes up to the toplevel container, thus jumping out
of Swing and going through the inefficient AWT painting.).

2006-02-13  Roman Kennke  <[EMAIL PROTECTED]>

* javax/swing/JRootPane.java
(JRootPane): Set opaque property to true.

/Roman
Index: javax/swing/JRootPane.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JRootPane.java,v
retrieving revision 1.33
diff -u -r1.33 JRootPane.java
--- javax/swing/JRootPane.java	30 Jan 2006 21:13:42 -	1.33
+++ javax/swing/JRootPane.java	13 Feb 2006 22:13:35 -
@@ -526,6 +526,7 @@
 getGlassPane();
 getLayeredPane();
 getContentPane();
+setOpaque(true);
 updateUI();
   }
 


Re: [cp-patches] Patch: request for approval of serialization related fixes

2006-02-13 Thread Olivier Jolly
>
>
>>The first
>>constructor of the first concrete non serializable super class was
>>selected instead of the first non serializable super class, either
>>concrete or abstract. It is reported in bugzilla as bug 14144 (
>>http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14144 )
>>
>>
>
>Strange. I cannot see why we ever wanted to stop on abstract classes.
>The only requirement seems to be that the first non-serial super class
>has a public no-arg constructor (which we indeed check). Maybe we didn't
>use AllocObject in the past. But we do now.
>
>Note that there is still a comment in the file about this:
>
>// find the first non-serializable, non-abstract
>// class in clazz's inheritance hierarchy
>
>That should be changed to say what the code does now.
>And could you add 2006 to the copyright years in both files?
>
>A good ChangeLog entry for this part would be:
>
>2006-02-12  Olivier Jolly  <[EMAIL PROTECTED]>
>
>   Fixes bug #14144
>* java/io/ObjectInputStream.java (readClassDescriptor):
>Class doesn't have to be abstract for first_nonserial.
>
>If you add Fixes bug #14144 to the CVS commit message (and ChangeLog)
>then cvs will automagically notify bugzilla about the commit related to
>that bug.
>
>  
>

Ok. I made the year changes in the copyright and changed the comment to
reflect the new algorithm.
I'd use the changelog you proposed (with date updated) at commit time.

>>  Those patches will make pass 2 dedicated tests in mauve in
>>java/io/InputOutputStream directory.
>>
>>
>
>Great. And no regressions I assume.
>
>  
>
yes, finally, after hours of struggle with mauve's batch_run and jikes,
I could saw no regression from my own eyes.
I will update the mauve testlet HierarchyTest to make all
compiler-runtime-... combo happy, as discussed on irc.

>Could you report the patches with the suggestions made above and the
>ChangeLog message you want to use. Then I'll add you to the CVS-commit
>list and sent an email about it so you can commit these yourself.
>
>Sorry for the micro-review. Just want to explain everything that goes on
>in detail.
>
>  
>
No problem, I prefer doing few but good work, so I really appreciate any
constructive feedback, especially as a classpath newbie.

>Thanks,
>
>Mark
>  
>
Regards

Olivier
Index: ObjectInputStream.java
===
RCS file: /sources/classpath/classpath/java/io/ObjectInputStream.java,v
retrieving revision 1.74
diff -u -r1.74 ObjectInputStream.java
--- ObjectInputStream.java	6 Feb 2006 11:50:46 -	1.74
+++ ObjectInputStream.java	13 Feb 2006 18:57:08 -
@@ -1,5 +1,5 @@
 /* ObjectInputStream.java -- Class used to read serialized objects
-   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006
Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
@@ -555,8 +555,7 @@
 classLookupTable.put(clazz, osc);
 setBlockDataMode(oldmode);
 
-// find the first non-serializable, non-abstract
-// class in clazz's inheritance hierarchy
+// find the first non-serializable class in clazz's inheritance hierarchy
 Class first_nonserial = clazz.getSuperclass();
 // Maybe it is a primitive class, those don't have a super class,
 // or Object itself.  Otherwise we can keep getting the superclass
@@ -565,9 +564,8 @@
 if (first_nonserial == null)
   first_nonserial = clazz;
 else
-  while (Serializable.class.isAssignableFrom(first_nonserial)
-	 || Modifier.isAbstract(first_nonserial.getModifiers()))
-	first_nonserial = first_nonserial.getSuperclass();
+  while (Serializable.class.isAssignableFrom(first_nonserial))
+first_nonserial = first_nonserial.getSuperclass();
 
 final Class local_constructor_class = first_nonserial;
 
Index: ObjectOutputStream.java
===
RCS file: /sources/classpath/classpath/java/io/ObjectOutputStream.java,v
retrieving revision 1.65
diff -u -r1.65 ObjectOutputStream.java
--- ObjectOutputStream.java	17 Dec 2005 16:29:45 -	1.65
+++ ObjectOutputStream.java	13 Feb 2006 18:56:30 -
@@ -1,5 +1,5 @@
 /* ObjectOutputStream.java -- Class used to write serialized objects
-   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
@@ -421,6 +421,8 @@
 	for (int i = 0; i < intfs.length; i++)
 	  realOutput.writeUTF(intfs[i].getName());
 
+assignNewHandle(osc);
+
 boolean oldmode = setBlockDataMode(true);
 annotateProxyClass(osc.forClass());
 setBlockDataMode(oldmode);


[cp-patches] Re: bootstrap, System.loadLibrary() and Math

2006-02-13 Thread Stuart Ballard
Mark Wielaard  klomp.org> writes:
> The problem is that some runtimes (like cacao and jamvm) dynamically
> load the "javalang" reference library through System.loadLibrary(). But
> we were relying on Math to do this since obviously it cannot be done in
> (VM)System/Runtime directly while those are being initialized.
> 
> I have tried to find a better spot in the bootstrap cycle to do this,
> but couldn't find one. Ideas welcome.
> 
> For now to get things working I just reintroduced the loadLibrary() call
> in the Math static initializer. This should work as before the
> Math/VMMath split even though it is a little ugly.

Another dumb question: Could you just do something like:

public class Math {
  static {
VMMath.initialize();
  }
  ...
}

class VMMath {
  static void initialize() {
System.loadLibrary("javalang");
  }
  ...
}

Or do the timing rules of class initialization make that impossible or
impractical somehow?




Re: [cp-patches] bootstrap, System.loadLibrary() and Math

2006-02-13 Thread Archie Cobbs

Mark Wielaard wrote:

Andrews latest patch showed an interesting bootstrap related regression
in some cases. Simple showcase:

public class TP
{
  public static void main(String[] args)
  {
System.out.println(java.util.TimeZone.getDefault());
  }
}

The problem is that some runtimes (like cacao and jamvm) dynamically
load the "javalang" reference library through System.loadLibrary(). But
we were relying on Math to do this since obviously it cannot be done in
(VM)System/Runtime directly while those are being initialized.

I have tried to find a better spot in the bootstrap cycle to do this,
but couldn't find one. Ideas welcome.

For now to get things working I just reintroduced the loadLibrary() call
in the Math static initializer. This should work as before the
Math/VMMath split even though it is a little ugly.


Dumb question: what's wrong with calling System.loadLibrary() from
within System or Runtime static initializers? Does this cause an
infinite loop? If so what's the loop?

-Archie

__
Archie Cobbs  *CTO, Awarix*  http://www.awarix.com



Re: [cp-patches] FYI: Remove freetype2 configure checks

2006-02-13 Thread Christian Thalinger
On Mon, 2006-02-13 at 21:40 +0100, Christian Thalinger wrote:
> Haven't recompiled the classpath for a long time on darwin, but this
> check is really necessary for darwin.  What was the exact reason to
> remove this?

As Mark suggested on irc, here is the linking error message:

ld: .libs/gnu_java_awt_peer_gtk_GdkTextLayout.o illegal reference to symbol: 
_FT_Done_Glyph defined in indirectly referenced dynamic library 
/opt/local/lib/libfreetype.6.dylib
ld: warning multiple definitions of symbol _locale_charset
/usr/lib/libiconv.dylib(localcharset.o) definition of _locale_charset
/opt/local/lib/libintl.dylib(localcharset.o) definition of _locale_charset
/usr/bin/libtool: internal link edit command failed
make: *** [libgtkpeer.la] Error 1

TWISTI



Re: [cp-patches] FYI: Remove freetype2 configure checks

2006-02-13 Thread Christian Thalinger
On Mon, 2005-11-07 at 14:31 +0100, Mark Wielaard wrote:
> Hi,
> 
> As discussed on the main list the checks for freetype2 are not necessary
> and might break on (really) old gtk+ installations. This patch removes
> them.
> 
> 2005-11-07  Mark Wielaard  <[EMAIL PROTECTED]>
> 
> * configure.ac: Don't check or replace FREETYPE2.
> * native/jni/gtk-peer/Makefile.am: Remove FREETYPE2_LIBS and
> FREETYPE2_CFLAGS.
> 
> Committed,

Haven't recompiled the classpath for a long time on darwin, but this
check is really necessary for darwin.  What was the exact reason to
remove this?

TWISTI



[cp-patches] Patch: FYI: update eclipse build

2006-02-13 Thread Tom Tromey
I'm checking this in.

This updates the eclipse build infrastructure for the recent relaxng
checkin.

Tom

2006-02-13  Tom Tromey  <[EMAIL PROTECTED]>

* .classpath: Updated for external/relaxngDatatype.

Index: .classpath
===
RCS file: /cvsroot/classpath/classpath/.classpath,v
retrieving revision 1.11
diff -u -r1.11 .classpath
--- .classpath  8 Feb 2006 07:35:30 -   1.11
+++ .classpath  13 Feb 2006 20:35:16 -
@@ -1,6 +1,7 @@
 
 
-   
+   
+   






Re: [cp-patches] RFC: Introduction of VMMath

2006-02-13 Thread Mark Wielaard
Hi Andrew,

On Mon, 2006-02-13 at 16:13 +, Andrew John Hughes wrote:
> On Mon, 2006-02-06 at 21:58 +, Andrew John Hughes wrote:
> > I'd welcome any comments on the attached patch,
> > which separates the Math native methods into a separate
> > class, VMMath, so that they can optionally be replaced
> > by the VM.  This fixes PR22198.
> > 
> Committed.

Thanks. Since this is a VM interface change could you update the NEWS
file (and doc/vmintegration.texinfo) to reflect this?

Cheers,

Mark



signature.asc
Description: This is a digitally signed message part


[cp-patches] Re: RFC: gtk+ awt peers (menu) font cleanup

2006-02-13 Thread Thomas Fitzsimmons
On Mon, 2006-02-13 at 16:29 +0100, Mark Wielaard wrote:
> Hi,
> 
> To better understand the gtk+ peers I documented GtkGenericPeer a little
> to make it more clear what should be overridden and why. I also cleaned
> up the setting of fonts of the Menu peers so they look better even when
> the user has set a custom (font) theme. While documenting this change I
> also noticed that the GtkTextFieldPeer was using a custom way to set the
> widget font which was similar to what was already done by
> GtkGenericPeer.
> 
> 2006-02-13  Mark Wielaard  <[EMAIL PROTECTED]>
> 
>* gnu/java/awt/peer/gtk/GtkGenericPeer.java (awtWidget): Made field
>final.
>(gtkWidgetModifyFont(Font)): New protected helper method.
>(gtkWidgetModifyFont(String,int,int)): Made protected and document.
>* gnu/java/awt/peer/gtk/GtkButtonPeer.java (gtkWidgetModifyFont):
>Made protected and document.
>* gnu/java/awt/peer/gtk/GtkCheckboxPeer.java (gtkWidgetModifyFont):
>Likewise.
>* gnu/java/awt/peer/gtk/GtkLabelPeer.java (gtkWidgetModifyFont):
>Likewise.
>* gnu/java/awt/peer/gtk/GtkListPeer.java (gtkWidgetModifyFont):
>Likewise.
>* gnu/java/awt/peer/gtk/GtkMenuBarPeer.java (create): Made protected.
>(setFont): Removed method. Done in GtkMenuComponent.
>* gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java (create): Made
>abstract and protected.
>(setFont): Made private, add implementation.
>(setFont(Font)): Implemented.
>* gnu/java/awt/peer/gtk/GtkMenuItemPeer.java (gtkWidgetModifyFont):
>Made protected and document.
>(create): Made protected.
>(setFont): Removed method. Done in GtkMenuComponent.
>* gnu/java/awt/peer/gtk/GtkTextAreaPeer.java
>(gtkWidgetModifyFont): Made protected and document.
>* gnu/java/awt/peer/gtk/GtkTextFieldPeer.java (gtkWidgetModifyFont):
>Removed, similar to GtkGenericPeer super class implementation.
>* include/gnu_java_awt_peer_gtk_GtkTextFieldPeer.h: Regenerated.
>* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c
>(Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkWidgetModifyFont):
>Removed.
> 
> Comments? OK to commit?

Looks good, please commit.

Thanks,
Tom

> 
> Tested against the vte and some local test programs on both menus and
> textfields to make sure fonts are handles correctly.
> 
> Thanks,
> 
> Mark




[cp-patches] bootstrap, System.loadLibrary() and Math

2006-02-13 Thread Mark Wielaard
Hi,

Andrews latest patch showed an interesting bootstrap related regression
in some cases. Simple showcase:

public class TP
{
  public static void main(String[] args)
  {
System.out.println(java.util.TimeZone.getDefault());
  }
}

The problem is that some runtimes (like cacao and jamvm) dynamically
load the "javalang" reference library through System.loadLibrary(). But
we were relying on Math to do this since obviously it cannot be done in
(VM)System/Runtime directly while those are being initialized.

I have tried to find a better spot in the bootstrap cycle to do this,
but couldn't find one. Ideas welcome.

For now to get things working I just reintroduced the loadLibrary() call
in the Math static initializer. This should work as before the
Math/VMMath split even though it is a little ugly.

2006-02-13  Mark Wielaard  <[EMAIL PROTECTED]>

* java/lang/Math.java (static): Explicitly call
System.loadLibrary("javalang").

Committed,

Mark
Index: java/lang/Math.java
===
RCS file: /cvsroot/classpath/classpath/java/lang/Math.java,v
retrieving revision 1.20
diff -u -r1.20 Math.java
--- java/lang/Math.java	13 Feb 2006 16:12:53 -	1.20
+++ java/lang/Math.java	13 Feb 2006 18:43:44 -
@@ -57,6 +57,21 @@
  */
 public final class Math
 {
+
+  // FIXME - This is here because we need to load the "javalang" system
+  // library somewhere late in the bootstrap cycle. We cannot do this
+  // from VMSystem or VMRuntime since those are used to actually load
+  // the library. This is mainly here because historically Math was
+  // late enough in the bootstrap cycle to start using System after it
+  // was initialized (called from the java.util classes).
+  static
+  {
+if (Configuration.INIT_LOAD_LIBRARY)
+  {
+System.loadLibrary("javalang");
+  }
+  }
+
   /**
* Math is non-instantiable
*/


signature.asc
Description: This is a digitally signed message part


[cp-patches] FYI: New file for javax.print

2006-02-13 Thread Wolfgang Baer
Hi,

changelog says all.

2006-02-13  Wolfgang Baer  <[EMAIL PROTECTED]>

* javax/print/StreamPrintServiceFactory.java: New file.

Wolfgang

/* StreamPrintServiceFactory.java -- 
   Copyright (C) 2006 Free Software Foundation, Inc.

This file is part of GNU Classpath.

GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version. */


package javax.print;

import gnu.classpath.ServiceFactory;

import java.io.OutputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;

/**
 * StreamPrintServiceFactory provides a static method to lookup 
 * registered factories to construct StreamPrintService instances.
 * 
 * StreamPrintService are used to print into a provided output 
 * stream in the document format provided by the stream print service 
 * implementation.
 * 
 * Implementations are located and loaded automatically through the SPI JAR 
 * file specification. Therefore implementation classes must provide a default 
 * constructor for instantiation.
 * 
 * 
 * @author Wolfgang Baer ([EMAIL PROTECTED])
 */
public abstract class StreamPrintServiceFactory
{   
  /**
   * Default public constructor.
   * Used for automatic loading and instantiation through 
   * the SPI jar file specification.
   */
  public StreamPrintServiceFactory()
  {
// nothing to do
  }
  
  /**
   * Searches for matching factories providing stream print services that  
   * support the printing of documents with the given document flavor into 
   * the given output mime type.
   * 
   * @param flavor the document flavor needed, null doesn't 
   * constrain the lookup result.
   * @param outputMimeType the mime type needed, null doesn't 
   * constrain the lookup result.
   * 
   * @return The matching StreamPrintServiceFactory instances.
   */
  public static StreamPrintServiceFactory[] lookupStreamPrintServiceFactories(
DocFlavor flavor, String outputMimeType)
  {
HashSet set = new HashSet();

Iterator it = 
  ServiceFactory.lookupProviders(StreamPrintServiceFactory.class);

while (it.hasNext())
  {
StreamPrintServiceFactory tmp = (StreamPrintServiceFactory) it.next();
if (tmp.getOutputFormat().equals(outputMimeType)
&& Arrays.asList(tmp.getSupportedDocFlavors()).contains(flavor))
  set.add(tmp);  
  }

StreamPrintServiceFactory[] tmp = new StreamPrintServiceFactory[set.size()];
return (StreamPrintServiceFactory[]) set.toArray(tmp);  
  } 
  
  /**
   * Returns the output format supported by this factory.
   * 
   * @return The mime type of the output format as string representation.
   */
  public abstract String getOutputFormat();
  
  /**
   * Returns the document flavors this factory supports as flavors
   * for the input documents.
   * 
   * @return The array of supported document flavors.
   */
  public abstract DocFlavor[] getSupportedDocFlavors();
  
  /**
   * Constructs a StreamPrintService which directs its output
   * the given output stream.
   * 
   * @param out the output stream for the produced document.
   * @return The constructed stream print service.
   */
  public abstract StreamPrintService getPrintService(OutputStream out);
}


[cp-patches] Patch: FYI: another .cvsignore update

2006-02-13 Thread Tom Tromey
I'm checking this in.

I'm not sure how I missed this earlier... this adds another
.cvsignore entry in the tools directory.

Tom

2006-02-13  Tom Tromey  <[EMAIL PROTECTED]>

* tools/.cvsignore: Added Makefile.

Index: tools/.cvsignore
===
RCS file: /cvsroot/classpath/classpath/tools/.cvsignore,v
retrieving revision 1.1
diff -u -r1.1 .cvsignore
--- tools/.cvsignore8 Feb 2006 20:52:31 -   1.1
+++ tools/.cvsignore13 Feb 2006 17:47:21 -
@@ -1 +1,2 @@
 Makefile.in
+Makefile



[cp-patches] FYI: Formatted some files in java.awt.print

2006-02-13 Thread Wolfgang Baer
Hi,

I formatted the files in java.awt.print which didn't follow
our coding style.

2006-02-13  Wolfgang Baer  <[EMAIL PROTECTED]>

* java/awt/print/PrinterGraphics.java: Reformatted.
* java/awt/print/Paper.java: Likewise.
* java/awt/print/PageFormat.java: Likewise.
* java/awt/print/Pageable.java: Likewise.

Wolfgang




[cp-patches] Patch: BorderLayout fix

2006-02-13 Thread Lillian Angel
Some of the problems I have had with Panels stemmed from BorderLayout.
Many things were not being painted because the size was set incorrectly.

This is now fixed.

2006-02-13  Lillian Angel  <[EMAIL PROTECTED]>

* java/awt/BorderLayout.java
(layoutContainer): Rewrote part of this function to
properly set the bounds of the components.
(setBounds): Removed method, not needed.

Index: java/awt/BorderLayout.java
===
RCS file: /sources/classpath/classpath/java/awt/BorderLayout.java,v
retrieving revision 1.22
diff -u -r1.22 BorderLayout.java
--- java/awt/BorderLayout.java	6 Dec 2005 16:30:03 -	1.22
+++ java/awt/BorderLayout.java	13 Feb 2006 17:27:22 -
@@ -460,27 +460,30 @@
   }
 
   /**
-   * Lays out the specified container according to the constraints
-   * in this object.
-   *
+   * Lays out the specified container according to the constraints in this
+   * object.
+   * 
* @param target The container to lay out.
*/
   public void layoutContainer(Container target)
   {
-synchronized (target.getTreeLock ())
+synchronized (target.getTreeLock())
   {
 Insets i = target.getInsets();
+int top = i.top;
+int bottom = target.height - i.bottom;
+int left = i.left;
+int right = target.width - i.right;
 
-ComponentOrientation orient = target.getComponentOrientation ();
-boolean left_to_right = orient.isLeftToRight ();
+boolean left_to_right = target.getComponentOrientation().isLeftToRight();
 
 Component my_north = north;
 Component my_east = east;
 Component my_south = south;
 Component my_west = west;
 
-// Note that we currently don't handle vertical layouts.  Neither
-// does JDK 1.3.
+// FIXME: Note that we currently don't handle vertical layouts.
+// Neither does JDK 1.3.
 if (firstLine != null)
   my_north = firstLine;
 if (lastLine != null)
@@ -500,65 +503,42 @@
   my_west = lastItem;
   }
 
-Dimension c = calcCompSize(center, PREF);
-Dimension n = calcCompSize(my_north, PREF);
-Dimension s = calcCompSize(my_south, PREF);
-Dimension e = calcCompSize(my_east, PREF);
-Dimension w = calcCompSize(my_west, PREF);
-int targetWidth = target.getWidth();
-int targetHeight = target.getHeight();
-
-/*
-	<-> hgap <-> hgap
-	++  }
-	|t   |  } i.top
-	|  +--+  |  --- y1  }
-	|  |n |  |
-	|  +--+  |  } vgap
-	|  +---+ +--+ +---+  |  --- y2  }}
-	|  |w  | |c | |e  |  |   } hh
-	|  +---+ +--+ +---+  |  } vgap   }
-	|  +--+  |  --- y3  }
-	|  |s |  |
-	|  +--+  |  }
-	||  } i.bottom
-	++  }
-	|x1   |x2  |x3
-	<-->
-	<--> ww   <-->
-	i.lefti.right
-*/
-
-int x1 = i.left;
-int x2 = x1 + w.width + (w.width == 0 ? 0 : hgap);
-int x3;
-if (targetWidth <= i.right + e.width)
-  x3 = x2 + w.width + (w.width == 0 ? 0 : hgap);
-else
-  x3 = targetWidth - i.right - e.width;
-int ww = targetWidth - i.right - i.left;
+if (my_north != null)
+  {
+Dimension n = calcCompSize(my_north, PREF);
+my_north.setBounds(left, top, right - left, n.height);
+top += n.height + vgap;
+  }
 
-int y1 = i.top;
-int y2 = y1 + n.height + (n.height == 0 ? 0 : vgap);
-int midh = Math.max(e.height, Math.max(w.height, c.height));
-int y3;
-if (targetHeight <= i.bottom + s.height)
-  y3 = y2 + midh + vgap;
-else
-  y3 = targetHeight - i.bottom - s.height;
-int hh = y3-y2-(s.height == 0 ? 0 : vgap);
+if (my_south != null)
+  {
+Dimension s = calcCompSize(my_south, PREF);
+my_south.setBounds(left, bottom - s.height, right - left, s.height);
+bottom -= s.height + vgap;
+  }
 
-setBounds(center, x2, y2, x3-x2-(w.width == 0 ? 0 : hgap), hh);
-setBounds(my_north, x1, y1, ww, n.height);
-setBounds(my_south, x1, y3, ww, s.height);
-setBounds(my_west, x1, y2, w.width, hh);
-setBounds(my_east, x3, y2, e.width, hh);
+if (my_east != null)
+  {
+Dimension e = calcCompSize(my_east, PREF);
+my_east.setBounds(right - e.width, top, e.width, bottom - top);
+right -= e.width + hgap;
+  }
+
+if (my_west != null)
+  {
+Dimension w = calcCompSize(my_west, PR

Re: [cp-patches] FYI: ElementBuffer.clone

2006-02-13 Thread Roman Kennke
Hi Tony,

Am 13.2.2006 schrieb "Anthony Balkissoon" <[EMAIL PROTECTED]>:

>On Fri, 2006-02-10 at 15:10 +, Roman Kennke wrote:
>> I added the missing ElementBuffer.clone() method.
>>
>> 2006-02-10  Roman Kennke  <[EMAIL PROTECTED]>
>>
>> * javax/swing/text/DefaultStyledDocument.java
>> (ElementBuffer.clone): New method.
>
>I don't understand ... I implemented this method on November 8, 2005 and
>committed the ChangeLog and sent an email to this list ... did I forget
>to commit the actual change or something?
>
>Oh I see now...it was in the wrong place, not in the inner ElementBuffer
>class.  Wups.

:-)

>Roman, comparing the one I wrote to the one you wrote, I think your
>second argument to replace is wrong ... no Elements are being removed
>here since the just-created BranchElement has no children.  I think it
>should be branchClone.replace(0, 0, cloneChildren).

Of course you are right. This came from my playing around with clone().
My first attempt tried to clone() the elements and then call replace()
which would have needed to first remove some children. Unfortunately
this does not work because we are not allowed to call clone() on an
interface (Element). So I wrote special impls for the know classes. BTW,
we should add SectionElement (and maybe even some text.html element
impls?), so that they are created using the correct type.


>If you agree, can you fix this?  And could you remove the one I wrote at
>the same time?

Both committed using the attached fix.

2006-02-13  Roman Kennke  <[EMAIL PROTECTED]>

* javax/swing/text/DefaultStyledDocument.java
(ElementBuffer.clone): Fixed replace call.
(clone): Removed method.

/Roman
Index: javax/swing/text/DefaultStyledDocument.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultStyledDocument.java,v
retrieving revision 1.60
diff -u -r1.60 DefaultStyledDocument.java
--- javax/swing/text/DefaultStyledDocument.java	10 Feb 2006 15:09:55 -	1.60
+++ javax/swing/text/DefaultStyledDocument.java	13 Feb 2006 17:19:56 -
@@ -671,7 +671,7 @@
   cloneChildren[i] = clone(branchClone,
branchClone.getElement(i));
 }
-  branchClone.replace(0, numChildren, cloneChildren);
+  branchClone.replace(0, 0, cloneChildren);
   clone = branchClone;
 }
   else if (clonee instanceof LeafElement)
@@ -1437,40 +1437,6 @@
 
 return curr;
   }
-
-  /**
-   * Creates a copy of the element clonee that has the parent
-   * parent.
-   * 
-   * @param parent
-   *  the parent of the newly created Element
-   * @param clonee
-   *  the Element to clone
-   * @return the cloned Element
-   */
-  public Element clone(Element parent, Element clonee)
-  {
-// If the Element we want to clone is a leaf, then simply copy it
-if (clonee.isLeaf())
-  return createLeafElement(parent, clonee.getAttributes(),
-   clonee.getStartOffset(), clonee.getEndOffset());
-
-// Otherwise create a new BranchElement with the desired parent and
-// the clonee's attributes
-BranchElement result = (BranchElement) createBranchElement(
-   parent,
-   clonee.getAttributes());
-
-// And clone all the of clonee's children
-Element[] children = new Element[clonee.getElementCount()];
-for (int i = 0; i < children.length; i++)
-  children[i] = clone(result, clonee.getElement(i));
-
-// Make the cloned children the children of the BranchElement
-result.replace(0, 0, children);
-return result;
-  }
-
   /**
* Instance of all editing information for an object in the Vector. This class
* is used to add information to the DocumentEvent associated with an


[cp-patches] FYI: UnicastRemoteObject reformatted

2006-02-13 Thread Roman Kennke
While I'm at it, this fixes the strange formatting in
UnicastRemoteObject.

2006-02-13  Roman Kennke  <[EMAIL PROTECTED]>

* java/rmi/server/UnicastRemoteObject.java: Reformatted.

/Roman
Index: java/rmi/server/UnicastRemoteObject.java
===
RCS file: /cvsroot/classpath/classpath/java/rmi/server/UnicastRemoteObject.java,v
retrieving revision 1.11
diff -u -r1.11 UnicastRemoteObject.java
--- java/rmi/server/UnicastRemoteObject.java	13 Feb 2006 17:02:02 -	1.11
+++ java/rmi/server/UnicastRemoteObject.java	13 Feb 2006 17:14:25 -
@@ -46,58 +46,75 @@
 
 public class UnicastRemoteObject extends RemoteServer
 {
-private static final long serialVersionUID = 4974527148936298033L;
-//The following serialized fields are from Java API Documentation "Serialized form"
-private int port = 0;
-private RMIClientSocketFactory csf = null;
-private RMIServerSocketFactory ssf = null;
+  private static final long serialVersionUID = 4974527148936298033L;
 
-protected UnicastRemoteObject() throws RemoteException {
+  //The following serialized fields are from Java API Documentation
+  // "Serialized form"
+  private int port = 0;
+  private RMIClientSocketFactory csf = null;
+  private RMIServerSocketFactory ssf = null;
+
+  protected UnicastRemoteObject()
+throws RemoteException
+  {
 	this(0);
-}
+  }
 
-protected UnicastRemoteObject(int port) throws RemoteException {
-	this(port, RMISocketFactory.getSocketFactory(), RMISocketFactory.getSocketFactory());
-}
+  protected UnicastRemoteObject(int port)
+throws RemoteException
+  {
+	this(port, RMISocketFactory.getSocketFactory(),
+ RMISocketFactory.getSocketFactory());
+  }
 
-protected UnicastRemoteObject(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws RemoteException {
-  this.port = port;
-  //Is RMIXXXSocketFactory serializable
-  //this.csf = csf;
-  //this.ssf = ssf;
-  this.ref = new UnicastServerRef(new ObjID(), port, ssf);
-  exportObject(this);
-}
+  protected UnicastRemoteObject(int port, RMIClientSocketFactory csf,
+RMIServerSocketFactory ssf)
+throws RemoteException
+  {
+this.port = port;
+//Is RMIXXXSocketFactory serializable
+//this.csf = csf;
+//this.ssf = ssf;
+this.ref = new UnicastServerRef(new ObjID(), port, ssf);
+exportObject(this);
+  }
 
-protected UnicastRemoteObject(RemoteRef ref) throws RemoteException {
-	super((UnicastServerRef)ref);
+  protected UnicastRemoteObject(RemoteRef ref)
+throws RemoteException
+  {
+	super((UnicastServerRef) ref);
 	exportObject(this);
-}
+  }
 
-public Object clone() throws CloneNotSupportedException {
+  public Object clone()
+throws CloneNotSupportedException
+  {
 	throw new Error("Not implemented");
-}
+  }
 
-public static RemoteStub exportObject(Remote obj) throws RemoteException {
+  public static RemoteStub exportObject(Remote obj)
+throws RemoteException
+  {
 	return (RemoteStub) exportObject(obj, 0);
-}
+  }
 
-  public static Remote exportObject(Remote obj, int port) throws RemoteException 
+  public static Remote exportObject(Remote obj, int port)
+throws RemoteException
   {
 return exportObject(obj, port, null);
   }
-  
+
   static Remote exportObject(Remote obj, int port, RMIServerSocketFactory ssf) 
-throws RemoteException 
+throws RemoteException
   {
 UnicastServerRef sref = null;
 if (obj instanceof RemoteObject)
-  sref = (UnicastServerRef)((RemoteObject)obj).getRef ();
-if(sref == null)
-  {
-	sref = new UnicastServerRef(new ObjID (), port, ssf);
-  }
-Remote stub = sref.exportObject (obj); 
+  sref = (UnicastServerRef) ((RemoteObject) obj).getRef();
+
+if (sref == null)
+  sref = new UnicastServerRef(new ObjID(), port, ssf);
+
+Remote stub = sref.exportObject(obj);
 addStub(obj, stub);
 return stub;
   }
@@ -105,8 +122,9 @@
   /**
* FIXME
*/
-  public static Remote exportObject(Remote obj, int port, RMIClientSocketFactory csf, 
-RMIServerSocketFactory ssf) 
+  public static Remote exportObject(Remote obj, int port,
+RMIClientSocketFactory csf,
+RMIServerSocketFactory ssf)
 throws RemoteException 
   {
 return (exportObject(obj, port, ssf));
@@ -117,14 +135,15 @@
   {
 if (obj instanceof RemoteObject)
   {
-	deleteStub(obj);
-	UnicastServerRef sref = (UnicastServerRef)((RemoteObject)obj).getRef();
-	return sref.unexportObject(obj, force);
+deleteStub(obj);
+UnicastServerRef sref =
+  (UnicastServerRef) ((RemoteObject) obj).getRef();
+return sref.unexportObject(obj, force);
   }
 else
   {
-	//FIX ME
-	;
+// FIXME
+;
   }
 return true;
   }


Re: [cp-patches] FYI: ElementBuffer.clone

2006-02-13 Thread Anthony Balkissoon
On Fri, 2006-02-10 at 15:10 +, Roman Kennke wrote:
> I added the missing ElementBuffer.clone() method.
> 
> 2006-02-10  Roman Kennke  <[EMAIL PROTECTED]>
> 
> * javax/swing/text/DefaultStyledDocument.java
> (ElementBuffer.clone): New method.

I don't understand ... I implemented this method on November 8, 2005 and
committed the ChangeLog and sent an email to this list ... did I forget
to commit the actual change or something?

Oh I see now...it was in the wrong place, not in the inner ElementBuffer
class.  Wups.

Roman, comparing the one I wrote to the one you wrote, I think your
second argument to replace is wrong ... no Elements are being removed
here since the just-created BranchElement has no children.  I think it
should be branchClone.replace(0, 0, cloneChildren).  

If you agree, can you fix this?  And could you remove the one I wrote at
the same time?

--Tony




[cp-patches] FYI: UnicastRemoteObject fix

2006-02-13 Thread Roman Kennke
Here comes a fix for UnicastRemoteObject.exportObject(Remote). This
method used to do strange things, including a cast from the argument to
RemoteObject, which my application here did not like (because it was not
an instance of RemoteObject that was passed as argument). It occured to
me that the fix would be to forward this to exportObject(Remote,0),
which made my application happy. Committed as follows:

2006-02-13  Roman Kennke  <[EMAIL PROTECTED]>

* java/rmi/server/UnicastRemoteObject.java
(exportObject(Remote)): Forward method call to export(Remote,int).

/Roman
Index: java/rmi/server/UnicastRemoteObject.java
===
RCS file: /cvsroot/classpath/classpath/java/rmi/server/UnicastRemoteObject.java,v
retrieving revision 1.10
diff -u -r1.10 UnicastRemoteObject.java
--- java/rmi/server/UnicastRemoteObject.java	2 Jul 2005 20:32:40 -	1.10
+++ java/rmi/server/UnicastRemoteObject.java	13 Feb 2006 17:00:22 -
@@ -79,8 +79,7 @@
 }
 
 public static RemoteStub exportObject(Remote obj) throws RemoteException {
-	UnicastServerRef sref = (UnicastServerRef)((RemoteObject)obj).getRef();
-	return (sref.exportObject(obj));
+	return (RemoteStub) exportObject(obj, 0);
 }
 
   public static Remote exportObject(Remote obj, int port) throws RemoteException 


Re: [cp-patches] RFC: Introduction of VMMath

2006-02-13 Thread Andrew John Hughes
On Mon, 2006-02-06 at 21:58 +, Andrew John Hughes wrote:
> I'd welcome any comments on the attached patch,
> which separates the Math native methods into a separate
> class, VMMath, so that they can optionally be replaced
> by the VM.  This fixes PR22198.
> 
> I also have code for most of the new Math methods here
> as well.  However, I've had some problems in using the methods
> for these in fdlibm.  Namely,
> 
> a) Existing methods such as sinh produce a linking error for
> ClasspathSinH or something like that which seems to be something
> to do with namespace.h.
> 
> b) Two of the methods require an update from 5.1 to 5.3 of fdlibm.
> Merely adding the two new c files to Makefile.am didn't seem to work
> (they don't seem to be being built).  The methods are log1p and expm1.
> 
> I'd appreciate some info. from anyone who knows how fdlibm works with
> Classpath.  At worst, I can simply commit the code I have and someone
> else can link these in, but it would be nice to know how to do this.
> I'm guessing that mprec is separate from fdlibm although it appears in
> the same directory; I recall there was talk of an update of this as well
> to probably handle 64-bit support.
> 
> Changelog:
> 
> 2006-02-06  Andrew John Hughes  <[EMAIL PROTECTED]>
> 
>   * include/Makefile.am:
>   Swapped Math.h for VMMath.h
>   * include/java_lang_Math.h:
>   Removed.
>   * include/java_lang_VMMath.h:
>   New autogenerated header for the new class.
>   * java/lang/Math.java:
>   (sin(double)): Changed to link to VMMath.
>   (cos(double)): Changed to link to VMMath.
>   (tan(double)): Changed to link to VMMath.
>   (asin(double)): Changed to link to VMMath.
>   (acos(double)): Changed to link to VMMath.
>   (atan(double)): Changed to link to VMMath.
>   (atan2(double)): Changed to link to VMMath.
>   (exp(double)): Changed to link to VMMath.
>   (log(double)): Changed to link to VMMath.
>   (sqrt(double)): Changed to link to VMMath.
>   (pow(double,double)): Changed to link to VMMath.
>   (IEEEremainder(double,double)): Changed to link to VMMath.
>   (ceil(double)): Changed to link to VMMath.
>   (floor(double)): Changed to link to VMMath.
>   (rint(double)): Changed to link to VMMath.
>   * native/jni/java-lang/Makefile.am:
>   Replaced java_lang_Math.c with java_lang_VMMath.c
>   * native/jni/java-lang/java_lang_Math.c:
>   Removed.
>   * native/jni/java-lang/java_lang_VMMath.c:
>   Renamed from java_lang_Math.c.
>   * vm/reference/java/lang/VMMath.java:
>   New class.
>   (sin(double)): New native method.
>   (cos(double)): New native method.
>   (tan(double)): New native method.
>   (asin(double)): New native method.
>   (acos(double)): New native method.
>   (atan(double)): New native method.
>   (atan2(double)): New native method.
>   (exp(double)): New native method.
>   (log(double)): New native method.
>   (sqrt(double)): New native method.
>   (pow(double,double)): New native method.
>   (IEEEremainder(double,double)): New native method.
>   (ceil(double)): New native method.
>   (floor(double)): New native method.
>   (rint(double)): New native method.
> 
Committed.
-- 
Andrew :-)

Please avoid sending me Microsoft Office (e.g. Word, PowerPoint) attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
Support OpenDocument instead. http://opendocumentfellowship.org

Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html
public class gcj extends Freedom implements Java { ... }

"Value your freedom, or you will lose it, teaches history.
`Don't bother us with politics' respond those who don't want to learn."
-- Richard Stallman





[cp-patches] RFC: gtk+ awt peers (menu) font cleanup

2006-02-13 Thread Mark Wielaard
Hi,

To better understand the gtk+ peers I documented GtkGenericPeer a little
to make it more clear what should be overridden and why. I also cleaned
up the setting of fonts of the Menu peers so they look better even when
the user has set a custom (font) theme. While documenting this change I
also noticed that the GtkTextFieldPeer was using a custom way to set the
widget font which was similar to what was already done by
GtkGenericPeer.

2006-02-13  Mark Wielaard  <[EMAIL PROTECTED]>

   * gnu/java/awt/peer/gtk/GtkGenericPeer.java (awtWidget): Made field
   final.
   (gtkWidgetModifyFont(Font)): New protected helper method.
   (gtkWidgetModifyFont(String,int,int)): Made protected and document.
   * gnu/java/awt/peer/gtk/GtkButtonPeer.java (gtkWidgetModifyFont):
   Made protected and document.
   * gnu/java/awt/peer/gtk/GtkCheckboxPeer.java (gtkWidgetModifyFont):
   Likewise.
   * gnu/java/awt/peer/gtk/GtkLabelPeer.java (gtkWidgetModifyFont):
   Likewise.
   * gnu/java/awt/peer/gtk/GtkListPeer.java (gtkWidgetModifyFont):
   Likewise.
   * gnu/java/awt/peer/gtk/GtkMenuBarPeer.java (create): Made protected.
   (setFont): Removed method. Done in GtkMenuComponent.
   * gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java (create): Made
   abstract and protected.
   (setFont): Made private, add implementation.
   (setFont(Font)): Implemented.
   * gnu/java/awt/peer/gtk/GtkMenuItemPeer.java (gtkWidgetModifyFont):
   Made protected and document.
   (create): Made protected.
   (setFont): Removed method. Done in GtkMenuComponent.
   * gnu/java/awt/peer/gtk/GtkTextAreaPeer.java
   (gtkWidgetModifyFont): Made protected and document.
   * gnu/java/awt/peer/gtk/GtkTextFieldPeer.java (gtkWidgetModifyFont):
   Removed, similar to GtkGenericPeer super class implementation.
   * include/gnu_java_awt_peer_gtk_GtkTextFieldPeer.h: Regenerated.
   * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c
   (Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkWidgetModifyFont):
   Removed.

Comments? OK to commit?

Tested against the vte and some local test programs on both menus and
textfields to make sure fonts are handles correctly.

Thanks,

Mark
Index: include/gnu_java_awt_peer_gtk_GtkTextFieldPeer.h
===
RCS file: /cvsroot/classpath/classpath/include/gnu_java_awt_peer_gtk_GtkTextFieldPeer.h,v
retrieving revision 1.11
diff -u -r1.11 gnu_java_awt_peer_gtk_GtkTextFieldPeer.h
--- include/gnu_java_awt_peer_gtk_GtkTextFieldPeer.h	4 Jul 2005 23:56:36 -	1.11
+++ include/gnu_java_awt_peer_gtk_GtkTextFieldPeer.h	13 Feb 2006 15:18:59 -
@@ -23,7 +23,6 @@
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_setEditable (JNIEnv *env, jobject, jboolean);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_setText (JNIEnv *env, jobject, jstring);
 JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkEntryGetBorderWidth (JNIEnv *env, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkWidgetModifyFont (JNIEnv *env, jobject, jstring, jint, jint);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_setEchoChar (JNIEnv *env, jobject, jchar);
 
 #ifdef __cplusplus
Index: gnu/java/awt/peer/gtk/GtkButtonPeer.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkButtonPeer.java,v
retrieving revision 1.39
diff -u -r1.39 GtkButtonPeer.java
--- gnu/java/awt/peer/gtk/GtkButtonPeer.java	15 Aug 2005 04:14:29 -	1.39
+++ gnu/java/awt/peer/gtk/GtkButtonPeer.java	13 Feb 2006 15:18:59 -
@@ -1,5 +1,5 @@
 /* GtkButtonPeer.java -- Implements ButtonPeer with GTK
-   Copyright (C) 1998, 1999, 2004  Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2004, 2006  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -57,7 +57,10 @@
 
   public native void connectSignals ();
 
-  native void gtkWidgetModifyFont (String name, int style, int size);
+  /**
+   * Overridden to set Font of Label inside Button inside EventBox.
+   */
+  protected native void gtkWidgetModifyFont(String name, int style, int size);
   native void gtkSetLabel (String label);
   native void gtkWidgetSetForeground (int red, int green, int blue);
   native void gtkWidgetSetBackground (int red, int green, int blue);
Index: gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java,v
retrieving revision 1.22
diff -u -r1.22 GtkCheckboxPeer.java
--- gnu/java/awt/peer/gtk/GtkCheckboxPeer.java	18 Aug 2005 01:22:00 -	1.22
+++ gnu/java/awt/peer/gtk/GtkCheckboxPeer.java	13 Feb 2006 15:18:59 -
@@ -1,5 +1,5 @@
 /* GtkCheckboxPeer.java -- Implements CheckboxPeer with GTK
-   Copyright (C) 1998, 1999, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2002, 2003, 2006 Fr

Re: [cp-patches] FYI: Component, GtkPanelPeer, GtkWindowPeer

2006-02-13 Thread Lillian Angel
Hi Roman,

> >unless you
> want to revert it again ;-) I'll go and find the application that had a
> problem with that and reinvestigate. Sorry for unnecessarily bugging
> you.

Done.

2006-02-13  Lillian Angel  <[EMAIL PROTECTED]>

* java/awt/Component.java
(repaint): No need to call isShowing, it is done in the other 
repaint call.
(repaint): Likewise.
(repaint): Likewise.

Index: java/awt/Component.java
===
RCS file: /sources/classpath/classpath/java/awt/Component.java,v
retrieving revision 1.95
diff -u -r1.95 Component.java
--- java/awt/Component.java	7 Feb 2006 11:36:08 -	1.95
+++ java/awt/Component.java	9 Feb 2006 21:57:37 -
@@ -1882,8 +1882,7 @@
*/
   public void repaint()
   {   
-if (isShowing())
-  repaint(0, 0, 0, width, height);
+repaint(0, 0, 0, width, height);
   }
 
   /**
@@ -1897,8 +1896,7 @@
*/
   public void repaint(long tm)
   {
-if (isShowing())
-  repaint(tm, 0, 0, width, height);
+repaint(tm, 0, 0, width, height);
   }
 
   /**
@@ -1915,8 +1913,7 @@
*/
   public void repaint(int x, int y, int w, int h)
   {
-if (isShowing())
-  repaint(0, x, y, w, h);
+repaint(0, x, y, w, h);
   }
 
   /**
 


Re: [cp-patches] Patch: Component, GtkPanelPeer, GtkWindowPeer

2006-02-13 Thread Roman Kennke
Hi Lillian,

Am Montag, den 13.02.2006, 09:57 -0500 schrieb Lillian Angel:
> On Mon, 2006-02-13 at 15:48 +0100, Roman Kennke wrote:
> > Hi Lillian,
> > 
> > Am Montag, den 13.02.2006, 09:34 -0500 schrieb Lillian Angel:
> > > Small fixes. 
> > > The repaint functions in Component were slightly inefficient, I fixed
> > > this. 
> > 
> > Actually these repaint calls where a bit more efficient since they avoid
> > unnecessary method calls. However, I would like you to revert the
> > changes on Component for a different reason, I once made it so because I
> > had an application that has overridden one of the repaint methods and
> > produced strange behaviour because it got called when the component was
> > not actually showing. I think I even have made a Mauve test for this
> > (must check, otherwise I can quickly make one).

Now I did make a Mauve test and it shows that you were actually right.
Aaaarg. Now you already reverted that patch. Sorry about that. So my
application must have a different problem. I suggest that we leave it as
it is now (I think it is slightly more efficient in the not-showing case
and slightly less efficient in the showing case but anyway), unless you
want to revert it again ;-) I'll go and find the application that had a
problem with that and reinvestigate. Sorry for unnecessarily bugging
you.

/Roman



signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


[cp-patches] RFC: ZipFile optimizations

2006-02-13 Thread Jeroen Frijters
Hi,

I noticed that ZipFile currently doesn't use any buffering when reading
the zip file directory, so I would like to propose the attached patch to
fix this. For me this significantly increases performance of reading the
zip directory.

In addition to the buffering tweaks, this patch also fixes the
following:
- PartialInputStream.read(byte[],int,int) has the following bug:
  if (count > 0)
filepos += len;
  (filepos should be incremented by count, not len)
- readEntries() no longer scans the entire file if it is not a valid zip
(and since the scanning is now buffered it is much faster anyway)
- checkLocalHeader() compared the length of the name string with the
encoded length in the zip file, but since the name is utf-8 encoded, the
lengths may differ, so we shouldn't do this check.

Please comment.

Regards,
Jeroen
Index: java/util/zip/ZipFile.java
===
RCS file: /cvsroot/classpath/classpath/java/util/zip/ZipFile.java,v
retrieving revision 1.27
diff -u -r1.27 ZipFile.java
--- java/util/zip/ZipFile.java  16 Sep 2005 01:07:21 -  1.27
+++ java/util/zip/ZipFile.java  13 Feb 2006 14:59:52 -
@@ -1,5 +1,5 @@
 /* ZipFile.java --
-   Copyright (C) 2001, 2002, 2003, 2004, 2005
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
@@ -41,8 +41,6 @@
 
 import gnu.java.util.EmptyEnumeration;
 
-import java.io.BufferedInputStream;
-import java.io.DataInput;
 import java.io.EOFException;
 import java.io.File;
 import java.io.IOException;
@@ -141,23 +139,33 @@
 checkZipFile();
   }
 
-  private void checkZipFile() throws IOException, ZipException
+  private void checkZipFile() throws ZipException
   {
-byte[] magicBuf = new byte[4];
-boolean validRead = true;
+boolean valid = false;
 
 try 
   {
-   raf.readFully(magicBuf);
-  } 
-catch (EOFException eof) 
+byte[] buf = new byte[4];
+raf.readFully(buf);
+int sig = buf[0] & 0xFF
+| ((buf[1] & 0xFF) << 8)
+| ((buf[2] & 0xFF) << 16)
+| ((buf[3] & 0xFF) << 24);
+valid = sig == LOCSIG;
+  }
+catch (IOException _)
   {
-   validRead = false;
   } 
 
-if (validRead == false || readLeInt(magicBuf, 0) != LOCSIG)
+if (!valid)
   {
-   raf.close();
+try
+  {
+   raf.close();
+  }
+catch (IOException _)
+  {
+  }
throw new ZipException("Not a valid zip file");
   }
   }
@@ -172,69 +180,6 @@
   }
 
   /**
-   * Read an unsigned short in little endian byte order from the given
-   * DataInput stream using the given byte buffer.
-   *
-   * @param di DataInput stream to read from.
-   * @param b the byte buffer to read in (must be at least 2 bytes long).
-   * @return The value read.
-   *
-   * @exception IOException if a i/o error occured.
-   * @exception EOFException if the file ends prematurely
-   */
-  private int readLeShort(DataInput di, byte[] b) throws IOException
-  {
-di.readFully(b, 0, 2);
-return (b[0] & 0xff) | (b[1] & 0xff) << 8;
-  }
-
-  /**
-   * Read an int in little endian byte order from the given
-   * DataInput stream using the given byte buffer.
-   *
-   * @param di DataInput stream to read from.
-   * @param b the byte buffer to read in (must be at least 4 bytes long).
-   * @return The value read.
-   *
-   * @exception IOException if a i/o error occured.
-   * @exception EOFException if the file ends prematurely
-   */
-  private int readLeInt(DataInput di, byte[] b) throws IOException
-  {
-di.readFully(b, 0, 4);
-return ((b[0] & 0xff) | (b[1] & 0xff) << 8)
-   | ((b[2] & 0xff) | (b[3] & 0xff) << 8) << 16;
-  }
-
-  /**
-   * Read an unsigned short in little endian byte order from the given
-   * byte buffer at the given offset.
-   *
-   * @param b the byte array to read from.
-   * @param off the offset to read from.
-   * @return The value read.
-   */
-  private int readLeShort(byte[] b, int off)
-  {
-return (b[off] & 0xff) | (b[off+1] & 0xff) << 8;
-  }
-
-  /**
-   * Read an int in little endian byte order from the given
-   * byte buffer at the given offset.
-   *
-   * @param b the byte array to read from.
-   * @param off the offset to read from.
-   * @return The value read.
-   */
-  private int readLeInt(byte[] b, int off)
-  {
-return ((b[off] & 0xff) | (b[off+1] & 0xff) << 8)
-   | ((b[off+2] & 0xff) | (b[off+3] & 0xff) << 8) << 16;
-  }
-  
-
-  /**
* Read the central directory of a zip file and fill the entries
* array.  This is called exactly once when first needed. It is called
* while holding the lock on raf.
@@ -246,63 +191,48 @@
   {
 /* Search for the End Of Central Directory.  When a zip comment is 
  * present the directory may start earlier.
- * FIXME: This searches the whole file in a

Re: [cp-patches] Patch: Component, GtkPanelPeer, GtkWindowPeer

2006-02-13 Thread Lillian Angel
On Mon, 2006-02-13 at 15:48 +0100, Roman Kennke wrote:
> Hi Lillian,
> 
> Am Montag, den 13.02.2006, 09:34 -0500 schrieb Lillian Angel:
> > Small fixes. 
> > The repaint functions in Component were slightly inefficient, I fixed
> > this. 
> 
> Actually these repaint calls where a bit more efficient since they avoid
> unnecessary method calls. However, I would like you to revert the
> changes on Component for a different reason, I once made it so because I
> had an application that has overridden one of the repaint methods and
> produced strange behaviour because it got called when the component was
> not actually showing. I think I even have made a Mauve test for this
> (must check, otherwise I can quickly make one).

Ok, sorry about that.

2006-02-13  Lillian Angel  <[EMAIL PROTECTED]>

* java/awt/Component.java
(repaint): Reverted last change.
(repaint): Likewise.
(repaint): Likewise.

Index: java/awt/Component.java
===
RCS file: /sources/classpath/classpath/java/awt/Component.java,v
retrieving revision 1.95
diff -u -r1.95 Component.java
--- java/awt/Component.java	7 Feb 2006 11:36:08 -	1.95
+++ java/awt/Component.java	9 Feb 2006 21:57:37 -
@@ -1882,8 +1882,7 @@
*/
   public void repaint()
   {   
-if (isShowing())
-  repaint(0, 0, 0, width, height);
+repaint(0, 0, 0, width, height);
   }
 
   /**
@@ -1897,8 +1896,7 @@
*/
   public void repaint(long tm)
   {
-if (isShowing())
-  repaint(tm, 0, 0, width, height);
+repaint(tm, 0, 0, width, height);
   }
 
   /**
@@ -1915,8 +1913,7 @@
*/
   public void repaint(int x, int y, int w, int h)
   {
-if (isShowing())
-  repaint(0, x, y, w, h);
+repaint(0, x, y, w, h);
   }
 
   /**
 


Re: [cp-patches] Patch: Component, GtkPanelPeer, GtkWindowPeer

2006-02-13 Thread Roman Kennke
Hi Lillian,

Am Montag, den 13.02.2006, 09:34 -0500 schrieb Lillian Angel:
> Small fixes. 
> The repaint functions in Component were slightly inefficient, I fixed
> this. 

Actually these repaint calls where a bit more efficient since they avoid
unnecessary method calls. However, I would like you to revert the
changes on Component for a different reason, I once made it so because I
had an application that has overridden one of the repaint methods and
produced strange behaviour because it got called when the component was
not actually showing. I think I even have made a Mauve test for this
(must check, otherwise I can quickly make one).

/Roman



signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


[cp-patches] Patch: Component, GtkPanelPeer, GtkWindowPeer

2006-02-13 Thread Lillian Angel
Small fixes. 
The repaint functions in Component were slightly inefficient, I fixed
this. 

2006-02-13  Lillian Angel  <[EMAIL PROTECTED]>

* gnu/java/awt/peer/gtk/GtkPanelPeer.java
(handleEvent): Made more efficent by handling paint event and
setting the clip for the graphics.
* gnu/java/awt/peer/gtk/GtkWindowPeer.java
(handleEvent): Likewise.
* java/awt/Component.java
(repaint): No need to call isShowing, it is done in the other 
repaint call.
(repaint): Likewise.
(repaint): Likewise.

Index: gnu/java/awt/peer/gtk/GtkPanelPeer.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/GtkPanelPeer.java,v
retrieving revision 1.21
diff -u -r1.21 GtkPanelPeer.java
--- gnu/java/awt/peer/gtk/GtkPanelPeer.java	9 Feb 2006 17:44:30 -	1.21
+++ gnu/java/awt/peer/gtk/GtkPanelPeer.java	9 Feb 2006 21:57:36 -
@@ -56,33 +56,39 @@
 super (p);
   }
 
-  public void handleEvent (AWTEvent event)
+  public void handleEvent(AWTEvent event)
   {
 int id = event.getID();
-
 switch (id)
   {
   case MouseEvent.MOUSE_PRESSED:
-awtComponent.requestFocusInWindow ();
+awtComponent.requestFocusInWindow();
 break;
+  case PaintEvent.UPDATE:
+  case PaintEvent.PAINT:
+  {
+try
+  {
+Graphics g = getGraphics();
+if (! awtComponent.isShowing() || awtComponent.getWidth() < 1
+|| awtComponent.getHeight() < 1 || g == null)
+  return;
+
+g.setClip(((PaintEvent) event).getUpdateRect());
+
+// Do not want to clear anything before painting.);
+awtComponent.paint(g);
+
+g.dispose();
+return;
+  }
+catch (InternalError e)
+  {
+System.err.println(e);
+  }
   }
-
-if (event.getID() == PaintEvent.UPDATE)
-  {
-Graphics g = getGraphics();
-if (!awtComponent.isShowing() || awtComponent.getWidth() < 1 
-|| awtComponent.getHeight() < 1 || g == null)
-  return;
-
-g.setClip(((PaintEvent) event).getUpdateRect());
-
-// Do not want to clear anything before painting.
-awtComponent.paint(g);
-
-g.dispose();
   }
-else
-  super.handleEvent (event);
+super.handleEvent(event);
   }
 
   native void connectSignals ();
Index: gnu/java/awt/peer/gtk/GtkWindowPeer.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java,v
retrieving revision 1.44
diff -u -r1.44 GtkWindowPeer.java
--- gnu/java/awt/peer/gtk/GtkWindowPeer.java	9 Feb 2006 17:44:30 -	1.44
+++ gnu/java/awt/peer/gtk/GtkWindowPeer.java	9 Feb 2006 21:57:36 -
@@ -241,21 +241,29 @@
   
   public void handleEvent(AWTEvent event)
   {
-if (event.getID() == PaintEvent.UPDATE)
+int id = event.getID();
+if (id == PaintEvent.UPDATE || id == PaintEvent.PAINT)
   {
-Graphics g = getGraphics();
-if (!awtComponent.isShowing() || awtComponent.getWidth() < 1 
-|| awtComponent.getHeight() < 1 || g == null)
-  return;
-
-g.setClip(((PaintEvent) event).getUpdateRect());
-
-// Do not want to clear anything before painting.
-awtComponent.paint(g);
-
-g.dispose();
+try
+  {
+Graphics g = getGraphics();
+if (! awtComponent.isShowing() || awtComponent.getWidth() < 1
+|| awtComponent.getHeight() < 1 || g == null)
+  return;
+
+g.setClip(((PaintEvent) event).getUpdateRect());
+
+// Do not want to clear anything before painting.
+awtComponent.paint(g);
+
+g.dispose();
+return;
+  }
+catch (InternalError e)
+  {
+System.err.println(e);
+  }
   }
-else
-  super.handleEvent(event);
+super.handleEvent(event);
   }
 }
Index: java/awt/Component.java
===
RCS file: /sources/classpath/classpath/java/awt/Component.java,v
retrieving revision 1.95
diff -u -r1.95 Component.java
--- java/awt/Component.java	7 Feb 2006 11:36:08 -	1.95
+++ java/awt/Component.java	9 Feb 2006 21:57:37 -
@@ -1882,8 +1882,7 @@
*/
   public void repaint()
   {   
-if (isShowing())
-  repaint(0, 0, 0, width, height);
+repaint(0, 0, 0, width, height);
   }
 
   /**
@@ -1897,8 +1896,7 @@
*/
   public void repaint(long tm)
   {
-if (isShowing())
-  repaint(tm, 0, 0, width, height);
+repaint(tm, 0, 0, width, height);
   }
 
   /**
@@ -1915,8 +1913,7 @@
*/
   public void repaint(int x, int y, int w, int h)
   {
-if (isShowing())
-  repaint(0, x, y, w, h);

[cp-patches] FYI: View fix

2006-02-13 Thread Roman Kennke
View.setParent() must message all the child views with setParent(null)
when it is called with a null argument. This gives the child views a
chance to clean up before they get disconnected from the View hierarchy.
This behaviour is part of the specification of this method.

2006-02-13  Roman Kennke  <[EMAIL PROTECTED]>

* javax/swing/text/AbstractDocument.java
(setParent): Added API docs. Call setParent(null) on children
before
disconnecting this view from the View hierarchy.

/Roman
Index: javax/swing/text/View.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/View.java,v
retrieving revision 1.27
diff -u -r1.27 View.java
--- javax/swing/text/View.java	9 Feb 2006 14:28:49 -	1.27
+++ javax/swing/text/View.java	13 Feb 2006 14:14:22 -
@@ -71,8 +71,29 @@
 
   public abstract void paint(Graphics g, Shape s);
 
+  /**
+   * Sets the parent for this view. This is the first method that is beeing
+   * called on a view to setup the view hierarchy. This is also the last method
+   * beeing called when the view is disconnected from the view hierarchy, in
+   * this case parent is null.
+   *
+   * If parent is null, a call to this method also
+   * calls setParent on the children, thus disconnecting them from
+   * the view hierarchy. That means that super must be called when this method
+   * is overridden.
+   *
+   * @param parent the parent to set, null when this view is
+   *beeing disconnected from the view hierarchy
+   */
   public void setParent(View parent)
   {
+if (parent == null)
+  {
+int numChildren = getViewCount();
+for (int i = 0; i < numChildren; i++)
+  getView(i).setParent(this);
+  }
+
 this.parent = parent;
   }
 


[cp-patches] FYI: AbstractDocument locking fix

2006-02-13 Thread Roman Kennke
In AbstractDocument we must not attempt to release a read lock if the
current thread also holds a write lock. That is because a thread the
holds a write lock is ignored in a readLock() request. Decrementing the
readLocks counter on readUnlock for such a thread would result in an
exception later.

2006-02-13  Roman Kennke  <[EMAIL PROTECTED]>

* javax/swing/text/AbstractDocument.java
(readUnlock): Don't attempt to unlock when the current threads
also
holds a write lock.

/Roman
Index: javax/swing/text/AbstractDocument.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/AbstractDocument.java,v
retrieving revision 1.45
diff -u -r1.45 AbstractDocument.java
--- javax/swing/text/AbstractDocument.java	9 Feb 2006 16:57:44 -	1.45
+++ javax/swing/text/AbstractDocument.java	13 Feb 2006 14:09:06 -
@@ -646,6 +646,12 @@
 // more times than you've previously called lock, but it doesn't make
 // sure that the threads calling unlock were the same ones that called lock
 
+// If the current thread holds the write lock, and attempted to also obtain
+// a readLock, then numReaders hasn't been incremented and we don't need
+// to unlock it here.
+if (currentWriter == Thread.currentThread())
+  return;
+
 // FIXME: the reference implementation throws a 
 // javax.swing.text.StateInvariantError here
 if (numReaders == 0)
@@ -847,7 +853,7 @@
*/
   protected void writeLock()
   {
-if (currentWriter!= null && currentWriter.equals(Thread.currentThread()))
+if (currentWriter != null && currentWriter.equals(Thread.currentThread()))
   return;
 synchronized (documentCV)
   {


Re: [cp-patches] Re: RFC: Don't unnecessary double queue GtkComponentPeer.repaint() events

2006-02-13 Thread Lillian Angel

> Thanks! Good to know this was confusing to others too.
> For your information, I am still trying to figure out how the Panel
> realization/getGraphics() should work (any help with that appreciated
> since I think I just don't really get it). And I am working on fixing a
> crash with adding Menus to Menus as in the attached patch.

I will try to help :)

Lillian




[cp-patches] FYI: MetalBorders.java - minor fixes

2006-02-13 Thread David Gilbert

This patch fixes some Mauve failures in the MetalBorders class:

2006-02-13  David Gilbert  <[EMAIL PROTECTED]>

* javax/swing/plaf/metal/MetalBorders.java
(ButtonBorder.getBorderInsets(Component)): Return insets directly,
(ButtonBorder.getBorderInsets(Component, Insets)): Don't check for null
insets argument,
(Flush3DBorder.borderInsets): New field,
(Flush3DBorder.getBorderInsets(Component)): Return insets directly,
(Flush3DBorder.getBorderInsets(Component, Insets)): Don't check for
null insets argument, and populate result from borderInsets,
(PaletteBorder.borderInsets): New field,
(PaletteBorder.getBorderInsets(Component)): Return insets directly,
(PaletteBorder.getBorderInsets(Component, Insets)): Don't check for
null insets argument, and populate result from borderInsets,
(InternalFrameBorder.borderInsets): New field,
(InternalFrameBorder.getBorderInsets(Component)): Return insets
directly,
(InternalFrameBorder.getBorderInsets(Component, Insets)): Don't check
for null insets argument, and populate result from borderInsets,
(MenuItemBorder.borderInsets): Initialise to correct value.

Regards,

Dave
Index: javax/swing/plaf/metal/MetalBorders.java
===
RCS file: 
/sources/classpath/classpath/javax/swing/plaf/metal/MetalBorders.java,v
retrieving revision 1.29
diff -u -r1.29 MetalBorders.java
--- javax/swing/plaf/metal/MetalBorders.java16 Nov 2005 20:33:06 -  
1.29
+++ javax/swing/plaf/metal/MetalBorders.java13 Feb 2006 13:56:39 -
@@ -1,5 +1,5 @@
 /* MetalBorders.java
-   Copyright (C) 2005 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -249,30 +249,27 @@
 /**
  * Returns the insets of the ButtonBorder.
  *
- * @param c the component for which the border is used
+ * @param c the component for which the border is used (ignored).
  *
- * @return The insets of the ButtonBorder
+ * @return The insets of the ButtonBorder.
  */
 public Insets getBorderInsets(Component c)
 {
-  return getBorderInsets(c, null);
+  return borderInsets;
 }
 
 /**
  * Returns the insets of the ButtonBorder in the specified 
  * newInsets object.
  *
- * @param c the component for which the border is used
- * @param newInsets the insets object where to put the values (if 
- *null, a new instance is created).
+ * @param c the component for which the border is used (ignored).
+ * @param newInsets the insets object where to put the values (
+ *  null not permitted).
  *
- * @return The insets.
+ * @return The newInsets reference.
  */
 public Insets getBorderInsets(Component c, Insets newInsets)
 {
-  if (newInsets == null)
-newInsets = new Insets(0, 0, 0, 0);
-
   newInsets.bottom = borderInsets.bottom;
   newInsets.left = borderInsets.left;
   newInsets.right = borderInsets.right;
@@ -352,6 +349,8 @@
   public static class Flush3DBorder extends AbstractBorder
 implements UIResource
   {
+private static final Insets borderInsets = new Insets(2, 2, 2, 2);
+
 /**
  * Creates a new border instance.
  */
@@ -369,26 +368,25 @@
  */
 public Insets getBorderInsets(Component c)
 {
-  return getBorderInsets(c, null);
+  return borderInsets;
 }
 
 /**
  * Returns the border insets.
  * 
  * @param c  the component (ignored).
- * @return The border insets.
+ * @param newInsets  an existing insets instance, that will be populated
+ *   with the border insets and returned as the result
+ *   (null not permitted).
+ *   
+ * @return The newInsets reference.
  */
 public Insets getBorderInsets(Component c, Insets newInsets)
 {
-  if (newInsets == null)
-newInsets = new Insets(2, 2, 2, 2);
-  else
-{
-  newInsets.top = 2;
-  newInsets.left = 2;
-  newInsets.bottom = 2;
-  newInsets.right = 2;
-}
+  newInsets.top = borderInsets.top;
+  newInsets.left = borderInsets.left;
+  newInsets.bottom = borderInsets.bottom;
+  newInsets.right = borderInsets.right;
   return newInsets;  
 }
 
@@ -427,6 +425,8 @@
   public static class PaletteBorder extends AbstractBorder
 implements UIResource
   {
+private static final Insets borderInsets = new Insets(1, 1, 1, 1);
+
 /**
  * Creates a new PaletteBorder.
  */
@@ -444,29 +444,25 @@
  */
 public Insets getBorderInsets(Component c)
 {
-  return getBorderInsets(c, null);
+  return borderInsets;
 }
 
 /**
  * Returns the border insets.
  * 
  * @

[cp-patches] FYI: AsyncBoxView

2006-02-13 Thread Roman Kennke
I implemented the javax.swing.text.AsyncBoxView.

This is really a piece of code that actually works better than with the
latest JDK. JDK1.5.0_06 seems to have a bug which triggers an NPE with
this class. I would guess that since that view is not used at all in one
of the standard text components, there sneaked in a bug that nobody
noticed. Good for us.

2006-02-13  Roman Kennke  <[EMAIL PROTECTED]>

* javax/swing/text/AsyncBoxView.java: New file.

/Roman
Index: javax/swing/text/AsyncBoxView.java
===
RCS file: javax/swing/text/AsyncBoxView.java
diff -N javax/swing/text/AsyncBoxView.java
--- /dev/null	1 Jan 1970 00:00:00 -
+++ javax/swing/text/AsyncBoxView.java	13 Feb 2006 13:43:12 -
@@ -0,0 +1,1486 @@
+/* AsyncBoxView.java -- A box view that performs layout asynchronously
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text;
+
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.util.ArrayList;
+
+import javax.swing.event.DocumentEvent;
+import javax.swing.text.Position.Bias;
+
+/**
+ * A [EMAIL PROTECTED] View} implementation that lays out its child views in a box, either
+ * vertically or horizontally. The difference to [EMAIL PROTECTED] BoxView} is that the
+ * layout is performed in an asynchronous manner. This helps to keep the
+ * eventqueue free from non-GUI related tasks.
+ *
+ * This view is currently not used in standard text components. In order to
+ * use it you would have to implement a special [EMAIL PROTECTED] EditorKit} with a
+ * [EMAIL PROTECTED] ViewFactory} that returns this view. For example:
+ *
+ * 
+ * static class AsyncEditorKit extends StyledEditorKit implements ViewFactory
+ * {
+ *   public View create(Element el)
+ *   {
+ * if (el.getName().equals(AbstractDocument.SectionElementName))
+ *   return new AsyncBoxView(el, View.Y_AXIS);
+ * return super.getViewFactory().create(el);
+ *   }
+ *   public ViewFactory getViewFactory() {
+ * return this;
+ *   }
+ * }
+ * 
+ *
+ * @author Roman Kennke ([EMAIL PROTECTED])
+ *
+ * @since 1.3
+ */
+public class AsyncBoxView
+  extends View
+{
+
+  /**
+   * Manages the effective position of child views. That keeps the visible
+   * layout stable while the AsyncBoxView might be changing until the layout
+   * thread decides to publish the new layout.
+   */
+  public class ChildLocator
+  {
+
+/**
+ * The last valid location.
+ */
+protected ChildState lastValidOffset;
+
+/**
+ * The last allocation.
+ */
+protected Rectangle lastAlloc;
+
+/**
+ * A Rectangle used for child allocation calculation to avoid creation
+ * of lots of garbage Rectangle objects.
+ */
+protected Rectangle childAlloc;
+
+/**
+ * Creates a new ChildLocator.
+ */
+public ChildLocator()
+{
+  lastAlloc = new Rectangle();
+  childAlloc = new Rectangle();
+}
+
+/**
+ * Receives notification that a child has changed. This is called by
+ * child state objects that have changed it's major span.
+ *
+ * This sets the [EMAIL PROTECTED] #lastValidOffset} field to cs if
+ * the new child state's view start offset is smaller 

Re: [cp-patches] RFC: Datatypes library

2006-02-13 Thread Mark Wielaard
Hi Chris,

Sorry for moving so slow on this. I am a bit over-committed lately and
clearly this is not a subject I am that knowledgeable about, so it takes
some time to digest.

On Tue, 2006-02-07 at 12:11 +, Chris Burdess wrote:
> > So, does anybody else have any comments? Otherwise I think Chris  
> > should go ahead with this (provided the interaction between xml.validation  
> > and relaxng.datatype will be clearly documented).
> 
> I have added documentation for this in README.jaxp (it's pretty  
> simple) and removed the org.relaxng.datatype package from the  
> generated javadoc. Patch attached.

Thanks. Looks good. But I have to admit that I am still not really clear
on how I get new xml.validation support through the datatype library. So
if I have a DatatypeBuilder and Datatype, where do I plug these in, and
what other boilerplate do I need to write to get a Schema and Validator
to pop out that uses these datatypes? And which datatypes are already
present, and which should be added for my own validator?
Maybe when your XML Schema is added it will be more clear.

> 2006-02-07  Chris Burdess  <[EMAIL PROTECTED]>
> 
>  * configure.ac,
>doc/README.jaxp,
>external/Makefile.am,
>external/relaxngDatatype/.cvsignore,
>external/relaxngDatatype/Makefile.am,
>external/relaxngDatatype/README.txt,
>external/relaxngDatatype/copying.txt,
>external/relaxngDatatype/org/relaxng/datatype/Datatype.java,
>external/relaxngDatatype/org/relaxng/datatype/ 
> DatatypeBuilder.java,
>external/relaxngDatatype/org/relaxng/datatype/ 
> DatatypeException.java,
>external/relaxngDatatype/org/relaxng/datatype/ 
> DatatypeLibrary.java,
>external/relaxngDatatype/org/relaxng/datatype/ 
> DatatypeLibraryFactory.java,
>external/relaxngDatatype/org/relaxng/datatype/ 
> DatatypeStreamingValidator.java,
>external/relaxngDatatype/org/relaxng/datatype/ 
> ValidationContext.java,
>external/relaxngDatatype/org/relaxng/datatype/helpers/ 
> DatatypeLibraryLoader.java,
>external/relaxngDatatype/org/relaxng/datatype/helpers/ 
> ParameterlessDatatypeBuilder.java,
>external/relaxngDatatype/org/relaxng/datatype/helpers/ 
> StreamingValidatorImpl.java,
>lib/Makefile.am,
>lib/gen-classlist.sh.in: Added external RELAX NG pluggable
>datatypes library API.
> 
> OK to commit?

Looks fine. Could you also add the following text to the top-level
LICENSE file?

---

Directory external/relaxngDatatype
RELAX NG Pluggable Datatype Libraries. All files are distributed under
the following notice:

Copyright (c) 2001, Thai Open Source Software Center Ltd, Sun
Microsystems. All rights reserved.

Redistribution and use in source and binary forms, with or
without
modification, are permitted provided that the following
conditions are met:

Redistributions of source code must retain the above
copyright
notice, this list of conditions and the following
disclaimer.

Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials
provided
with the distribution.

Neither the names of the copyright holders nor the names of
its
contributors may be used to endorse or promote products
derived
from this software without specific prior written
permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.


And please add a little notice to the NEWS file about it.

Thanks,

Mark


signature.asc
Description: This is a digitally signed message part


Re: [cp-patches] Re: RFC: Don't unnecessary double queue GtkComponentPeer.repaint() events

2006-02-13 Thread Mark Wielaard
Hi Lillian,

On Sun, 2006-02-12 at 21:00 -0500, Lillian Angel wrote:
> This is so awesome! I was working on fixing this same bug.

Thanks! Good to know this was confusing to others too.
For your information, I am still trying to figure out how the Panel
realization/getGraphics() should work (any help with that appreciated
since I think I just don't really get it). And I am working on fixing a
crash with adding Menus to Menus as in the attached patch.

Cheers,

Mark
import java.awt.*;
import java.awt.event.*;

public class MenuMenu extends Frame implements ActionListener
{
  Menu m;

  public static void main(String[] args)
  {
new MenuMenu();
  }

  MenuMenu()
  {
super("MenuMenu");
MenuBar bar = new MenuBar();
m = new Menu("Menu");
bar.add(m);
MenuItem item = new MenuItem("Item");
item.addActionListener(this);
m.add(item);

setMenuBar(bar);
setSize(60, 60);
show();
  }

  public void actionPerformed(ActionEvent ae)
  {
Menu m2 = new Menu("Menu2");
MenuItem item2 = new MenuItem("Item2");
m.add(item2);
m.add(m2);
  }
}


signature.asc
Description: This is a digitally signed message part