Re: [cp-patches] FYI: Fix for PR34991

2009-01-07 Thread Robert Schuster
Hi,
thanks for the hint I will rework it that way.

Regards
Robert

David Gilbert schrieb:
 Robert Schuster wrote:
 
 -draw(new Polygon(xPoints, yPoints, nPoints));
 +for (int i = 1; i  nPoints; i++)
 +  draw(new Line2D.Double(xPoints[i - 1], yPoints[i - 1],
 + xPoints[i], yPoints[i]));
 
 Hi Robert,
 
 Line2D instances are mutable (via setLine() methods) so you could save
 some garbage here by creating one Line2D instance and reusing it within
 the loop...
 
 Regards,
 
 Dave Gilbert
 http://www.jfree.org/
 
 




signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: Fix for PR34991

2009-01-06 Thread Robert Schuster
Hi,
it was already asked whether this patch has been applied. Now it is. :)

Regards
Robert

2009-01-05  Robert Schuster  robertschus...@fsfe.org

  * gnu/java/awt/peer/gtk/CairoGraphics2D.java:
  (drawPolyline): Rewritten.
Index: gnu/java/awt/peer/gtk/CairoGraphics2D.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- gnu/java/awt/peer/gtk/CairoGraphics2D.java	8 Feb 2008 22:17:39 -	1.73
+++ gnu/java/awt/peer/gtk/CairoGraphics2D.java	6 Jan 2009 12:20:25 -	1.74
@@ -1246,7 +1246,9 @@
 
   public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
   {
-draw(new Polygon(xPoints, yPoints, nPoints));
+for (int i = 1; i  nPoints; i++)
+  draw(new Line2D.Double(xPoints[i - 1], yPoints[i - 1],
+ xPoints[i], yPoints[i]));
   }
 
   public void drawOval(int x, int y, int width, int height)
@@ -2171,4 +2173,4 @@
 
 return new Rectangle2D.Double(minX, minY, (maxX - minX), (maxY - minY));
   }
-}
\ No newline at end of file
+}


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: fix for DecimalFormat

2008-09-05 Thread Robert Schuster
Hi,
the attached patch fixes a problem when you numberformat pattern
contains the currency replacement character (/u00a4).

I suggest that this patch should be added to GCJ as well, as it fixes an
annoying issue.

Regards
Robert

ChangeLog:

2008-09-04  Robert Schuster  [EMAIL PROTECTED]

* java/text/DecimalFormat.java:
(scanFix): Use 'i + 1' when looking at following character.
(scanNegativePattern): Dito.


Index: java/text/DecimalFormat.java
===
RCS file: /sources/classpath/classpath/java/text/DecimalFormat.java,v
retrieving revision 1.37
diff -u -r1.37 DecimalFormat.java
--- java/text/DecimalFormat.java	17 Aug 2008 22:31:56 -	1.37
+++ java/text/DecimalFormat.java	3 Sep 2008 23:01:41 -
@@ -1321,7 +1321,7 @@
 currencySymbol = this.symbols.getCurrencySymbol();
 
 // if \u00A4 is doubled, we use the international currency symbol
-if (i  len  pattern.charAt(i + 1) == '\u00A4')
+if ((i + 1)  len  pattern.charAt(i + 1) == '\u00A4')
   {
 currencySymbol = this.symbols.getInternationalCurrencySymbol();
 i++;
@@ -1345,7 +1345,7 @@
 else if (ch == '\'')
   {
 // QUOTE
-if (i  len  pattern.charAt(i + 1) == '\'')
+if ((i + 1)  len  pattern.charAt(i + 1) == '\'')
   {
 // we need to add ' to the buffer 
 buffer.append(ch);
@@ -1717,7 +1717,7 @@
 else if (ch == '\'')
   {
 // QUOTE
-if (i  len  pattern.charAt(i + 1) == '\'')
+if ((i + 1)  len  pattern.charAt(i + 1) == '\'')
   {
 // we need to add ' to the buffer 
 buffer.append(ch);


[cp-patches] FYI: Fix unmappable case in ByteDecodeLoopHelper/ByteEncodeLoopHelper

2008-09-03 Thread Robert Schuster
Hi,
the attached patch fixes the way ByteDecodeLoopHelper and
ByteEncodeLoopHelper deal with the situation of unmappable characters:
With the attached patch the method really returns with a CoderResult
indicating unmappable characters. The former variant overwrote the
return value with either CoderResult.UNDERFLOW or CoderResult.OVERFLOW.

I found and debugged this problem while using mysql connector/j.

Regards
Robert

ChangeLog:

2008-09-04  Robert Schuster  [EMAIL PROTECTED]

* gnu/java/nio/charset/ByteDecodeLoopHelper:
(arrayDecodeLoop): Added new break label, escape to that label.
* gnu/java/nio/charset/ByteEncodeLoopHelper:
(arrayDecodeLoop): Added new break label, escape to that label.

Index: gnu/java/nio/charset/ByteDecodeLoopHelper.java
===
RCS file: /sources/classpath/classpath/gnu/java/nio/charset/ByteDecodeLoopHelper.java,v
retrieving revision 1.1
diff -u -r1.1 ByteDecodeLoopHelper.java
--- gnu/java/nio/charset/ByteDecodeLoopHelper.java	23 Nov 2007 16:11:17 -	1.1
+++ gnu/java/nio/charset/ByteDecodeLoopHelper.java	3 Sep 2008 23:11:29 -
@@ -119,6 +119,8 @@
 int inRemaining = in.remaining();
 int outRemaining = out.remaining();
 CoderResult result;
+
+	bailOut:
 if (inRemaining = outRemaining)
   {
 for (int i = 0; i  inRemaining; i++)
@@ -129,7 +131,7 @@
   {
 inPos--;
 result = CoderResult.unmappableForLength(1);
-break;
+break bailOut;
   }
 char c = mapToChar(b);
 outArray[outPos] = c;
@@ -147,7 +149,7 @@
   {
 inPos--;
 result = CoderResult.unmappableForLength(1);
-break;
+break bailOut;
   }
 char c = mapToChar(b);
 outArray[outPos] = c;
Index: gnu/java/nio/charset/ByteEncodeLoopHelper.java
===
RCS file: /sources/classpath/classpath/gnu/java/nio/charset/ByteEncodeLoopHelper.java,v
retrieving revision 1.1
diff -u -r1.1 ByteEncodeLoopHelper.java
--- gnu/java/nio/charset/ByteEncodeLoopHelper.java	23 Nov 2007 16:11:17 -	1.1
+++ gnu/java/nio/charset/ByteEncodeLoopHelper.java	3 Sep 2008 23:11:29 -
@@ -120,6 +120,8 @@
 int inRemaining = in.remaining();
 int outRemaining = out.remaining();
 CoderResult result;
+
+	bailOut:
 if (inRemaining = outRemaining)
   {
 for (int i = 0; i  inRemaining; i++)
@@ -130,7 +132,7 @@
   {
 inPos--;
 result = CoderResult.unmappableForLength(1);
-break;
+break bailOut;
   }
 byte b = mapToByte(inChar);
 outArray[outPos] = b;
@@ -148,7 +150,7 @@
   {
 inPos--;
 result = CoderResult.unmappableForLength(1);
-break;
+break bailOut;
   }
 byte b = mapToByte(inChar);
 outArray[outPos] = b;


[cp-patches] FYI: fix access out of array bounds

2008-08-12 Thread Robert Schuster
Hi,
today I applied the patch we discussed in June. It fixes the illegal
acces outside the array bounds. Thanks go to GCC which found it in the
first place and Andrew Haley who gave suggestions for that patch.

The patch also works for older classpath release and is needed for
anyone who wants to compile classpath with newer GCCs (~4.3) and
--enable-local-sockets.

ChangeLog:

2008-08-12  Robert Schuster  [EMAIL PROTECTED]

  * native/jni/java-net/local.c
  (local_bind): Removed fprintf call, fixed access outside
  of array bounds.


Regards
Robert
Index: native/jni/java-net/local.c
===
RCS file: /sources/classpath/classpath/native/jni/java-net/local.c,v
retrieving revision 1.4
diff -u -r1.4 local.c
--- native/jni/java-net/local.c	17 Apr 2007 21:46:27 -	1.4
+++ native/jni/java-net/local.c	27 Jun 2008 13:14:40 -
@@ -73,27 +73,18 @@
   return socket (PF_UNIX, stream ? SOCK_STREAM : SOCK_DGRAM, 0);
 }
 
-static int gcc_sucks = 0;
-
 int
 local_bind (int fd, const char *addr)
 {
   struct sockaddr_un saddr;
 
-  /* For some reason, GCC 4.0.1 on Darwin/x86 MODIFIES the `addr'
- pointer in the CALLER's STACK FRAME after calling this function,
- but if we add this statement below, it doesn't!  */
-  if (gcc_sucks)
-fprintf (stderr, bind %p\n, addr);
-
-  if (strlen (addr)  sizeof (saddr.sun_path))
+  if (strlen (addr) = sizeof (saddr.sun_path))
 {
   errno = ENAMETOOLONG;
   return -1;
 }
 
-  strncpy (saddr.sun_path, addr, sizeof (saddr.sun_path));
-  saddr.sun_path[sizeof (saddr.sun_path)] = '\0';
+  strcpy (saddr.sun_path, addr);
   saddr.sun_family = AF_LOCAL;
 
   return bind (fd, (struct sockaddr *) saddr, SUN_LEN (saddr));


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] RFC: @file support for gjavah gjar

2008-06-06 Thread Robert Schuster
Hi Andrew,
thanks a lot for fixing the remaining issues and committing this.

Regards
Robert

Andrew John Hughes schrieb:
 Committed with the amendments suggested by Tom and Mario:
 
 2008-06-06  Andrew John Hughes  [EMAIL PROTECTED]
 
 * tools/gnu/classpath/tools/common/ClasspathToolParser.java:
 Fixed indentation and changed to use OptionException.
 * tools/gnu/classpath/tools/getopt/OptionException.java:
 (OptionException(String,Throwable)): Added.
 
 2008-06-03  Robert Schuster  [EMAIL PROTECTED]
 
 * tools/gnu/classpath/tools/jar/Main.java:
 (run): Call different ClasspathToolParser.parse() variant.
 (getParser): Changed return type to ClasspathToolParser.
 * tools/gnu/classpath/tools/javah/GcjhMain.java:
 (getParser): Changed return type to ClasspathToolParser.
 * tools/gnu/classpath/tools/javah/Main.java:
 (getParser): Changed return type to ClasspathToolParser.
 * tools/gnu/classpath/tools/getopt/Parser.java: Make 'programName'
 protected.
 * tools/gnu/classpath/tools/common/ClasspathToolParser.java:
 (parse(String[], FileArgumentCallback,boolean): New method.
 (parse(String[], boolean): New method.
 (parseFileList): New method.
 (parseLine): New method.
 (AtFileArgumentCallback): New inner class.
 
 




signature.asc
Description: OpenPGP digital signature


[cp-patches] RFC: move from gnu.java.security.action.GetPropertyAction to sun.security.action.GetPropertyAction

2008-06-04 Thread Robert Schuster
Hi,
the attached patch refactors all of Classpath' code to use
sun.security.action.GetPropertyAction instead of
gnu.java.security.action.GetPropertyAction.

Additionally the class in question is moved to its new package.

While I don't like the usage of a non-standard API as much as you I also
think that with OpenJDK being available under the GPL it is equally bad
to have

gnu.java.security.action.GetPropertyAction

or

sun.security.action.GetPropertyAction

But what I think what is even worse is having both. :)

2008-06-04  Robert Schuster  [EMAIL PROTECTED]

  * gnu/java/security/action/GetPropertyAction.java: Removed.
  * sun/security/action/GetPropertyAction.java: Copied content
  from gnu/java/security/action/GetPropertyAction.java.
  * gnu/classpath/debug/Simple1LineFormatter.java: Changed import
  of gnu.java.security.action.GetPropertyAction to
  sun.security.action.GetPropertyAction
  * gnu/classpath/debug/SystemLogger.java: Dito.
  * gnu/java/security/PolicyFile.java: Dito.
  * gnu/java/security/key/dss/DSSKey.java: Dito.
  * gnu/java/security/key/dss/DSSPrivateKey.java: Dito.
  * gnu/java/security/key/dss/DSSPublicKey.java: Dito.
  * gnu/java/security/key/rsa/GnuRSAKey.java: Dito.
  * gnu/java/security/key/rsa/GnuRSAPrivateKey.java: Dito.
  * gnu/java/security/key/rsa/GnuRSAPublicKey.java: Dito.
  * gnu/javax/crypto/key/dh/GnuDHKey.java: Dito.
  * gnu/javax/crypto/key/dh/GnuDHPrivateKey.java: Dito.
  * gnu/javax/crypto/key/dh/GnuDHPublicKey.java: Dito.
  * gnu/javax/crypto/sasl/plain/PasswordFile.java: Dito.
  * gnu/javax/net/ssl/provider/X509TrustManagerFactory.java: Dito.
  * gnu/xml/aelfred2/XmlParser.java: Dito.

Regards
Robert
Index: gnu/classpath/debug/Simple1LineFormatter.java
===
RCS file: /sources/classpath/classpath/gnu/classpath/debug/Simple1LineFormatter.java,v
retrieving revision 1.3
diff -u -r1.3 Simple1LineFormatter.java
--- gnu/classpath/debug/Simple1LineFormatter.java	11 Jul 2006 16:03:59 -	1.3
+++ gnu/classpath/debug/Simple1LineFormatter.java	4 Jun 2008 08:51:55 -
@@ -38,8 +38,6 @@
 
 package gnu.classpath.debug;
 
-import gnu.java.security.action.GetPropertyAction;
-
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.security.AccessController;
@@ -51,6 +49,8 @@
 import java.util.logging.Formatter;
 import java.util.logging.LogRecord;
 
+import sun.security.action.GetPropertyAction;
+
 /**
  * A simple 1-line formatter to use instead of the 2-line SimpleFormatter used
  * by default in the JDK logging handlers.
Index: gnu/classpath/debug/SystemLogger.java
===
RCS file: /sources/classpath/classpath/gnu/classpath/debug/SystemLogger.java,v
retrieving revision 1.3
diff -u -r1.3 SystemLogger.java
--- gnu/classpath/debug/SystemLogger.java	10 Dec 2006 20:25:41 -	1.3
+++ gnu/classpath/debug/SystemLogger.java	4 Jun 2008 08:51:55 -
@@ -38,13 +38,13 @@
 
 package gnu.classpath.debug;
 
-import gnu.java.security.action.GetPropertyAction;
-
 import java.security.AccessController;
 import java.util.StringTokenizer;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import sun.security.action.GetPropertyAction;
+
 public final class SystemLogger extends Logger
 {
   public static final SystemLogger SYSTEM = new SystemLogger();
Index: gnu/java/security/PolicyFile.java
===
RCS file: /sources/classpath/classpath/gnu/java/security/PolicyFile.java,v
retrieving revision 1.10
diff -u -r1.10 PolicyFile.java
--- gnu/java/security/PolicyFile.java	5 May 2008 17:12:40 -	1.10
+++ gnu/java/security/PolicyFile.java	4 Jun 2008 08:51:55 -
@@ -41,7 +41,6 @@
 import gnu.classpath.debug.SystemLogger;
 
 import gnu.java.lang.CPStringBuilder;
-import gnu.java.security.action.GetPropertyAction;
 
 import java.io.File;
 import java.io.IOException;
@@ -74,6 +73,8 @@
 import java.util.StringTokenizer;
 import java.util.logging.Logger;
 
+import sun.security.action.GetPropertyAction;
+
 /**
  * An implementation of a [EMAIL PROTECTED] java.security.Policy} object whose
  * permissions are specified by a empolicy file/em.
Index: gnu/java/security/action/GetPropertyAction.java
===
RCS file: gnu/java/security/action/GetPropertyAction.java
diff -N gnu/java/security/action/GetPropertyAction.java
--- gnu/java/security/action/GetPropertyAction.java	10 Dec 2006 20:25:42 -	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -
@@ -1,89 +0,0 @@
-/* GetPropertyAction.java
-   Copyright (C) 2004 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

Re: [cp-patches] RFC: add a copy of gnu/java/security/action/GetPropertyAction into sun/security/action

2008-06-04 Thread Robert Schuster
Hi.

Andrew Haley schrieb:
 What is the public equivalent for GetPropertyAction?
 
 There isn't any need, is there?
That depends. :)

  It's just a wrapper for
 (String) AccessController.doPrivileged(new PrivilegedAction() {
   public java.lang.Object run() {
   return System.getProperty(prop); }
 });
That is certainly true but has the nasty side effect of creating an
anonymous class per code location. In the PhoneME code I found ~20
occurrences of GetPropertyAction. Even in Classpath we avoided that by
introducing our own wrapper class.

Regards
Robert



signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] RFC: changes to java.lang.Integer, Long...

2008-06-03 Thread Robert Schuster
Hi,

Andrew John Hughes schrieb:
  I'd second that.  Are there clear performance benefits to justify
 creating 256 objects ahead of time?
 Not only does that introduce an overhead in initialising the Long
 class, but it also results in increased
 memory usage for all applications.
 
 I'd also prefer that future patches focused on just one change.  This
 seems to be in essence four
 patches in one.

Couldnt we have the best of both world? Instead of initializing the
array with all values explicitly let us do it lazily. Something like:

Integer valueOf(int i)
{
  Integer I = cached[i];
  if (I == null)
   I = cached[i] = new Integer(i);

  return I;
}



signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] FYI: gjar @file fix

2008-06-03 Thread Robert Schuster
Hi Tom,

 I am less sure about adding java-specific file name parsing to the
 generic command-line parser code.  That code is not supposed to be
 specific to java tooling (at least frysk uses it, fwiw).
I will implement the @file handling ClasspathToolParser now. That way
only our Classpath tools are affected.

Regards
Robert



signature.asc
Description: OpenPGP digital signature


[cp-patches] RFC: @file support for gjavah gjar

2008-06-03 Thread Robert Schuster
Hi,
the following patch adds @file support to gjavah and gjar by enhancing
ClasspathToolParser with a few methods and making both tools use those.

The other tools are not affected by this change nor does this modify the
core getopt functionality (except that I made the 'programName' field
protected - was private).

I originally wanted to use StreamTokenizer or StringTokenizer but I
think those are to complex for the task.

2008-06-03  Robert Schuster  [EMAIL PROTECTED]

  * tools/gnu/classpath/tools/jar/Main.java:
  (run): Call different ClasspathToolParser.parse() variant.
  (getParser): Changed return type to ClasspathToolParser.
  * tools/gnu/classpath/tools/javah/GcjhMain.java:
  (getParser): Changed return type to ClasspathToolParser.
  * tools/gnu/classpath/tools/javah/Main.java:
  (getParser): Changed return type to ClasspathToolParser.
  * tools/gnu/classpath/tools/getopt/Parser.java: Make 'programName'
  protected.
  * tools/gnu/classpath/tools/common/ClasspathToolParser.java:
  (parse(String[], FileArgumentCallback,boolean): New method.
  (parse(String[], boolean): New method.
  (parseFileList): New method.
  (parseLine): New method.
  (AtFileArgumentCallback): New inner class.

Regards
Robert
? tools/generated
Index: tools/gnu/classpath/tools/common/ClasspathToolParser.java
===
RCS file: /sources/classpath/classpath/tools/gnu/classpath/tools/common/ClasspathToolParser.java,v
retrieving revision 1.1
diff -u -r1.1 ClasspathToolParser.java
--- tools/gnu/classpath/tools/common/ClasspathToolParser.java	22 Sep 2006 01:01:26 -	1.1
+++ tools/gnu/classpath/tools/common/ClasspathToolParser.java	3 Jun 2008 16:34:45 -
@@ -38,9 +38,16 @@
 
 package gnu.classpath.tools.common;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.Reader;
 import java.text.MessageFormat;
+import java.util.ArrayList;
 
 import gnu.classpath.Configuration;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
 import gnu.classpath.tools.getopt.Parser;
@@ -84,4 +91,137 @@
}
  });
   }
+
+	public void parse(String[] inArgs, FileArgumentCallback files,
+	  boolean handleFileLists)
+	{
+		FileArgumentCallback cb;
+
+		if (handleFileLists)
+			cb = new AtFileArgumentCallback(files);
+		else
+			cb = files;
+
+		parse(inArgs, cb);
+	}
+
+  public String[] parse(String[] inArgs, boolean handleFileLists)
+  {
+final ArrayList fileResult = new ArrayList();
+
+		final FileArgumentCallback cb = new FileArgumentCallback()
+  	{
+	public void notifyFile(String fileArgument)
+	{
+	  fileResult.add(fileArgument);
+	}
+};
+
+		if (handleFileLists)
+			parse(inArgs, new AtFileArgumentCallback(cb));
+		else
+			parse(inArgs, cb);
+
+return (String[]) fileResult.toArray(new String[0]);
+  }
+
+
+  /** Simple function that takes the given [EMAIL PROTECTED] Reader}, treats it like
+   * a textfile and reads all the whitespace separated entries from it
+   * and adds them to the @{link FileArgumentCallback} instance.
+   */
+  public void parseFileList(Reader reader, FileArgumentCallback cb)
+	throws OptionException
+  {
+BufferedReader breader = new BufferedReader(reader);
+String line = null;
+
+try
+  {
+while ((line = breader.readLine()) != null)
+  parseLine(line, cb);
+  
+reader.close();
+  }
+catch (IOException ioe)
+  {
+System.err.println(programName + : IO error while reading from inputstream);
+System.exit(1);
+  }
+  
+  }
+  
+  /** Parses whitespace separated file entries.
+   *
+   * Note: This is not coping with whitespace in files or quoting.
+   */
+  private void parseLine(String line, FileArgumentCallback cb)
+throws IOException, OptionException
+  {
+final int length = line.length();
+int start = 0;
+int end = 0;
+
+		// While not reached end of line ...
+while (start  length)
+  {
+// Search for first non-whitespace character for the start of a word.
+while (Character.isWhitespace(line.codePointAt(start)))
+  {
+start++;
+
+if (start == length)
+  return;
+  }
+
+end = start + 1;
+	
+// Search for first whitespace character for the end of a word.
+while (end  length  !Character.isWhitespace(line.codePointAt(end)))
+  end++;
+  
+cb.notifyFile(line.substring(start, end));
+
+start = end + 1;
+  }
+  }
+
+	/** Implementation of [EMAIL PROTECTED] FileArgumentCallback} that handles
+ 		* file arguments in [EMAIL PROTECTED] #notifyFile} starting with a code@/code
+		* through [EMAIL PROTECTED] ClasspathToolParser#parseFileList}.
+		*/
+	class AtFileArgumentCallback extends

Re: [cp-patches] FYI: gjar @file fix

2008-06-02 Thread Robert Schuster
Hi Andrew,
I am not so happy with that patch. :)

I was trying to get Classpath to build PhoneME today and that requires
our javah to support @-style arguments as well. From my work for MIDPath
I know that we also lack that functionality in gjar that is why I tried
an implementation that can be used in all getopt using classpath tools.

What I am also unhappy is that a simple BufferedReader.readLine() is
used to get the filelist entries. The filelist the phoneme build
generates looks like this: Bla Foo Baz. So a simple parser is needed
that splits at whitespace bounds. My suggested implementation does
exactly that.

What my implementation does not handle is whitespace inside filenames
and quoting. However I am not sure whether this is supported in filelist
 anyway.

It may be possible that some tools need @file support and some not (Does
anyone know more about this?). And such a case I would change the getopt
API to explicitly request @file support in parse().

Please have a look at the attached patch. :)

Regards
Robert

Andrew John Hughes schrieb:
 This adds support in gjar for the @file argument
 as used by the OpenJDK build.
 
 ChangeLog:
 
 2008-06-02  Andrew John Hughes  [EMAIL PROTECTED]
 
   * tools/gnu/classpath/tools/getopt/OptionException.java:
   (OptionException(String,Throwable)): New constructor.
   * tools/gnu/classpath/tools/jar/Main.java:
   (fileLists): New queue for streams containing lists of files.
   (HandleFile.NotifyFile(String)): Check for '@' arguments
   and add to stream queue.
   (parsed(String)): Add stdin to queue instead of setting flag.
   (readNames()): Work with the queue rather than just stdin.
   (run(String[])): Always execute readNames().
 
 

? sun/security
? tools/generated
Index: ChangeLog
===
RCS file: /sources/classpath/classpath/ChangeLog,v
retrieving revision 1.9623
diff -u -r1.9623 ChangeLog
--- ChangeLog	1 Jun 2008 12:01:11 -	1.9623
+++ ChangeLog	2 Jun 2008 22:40:10 -
@@ -1,3 +1,10 @@
+2008-06-03  Robert Schuster  [EMAIL PROTECTED]
+
+  * tools/gnu/classpath/tools/getopt/Parser.java:
+  (parse): Added twos checks for '@' character and calls to parseFileList.
+  (parseFileList): New method.
+  (parseLine): New method.
+
 2008-06-01  Mark Wielaard  [EMAIL PROTECTED]
 
 	* gnu/java/awt/java2d/AbstractGraphics2D.java: Removed XDialogPeer
Index: tools/gnu/classpath/tools/getopt/Parser.java
===
RCS file: /sources/classpath/classpath/tools/gnu/classpath/tools/getopt/Parser.java,v
retrieving revision 1.10
diff -u -r1.10 Parser.java
--- tools/gnu/classpath/tools/getopt/Parser.java	20 Mar 2008 18:04:44 -	1.10
+++ tools/gnu/classpath/tools/getopt/Parser.java	2 Jun 2008 22:40:11 -
@@ -38,6 +38,10 @@
 
 package gnu.classpath.tools.getopt;
 
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
 import java.io.PrintStream;
 import java.text.BreakIterator;
 import java.text.MessageFormat;
@@ -442,7 +446,12 @@
 || args[currentIndex].charAt(0) != '-'
 || -.equals(args[currentIndex])) //$NON-NLS-1$
   {
-files.notifyFile(args[currentIndex]);
+// Treat file names starting with @ like a file containing a file list.
+	if (args[currentIndex].codePointAt(0) == '@')
+	  parseFileList(args[currentIndex].substring(1), files);
+	else
+  files.notifyFile(args[currentIndex]);
+  
 continue;
   }
 if (--.equals(args[currentIndex])) //$NON-NLS-1$
@@ -456,7 +465,13 @@
   }
 // Add remaining arguments to leftovers.
 for (++currentIndex; currentIndex  args.length; ++currentIndex)
-  files.notifyFile(args[currentIndex]);
+	  {
+	// Treat file names starting with @ like a file containing a file list.
+	if (args[currentIndex].codePointAt(0) == '@')
+	  parseFileList(args[currentIndex].substring(1), files);
+	else
+  files.notifyFile(args[currentIndex]);
+  }
 // See if something went wrong.
 validate();
   }
@@ -492,4 +507,71 @@
 });
 return (String[]) fileResult.toArray(new String[0]);
   }
+  
+  /** Simple function that takes the given file, treats it as a textfile
+   * and reads all the whitespace separated entries from it notifying
+   * [EMAIL PROTECTED] FileArgumentCallback} instance each time.
+  */
+  private void parseFileList(String fileName, FileArgumentCallback files)
+throws OptionException
+  {
+BufferedReader reader = null;
+String line = null;
+
+try
+  {
+reader = new BufferedReader(new FileReader(fileName));
+  }
+catch (FileNotFoundException fnfe)
+  {
+System.err.println

Re: [cp-patches] FYI: gjar @file fix

2008-06-02 Thread Robert Schuster
Hi Andrew,

  I was trying to get Classpath to build PhoneME today and that requires
  our javah to support @-style arguments as well. From my work for MIDPath
  I know that we also lack that functionality in gjar that is why I tried
  an implementation that can be used in all getopt using classpath tools.

 
 Ok I wasn't aware you were working on this, sorry.
Sorry, I did not announce this anywhere. :)

  What I am also unhappy is that a simple BufferedReader.readLine() is
  used to get the filelist entries. The filelist the phoneme build
  generates looks like this: Bla Foo Baz. So a simple parser is needed
  that splits at whitespace bounds. My suggested implementation does
  exactly that.

 
 So I see.  Is there a reason you didn't use String.split or
 StringTokenizer for this?

I considered String.split() to be to costly (regular expressions).
StringTokenizer would be a good idea ...

  The patch looks
 good, though I wonder how we can still integrate the stdin support
 gjar has.
I just saw that StreamTokenizer might provide a good parser that can
also deal with quoting.

If we use that in the parser and add an optional InputStream argument to
Parser.parse() we could have the best of your and my approach and
additionally get quoting right.

Unfortunately I need some sleep now and will continue with this patch in
~10 hours.

Regards
Robert



signature.asc
Description: OpenPGP digital signature


[cp-patches] RFC: add a copy of gnu/java/security/action/GetPropertyAction into sun/security/action

2008-06-02 Thread Robert Schuster
Hi,
the attached does something very dumb: It makes a copy of an existing
class. Still I need it because otherwise a resulting binary is either
not runnable with classpath or with openjdk's class library.

A better patch would possibly refactor all classpath code to use the
sun/security variant and remove the gnu/java/security one.

Opinions?

2008-06-03  Robert Schuster  [EMAIL PROTECTED]

  * sun/security/action/GetPropertyAction.java: Functional copy
  of gnu/java/security/action/GetPropertyAction.java.

Regards
Robert
Index: sun/security/action/GetPropertyAction.java
===
RCS file: sun/security/action/GetPropertyAction.java
diff -N sun/security/action/GetPropertyAction.java
--- /dev/null	1 Jan 1970 00:00:00 -
+++ sun/security/action/GetPropertyAction.java	2 Jun 2008 23:11:06 -
@@ -0,0 +1,93 @@
+/* GetPropertyAction.java
+   Copyright (C) 2004, 2008 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 sun.security.action;
+
+import java.security.PrivilegedAction;
+
+/**
+ * PrivilegedAction implementation that calls System.getProperty() with
+ * the property name passed to its constructor.
+ *
+ * Example of use:
+ * code
+ * GetPropertyAction action = new GetPropertyAction(http.proxyPort);
+ * String port = AccessController.doPrivileged(action);
+ * /code
+ *
+ * Note: Usage of this class is discouraged as it is not a part of the 
+ * J2SE API. This class is (and should always be) a doppelgaenger of
+ * [EMAIL PROTECTED] gnu.java.security.action.GetPropertyAction}.
+ */
+public class GetPropertyAction implements PrivilegedActionString
+{
+  String name;
+  String value = null;
+
+  public GetPropertyAction()
+  {
+  }
+  
+  public GetPropertyAction(String propName)
+  {
+setParameters(propName);
+  }
+
+  public GetPropertyAction(String propName, String defaultValue)
+  {
+setParameters(propName, defaultValue);
+  }
+  
+  public String run()
+  {
+return System.getProperty(name, value);
+  }
+  
+  public GetPropertyAction setParameters(String propName)
+  {
+this.name = propName;
+this.value = null;
+return this;
+  }
+
+  public GetPropertyAction setParameters(String propName, String defaultValue)
+  {
+this.name = propName;
+this.value = defaultValue;
+return this;
+  }
+}


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] [release] FYI: Allow native-only build #06: Regenerate headers by default only when necessary

2008-06-01 Thread Robert Schuster
Hi,
thank you very much for this change!

Regards
Robert

Andrew John Hughes schrieb:
 This changes the default behaviour for a source tree
 which already contains the header files.  It now won't
 regenerate them unless asked.  Generating them by default
 for a development (CVS) tree remains the default.  This
 moves javah to being a dev-only requirement.
 
 ChangeLog:
 
 2008-06-01  Andrew John Hughes  [EMAIL PROTECTED]
 
   * configure.ac: Only regenerate headers by
   default if the headers aren't in the source tree.
 
 




signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] RFC: NetworkInterface - implement some 1.6 methods

2008-05-15 Thread Robert Schuster
Hi,
I committed this today.

2008-05-15  Robert Schuster  [EMAIL PROTECTED]

  * java/net/NetworkInterface.java:
  (isUp): New method.
  (isPointToPoint): Dito.
  (isLoopback): Dito.
  (supportsMulticast): Dito.
  * vm/reference/java/net/VMNetworkInterface.java:
  (isUp): New method.
  (isPointToPoint): Dito.
  (isLoopback): Dito.
  (supportsMulticast): Dito.
  * native/jni/java-net/java_net_VMNetworkInterface.c:
  (isUp): New method.
  (isPointToPoint): Dito.
  (isLoopback): Dito.
  (supportsMulticast): Dito.

Regards
Robert

Robert Schuster schrieb:
 Hi.
 
 Robert Schuster schrieb:
 Hi,
 I fixed the copy and paste error and another flaw. Casting to jboolean
 did not alway returned the correct result. I made the if-flag-set then
 JNI_TRUE otherwise JNI_FALSE explicit. Now it works correctly.
 If no one objects I would like to commit this patch.
 
 Regards
 Robert
 




signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] RFC: NetworkInterface - implement some 1.6 methods

2008-04-22 Thread Robert Schuster
Hi.

Robert Schuster schrieb:
 Hi,
 I fixed the copy and paste error and another flaw. Casting to jboolean
 did not alway returned the correct result. I made the if-flag-set then
 JNI_TRUE otherwise JNI_FALSE explicit. Now it works correctly.
If no one objects I would like to commit this patch.

Regards
Robert



signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] RFC: NetworkInterface - implement some 1.6 methods

2008-04-21 Thread Robert Schuster
Hi,
I fixed the copy and paste error and another flaw. Casting to jboolean
did not alway returned the correct result. I made the if-flag-set then
JNI_TRUE otherwise JNI_FALSE explicit. Now it works correctly.

Christian Thalinger schrieb:
 I wonder if it would be simpler to only have one native method,
 returning the socket flags, and mapping the IFF_ defines in
 java/net/VMNetworkInterface so you could implement it in Java.  But I
 don't know if the flags are consistent between different OS or even libc
 versions.
I would like this, too. I think our POSIX gurus should comment. :)

Regards
Robert

Index: java/net/NetworkInterface.java
===
RCS file: /sources/classpath/classpath/java/net/NetworkInterface.java,v
retrieving revision 1.23
diff -u -r1.23 NetworkInterface.java
--- java/net/NetworkInterface.java	18 Dec 2006 21:37:39 -	1.23
+++ java/net/NetworkInterface.java	21 Apr 2008 10:38:25 -
@@ -1,5 +1,5 @@
 /* NetworkInterface.java --
-   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -265,4 +265,50 @@
 
 return result.toString();
   }
+
+  /**
+   * Determines whether this interface is ready to transfer data.
+   *
+   * @return whether the interface is up
+  */
+  public boolean isUp()
+throws SocketException
+  {
+return VMNetworkInterface.isUp(netif.name);
+  }
+
+  /**
+   * Determines whether this interface does point to point
+   * transmission.
+   *
+   * @return whether the interface does point to point transmission
+  */
+  public boolean isPointToPoint()
+throws SocketException
+  {
+return VMNetworkInterface.isPointToPoint(netif.name);
+  }
+
+  /**
+   * Determines whether this interface is the loopback interface.
+   *
+   * @return whether the interface is the loopback interface
+  */
+  public boolean isLoopback()
+throws SocketException
+  {
+return VMNetworkInterface.isLoopback(netif.name);
+  }
+
+  /**
+   * Determines whether this interface supports multicast transmission.
+   *
+   * @return whether the interface supports multicast transmission.
+  */
+  public boolean supportsMulticast()
+throws SocketException
+  {
+return VMNetworkInterface.supportsMulticast(netif.name);
+  }
+
 }
Index: vm/reference/java/net/VMNetworkInterface.java
===
RCS file: /sources/classpath/classpath/vm/reference/java/net/VMNetworkInterface.java,v
retrieving revision 1.7
diff -u -r1.7 VMNetworkInterface.java
--- vm/reference/java/net/VMNetworkInterface.java	18 Dec 2006 21:37:39 -	1.7
+++ vm/reference/java/net/VMNetworkInterface.java	21 Apr 2008 10:38:25 -
@@ -1,5 +1,5 @@
 /* VMNetworkInterface.java --
-   Copyright (C) 2005  Free Software Foundation, Inc.
+   Copyright (C) 2005, 2008  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -119,4 +119,13 @@
 else
   throw new SocketException(invalid interface address);
   }
+
+  static native boolean isUp(String name) throws SocketException;
+
+  static native boolean isLoopback(String name) throws SocketException;
+
+  static native boolean isPointToPoint(String name) throws SocketException;
+
+  static native boolean supportsMulticast(String name) throws SocketException;
+
 }
Index: native/jni/java-net/java_net_VMNetworkInterface.c
===
RCS file: /sources/classpath/classpath/native/jni/java-net/java_net_VMNetworkInterface.c,v
retrieving revision 1.6
diff -u -r1.6 java_net_VMNetworkInterface.c
--- native/jni/java-net/java_net_VMNetworkInterface.c	5 Apr 2007 12:34:19 -	1.6
+++ native/jni/java-net/java_net_VMNetworkInterface.c	21 Apr 2008 10:38:25 -
@@ -1,5 +1,5 @@
 /* VMNetworkInterface.c - Native methods for NetworkInterface class
-   Copyright (C) 2003, 2005, 2006  Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005, 2006, 2008 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -50,11 +50,18 @@
 #include stdio.h
 #include string.h
 
+#include net/if.h
+#include sys/ioctl.h
+
 #include jni.h
 #include jcl.h
 
+#include cpnative.h
+#include cpnet.h
+
 #include java_net_VMNetworkInterface.h
 
+int iff_flags(JNIEnv *, jstring, jint *);
 
 static jmethodID java_net_VMNetworkInterface_init;
 static jmethodID java_net_VMNetworkInterface_addAddress;
@@ -251,4 +258,136 @@
 #endif /* HAVE_IFADDRS_H  HAVE_GETIFADDRS */
 }
 
+int iff_flags(JNIEnv *env, jstring name, jint *flags)
+{
+  struct ifreq iff;
+  const char *iff_name;
+  jint socket;
+  int error, retval;
+
+  if ((error = cpnet_openSocketDatagram(env, socket, AF_INET)))
+  {
+return error;
+  }
+
+  iff_name = JCL_jstring_to_cstring(env, name);
+  memset(iff, 0, sizeof(iff));
+  strcpy(iff.ifr_name, iff_name);
+ 
+  if (ioctl(socket, SIOCGIFFLAGS, 

[cp-patches] RFC: NetworkInterface - implement some 1.6 methods

2008-04-21 Thread Robert Schuster
Hi,
people using Jalimo asked for those methods and I found them simple to
implement.

Since I am lousy non-Java hacker I appreciate comments on the code in
java_net_VMNetworkInterface.c.

Regards
Robert

2008-04-21  Robert Schuster  [EMAIL PROTECTED]

  * java/net/NetworkInterface.java:
  (isUp): New method.
  (isPointToPoint): Dito.
  (isLoopback): Dito.
  (supportsMulticast): Dito.
  * vm/reference/java/net/VMNetworkInterface.java:
  (isUp): New method.
  (isPointToPoint): Dito.
  (isLoopback): Dito.
  (supportsMulticast): Dito.
  * native/jni/java-net/java_net_VMNetworkInterface.c:
  (isUp): New method.
  (isPointToPoint): Dito.
  (isLoopback): Dito.
  (supportsMulticast): Dito.
Index: vm/reference/java/net/VMNetworkInterface.java
===
RCS file: /sources/classpath/classpath/vm/reference/java/net/VMNetworkInterface.java,v
retrieving revision 1.7
diff -u -r1.7 VMNetworkInterface.java
--- vm/reference/java/net/VMNetworkInterface.java	18 Dec 2006 21:37:39 -	1.7
+++ vm/reference/java/net/VMNetworkInterface.java	21 Apr 2008 06:55:11 -
@@ -1,5 +1,5 @@
 /* VMNetworkInterface.java --
-   Copyright (C) 2005  Free Software Foundation, Inc.
+   Copyright (C) 2005, 2008  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -119,4 +119,13 @@
 else
   throw new SocketException(invalid interface address);
   }
+
+  static native boolean isUp(String name) throws SocketException;
+
+  static native boolean isLoopback(String name) throws SocketException;
+
+  static native boolean isPointToPoint(String name) throws SocketException;
+
+  static native boolean supportsMulticast(String name) throws SocketException;
+
 }
Index: native/jni/java-net/java_net_VMNetworkInterface.c
===
RCS file: /sources/classpath/classpath/native/jni/java-net/java_net_VMNetworkInterface.c,v
retrieving revision 1.6
diff -u -r1.6 java_net_VMNetworkInterface.c
--- native/jni/java-net/java_net_VMNetworkInterface.c	5 Apr 2007 12:34:19 -	1.6
+++ native/jni/java-net/java_net_VMNetworkInterface.c	21 Apr 2008 06:55:12 -
@@ -1,5 +1,5 @@
 /* VMNetworkInterface.c - Native methods for NetworkInterface class
-   Copyright (C) 2003, 2005, 2006  Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005, 2006, 2008 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -50,11 +50,18 @@
 #include stdio.h
 #include string.h
 
+#include net/if.h
+#include sys/ioctl.h
+
 #include jni.h
 #include jcl.h
 
+#include cpnative.h
+#include cpnet.h
+
 #include java_net_VMNetworkInterface.h
 
+int iff_flags(JNIEnv *, jstring, jint *);
 
 static jmethodID java_net_VMNetworkInterface_init;
 static jmethodID java_net_VMNetworkInterface_addAddress;
@@ -251,4 +258,133 @@
 #endif /* HAVE_IFADDRS_H  HAVE_GETIFADDRS */
 }
 
+int iff_flags(JNIEnv *env, jstring name, jint *flags)
+{
+  struct ifreq iff;
+  const char *iff_name;
+  jint socket;
+  int error, retval;
+
+  if ((error = cpnet_openSocketDatagram(env, socket, AF_INET)))
+  {
+return error;
+  }
+
+  iff_name = JCL_jstring_to_cstring(env, name);
+  memset(iff, 0, sizeof(iff));
+  strcpy(iff.ifr_name, iff_name);
+ 
+  if (ioctl(socket, SIOCGIFFLAGS, iff) = 0)
+  {
+*flags = (jint) iff.ifr_flags;
+
+retval = 0;
+  }
+  else
+  {
+retval = errno;
+  }
+
+  cpnet_close(env, socket);
+
+  JCL_free_cstring(env, name, iff_name);
+
+  return retval;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_java_net_VMNetworkInterface_isUp (JNIEnv *env, jclass class UNUSED,
+   jstring name)
+{
+  jint flags;
+  int error;
+  jboolean retval;
+
+  if ((error = iff_flags(env, name, flags)))
+  {
+JCL_ThrowException(env, java/net/SocketException,
+   cpnative_getErrorString(error));
+
+retval = JNI_FALSE;
+  }
+  else
+  {
+retval = (jboolean) (flags  (IFF_UP | IFF_RUNNING));
+  }
+
+  return retval;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_java_net_VMNetworkInterface_isPointToPoint (JNIEnv *env,
+ jclass class UNUSED,
+ jstring name)
+{
+  jint flags;
+  int error;
+  jboolean retval;
+
+  if ((error = iff_flags(env, name, flags)))
+  {
+JCL_ThrowException(env, java/net/SocketException,
+   cpnative_getErrorString(error));
+
+retval = JNI_FALSE;
+  }
+  else
+  {
+retval = (jboolean) (flags  IFF_POINTOPOINT);
+  }
+
+  return retval;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_java_net_VMNetworkInterface_isLoopback (JNIEnv *env,
+ jclass class UNUSED,
+ jstring name)
+{
+  jint flags;
+  int error;
+  jboolean retval;
+
+  if ((error = iff_flags(env, name, flags)))
+  {
+JCL_ThrowException(env, java/net/SocketException,
+   cpnative_getErrorString

[cp-patches] FYI: fix StAX API incompatibility

2008-03-04 Thread Robert Schuster
Hi,
while trying to compile woodstox 2.0.6 on classpath I stumbled across an
incompatibility in out StAX API. The attached patch fixes the interface
and adjust all implementations within classpath.

Regards
Robert

2008-03-04  Robert Schuster  [EMAIL PROTECTED]

  * gnu/xml/stream/AttributeImpl.java: Changed type field to String.
  (getDTDType): Changed return type to String.
  * gnu/xml/stream/XMLEventAllocatorImpl.java:
  (allocate): Removed wrapping of string in QName object.
  * gnu/xml/stream/XMLEventFactoryImpl.java:
  (createAttribute(String, String)): Removed wrapping of string in
  QName object.
  (createAttribute(QName, String)): Dito.
  (createAttribute(String, String, String, String)): Dito.
  * javax/xml/stream/events/Attribute.java:
  (getDTDType): Changed return type to String.
Index: gnu/xml/stream/AttributeImpl.java
===
RCS file: /sources/classpath/classpath/gnu/xml/stream/AttributeImpl.java,v
retrieving revision 1.1
diff -u -r1.1 AttributeImpl.java
--- gnu/xml/stream/AttributeImpl.java	4 Sep 2005 09:52:10 -	1.1
+++ gnu/xml/stream/AttributeImpl.java	4 Mar 2008 16:02:43 -
@@ -56,11 +56,11 @@
 
   protected final QName name;
   protected final String value;
-  protected final QName type;
+  protected final String type;
   protected final boolean specified;
 
   protected AttributeImpl(Location location,
-  QName name, String value, QName type,
+  QName name, String value, String type,
   boolean specified)
   {
 super(location);
@@ -85,7 +85,7 @@
 return value;
   }
 
-  public QName getDTDType()
+  public String getDTDType()
   {
 return type;
   }
Index: gnu/xml/stream/XMLEventAllocatorImpl.java
===
RCS file: /sources/classpath/classpath/gnu/xml/stream/XMLEventAllocatorImpl.java,v
retrieving revision 1.3
diff -u -r1.3 XMLEventAllocatorImpl.java
--- gnu/xml/stream/XMLEventAllocatorImpl.java	3 Mar 2006 12:30:59 -	1.3
+++ gnu/xml/stream/XMLEventAllocatorImpl.java	4 Mar 2008 16:02:44 -
@@ -165,7 +165,7 @@
   attributes.add(new AttributeImpl(location,
reader.getAttributeName(i),
reader.getAttributeValue(i),
-   QName.valueOf(reader.getAttributeType(i)),
+   reader.getAttributeType(i),
reader.isAttributeSpecified(i)));
 return new StartElementImpl(location,
 reader.getName(),
Index: gnu/xml/stream/XMLEventFactoryImpl.java
===
RCS file: /sources/classpath/classpath/gnu/xml/stream/XMLEventFactoryImpl.java,v
retrieving revision 1.2
diff -u -r1.2 XMLEventFactoryImpl.java
--- gnu/xml/stream/XMLEventFactoryImpl.java	3 Mar 2006 12:30:59 -	1.2
+++ gnu/xml/stream/XMLEventFactoryImpl.java	4 Mar 2008 16:02:44 -
@@ -79,20 +79,20 @@
   {
 return new AttributeImpl(location,
  new QName(namespaceURI, localName, prefix),
- value, QName.valueOf(CDATA), true);
+ value, CDATA, true);
   }
   
   public Attribute createAttribute(String localName, String value)
   {
 return new AttributeImpl(location,
  new QName(localName),
- value, QName.valueOf(CDATA), true);
+ value, CDATA, true);
   }
 
   public Attribute createAttribute(QName name, String value)
   {
 return new AttributeImpl(location, name, value,
- QName.valueOf(CDATA), true);
+ CDATA, true);
   }
 
   public Namespace createNamespace(String namespaceURI)
Index: javax/xml/stream/events/Attribute.java
===
RCS file: /sources/classpath/classpath/javax/xml/stream/events/Attribute.java,v
retrieving revision 1.2
diff -u -r1.2 Attribute.java
--- javax/xml/stream/events/Attribute.java	4 Sep 2005 09:44:30 -	1.2
+++ javax/xml/stream/events/Attribute.java	4 Mar 2008 16:02:48 -
@@ -59,7 +59,7 @@
   /**
* Returns the type of this attribute.
*/
-  QName getDTDType();
+  String getDTDType();
 
   /**
* Indicates whether this attribute was specified in the input source, or


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] RFC: Abstract StringBuilder and StringBuffer

2008-02-17 Thread Robert Schuster
Hi Andrew,

 public final class StringBuilder
 +  extends AbstractStringBuffer
StringBuffer and StringBuilder have Object as their superclass. I think
we are not allowed to break that. If so you should change your
implementation to follow a delegation pattern and make as many methods
'final' as possible. :)

Regards
Robert



signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] [PATCH] libjava: java.net.URI.relativize method results inconsistent with other Java VMs

2008-01-09 Thread Robert Schuster
Hi,


 The second change involved removing a leading '/' from the returned
 relative path to make it consistent with results from other Java VMs.
 
 This patch corrects two issues found in URI.relativize() method in
 libjava/classpath/java/net/URI.java. It applies from gcc 4.1.2 through latest
 trunk:
 
 * does stricter check for a path match while still using String.startsWith()
 * excludes leading '/' if necessary for relative path fragment being returned
Please check whether this does not cause the wrong behavior described
here come up again: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24249

Regards
Robert



signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: added myself to AUTHORS

2007-12-11 Thread Robert Schuster
Hi,
as expressed by Mark I add myself to the AUTHORS file.

2007-12-11  Robert Schuster  [EMAIL PROTECTED]

  * AUTHORS: Added my name to the list.
Index: AUTHORS
===
RCS file: /sources/classpath/classpath/AUTHORS,v
retrieving revision 1.42
diff -u -r1.42 AUTHORS
--- AUTHORS	23 Nov 2007 14:38:58 -	1.42
+++ AUTHORS	11 Dec 2007 08:32:49 -
@@ -41,6 +41,7 @@
 Aaron M. Renn ([EMAIL PROTECTED])
 Ian Rogers ([EMAIL PROTECTED])
 Andrew Selkirk ([EMAIL PROTECTED])
+Robert Schuster ([EMAIL PROTECTED])
 Christian Thalinger ([EMAIL PROTECTED])
 Andreas Tobler ([EMAIL PROTECTED])
 Mario Torre ([EMAIL PROTECTED])


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] FYI: add myself to THANKYOU

2007-12-11 Thread Robert Schuster
Hi.

Mark Wielaard schrieb:
 But...
 People with active commit rights should be in the AUTHORS file. Really!
Done! :)

Regards
Robert



signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: remove debug output from GlyphView::paint()

2007-12-10 Thread Robert Schuster
Hi,
this little patch removes some debug output from GlyphView::paint().

2007-12-10  Robert Schuster  [EMAIL PROTECTED]

  * javax/swing/text/GlyphView.java:
  (paint): Removed debug output.
Index: javax/swing/text/GlyphView.java
===
RCS file: /sources/classpath/classpath/javax/swing/text/GlyphView.java,v
retrieving revision 1.28
diff -u -r1.28 GlyphView.java
--- javax/swing/text/GlyphView.java	4 Dec 2006 20:26:16 -	1.28
+++ javax/swing/text/GlyphView.java	10 Dec 2007 16:01:25 -
@@ -736,7 +736,6 @@
 if (bg != null)
   {
 g.setColor(bg);
-System.err.println(fill background:  + bg);
 g.fillRect(r.x, r.y, r.width, r.height);
   }
 


signature.asc
Description: OpenPGP digital signature


[cp-patches] RFC: fix for 32516

2007-12-10 Thread Robert Schuster
Hi,
the attached patch removes the dreaded dot - file separator prefixes
from files which should be added to zip (jar) archives. This fixes
32516[0] for me.

ChangeLog:

2007-12-10  Robert Schuster  [EMAIL PROTECTED]

PR classpath/32516:
  * tools/gnu/classpath/tools/jar/Entry.java:
  (Entry(File, String)): Added loop to remove all dot-file separator
  prefixes.
  (Entry(File)): Call Entry(File, String) constructor variant.

[0] - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32516
Index: tools/gnu/classpath/tools/jar/Entry.java
===
RCS file: /sources/classpath/classpath/tools/gnu/classpath/tools/jar/Entry.java,v
retrieving revision 1.1
diff -u -r1.1 Entry.java
--- tools/gnu/classpath/tools/jar/Entry.java	8 May 2006 18:38:20 -	1.1
+++ tools/gnu/classpath/tools/jar/Entry.java	10 Dec 2007 19:46:18 -
@@ -49,12 +49,22 @@
   public Entry(File file, String name)
   {
 this.file = file;
-this.name = name;
+
+/* Removes any './' prefixes automatically. Those caused trouble
+ * in (boot) classpath use-cases. See #32516.
+ */
+int start = 0;
+while (name.length()  start + 2
+name.codePointAt(start) == '.'
+name.codePointAt(start + 1) == File.separatorChar)
+  start += 2;
+
+this.name = name.substring(start);
   }
 
   public Entry(File file)
   {
-this.file = file;
-this.name = file.toString();
+this(file, file.toString());
   }
+
 }


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] RFC: fix for 32516

2007-12-10 Thread Robert Schuster
Hi.

Robert Schuster schrieb:
 Hi,
 the attached patch removes the dreaded dot - file separator prefixes
from files which should be added to zip (jar) archives. This fixes
 32516[0] for me.
 
 ChangeLog:
 
 2007-12-10  Robert Schuster  [EMAIL PROTECTED]
 
 PR classpath/32516:
   * tools/gnu/classpath/tools/jar/Entry.java:
   (Entry(File, String)): Added loop to remove all dot-file separator
   prefixes.
   (Entry(File)): Call Entry(File, String) constructor variant.
 
 [0] - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32516
 

Tom Tromey confirmed this on IRC. Committing as attached with a small
fix to the copyright line.

ChangeLog:

2007-12-10  Robert Schuster  [EMAIL PROTECTED]

PR classpath/32516:
  * tools/gnu/classpath/tools/jar/Entry.java:
  (Entry(File, String)): Added loop to remove all dot-file separator
  prefixes.
  (Entry(File)): Call Entry(File, String) constructor variant.

Regards
Robert
Index: tools/gnu/classpath/tools/jar/Entry.java
===
RCS file: /sources/classpath/classpath/tools/gnu/classpath/tools/jar/Entry.java,v
retrieving revision 1.1
diff -u -r1.1 Entry.java
--- tools/gnu/classpath/tools/jar/Entry.java	8 May 2006 18:38:20 -	1.1
+++ tools/gnu/classpath/tools/jar/Entry.java	10 Dec 2007 22:20:05 -
@@ -1,5 +1,5 @@
 /* Entry.java - represent a single file to write to a jar
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
 
  This file is part of GNU Classpath.
 
@@ -49,12 +49,22 @@
   public Entry(File file, String name)
   {
 this.file = file;
-this.name = name;
+
+/* Removes any './' prefixes automatically. Those caused trouble
+ * in (boot) classpath use-cases. See #32516.
+ */
+int start = 0;
+while (name.length()  start + 2
+name.codePointAt(start) == '.'
+name.codePointAt(start + 1) == File.separatorChar)
+  start += 2;
+
+this.name = name.substring(start);
   }
 
   public Entry(File file)
   {
-this.file = file;
-this.name = file.toString();
+this(file, file.toString());
   }
+
 }


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: add myself to THANKYOU

2007-12-10 Thread Robert Schuster
Hi,
I added myself to the thankyou file. :)

Thank you, too, GNU Classpath and friends. Working on the project has
always been fulfilling for me!

2007-12-10  Robert Schuster  [EMAIL PROTECTED]

  * THANKYOU: Added my name to the list.
Index: THANKYOU
===
RCS file: /sources/classpath/classpath/THANKYOU,v
retrieving revision 1.37
diff -u -r1.37 THANKYOU
--- THANKYOU	17 May 2006 09:06:09 -	1.37
+++ THANKYOU	10 Dec 2007 22:24:03 -
@@ -41,6 +41,7 @@
 Petter Reinholdtsen ([EMAIL PROTECTED])
 Julian Scheid ([EMAIL PROTECTED])
 Martin Schröder ([EMAIL PROTECTED])
+Robert Schuster ([EMAIL PROTECTED])
 Gaute Smaaland ([EMAIL PROTECTED])
 Michael Smith ([EMAIL PROTECTED])
 J. Russell Smyth ([EMAIL PROTECTED])


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] RFC: fix warning in cpio_df

2007-11-08 Thread Robert Schuster
Hi.

Mario Torre schrieb:
 Il giorno gio, 08/11/2007 alle 13.06 +0100, Mark Wielaard ha scritto:
 Hi Robert,

 On Wed, 2007-11-07 at 22:13 +0100, Robert Schuster wrote:
 this patch marks the parameters of cpio_df as possibly unused and
 silents the warning/lets the build continue with -Wall.
 Which system is this?
 I am not really opposed to the patch, but it would of course be better
 to figure out how to correctly return something for your setup if at all
 possible.
 
 Yes, please, I had troubles figuring out this.
 
 As for the patch, I did that way to catch exactly the systems where no
 statvfs is available.
 
 Can you try using statfs? If it's a system where df is available we can
 try to steal some code from there also.
This is Debian Lenny/Sid x86. I am not sure whether it is normal that
statvfs is not available on it but even then I think the problem is more
a tiny glitch in the code:

JNIEXPORT long long
cpio_df (const char *path, CPFILE_DF_TYPE type)
{
  long long result = 0L;

#if defined(HAVE_STATVFS)

  ... much stuff

#endif

  return result;
}

Now if HAVE_STATVFS is not defined the compiler is correct mourning that
'path' and 'type' are not used. I have seen code (in classpath) where
this issue is solved this way:

JNIEXPORT long long
cpio_df (const char *path, CPFILE_DF_TYPE type)
{
  long long result = 0L;

#if defined(HAVE_STATVFS)

  ... much stuff
#else

 (void) path;
 (void) type;

#endif

  return result;
}

See Java_gnu_java_nio_KqueueSelectorImpl_kevent_1set for example.

Regards
Robert



signature.asc
Description: OpenPGP digital signature


[cp-patches] FIY: build fix for localsockets

2007-09-12 Thread Robert Schuster
Hi,
a C file from the local sockets implementation unconditionally defined
_GNU_SOURCE causing trouble in builds where this is already defined.

Thanks go to Dalibor who helped me to track this down.

Regards
Robert

2007-09-12  Robert Schuster  [EMAIL PROTECTED]

* native/jni/java-net/gnu_java_net_local_LocalSocketImpl.c:
Add #ifndef guard around definition of _GNU_SOURCE.
Index: native/jni/java-net/gnu_java_net_local_LocalSocketImpl.c
===
RCS file: /sources/classpath/classpath/native/jni/java-net/gnu_java_net_local_LocalSocketImpl.c,v
retrieving revision 1.4
diff -u -r1.4 gnu_java_net_local_LocalSocketImpl.c
--- native/jni/java-net/gnu_java_net_local_LocalSocketImpl.c	21 Aug 2006 09:40:13 -	1.4
+++ native/jni/java-net/gnu_java_net_local_LocalSocketImpl.c	12 Sep 2007 18:55:03 -
@@ -35,8 +35,9 @@
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version.  */
 
-
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif
 
 #include config.h
 


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: NPE fix for OpenTypeFont

2007-05-25 Thread Robert Schuster
Hi,
I applied this little patch to prevent a NPE when using a JTextField
with the X peers.

Regards
Robert

2007-05-25  Robert Schuster  [EMAIL PROTECTED]

* gnu/java/awt/font/opentype/OpenTypeFont.java:
(getGlyphIndex): Call getGlyphCharMap() instead of
accessing cmap field directly.
Index: gnu/java/awt/font/opentype/OpenTypeFont.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/font/opentype/OpenTypeFont.java,v
retrieving revision 1.7
diff -u -r1.7 OpenTypeFont.java
--- gnu/java/awt/font/opentype/OpenTypeFont.java	8 May 2007 14:40:12 -	1.7
+++ gnu/java/awt/font/opentype/OpenTypeFont.java	25 May 2007 09:44:17 -
@@ -626,7 +626,7 @@
*/
   public int getGlyphIndex(int c)
   {
-return cmap.getGlyph(c);
+return getCharGlyphMap().getGlyph(c);
   }
 
   /**


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: Added translation to XGraphics

2007-05-25 Thread Robert Schuster
Hi,
the following patch adds adding the translation to rawFillRect() and
rawDrawLine() in XGraphics2D. This fixes painting the gradient and
backgrounds for Swing components.

2007-05-25  Robert Schuster  [EMAIL PROTECTED]

* gnu/java/awt/peer/x/XGraphics2D.java:
(rawDrawLine): Added addition of translation.
(rawFillRect): Dito.

Regards
Robert
Index: gnu/java/awt/peer/x/XGraphics2D.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/x/XGraphics2D.java,v
retrieving revision 1.4
diff -u -r1.4 XGraphics2D.java
--- gnu/java/awt/peer/x/XGraphics2D.java	24 May 2007 16:26:55 -	1.4
+++ gnu/java/awt/peer/x/XGraphics2D.java	25 May 2007 10:36:20 -
@@ -94,12 +94,15 @@
 
   protected void rawDrawLine(int x0, int y0, int x1, int y1)
   {
-xdrawable.segment(xgc, x0, y0, x1, y1);
+int tx = (int) transform.getTranslateX();
+int ty = (int) transform.getTranslateY();
+xdrawable.segment(xgc, x0 + tx, y0 + ty, x1 + tx, y1 + ty);
   }
 
   protected void rawFillRect(int x, int y, int w, int h)
   {
-xdrawable.rectangle(xgc, x, y, w, h, true);
+xdrawable.rectangle(xgc, x + (int) transform.getTranslateX(),
+ y + (int) transform.getTranslateY(), w, h, true);
   }
 
   /**
@@ -317,4 +320,7 @@
   }
 return ret;
   }
+
+
 }
+


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: XEventPump fix

2007-05-22 Thread Robert Schuster
Hi,
the attached patch makes mouse events work again for the X peers (and
prevent a NPE later).

Regards
Robert

2007-05-22  Robert Schuster  [EMAIL PROTECTED]

* gnu/java/awt/peer/x/XEventQueue.java:
(handleEvent): Use Input.event_window_id instead of
Input.child_window_id for mouse  key presses/releases.
Index: gnu/java/awt/peer/x/XEventPump.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/x/XEventPump.java,v
retrieving revision 1.3
diff -u -r1.3 XEventPump.java
--- gnu/java/awt/peer/x/XEventPump.java	30 Apr 2007 20:30:56 -	1.3
+++ gnu/java/awt/peer/x/XEventPump.java	22 May 2007 17:41:57 -
@@ -151,20 +151,19 @@
 
 Integer key = null;
 Window awtWindow = null;
-if (xEvent instanceof Input)
-  {
-key= new Integer(((Input) xEvent).child_window_id);
-awtWindow = (Window) windows.get(key);
-  }
+
 if (XToolkit.DEBUG)
   System.err.println(fetched event:  + xEvent);
 switch (xEvent.code())
 {
 case ButtonPress.CODE:
   ButtonPress bp = (ButtonPress) xEvent;
+  key= new Integer(bp.event_window_id);
+  awtWindow = (Window) windows.get(key);
   // Create and post the mouse event.
   int button = bp.detail();
   drag = button;
+
   MouseEvent mp = new MouseEvent(awtWindow, MouseEvent.MOUSE_PRESSED,
  System.currentTimeMillis(), 0,
  bp.event_x(), bp.event_y(),
@@ -173,6 +172,8 @@
   break;
 case ButtonRelease.CODE:
   ButtonRelease br = (ButtonRelease) xEvent;
+  key= new Integer(br.event_window_id);
+  awtWindow = (Window) windows.get(key);
   drag = -1;
   MouseEvent mr = new MouseEvent(awtWindow, MouseEvent.MOUSE_RELEASED,
  System.currentTimeMillis(), 0,
@@ -182,6 +183,9 @@
   break;
 case MotionNotify.CODE:
   MotionNotify mn = (MotionNotify) xEvent;
+  key= new Integer(mn.event_window_id);
+  awtWindow = (Window) windows.get(key);
+
   MouseEvent mm;
   if (drag == -1)
 {


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] FYI: X Peers enhancement

2007-05-22 Thread Robert Schuster
Hi,
you forgot to commit the changelog entry. Did that for you.

Regards
Robert

Roman Kennke schrieb:
 This brings the X peers up to the recent enhancement of the rasterizer.
 
 2007-05-22  Roman Kennke  [EMAIL PROTECTED]
 
 * gnu/java/awt/peer/x/XFontPeer2.java
 (XFontMetrics.charWidth): Use cached Point2D instance.
 * gnu/java/awt/peer/x/XGraphics2D.java
 (renderScanline): New method. Renders a scanline according to
 the coverage information.
 (setPaint): Call super, so that the state is updated correctly.
 
 /Roman
 
 
 
 
 Index: gnu/java/awt/peer/x/XFontPeer2.java
 ===
 RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/x/XFontPeer2.java,v
 retrieving revision 1.4
 diff -u -1 -5 -r1.4 XFontPeer2.java
 --- gnu/java/awt/peer/x/XFontPeer2.java   8 May 2007 15:03:07 -   
 1.4
 +++ gnu/java/awt/peer/x/XFontPeer2.java   22 May 2007 13:12:05 -
 @@ -194,31 +194,31 @@
 false, false, false);
  }
  
  public int getHeight()
  {
GlyphVector gv = fontDelegate.createGlyphVector(getFont(),
  new FontRenderContext(IDENDITY, false, false),
  new StringCharacterIterator(m));
Rectangle2D b = gv.getVisualBounds();
return (int) b.getHeight();
  }
  
  public int charWidth(char c)
  {
int code = fontDelegate.getGlyphIndex(c);
 -  Point2D advance = new Point2D.Double();
 +  Point2D advance = cachedPoint;
fontDelegate.getAdvance(code, font.getSize2D(), IDENDITY,
false, false, true, advance);
return (int) advance.getX();
  }
  
  public int charsWidth(char[] chars, int offs, int len)
  {
return stringWidth(new String(chars, offs, len));
  }
  
  public int stringWidth(String s)
  {
GlyphVector gv = fontDelegate.createGlyphVector(getFont(),
  new FontRenderContext(IDENDITY, false, false),
  new StringCharacterIterator(s));
 Index: gnu/java/awt/peer/x/XGraphics2D.java
 ===
 RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/x/XGraphics2D.java,v
 retrieving revision 1.2
 diff -u -1 -5 -r1.2 XGraphics2D.java
 --- gnu/java/awt/peer/x/XGraphics2D.java  30 Apr 2007 20:30:56 -  
 1.2
 +++ gnu/java/awt/peer/x/XGraphics2D.java  22 May 2007 13:12:05 -
 @@ -40,30 +40,31 @@
  import java.awt.Color;
  import java.awt.Graphics;
  import java.awt.GraphicsConfiguration;
  import java.awt.Image;
  import java.awt.Paint;
  import java.awt.Rectangle;
  import java.awt.Shape;
  import java.awt.Toolkit;
  import java.awt.geom.AffineTransform;
  import java.awt.image.ColorModel;
  import java.awt.image.ImageObserver;
  import java.awt.image.Raster;
  import java.util.HashMap;
  
  import gnu.java.awt.java2d.AbstractGraphics2D;
 +import gnu.java.awt.java2d.ScanlineCoverage;
  import gnu.x11.Colormap;
  import gnu.x11.Drawable;
  import gnu.x11.GC;
  import gnu.x11.image.ZPixmap;
  
  public class XGraphics2D
extends AbstractGraphics2D
  {
  
/**
 * The X Drawable to draw on.
 */
private Drawable xdrawable;
  
/**
 @@ -204,52 +205,92 @@
{
  pixel = raster.getPixel(tx, ty, pixel);
  //System.err.println(tx:  + tx + , ty:  + ty + , pixel: 
  + pixel[0] + ,  + pixel[1] + ,  + pixel[2]);
  //  System.err.print(r:  + pixel[0]);
  //  System.err.print(, g:  + pixel[1]);
  //  System.err.println(, b:  + pixel[2]);
  zPixmap.set_red(tx - x, ty - y, pixel[0]);
  zPixmap.set_green(tx - x, ty - y, pixel[1]);
  zPixmap.set_blue(tx - x, ty - y, pixel[2]);
}
}
  xdrawable.put_image(xgc, zPixmap, x, y);
}
}
  
 +  public void renderScanline(int y, ScanlineCoverage c)
 +  {
 +ScanlineCoverage.Coverage start = c.iterate();
 +ScanlineCoverage.Coverage end = c.next();
 +assert (start != null);
 +assert (end != null);
 +int coverageAlpha = 0;
 +int maxCoverage = c.getMaxCoverage();
 +Color old = getColor();
 +Color col = getColor();
 +if (col == null)
 +  col = Color.BLACK;
 +do
 +  {
 +// TODO: Dumb implementation for testing.
 +coverageAlpha = coverageAlpha + start.getCoverageDelta();
 +if (coverageAlpha  0)
 +  {
 +int red = col.getRed();
 +int green = col.getGreen();
 +int blue = col.getBlue();
 +if (coverageAlpha  c.getMaxCoverage())
 +  {
 +float alpha = coverageAlpha / maxCoverage;
 +red = 255 - (int) ((255 - red) * alpha);

Re: [cp-patches] FYI: XEventPump fix

2007-05-22 Thread Robert Schuster
Hi,
actually the changelog should read:

2007-05-22  Robert Schuster  [EMAIL PROTECTED]

* gnu/java/awt/peer/x/XEventQueue.java:
(handleEvent): Use Input.event_window_id instead of
Input.child_window_id for mouse presses/releases 
movement.

Sorry for the inconvenience.


Regards
Robert

Robert Schuster schrieb:
 Hi,
 the attached patch makes mouse events work again for the X peers (and
 prevent a NPE later).
 
 Regards
 Robert
 
 2007-05-22  Robert Schuster  [EMAIL PROTECTED]
 
 * gnu/java/awt/peer/x/XEventQueue.java:
 (handleEvent): Use Input.event_window_id instead of
 Input.child_window_id for mouse  key presses/releases.
 
 
 
 
 Index: gnu/java/awt/peer/x/XEventPump.java
 ===
 RCS file: /sources/classpath/classpath/gnu/java/awt/peer/x/XEventPump.java,v
 retrieving revision 1.3
 diff -u -r1.3 XEventPump.java
 --- gnu/java/awt/peer/x/XEventPump.java   30 Apr 2007 20:30:56 -  
 1.3
 +++ gnu/java/awt/peer/x/XEventPump.java   22 May 2007 17:41:57 -
 @@ -151,20 +151,19 @@
  
  Integer key = null;
  Window awtWindow = null;
 -if (xEvent instanceof Input)
 -  {
 -key= new Integer(((Input) xEvent).child_window_id);
 -awtWindow = (Window) windows.get(key);
 -  }
 +
  if (XToolkit.DEBUG)
System.err.println(fetched event:  + xEvent);
  switch (xEvent.code())
  {
  case ButtonPress.CODE:
ButtonPress bp = (ButtonPress) xEvent;
 +  key= new Integer(bp.event_window_id);
 +  awtWindow = (Window) windows.get(key);
// Create and post the mouse event.
int button = bp.detail();
drag = button;
 +
MouseEvent mp = new MouseEvent(awtWindow, MouseEvent.MOUSE_PRESSED,
   System.currentTimeMillis(), 0,
   bp.event_x(), bp.event_y(),
 @@ -173,6 +172,8 @@
break;
  case ButtonRelease.CODE:
ButtonRelease br = (ButtonRelease) xEvent;
 +  key= new Integer(br.event_window_id);
 +  awtWindow = (Window) windows.get(key);
drag = -1;
MouseEvent mr = new MouseEvent(awtWindow, MouseEvent.MOUSE_RELEASED,
   System.currentTimeMillis(), 0,
 @@ -182,6 +183,9 @@
break;
  case MotionNotify.CODE:
MotionNotify mn = (MotionNotify) xEvent;
 +  key= new Integer(mn.event_window_id);
 +  awtWindow = (Window) windows.get(key);
 +
MouseEvent mm;
if (drag == -1)
  {



signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: fix key events for X peers

2007-05-22 Thread Robert Schuster
Hi,
I was missing the keyboard part in my last patch. Here it is.

2007-05-22  Robert Schuster  [EMAIL PROTECTED]

* gnu/java/awt/peer/x/XEventQueue.java:
(handleEvent): Use Input.event_window_id for
key presses/releases.

Regards
Robert
Index: gnu/java/awt/peer/x/XEventPump.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/x/XEventPump.java,v
retrieving revision 1.4
diff -u -r1.4 XEventPump.java
--- gnu/java/awt/peer/x/XEventPump.java	22 May 2007 17:54:43 -	1.4
+++ gnu/java/awt/peer/x/XEventPump.java	22 May 2007 18:40:57 -
@@ -241,6 +241,8 @@
   break;
 case KeyPress.CODE:
 case KeyRelease.CODE:
+  key = new Integer(((Input) xEvent).event_window_id);
+  awtWindow = (Window) windows.get(key);
   handleKeyEvent(xEvent, awtWindow);
   break;
 default:


signature.asc
Description: OpenPGP digital signature


[cp-patches] RFC: calculate button modifiers for X peers

2007-05-22 Thread Robert Schuster
Hi,
the attached patch properly calculates the modifiers for mouse press
and release events.

Ok, to commit?

2007-05-22  Robert Schuster  [EMAIL PROTECTED]

* gnu/java/awt/peer/x/XEventQueue.java:
(handleEvent): Calculate modifier value for mouse presse
and release events.
(buttonToModifier): New method.
* gnu/java/awt/peer/x/KeyboardMapping.java:
(mapModifiers): Added cases for alt gr and the meta key.

Regards
Robert

Index: gnu/java/awt/peer/x/KeyboardMapping.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/x/KeyboardMapping.java,v
retrieving revision 1.1
diff -u -r1.1 KeyboardMapping.java
--- gnu/java/awt/peer/x/KeyboardMapping.java	29 Jun 2006 15:15:56 -	1.1
+++ gnu/java/awt/peer/x/KeyboardMapping.java	22 May 2007 21:37:43 -
@@ -405,8 +405,12 @@
 
 if ((xMods  Input.SHIFT_MASK) != 0)
   mods |= KeyEvent.SHIFT_MASK | KeyEvent.SHIFT_DOWN_MASK;
+if ((xMods  Input.META_MASK) != 0)
+  mods |= KeyEvent.META_MASK | KeyEvent.META_DOWN_MASK;
 if ((xMods  Input.ALT_MASK) != 0)
   mods |= KeyEvent.ALT_MASK | KeyEvent.ALT_DOWN_MASK;
+if ((xMods  Input.MOD5_MASK) != 0)
+  mods |= KeyEvent.ALT_GRAPH_MASK | KeyEvent.ALT_GRAPH_DOWN_MASK;
 if ((xMods  Input.CONTROL_MASK) != 0)
   mods |= KeyEvent.CTRL_MASK | KeyEvent.CTRL_DOWN_MASK;
 
Index: gnu/java/awt/peer/x/XEventPump.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/x/XEventPump.java,v
retrieving revision 1.5
diff -u -r1.5 XEventPump.java
--- gnu/java/awt/peer/x/XEventPump.java	22 May 2007 18:45:13 -	1.5
+++ gnu/java/awt/peer/x/XEventPump.java	22 May 2007 21:37:43 -
@@ -48,6 +48,8 @@
 import java.awt.event.PaintEvent;
 import java.util.HashMap;
 
+import gnu.java.awt.EventModifier;
+
 import gnu.x11.Display;
 import gnu.x11.event.ButtonPress;
 import gnu.x11.event.ButtonRelease;
@@ -162,10 +164,15 @@
   awtWindow = (Window) windows.get(key);
   // Create and post the mouse event.
   int button = bp.detail();
+
+  // AWT cannot handle more than 3 buttons and expects 0 instead.
+  if (button = 3)
+button = 0;
   drag = button;
 
   MouseEvent mp = new MouseEvent(awtWindow, MouseEvent.MOUSE_PRESSED,
- System.currentTimeMillis(), 0,
+ System.currentTimeMillis(),
+ KeyboardMapping.mapModifiers(bp.state()) | buttonToModifier(button),
  bp.event_x(), bp.event_y(),
  1, false, button);
   Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(mp);
@@ -174,11 +181,17 @@
   ButtonRelease br = (ButtonRelease) xEvent;
   key= new Integer(br.event_window_id);
   awtWindow = (Window) windows.get(key);
+
+  button = br.detail();
+  // AWT cannot handle more than 3 buttons and expects 0 instead.
+  if (button = 3)
+button = 0;
   drag = -1;
   MouseEvent mr = new MouseEvent(awtWindow, MouseEvent.MOUSE_RELEASED,
- System.currentTimeMillis(), 0,
+ System.currentTimeMillis(),
+ KeyboardMapping.mapModifiers(br.state()) | buttonToModifier(button),
  br.event_x(), br.event_y(),
- 1, false, br.detail());
+ 1, false, button);
   Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(mr);
   break;
 case MotionNotify.CODE:
@@ -297,6 +310,23 @@
 
   }
 
+  /** Translates an X button identifier to the AWT's MouseEvent modifier
+   *  mask. As the AWT cannot handle more than 3 buttons those return
+   *  code0/code.
+   */
+  static int buttonToModifier(int button)
+  {
+switch (button)
+{
+  case 1:
+return MouseEvent.BUTTON1_DOWN_MASK | MouseEvent.BUTTON1_MASK;
+  case 2:
+return MouseEvent.BUTTON2_DOWN_MASK | MouseEvent.BUTTON2_MASK;
+  case 3:
+return MouseEvent.BUTTON3_DOWN_MASK | MouseEvent.BUTTON3_MASK;
+}
 
-}
+return 0;
+  }
 
+}



signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: mouse event modifiers fix for the X peers

2007-05-22 Thread Robert Schuster
Hi,
the attached patch fixes the modifiers for the X peers.

Changes since my last RFC are: Removed a superfluous import, changed all
number literals to constant names and mentioned the button clipping in
the changelog.

2007-05-22  Robert Schuster  [EMAIL PROTECTED]

* gnu/java/awt/peer/x/XEventQueue.java:
(handleEvent): Calculate modifier value for mouse presse
and release events, clip button values.
(buttonToModifier): New method.
* gnu/java/awt/peer/x/KeyboardMapping.java:
(mapModifiers): Added cases for alt gr and the meta key.

Regards
Robert
Index: gnu/java/awt/peer/x/XEventPump.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/x/XEventPump.java,v
retrieving revision 1.5
diff -u -r1.5 XEventPump.java
--- gnu/java/awt/peer/x/XEventPump.java	22 May 2007 18:45:13 -	1.5
+++ gnu/java/awt/peer/x/XEventPump.java	22 May 2007 22:21:58 -
@@ -162,10 +162,15 @@
   awtWindow = (Window) windows.get(key);
   // Create and post the mouse event.
   int button = bp.detail();
+
+  // AWT cannot handle more than 3 buttons and expects 0 instead.
+  if (button = gnu.x11.Input.BUTTON3)
+button = 0;
   drag = button;
 
   MouseEvent mp = new MouseEvent(awtWindow, MouseEvent.MOUSE_PRESSED,
- System.currentTimeMillis(), 0,
+ System.currentTimeMillis(),
+ KeyboardMapping.mapModifiers(bp.state()) | buttonToModifier(button),
  bp.event_x(), bp.event_y(),
  1, false, button);
   Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(mp);
@@ -174,11 +179,17 @@
   ButtonRelease br = (ButtonRelease) xEvent;
   key= new Integer(br.event_window_id);
   awtWindow = (Window) windows.get(key);
+
+  button = br.detail();
+  // AWT cannot handle more than 3 buttons and expects 0 instead.
+  if (button = gnu.x11.Input.BUTTON3)
+button = 0;
   drag = -1;
   MouseEvent mr = new MouseEvent(awtWindow, MouseEvent.MOUSE_RELEASED,
- System.currentTimeMillis(), 0,
+ System.currentTimeMillis(),
+ KeyboardMapping.mapModifiers(br.state()) | buttonToModifier(button),
  br.event_x(), br.event_y(),
- 1, false, br.detail());
+ 1, false, button);
   Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(mr);
   break;
 case MotionNotify.CODE:
@@ -297,6 +308,23 @@
 
   }
 
+  /** Translates an X button identifier to the AWT's MouseEvent modifier
+   *  mask. As the AWT cannot handle more than 3 buttons those return
+   *  code0/code.
+   */
+  static int buttonToModifier(int button)
+  {
+switch (button)
+{
+  case gnu.x11.Input.BUTTON1:
+return MouseEvent.BUTTON1_DOWN_MASK | MouseEvent.BUTTON1_MASK;
+  case gnu.x11.Input.BUTTON2:
+return MouseEvent.BUTTON2_DOWN_MASK | MouseEvent.BUTTON2_MASK;
+  case gnu.x11.Input.BUTTON3:
+return MouseEvent.BUTTON3_DOWN_MASK | MouseEvent.BUTTON3_MASK;
+}
 
-}
+return 0;
+  }
 
+}
Index: gnu/java/awt/peer/x/KeyboardMapping.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/x/KeyboardMapping.java,v
retrieving revision 1.1
diff -u -r1.1 KeyboardMapping.java
--- gnu/java/awt/peer/x/KeyboardMapping.java	29 Jun 2006 15:15:56 -	1.1
+++ gnu/java/awt/peer/x/KeyboardMapping.java	22 May 2007 22:21:58 -
@@ -405,8 +405,12 @@
 
 if ((xMods  Input.SHIFT_MASK) != 0)
   mods |= KeyEvent.SHIFT_MASK | KeyEvent.SHIFT_DOWN_MASK;
+if ((xMods  Input.META_MASK) != 0)
+  mods |= KeyEvent.META_MASK | KeyEvent.META_DOWN_MASK;
 if ((xMods  Input.ALT_MASK) != 0)
   mods |= KeyEvent.ALT_MASK | KeyEvent.ALT_DOWN_MASK;
+if ((xMods  Input.MOD5_MASK) != 0)
+  mods |= KeyEvent.ALT_GRAPH_MASK | KeyEvent.ALT_GRAPH_DOWN_MASK;
 if ((xMods  Input.CONTROL_MASK) != 0)
   mods |= KeyEvent.CTRL_MASK | KeyEvent.CTRL_DOWN_MASK;
 


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: add offset to memcpy operation

2006-11-09 Thread Robert Schuster
Hi,
the memcpy operation in gnu_java_nio_VMChannel.c::getsockname() for the
IPv6 case was copying the port value into the same space as the IPv6
address. I fixed this by adding an offset (like its done in the IPv4 case).

ChangeLog:

2006-11-09  Robert Schuster  [EMAIL PROTECTED]

* native/jni/java-nio/gnu_java_nio_VMChannel.c:
(getsockname): Added 16 byte offset to memcpy operation.

cya
Robert



signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: add offset to memcpy operation - getpeername

2006-11-09 Thread Robert Schuster
Hi,
gnu_java_nio_VMChannel.c::getpeername() the memcpy operation in the IPv6
case is missing an offset when copying the port value in. This patch
fixes that.

ChangeLog:

2006-11-09  Robert Schuster  [EMAIL PROTECTED]

* native/jni/java-nio/gnu_java_nio_VMChannel.c:
(getpeername): Added 16 byte offset to memcpy operation.

cya
Robert




signature.asc
Description: PGP signature
Index: native/jni/java-nio/gnu_java_nio_VMChannel.c
===
RCS file: /cvsroot/classpath/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c,v
retrieving revision 1.8
diff -u -r1.8 gnu_java_nio_VMChannel.c
--- native/jni/java-nio/gnu_java_nio_VMChannel.c	9 Nov 2006 11:10:55 -	1.8
+++ native/jni/java-nio/gnu_java_nio_VMChannel.c	9 Nov 2006 11:26:09 -
@@ -1331,7 +1331,7 @@
 {
   addr6 = (struct sockaddr_in6 *) sockaddr;
   memcpy (nameptr, (addr6-sin6_addr.s6_addr), 16);
-  memcpy (nameptr, (addr6-sin6_port), 2);
+  memcpy (nameptr + 16, (addr6-sin6_port), 2);
   return 16;
 }
 #endif /* HAVE_INET6 */


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: Fix for PR29576

2006-10-24 Thread Robert Schuster
Hi,
the attached patch partly fixes PR29576. Without redesigning VMNetworkInterface
I just added a constructor which sets the field name to null and adds the
ANY_ADDR to the address list. NetworkInterface got a new package private method
which is to be called by MulticastSocket. Some other methods learned to deal
with the field name of an VMNetworkInterface instance being null.

ChangeLog:
2006-10-25  Robert Schuster  [EMAIL PROTECTED]

Fixes PR29576
* java/net/NetworkInterface.java:
(createAnyInterface): New method.
(equals): Added if-statement to handle case where netif.name is null.
* vm/reference/java/net/VMNetworkInterface.java:
(hashCode): Rewritten.
(VMNetworkInterface): New constructor.


cya
Robert
Index: java/net/NetworkInterface.java
===
RCS file: /cvsroot/classpath/classpath/java/net/NetworkInterface.java,v
retrieving revision 1.20
diff -u -r1.20 NetworkInterface.java
--- java/net/NetworkInterface.java	17 Sep 2006 07:31:42 -	1.20
+++ java/net/NetworkInterface.java	24 Oct 2006 23:17:23 -
@@ -67,6 +67,16 @@
 this.netif = netif;
   }
   
+  /** Creates an NetworkInterface instance which
+   * represents any interface in the system. Its only
+   * address is code0.0.0.0/0.0.0.0/code. This
+   * method is needed by [EMAIL PROTECTED] MulticastSocket#getNetworkInterface}
+   */
+  static NetworkInterface createAnyInterface()
+  {
+return new NetworkInterface(new VMNetworkInterface());
+  }
+  
   /**
* Returns the name of the network interface
*
@@ -206,6 +216,9 @@
   return false;
 
 NetworkInterface tmp = (NetworkInterface) obj;
+
+if (netif.name == null)
+  return tmp.netif.name == null;
 
 return (netif.name.equals(tmp.netif.name)
  (netif.addresses.equals(tmp.netif.addresses)));
@@ -219,7 +232,12 @@
   public int hashCode()
   {
 // FIXME: hash correctly
-return netif.name.hashCode() + netif.addresses.hashCode();
+int hc = netif.addresses.hashCode();
+
+if (netif.name != null)
+  hc += netif.name.hashCode();
+
+return hc;
   }
 
   /**
Index: vm/reference/java/net/VMNetworkInterface.java
===
RCS file: /cvsroot/classpath/classpath/vm/reference/java/net/VMNetworkInterface.java,v
retrieving revision 1.5
diff -u -r1.5 VMNetworkInterface.java
--- vm/reference/java/net/VMNetworkInterface.java	17 Sep 2006 07:31:43 -	1.5
+++ vm/reference/java/net/VMNetworkInterface.java	24 Oct 2006 23:17:23 -
@@ -66,6 +66,23 @@
 addresses = new HashSet();
   }
   
+  /**
+   * Creates a dummy instance which represents any network
+   * interface.
+   */
+  public VMNetworkInterface()
+  {
+addresses = new HashSet();
+try
+  {
+addresses.add(InetAddress.getByName(0.0.0.0));
+  }
+catch (UnknownHostException _)
+  {
+// Cannot happen.
+  }
+  }
+  
   static
   {
 if (Configuration.INIT_LOAD_LIBRARY)


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: final fix for PR29576

2006-10-24 Thread Robert Schuster
Hi,
with this small change to MulticastSocket a proper instance is returned when the
socket's multicast interface results to any.

I know: Test would be nice. I am working on it. :)

ChangeLog:
2006-10-25  Robert Schuster  [EMAIL PROTECTED]

Fixes PR29576
* java/net/MulticastSocket.java:
(getNetworkInterface): Return a special NetworkInterface instance
if the socket's multicast interface is set to any.

cya
Robert


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: Inet6Address fix

2006-10-24 Thread Robert Schuster
Hi,
byte value comparisons in Java are evil. Adding a cast to a byte of the right
value fixes the Inet6Address.isMulticastAddress method.

ChangeLog:
2006-10-25  Robert Schuster  [EMAIL PROTECTED]

* java/net/Inet6Address.java:
(isMulticastAddress): Fixed check.


cya
Robert
Index: java/net/Inet6Address.java
===
RCS file: /cvsroot/classpath/classpath/java/net/Inet6Address.java,v
retrieving revision 1.16
diff -u -r1.16 Inet6Address.java
--- java/net/Inet6Address.java	11 Sep 2006 11:44:24 -	1.16
+++ java/net/Inet6Address.java	24 Oct 2006 23:45:19 -
@@ -121,7 +121,7 @@
*/
   public boolean isMulticastAddress()
   {
-return ipaddress[0] == 0xFF;
+return ipaddress[0] == (byte) 0xFF;
   }
 
   /**


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] FYI: final fix for PR29576

2006-10-24 Thread Robert Schuster
Ahem,
and here is the patch.

Robert Schuster wrote:
 Hi,
 with this small change to MulticastSocket a proper instance is returned when 
 the
 socket's multicast interface results to any.
 
 I know: Test would be nice. I am working on it. :)
 
 ChangeLog:
 2006-10-25  Robert Schuster  [EMAIL PROTECTED]
 
 Fixes PR29576
 * java/net/MulticastSocket.java:
 (getNetworkInterface): Return a special NetworkInterface instance
 if the socket's multicast interface is set to any.
 
 cya
 Robert
Index: java/net/MulticastSocket.java
===
RCS file: /cvsroot/classpath/classpath/java/net/MulticastSocket.java,v
retrieving revision 1.26
diff -u -r1.26 MulticastSocket.java
--- java/net/MulticastSocket.java	2 Jul 2005 20:32:39 -	1.26
+++ java/net/MulticastSocket.java	24 Oct 2006 23:28:09 -
@@ -230,6 +258,10 @@
 
 InetAddress address =
   (InetAddress) getImpl().getOption(SocketOptions.IP_MULTICAST_IF);
+
+if (address.isAnyLocalAddress())
+  return NetworkInterface.createAnyInterface();
+
 NetworkInterface netIf = NetworkInterface.getByInetAddress(address);
 
 return netIf;


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: Java NIO/NET/Socket fixes

2006-10-24 Thread Robert Schuster
Hi,
this patch contains the bulk of my recent work on java.nio/java.net, the
respective VM classes and their native counterparts.

It consists of:
- adding multicast stuff
- fixing exception classes (IOException - SocketException)
- removing the need for VMPlainDatagramSocketImpl and the removal of that class
- a missing case in getOptions (SO_REUSEADDR)
- a wrong constant in leave6
- a rework of accept along with a new method isThreadInterrupted()
- filtering of unwanted options for TCP in PlainSocketImpl
- using the user-given address of a remote host instead of the one provided by a
DNS lookup
- correctly handling SO_LINGER on the Java and the native side
- automatically closing of Socket whose connect() inside the constructor fails.
- documentation of the VM interface changes
- using 'Integer.valueOf()' instead of 'new Integer()'

I got positive feedback for the bigger changes and think that the minor fixes
are just ok.

ChangeLog:
2006-10-25  Robert Schuster  [EMAIL PROTECTED]

* gnu/java/net/PlainDatagramSocketImpl.java:
(connect): Use VMChannel instance for connect call.
(getTimeToLive): Call VMPlainSocketImpl.getTimeToLive.
(setTimeToLive): Call VMPlainSocketImpl.setTimeToLive.
(setOption): Handle multicast options.
(getOption): Handle multicast options.
* gnu/java/net/PlainSocketImpl.java:
(getTimeToLive): Call VMPlainSocketImpl.getTimeToLive.
(setTimeToLive): Call VMPlainSocketImpl.setTimeToLive.
(setOption): Filter unappropriate options.
(getOption): Filter unappropriate options.
(connect): Use given SocketAddress.
(close): Reset address and port.
(getInetAddress):
* include/Makefile.am: Removed all occurences of
gnu_java_net_VMPlainDatagramSocketImpl.h.
* include/gnu_java_net_VMPlainDatagramSocketImpl.h: Removed.
* native/jni/java-net/Makefile.am: Removed
gnu_java_net_VMPlainDatagramSocketImpl.c from sources.
* native/jni/java-net/gnu_java_net_VMPlainDatagramSocketImpl.c:
Removed.
as SocketException, declare to throw SocketException.
* native/jni/java-nio/gnu_java_nio_VMChannel.c: Added definitions
for SocketException and ConnectException.
(Java_gnu_java_nio_VMChannel_connect): Throw SocketException instead
of IOException.
(Java_gnu_java_nio_VMChannel_connect6): Throw SocketException instead
of IOException.
(Java_gnu_java_nio_VMChannel_accept): Rewritten.
(JCL_thread_interrupted): New function.
(initIDs): Added initialisation for isThreadInterrupted method id.
* native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c: Added
CPNET_IP_TTL to java_sockopt enum.
(Java_gnu_java_net_VMPlainSocketImpl_setOption): Handle CPNET_IP_TTL
case, handle SO_LINGER case properly.
(Java_gnu_java_net_VMPlainSocketImpl_getOption): Handle CPNET_IP_TTL
case, handle SO_LINGER case properly.
(Java_gnu_java_net_VMPlainSocketImpl_getMulticastInterface): New
function.
(Java_gnu_java_net_VMPlainSocketImpl_setMulticastInterface): New
function.
(Java_gnu_java_net_VMPlainSocketImpl_setMulticastInterface6): New
function.
(Java_gnu_java_net_VMPlainSocketImpl_leave6): Fixed constant to be
IPV6_LEAVE_GROUP.
* vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java: Removed.
* vm/reference/gnu/java/nio/VMChannel.java:
(connect(int, byte[], int, int)): Declare to throw SocketException.
(connect6): Declare to throw SocketException.
(connect(InetSocketAddress, int)): Catch IOException and rethrow
(isThreadInterrupted): New method.
* vm/reference/gnu/java/net/VMPlainSocketImpl.java: Added CP_IP_TTL
field.
(setTimeToLive): New method.
(getTimeToLive): New method.
(setMulticastInterface(int, InetAddress)): New method.
(setMulticastInterface(int, int, Inet4Address): New method.
(setMulticastInterface6(int, int, Inet6Address): New method.
(setOptions): Handle SO_LINGER case.
(getOptions): Add missing SO_REUSEADDR case.
* java/net/Socket.java:
(Socket(InetAddress, int, InetAddress, int, boolean)): Close socket
when exception was thrown out of connect().
(setSoLinger): Replaced instantiations with valueOf calls, replaced
Boolean.FALSE with Integer.valueOf(-1).
* native/jni/native-lib/cpio.h: Added cpio_closeOnExec declaration.
* native/jni/native-lib/cpio.c: Added cpio_closeOnExec implementation.
* NEWS: Documented VM interface changes.

That was a big one. :)

cya
Robert
Index: gnu/java/net/PlainSocketImpl.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/net/PlainSocketImpl.java,v
retrieving revision 1.14
diff -u -r1.14

[cp-patches] FYI: make _javanet_create_inetaddress accessable

2006-10-24 Thread Robert Schuster
Hi,
my last patch need _javanet_create_inetaddress from javanet.c to be accessable
from another compilation unit. This patch does that.

ChangeLog:
2006-10-25  Robert Schuster  [EMAIL PROTECTED]

* native/jni/java-net/javanet.h: Added declaration for
_javanet_create_inetaddress.
* native/jni/java-net/javanet.c:
(_javanet_create_inetaddress): Removed static keyword.

cya
Robert
Index: native/jni/java-net/javanet.c
===
RCS file: /cvsroot/classpath/classpath/native/jni/java-net/javanet.c,v
retrieving revision 1.36
diff -u -r1.36 javanet.c
--- native/jni/java-net/javanet.c	21 Aug 2006 23:34:45 -	1.36
+++ native/jni/java-net/javanet.c	25 Oct 2006 00:36:06 -
@@ -232,7 +232,7 @@
 /*
  * Builds an InetAddress object from a 32 bit address in host byte order
  */
-static jobject
+jobject
 _javanet_create_inetaddress (JNIEnv * env, cpnet_address *netaddr)
 {
 #ifndef WITHOUT_NETWORK
Index: native/jni/java-net/javanet.h
===
RCS file: /cvsroot/classpath/classpath/native/jni/java-net/javanet.h,v
retrieving revision 1.15
diff -u -r1.15 javanet.h
--- native/jni/java-net/javanet.h	21 Aug 2006 23:34:46 -	1.15
+++ native/jni/java-net/javanet.h	25 Oct 2006 00:36:06 -
@@ -81,6 +81,7 @@
 
 extern int _javanet_get_int_field(JNIEnv *, jobject, const char *);
 extern cpnet_address *_javanet_get_ip_netaddr(JNIEnv *, jobject);
+extern jobject _javanet_create_inetaddress (JNIEnv *, cpnet_address *);
 extern void _javanet_create(JNIEnv *, jobject, jboolean);
 extern void _javanet_close(JNIEnv *, jobject, int);
 extern void _javanet_connect(JNIEnv *, jobject, jobject, jint, jboolean);


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: MulticastSocket.setNetworkInterface fix

2006-10-24 Thread Robert Schuster
Hi,
I partly rewrote this method because it failed to set an IPv4 address on a
Socket connected to an IPv4 multicast group. This happened because on my system
the interface's IPv6 address seems to come before its IPv4 address and the
method took the first one in the old implementation.

While this doesn't fix the problems with MulticastSockets which should deal with
IPv6 multicast groups (see my mail to classpath@gnu.org) it makes at least the
IPv4 case working completely. However the patch shows what kind of unelegant
code is needed to get stuff working at all in an environment with mixed IP 
versions.

ChangeLog:
2006-10-25  Robert Schuster  [EMAIL PROTECTED]

* java/net/MulticastSocket.java:
(setNetworkInterface): Rewritten.

cya
Robert
Index: java/net/MulticastSocket.java
===
RCS file: /cvsroot/classpath/classpath/java/net/MulticastSocket.java,v
retrieving revision 1.27
diff -u -r1.27 MulticastSocket.java
--- java/net/MulticastSocket.java	24 Oct 2006 23:32:25 -	1.27
+++ java/net/MulticastSocket.java	25 Oct 2006 00:42:42 -
@@ -202,13 +202,41 @@
   {
 if (isClosed())
   throw new SocketException(socket is closed);
-
-Enumeration e = netIf.getInetAddresses();
-
-if (! e.hasMoreElements())
-  throw new SocketException(no network devices found);
-
-InetAddress address = (InetAddress) e.nextElement();
+
+InetAddress address;
+if (netIf != null)
+  out:
+  {
+Enumeration e = netIf.getInetAddresses();
+if (getLocalAddress() instanceof Inet4Address)
+  {
+// Search for a IPv4 address.
+while (e.hasMoreElements())
+  {
+address = (InetAddress) e.nextElement();
+if (address instanceof Inet4Address)
+  break out;
+  }
+throw new SocketException(interface  + netIf.getName() +  has no IPv6 address);
+  }
+else if (getLocalAddress() instanceof Inet6Address)
+  {
+// Search for a IPv6 address.
+while (e.hasMoreElements())
+  {
+address = (InetAddress) e.nextElement();
+if (address instanceof Inet6Address)
+  break out;
+  }
+throw new SocketException(interface  + netIf.getName() +  has no IPv6 address);
+  }
+else
+  throw new SocketException(interface  + netIf.getName() +  has no suitable IP address);
+  }
+else
+  address = InetAddress.ANY_IF;
+
+
 getImpl().setOption(SocketOptions.IP_MULTICAST_IF, address);
   }
 


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: fix for wrong JNI code in gnu_java_net_VMPlainSocketImpl.c

2006-10-09 Thread Robert Schuster
Hi,
somehow conversion of a jstring into a char * was missing in the JNI code below
making the those functions unusuable.

ChangeLog:

2006-10-09  Robert Schuster  [EMAIL PROTECTED]

* native/jni/java-net/gnu_java_net/VMPlainSocketImpl.c:
(Java_gnu_java_net_VMPlainSocketImpl_joinGroup): Properly
convert jstring into char *.
(Java_gnu_java_net_VMPlainSocketImpl_joinGroup6): Dito.
(Java_gnu_java_net_VMPlainSocketImpl_leaveGroup): Dito.
(Java_gnu_java_net_VMPlainSocketImpl_leaveGroup6): Dito.
(getif_address): Added const modifier to second argument.
(getif_index): Dito.

cya
Robert
Index: native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c
===
RCS file: /cvsroot/classpath/classpath/native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c	9 Oct 2006 11:08:17 -	1.10
+++ native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c	9 Oct 2006 11:10:41 -	1.11
@@ -555,8 +555,8 @@
 #endif /* HAVE_SETSOCKOPT */
 }
 
-static uint32_t getif_address (JNIEnv *env, char *ifname);
-static int getif_index (JNIEnv *env, char *ifname);
+static uint32_t getif_address (JNIEnv *env, const char *ifname);
+static int getif_index (JNIEnv *env, const char *ifname);
 
 /*
  * Class: gnu_java_net_VMPlainSocketImpl
@@ -572,10 +572,14 @@
 #ifdef HAVE_SETSOCKOPT
   struct ip_mreq maddr;
   jbyte *addr_elems;
+  const char *str_ifname;
 
   if (ifname != NULL)
 {
-  maddr.imr_interface.s_addr = getif_address (env, ifname);
+  str_ifname = JCL_jstring_to_cstring(env, ifname);
+  maddr.imr_interface.s_addr = getif_address (env, str_ifname);
+  JCL_free_cstring(env, ifname, str_ifname);
+
   if ((*env)-ExceptionCheck (env))
 return;
 }
@@ -593,6 +597,7 @@
   if (-1 == setsockopt (fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
 maddr, sizeof (struct ip_mreq)))
 JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
+
 #else
   (void) fd;
   (void) addr;
@@ -617,10 +622,14 @@
 #ifdef HAVE_INET6
   struct ipv6_mreq maddr;
   jbyte *addr_elems;
+  const char *str_ifname;
 
   if (ifname == NULL)
 {
-  maddr.ipv6mr_interface = getif_index (env, ifname);
+  str_ifname = JCL_jstring_to_cstring(env, ifname);
+  maddr.ipv6mr_interface = getif_index (env, str_ifname);
+  JCL_free_cstring(env, ifname, str_ifname);
+
   if ((*env)-ExceptionCheck (env))
 return;
 }
@@ -666,10 +675,14 @@
 #ifdef HAVE_SETSOCKOPT
   struct ip_mreq maddr;
   jbyte *addr_elems;
+  const char *str_ifname;
 
   if (ifname != NULL)
 {
-  maddr.imr_interface.s_addr = getif_address (env, ifname);
+  str_ifname = JCL_jstring_to_cstring(env, ifname);
+  maddr.imr_interface.s_addr = getif_address (env, str_ifname);
+  JCL_free_cstring(env, ifname, str_ifname);
+
   if ((*env)-ExceptionCheck (env))
 return;
 }
@@ -711,10 +724,14 @@
 #ifdef HAVE_INET6
   struct ipv6_mreq maddr;
   jbyte *addr_elems;
+  const char *str_ifname;
 
   if (ifname == NULL)
 {
-  maddr.ipv6mr_interface = getif_index (env, ifname);
+  str_ifname = JCL_jstring_to_cstring(env, ifname);
+  maddr.ipv6mr_interface = getif_index (env, str_ifname);
+  JCL_free_cstring(env, ifname, str_ifname);
+
   if ((*env)-ExceptionCheck (env))
 return;
 }
@@ -747,7 +764,7 @@
 }
 
 static uint32_t
-getif_address (JNIEnv *env, char *ifname)
+getif_address (JNIEnv *env, const char *ifname)
 {
 #ifdef HAVE_GETIFADDRS
   struct ifaddrs *ifaddrs, *i;
@@ -789,7 +806,7 @@
 }
 
 static int
-getif_index (JNIEnv *env, char *ifname)
+getif_index (JNIEnv *env, const char *ifname)
 {
 #ifdef HAVE_GETIFADDRS
   struct ifaddrs *ifaddrs, *i;


signature.asc
Description: OpenPGP digital signature


[cp-patches] RFC/Need help: java-net/java-nio update

2006-10-09 Thread Robert Schuster
Hi,
this is the patch which removes VMPlainDatagramSocketImpl.

However I tried getting the multicast stuff working. So far I succeeded for IP4
sockets. Running in Azureus I get a Protocol not available in the native part
of setMulticastInterface6.

Casey, can you help me with this stuff? I am feeling lost here :|

Here is the how the ChangeLog would look like:

2006-10-09  Robert Schuster  [EMAIL PROTECTED]

* gnu/java/net/PlainDatagramSocketImpl.java:
(connect): Use VMChannel instance for connect call.
(getTimeToLive): Call VMPlainSocketImpl.getTimeToLive.
(setTimeToLive): Call VMPlainSocketImpl.setTimeToLive.
(setOption): Handle multicast options.
(getOption): Handle multicast options.
* gnu/java/net/PlainSocketImpl.java:
(getTimeToLive): Call VMPlainSocketImpl.getTimeToLive.
(setTimeToLive): Call VMPlainSocketImpl.setTimeToLive.
(setOption): Handle multicast options.
(getOption): Handle multicast options.
* include/Makefile.am: Removed all occurences of
gnu_java_net_VMPlainDatagramSocketImpl.h.
* include/gnu_java_net_VMPlainDatagramSocketImpl.h: Removed.
* native/jni/java-net/Makefile.am: Removed
gnu_java_net_VMPlainDatagramSocketImpl.c from sources.
* native/jni/java-net/gnu_java_net_VMPlainDatagramSocketImpl.c:
Removed.
as SocketException, declare to throw SocketException.
* native/jni/java-nio/gnu_java_nio_VMChannel.c: Added definitions
for SocketException and ConnectException.
(Java_gnu_java_nio_VMChannel_connect): Throw SocketException instead
of IOException.
(Java_gnu_java_nio_VMChannel_connect6): Throw SocketException instead
of IOException.
* native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c: Added
CPNET_IP_TTL to java_sockopt enum.
(Java_gnu_java_net_VMPlainSocketImpl_setOption): Handle CPNET_IP_TTL
case.
(Java_gnu_java_net_VMPlainSocketImpl_getOption): Handle CPNET_IP_TTL
case.
(Java_gnu_java_net_VMPlainSocketImpl_getMulticastInterface): New
function.
(Java_gnu_java_net_VMPlainSocketImpl_setMulticastInterface): New
function.
(Java_gnu_java_net_VMPlainSocketImpl_setMulticastInterface6): New
function.
* vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java: Removed.
* vm/reference/gnu/java/nio/VMChannel.java:
(connect(int, byte[], int, int)): Declare to throw SocketException.
(connect6): Declare to throw SocketException.
(connect(InetSocketAddress, int)): Catch IOException and rethrow
* vm/reference/gnu/java/net/VMPlainSocketImpl.java:
(setTimeToLive): New method.
(getTimeToLive): New method.
(setMulticastInterface(int, InetAddress)): New method.
(setMulticastInterface(int, int, Inet4Address): New method.
(setMulticastInterface6(int, int, Inet6Address): New method.
* NEWS: Documented VM interface changes.
Index: gnu/java/net/PlainSocketImpl.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/net/PlainSocketImpl.java,v
retrieving revision 1.14
diff -u -r1.14 PlainSocketImpl.java
--- gnu/java/net/PlainSocketImpl.java	17 Sep 2006 07:31:41 -	1.14
+++ gnu/java/net/PlainSocketImpl.java	9 Oct 2006 23:58:11 -
@@ -150,7 +150,8 @@
   {
 case IP_MULTICAST_IF:
 case IP_MULTICAST_IF2:
-  throw new UnsupportedOperationException(FIXME);
+  impl.setMulticastInterface(optionId, (InetAddress) value);
+  break;
 
 case IP_MULTICAST_LOOP:
 case SO_BROADCAST:
@@ -198,8 +199,8 @@
   }
   }
 if (optionId == IP_MULTICAST_IF || optionId == IP_MULTICAST_IF2)
-  throw new UnsupportedOperationException (can't get option  +
-   optionId +  yet);
+  return impl.getMulticastInterface(optionId);
+
 return impl.getOption(optionId);
   }
 
Index: gnu/java/net/PlainDatagramSocketImpl.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/net/PlainDatagramSocketImpl.java,v
retrieving revision 1.13
diff -u -r1.13 PlainDatagramSocketImpl.java
--- gnu/java/net/PlainDatagramSocketImpl.java	22 Sep 2006 00:11:56 -	1.13
+++ gnu/java/net/PlainDatagramSocketImpl.java	9 Oct 2006 23:58:11 -
@@ -42,7 +42,6 @@
 
 import java.io.IOException;
 import java.io.InterruptedIOException;
-import java.lang.reflect.Field;
 import java.net.DatagramPacket;
 import java.net.DatagramSocketImpl;
 import java.net.InetAddress;
@@ -69,7 +68,6 @@
  */
 public final class PlainDatagramSocketImpl extends DatagramSocketImpl
 {
-  
   private final VMChannel channel;
   
   /**
@@ -171,7 +169,7 @@
*/
   protected void connect(InetAddress addr, int port) throws SocketException

[cp-patches] RFC: VMPlainDatagramImpl removal

2006-10-08 Thread Robert Schuster
Hi,
this patch removes the above mentioned class and implements their functions
elsewhere. DatagramImpl.connect() has a different exception clause than
SocketImpl.connect() and fixing that required some changes in method signatures
and the native implementation of VMChannel.

These changes are crucial for the porting of Classpath' IO system to GCJ which I
am currently doing.


ChangeLog:
2006-10-09  Robert Schuster  [EMAIL PROTECTED]

* gnu/java/net/PlainSocketImpl.java:
(connect): Use VMChannel instance for connect call.
(getTimeToLive): Call VMPlainSocketImpl.getTimeToLive.
(setTimeToLive): Call VMPlainSocketImpl.setTimeToLive.
* include/Makefile.am: Removed all occurences of
gnu_java_net_VMPlainDatagramSocketImpl.h.
* include/gnu_java_net_VMPlainDatagramSocketImpl.h: Removed.
* native/jni/java-net/Makefile.am: Removed
gnu_java_net_VMPlainDatagramSocketImpl.c from sources.
* native/jni/java-net/gnu_java_net_VMPlainDatagramSocketImpl.c:
Removed.
as SocketException, declare to throw SocketException.
* native/jni/java-nio/gnu_java_net_VMChannel.c: Added definitions
for SocketException and ConnectException.
(Java_gnu_java_nio_VMChannel_connect): Throw SocketException instead
of IOException.
(Java_gnu_java_nio_VMChannel_connect6): Throw SocketException instead
of IOException.
* native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c: Added
CPNET_IP_TTL to java_sockopt enum.
(Java_gnu_java_net_VMPlainSocketImpl_setOption): Handle CPNET_IP_TTL
case.
(Java_gnu_java_net_VMPlainSocketImpl_getOption): Handle CPNET_IP_TTL
case.
* vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java: Removed.
* vm/reference/gnu/java/nio/VMChannel.java:
(connect(int, byte[], int, int)): Declare to throw SocketException.
(connect6): Declare to throw SocketException.
(connect(InetSocketAddress, int)): Catch IOException and rethrow
* vm/reference/gnu/java/net/VMPlainSocketImpl.java:
(setTimeToLive): New method.
(getTimeToLive): New method.
* NEWS: Documented VM interface changes.

cya
Robert
Index: include/Makefile.am
===
RCS file: /cvsroot/classpath/classpath/include/Makefile.am,v
retrieving revision 1.71
diff -u -r1.71 Makefile.am
--- include/Makefile.am	20 Sep 2006 21:39:41 -	1.71
+++ include/Makefile.am	8 Oct 2006 23:26:53 -
@@ -125,7 +125,6 @@
 $(GTKPEER_H_FILES) \
 $(QTPEER_H_FILES) \
 $(GCONF_PREFS_FILES) \
-$(top_srcdir)/include/gnu_java_net_VMPlainDatagramSocketImpl.h \
 $(top_srcdir)/include/gnu_java_net_VMPlainSocketImpl.h \
 $(top_srcdir)/include/gnu_java_net_local_LocalSocketImpl.h \
 $(top_srcdir)/include/gnu_java_nio_EpollSelectorImpl.h \
@@ -180,8 +179,6 @@
 $(top_srcdir)/include/gnu_java_util_prefs_gconf_%.h: $(top_builddir)/$(CLASSDIR)/gnu/java/util/prefs/gconf/%.class
 	$(JAVAH) -o $@ gnu.java.util.prefs.gconf.$*
 
-$(top_srcdir)/include/gnu_java_net_VMPlainDatagramSocketImpl.h: $(top_srcdir)/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java
-	$(JAVAH) -o $@ gnu.java.net.VMPlainDatagramSocketImpl
 $(top_srcdir)/include/gnu_java_net_VMPlainSocketImpl.h: $(top_srcdir)/vm/reference/gnu/java/net/VMPlainSocketImpl.java
 	$(JAVAH) -o $@ gnu.java.net.VMPlainSocketImpl
 $(top_srcdir)/include/gnu_java_net_local_LocalSocketImpl.h: $(top_srcdir)/gnu/java/net/local/LocalSocketImpl.java
Index: include/gnu_java_net_VMPlainDatagramSocketImpl.h
===
RCS file: include/gnu_java_net_VMPlainDatagramSocketImpl.h
diff -N include/gnu_java_net_VMPlainDatagramSocketImpl.h
--- include/gnu_java_net_VMPlainDatagramSocketImpl.h	19 Mar 2006 23:17:16 -	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -
@@ -1,30 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-
-#ifndef __gnu_java_net_VMPlainDatagramSocketImpl__
-#define __gnu_java_net_VMPlainDatagramSocketImpl__
-
-#include jni.h
-
-#ifdef __cplusplus
-extern C
-{
-#endif
-
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainDatagramSocketImpl_bind (JNIEnv *env, jclass, jobject, jint, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainDatagramSocketImpl_create (JNIEnv *env, jclass, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainDatagramSocketImpl_connect (JNIEnv *env, jclass, jobject, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainDatagramSocketImpl_nativeSendTo (JNIEnv *env, jclass, jobject, jobject, jint, jbyteArray, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainDatagramSocketImpl_nativeReceive (JNIEnv *env, jclass, jobject, jbyteArray, jint, jint, jbyteArray, jintArray, jintArray);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainDatagramSocketImpl_setOption (JNIEnv *env, jclass, jobject, jint, jobject);
-JNIEXPORT jobject JNICALL

[cp-patches] RFC: renamed method in KqueueSelectorImpl and removed IP_TTL field

2006-10-03 Thread Robert Schuster
Hi,
the attached patch renames a method in KqueueSelectorImpl (this conflicts with
the field of the same name in GCJ) and removes the IP_TTL field in
VMPlainDatagramSocketImpl. The latter is seemingly not used anywhere and causes
a problem during GCJ compilation.

Please comment whether this change is ok?

ChangeLog:

2006-10-03  Robert Schuster  [EMAIL PROTECTED]

* gnu/java/nio/KqueueSelectorImpl.java: Renamed method
sizeof_struct_kevent to get_sizeof_struct_kevent.
* include/gnu_java_nio_KqueueSelectorImpl.h: Dito.
* native/jni/java-nio/gnu_java_nio_KqueueSelectorImpl.c: Dito.
* vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java: Removed
unneeded IP_TTL field.


cya
Robert
Index: include/gnu_java_nio_KqueueSelectorImpl.h
===
RCS file: /cvsroot/classpath/classpath/include/gnu_java_nio_KqueueSelectorImpl.h,v
retrieving revision 1.2
diff -u -r1.2 gnu_java_nio_KqueueSelectorImpl.h
--- include/gnu_java_nio_KqueueSelectorImpl.h	27 Sep 2006 21:19:31 -	1.2
+++ include/gnu_java_nio_KqueueSelectorImpl.h	3 Oct 2006 22:11:32 -
@@ -29,10 +29,10 @@
 
 /*
  * Class: gnu_java_nio_KqueueSelectorImpl
- * Method:sizeof_struct_kevent
+ * Method:get_sizeof_struct_kevent
  * Signature: ()I
  */
-JNIEXPORT jint JNICALL Java_gnu_java_nio_KqueueSelectorImpl_sizeof_1struct_1kevent
+JNIEXPORT jint JNICALL Java_gnu_java_nio_KqueueSelectorImpl_get_sizeof_1struct_1kevent
   (JNIEnv *, jclass);
 
 /*
Index: native/jni/java-nio/gnu_java_nio_KqueueSelectorImpl.c
===
RCS file: /cvsroot/classpath/classpath/native/jni/java-nio/gnu_java_nio_KqueueSelectorImpl.c,v
retrieving revision 1.2
diff -u -r1.2 gnu_java_nio_KqueueSelectorImpl.c
--- native/jni/java-nio/gnu_java_nio_KqueueSelectorImpl.c	27 Sep 2006 21:19:31 -	1.2
+++ native/jni/java-nio/gnu_java_nio_KqueueSelectorImpl.c	3 Oct 2006 22:11:32 -
@@ -91,11 +91,11 @@
 
 /*
  * Class: gnu_java_nio_KqueueSelectorImpl
- * Method:sizeof_struct_kevent
+ * Method:get_sizeof_struct_kevent
  * Signature: ()I
  */
 JNIEXPORT jint JNICALL
-Java_gnu_java_nio_KqueueSelectorImpl_sizeof_1struct_1kevent
+Java_gnu_java_nio_KqueueSelectorImpl_get_sizeof_1struct_1kevent
 (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)))
 {
 #if defined(HAVE_KQUEUE)  defined(HAVE_KEVENT)
Index: gnu/java/nio/KqueueSelectorImpl.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/nio/KqueueSelectorImpl.java,v
retrieving revision 1.2
diff -u -r1.2 KqueueSelectorImpl.java
--- gnu/java/nio/KqueueSelectorImpl.java	27 Sep 2006 21:19:31 -	1.2
+++ gnu/java/nio/KqueueSelectorImpl.java	3 Oct 2006 22:11:32 -
@@ -80,7 +80,7 @@
   }
 
 if (kqueue_supported ())
-  sizeof_struct_kevent = sizeof_struct_kevent();
+  sizeof_struct_kevent = get_sizeof_struct_kevent();
 else
   sizeof_struct_kevent = -1;
 INITIAL_CAPACITY = 16 * sizeof_struct_kevent;
@@ -437,10 +437,13 @@
   
   /**
* Return the size of a codestruct kevent/code on this system.
+   *
+   * The name of the method is deliberately chosen to not conflict
+   * with the static field.
* 
* @return The size of codestruct kevent/code.
*/
-  private static native int sizeof_struct_kevent();
+  private static native int get_sizeof_struct_kevent();
   
   /**
* Opens a kqueue descriptor.
Index: vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java
===
RCS file: /cvsroot/classpath/classpath/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java,v
retrieving revision 1.2
diff -u -r1.2 VMPlainDatagramSocketImpl.java
--- vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java	12 Jan 2006 11:56:08 -	1.2
+++ vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java	3 Oct 2006 22:11:32 -
@@ -55,12 +55,6 @@
  */
 public final class VMPlainDatagramSocketImpl
 {
-  /**
-   * Option id for the IP_TTL (time to live) value.
-   */
-  static final int IP_TTL = 0x1E61; // 
-
-
   // Static initializer to load native library
   static
   {


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: Updated INSTALL and configure.ac

2006-09-27 Thread Robert Schuster
Hi,
I updated INSTALL and configure.ac with infos about grmic being built when
asm.jar is specified.

ChangeLog:

2006-09-27  Robert Schuster  [EMAIL PROTECTED]

* INSTALL: Added information about grmic being built when ASM
is available.
* configure.ac: Dito.
Index: INSTALL
===
RCS file: /cvsroot/classpath/classpath/INSTALL,v
retrieving revision 1.39
diff -u -r1.39 INSTALL
--- INSTALL	31 Jul 2006 22:37:58 -	1.39
+++ INSTALL	27 Sep 2006 16:56:10 -
@@ -1,4 +1,4 @@
-Installing GNU Classpath - Last updated: September 7, 2005
+Installing GNU Classpath - Last updated: June 19, 2006
 
 First, this is a development release only! Unless you are interested in
 active development and debugging, or just like running random alpha code,
@@ -54,6 +54,11 @@
 	For building gcjwebplugin you'll need the Mozilla plugin
 	support headers and libraries.
 
+	The GConf-based backend for java.util.prefs needs the following
+	library headers:
+
+	- gconf 2.11.2 (or higher)
+
 	For building the Qt AWT peer JNI native libraries you have to
 	specify --enable-qt-peer and need the following library:
 
@@ -65,10 +70,10 @@
 	http://escher.sourceforge.net
 
 	Please note that at the moment most operating systems do not
-ship Qt4 by default. We recommend using GNU Classpath' Qt4
-support only for its developers and bug reporters. See
-http://developer.classpath.org/mediation/ClasspathShowcase
-for details on how to get it to work.
+	ship Qt4 by default. We recommend using GNU Classpath' Qt4
+	support only for its developers and bug reporters. See
+	http://developer.classpath.org/mediation/ClasspathShowcase
+	for details on how to get it to work.
 
 	For building the xmlj JAXP implementation (disabled by default, use
 	configure --enable-xmlj) you need the following installed:
@@ -80,7 +85,7 @@
 	  http://www.xmlsoft.org/XSLT/
 	  Minimum version of libxslt required: 1.1.11
 
-	For building the javah tool, you will need the ASM library.
+	For building the gjavah and grmic tool, you will need the ASM library.
 	Current version 2.2.1 is needed (other 2.2.x versions should
 	be ok; 3.x is not ok).  You can get ASM from
 	http://asm.objectweb.org/
Index: configure.ac
===
RCS file: /cvsroot/classpath/classpath/configure.ac,v
retrieving revision 1.187
diff -u -r1.187 configure.ac
--- configure.ac	24 Sep 2006 20:12:04 -	1.187
+++ configure.ac	27 Sep 2006 16:56:10 -
@@ -809,7 +809,7 @@
 dnl ---
 AC_ARG_WITH([asm],
 	 AS_HELP_STRING([--with-asm=ABS.PATH],
-	[specify path to ASM jar for javah]))
+	[specify path to ASM jar to enable gjavah and grmic build]))
 case $with_asm in
 )
 use_asm=false


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] FYI: Updated INSTALL and configure.ac

2006-09-27 Thread Robert Schuster
Hi,
there where other changes in this file which I made earlier and forgot to tell
about in the first ChangeLog. I applied the same patch but with this ChangeLog
entry:

2006-09-27  Robert Schuster  [EMAIL PROTECTED]

* INSTALL: Added information about grmic being built when ASM
is available, added information about gconf dependency, indented
Qt4 dependency section.
* configure.ac: Added information about grmic being built when ASM
is available.

cya
Robert

Robert Schuster wrote:
 Hi,
 I updated INSTALL and configure.ac with infos about grmic being built when
 asm.jar is specified.
 
 ChangeLog:
 
 2006-09-27  Robert Schuster  [EMAIL PROTECTED]
 
 * INSTALL: Added information about grmic being built when ASM
 is available.
 * configure.ac: Dito.
 
 
 
 
 Index: INSTALL
 ===
 RCS file: /cvsroot/classpath/classpath/INSTALL,v
 retrieving revision 1.39
 diff -u -r1.39 INSTALL
 --- INSTALL   31 Jul 2006 22:37:58 -  1.39
 +++ INSTALL   27 Sep 2006 16:56:10 -
 @@ -1,4 +1,4 @@
 -Installing GNU Classpath - Last updated: September 7, 2005
 +Installing GNU Classpath - Last updated: June 19, 2006
  
  First, this is a development release only! Unless you are interested in
  active development and debugging, or just like running random alpha code,
 @@ -54,6 +54,11 @@
   For building gcjwebplugin you'll need the Mozilla plugin
   support headers and libraries.
  
 + The GConf-based backend for java.util.prefs needs the following
 + library headers:
 +
 + - gconf 2.11.2 (or higher)
 +
   For building the Qt AWT peer JNI native libraries you have to
   specify --enable-qt-peer and need the following library:
  
 @@ -65,10 +70,10 @@
   http://escher.sourceforge.net
  
   Please note that at the moment most operating systems do not
 -ship Qt4 by default. We recommend using GNU Classpath' Qt4
 -support only for its developers and bug reporters. See
 -http://developer.classpath.org/mediation/ClasspathShowcase
 -for details on how to get it to work.
 + ship Qt4 by default. We recommend using GNU Classpath' Qt4
 + support only for its developers and bug reporters. See
 + http://developer.classpath.org/mediation/ClasspathShowcase
 + for details on how to get it to work.
  
   For building the xmlj JAXP implementation (disabled by default, use
   configure --enable-xmlj) you need the following installed:
 @@ -80,7 +85,7 @@
 http://www.xmlsoft.org/XSLT/
 Minimum version of libxslt required: 1.1.11
  
 - For building the javah tool, you will need the ASM library.
 + For building the gjavah and grmic tool, you will need the ASM library.
   Current version 2.2.1 is needed (other 2.2.x versions should
   be ok; 3.x is not ok).  You can get ASM from
   http://asm.objectweb.org/
 Index: configure.ac
 ===
 RCS file: /cvsroot/classpath/classpath/configure.ac,v
 retrieving revision 1.187
 diff -u -r1.187 configure.ac
 --- configure.ac  24 Sep 2006 20:12:04 -  1.187
 +++ configure.ac  27 Sep 2006 16:56:10 -
 @@ -809,7 +809,7 @@
  dnl ---
  AC_ARG_WITH([asm],
AS_HELP_STRING([--with-asm=ABS.PATH],
 - [specify path to ASM jar for javah]))
 + [specify path to ASM jar to enable gjavah and grmic 
 build]))
  case $with_asm in
  )
  use_asm=false


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: some NIO implementation cleanups

2006-09-27 Thread Robert Schuster
Hi,
this small patch cleans some imports and 'new Integer' invocations to
'Integer.valueOf'.

This is in preparation of getting the latest Classpath changes in the NIO area
to gcj.

ChangeLog:

2006-09-27  Robert Schuster  [EMAIL PROTECTED]

* vm/reference/gnu/java/nio/VMChannel.java: Removed unneeded imports.
* vm/reference/gnu/java/nio/VMPipe.java: Removed unneeded imports.
* gnu/java/nio/EpollSelectorImpl.java:
(doSelect): Use Integer.valueOf() instead of constructor call.
(register): Use Integer.valueOf() instead of constructor call.

cya
Robert
Index: gnu/java/nio/EpollSelectorImpl.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/nio/EpollSelectorImpl.java,v
retrieving revision 1.3
diff -u -r1.3 EpollSelectorImpl.java
--- gnu/java/nio/EpollSelectorImpl.java	23 Sep 2006 06:44:13 -	1.3
+++ gnu/java/nio/EpollSelectorImpl.java	27 Sep 2006 21:20:02 -
@@ -138,7 +138,7 @@
 EpollSelectionKeyImpl key = (EpollSelectionKeyImpl) it.next();
 epoll_delete(epoll_fd, key.fd);
 key.valid = false;
-keys.remove(new Integer(key.fd));
+keys.remove(Integer.valueOf(key.fd));
 it.remove();
   }
 
@@ -161,7 +161,7 @@
 ByteBuffer b = selected.slice();
 int fd = selected_fd(b);
 EpollSelectionKeyImpl key
-  = (EpollSelectionKeyImpl) keys.get(new Integer(fd));
+  = (EpollSelectionKeyImpl) keys.get(Integer.valueOf(fd));
 if (key == null)
   throw new IOException(fd was selected, but no key found);
 key.selectedOps = selected_ops(b)  key.interestOps;
@@ -228,7 +228,7 @@
 int native_fd = channel.getState().getNativeFD();
 synchronized (keys)
 {
-  if (keys.containsKey(new Integer(native_fd)))
+  if (keys.containsKey(Integer.valueOf(native_fd)))
 throw new IllegalArgumentException(channel already registered);
   EpollSelectionKeyImpl result =
 new EpollSelectionKeyImpl(this, ch, native_fd);
@@ -240,7 +240,7 @@
   result.attach(att);
   result.key = System.identityHashCode(result);
   epoll_add(epoll_fd, result.fd, ops);
-  keys.put(new Integer(native_fd), result);
+  keys.put(Integer.valueOf(native_fd), result);
   return result;
 }
   }
Index: vm/reference/gnu/java/nio/VMChannel.java
===
RCS file: /cvsroot/classpath/classpath/vm/reference/gnu/java/nio/VMChannel.java,v
retrieving revision 1.3
diff -u -r1.3 VMChannel.java
--- vm/reference/gnu/java/nio/VMChannel.java	25 Sep 2006 21:54:44 -	1.3
+++ vm/reference/gnu/java/nio/VMChannel.java	27 Sep 2006 21:20:02 -
@@ -39,12 +39,7 @@
 package gnu.java.nio;
 
 import gnu.classpath.Configuration;
-import gnu.classpath.Pointer;
 import gnu.classpath.jdwp.exception.NotImplementedException;
-import gnu.java.net.PlainSocketImpl;
-import gnu.java.nio.PipeImpl.SinkChannelImpl;
-import gnu.java.nio.PipeImpl.SourceChannelImpl;
-import gnu.java.nio.FileChannelImpl;
 
 import java.io.IOException;
 import java.net.Inet4Address;
Index: vm/reference/gnu/java/nio/VMPipe.java
===
RCS file: /cvsroot/classpath/classpath/vm/reference/gnu/java/nio/VMPipe.java,v
retrieving revision 1.3
diff -u -r1.3 VMPipe.java
--- vm/reference/gnu/java/nio/VMPipe.java	17 Sep 2006 07:31:43 -	1.3
+++ vm/reference/gnu/java/nio/VMPipe.java	27 Sep 2006 21:20:02 -
@@ -38,7 +38,6 @@
 package gnu.java.nio;
 
 import java.io.IOException;
-import java.nio.channels.spi.SelectorProvider;
 import gnu.classpath.Configuration;
 
 /**


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: remove unneeded imports

2006-09-27 Thread Robert Schuster
Hi,
another small patch in preparation of the epoll work on gcj.

2006-09-27  Robert Schuster  [EMAIL PROTECTED]

* gnu/java/nio/VMChannelOwner.java: Removed unneeded imports.

cya
Robert
Index: gnu/java/nio/VMChannelOwner.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/nio/VMChannelOwner.java,v
retrieving revision 1.1
diff -u -r1.1 VMChannelOwner.java
--- gnu/java/nio/VMChannelOwner.java	17 Sep 2006 07:31:41 -	1.1
+++ gnu/java/nio/VMChannelOwner.java	27 Sep 2006 21:41:13 -
@@ -38,9 +38,6 @@
 
 package gnu.java.nio;
 
-import java.nio.channels.Channel;
-import java.nio.channels.Selector;
-
 /**
  * This interface is meant to be implemented by any [EMAIL PROTECTED] Channel}
  * implementation we support that uses a platform-specific [EMAIL PROTECTED] VMChannel}


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: BasicTabbedPaneUI fix

2006-09-01 Thread Robert Schuster
Hi,
by calling the getTabRunOverlay method from
BasicTabbedPaneUI.calculateTabAreaWidth (and calculateTabAreaHeight) instead of
accessing the variable directly the overridden behavior in MetalTabbedPaneUI
comes to effect.

This fixes the ill positioning of the content area in tabbed panes with more
than 2 tab runs (like in our Swing demo).

ChangeLog:

2006-09-01  Robert Schuster  [EMAIL PROTECTED]

* javax/swing/plaf/basic/BasicTabbedPaneUI.java:
(calculateTabAreaHeight): Use getTabRunOverlay method instead
of accessing variable directly.
(calculateTabAreaWidth): Dito.

cya
Robert
Index: javax/swing/plaf/basic/BasicTabbedPaneUI.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java,v
retrieving revision 1.55
diff -u -r1.55 BasicTabbedPaneUI.java
--- javax/swing/plaf/basic/BasicTabbedPaneUI.java	24 Aug 2006 17:29:28 -	1.55
+++ javax/swing/plaf/basic/BasicTabbedPaneUI.java	1 Sep 2006 07:16:29 -
@@ -902,6 +902,7 @@
 default:
   tabAreaHeight = calculateTabAreaHeight(tabPlacement, runCount,
  maxTabHeight);
+
   compX = insets.left + contentBorderInsets.left;
   compY = tabAreaHeight + insets.top + contentBorderInsets.top;
   }
@@ -3528,7 +3529,8 @@
   {
 Insets insets = getTabAreaInsets(tabPlacement);
 int tabAreaHeight = horizRunCount * maxTabHeight
-- (horizRunCount - 1) * tabRunOverlay;
+- (horizRunCount - 1)
+* getTabRunOverlay(tabPlacement);
 
 tabAreaHeight += insets.top + insets.bottom;
 
@@ -3550,7 +3552,8 @@
   {
 Insets insets = getTabAreaInsets(tabPlacement);
 int tabAreaWidth = vertRunCount * maxTabWidth
-   - (vertRunCount - 1) * tabRunOverlay;
+   - (vertRunCount - 1)
+   * getTabRunOverlay(tabPlacement);
 
 tabAreaWidth += insets.left + insets.right;
 


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: small tab pane demo change

2006-09-01 Thread Robert Schuster
Hi,
this fixes the naming in the tabbed pane demo a bit.

ChangeLog:

2006-09-01  Robert Schuster  [EMAIL PROTECTED]

* examples/gnu/classpath/examples/swing/TabbedPaneDemo.java:
(createContent): Changed menu item name and tab naming.


cya
Robert
Index: examples/gnu/classpath/examples/swing/TabbedPaneDemo.java
===
RCS file: /cvsroot/classpath/classpath/examples/gnu/classpath/examples/swing/TabbedPaneDemo.java,v
retrieving revision 1.3
diff -u -r1.3 TabbedPaneDemo.java
--- examples/gnu/classpath/examples/swing/TabbedPaneDemo.java	16 Aug 2006 00:03:06 -	1.3
+++ examples/gnu/classpath/examples/swing/TabbedPaneDemo.java	1 Sep 2006 17:43:03 -
@@ -80,12 +80,12 @@
 p.setLayout(new GridLayout(1, 1));
 
 int COUNT = 25;
-JTabbedPane tp = createTabbedPane(SwingConstants.TOP, top, COUNT);
+JTabbedPane tp = createTabbedPane(SwingConstants.TOP, tab, COUNT);
 p.add(tp);
 
 final JPopupMenu popup = new JPopupMenu();
 
-JMenu menu = new JMenu(directions);
+JMenu menu = new JMenu(tab placement);
 menu.add(createPlacementChangingMenuItem(top,
  SwingConstants.TOP,
  tp));


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: BasicLookAndFeel properties corrected

2006-09-01 Thread Robert Schuster
Hi,
the attached patch fixes some properties of the tabbed panes in 
BasicLookAndFeel.

ChangeLog:

2006-09-01  Robert Schuster  [EMAIL PROTECTED]

* javax/swing/plaf/basic/BasicLookAndFeel.java:
(initComponentDefaults): Added, changed and removed some
tabbed pane properties.

cya
Robert
Index: javax/swing/plaf/basic/BasicLookAndFeel.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java,v
retrieving revision 1.98
diff -u -r1.98 BasicLookAndFeel.java
--- javax/swing/plaf/basic/BasicLookAndFeel.java	26 Jul 2006 07:48:55 -	1.98
+++ javax/swing/plaf/basic/BasicLookAndFeel.java	1 Sep 2006 17:58:28 -
@@ -1218,10 +1218,10 @@
 ctrl UP, requestFocus,
 ctrl KP_UP, requestFocus
   }),
-  TabbedPane.background, new ColorUIResource(light),
+  TabbedPane.background, new ColorUIResource(192, 192, 192),
   TabbedPane.contentBorderInsets, new InsetsUIResource(2, 2, 3, 3),
-  TabbedPane.darkShadow, new ColorUIResource(shadow),
-  TabbedPane.focus, new ColorUIResource(darkShadow),
+  TabbedPane.darkShadow, new ColorUIResource(Color.black),
+  TabbedPane.focus, new ColorUIResource(Color.black),
   TabbedPane.focusInputMap, new UIDefaults.LazyInputMap(new Object[] {
 KeyStroke.getKeyStroke(ctrl DOWN), requestFocusForVisibleComponent,
 KeyStroke.getKeyStroke(KP_UP), navigateUp,
@@ -1235,17 +1235,16 @@
 KeyStroke.getKeyStroke(DOWN), navigateDown
   }),
   TabbedPane.font, new FontUIResource(Dialog, Font.PLAIN, 12),
-  TabbedPane.foreground, new ColorUIResource(darkShadow),
-  TabbedPane.highlight, new ColorUIResource(highLight),
-  TabbedPane.light, new ColorUIResource(highLight),
+  TabbedPane.foreground, new ColorUIResource(Color.black),
+  TabbedPane.highlight, new ColorUIResource(Color.white),
+  TabbedPane.light, new ColorUIResource(192, 192, 192),
   TabbedPane.selectedTabPadInsets, new InsetsUIResource(2, 2, 2, 1),
-  TabbedPane.shadow, new ColorUIResource(shadow),
-  TabbedPane.tabbedPaneContentBorderInsets, new InsetsUIResource(3, 2, 1, 2),
-  TabbedPane.tabbedPaneTabPadInsets, new InsetsUIResource(1, 1, 1, 1),
+  TabbedPane.shadow, new ColorUIResource(128, 128, 128),
   TabbedPane.tabsOpaque, Boolean.TRUE,
   TabbedPane.tabAreaInsets, new InsetsUIResource(3, 2, 0, 2),
   TabbedPane.tabInsets, new InsetsUIResource(0, 4, 1, 4),
   TabbedPane.tabRunOverlay, new Integer(2),
+  TabbedPane.tabsOverlapBorder, Boolean.FALSE,
   TabbedPane.textIconGap, new Integer(4),
   Table.ancestorInputMap, new UIDefaults.LazyInputMap(new Object[] {
 ctrl DOWN, selectNextRowChangeLead,


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: MetalCheckBoxUI fix

2006-09-01 Thread Robert Schuster
Hi,
in order to call the isChecked() method it is not needed to cast a component to
a JCheckBox - an AbstractButton is enough. I dont think this costs us anything
and makes the class more flexible for all the possible misuses out there. :)

ChangeLog:

2006-09-01  Robert Schuster  [EMAIL PROTECTED]

* javax/swing/plaf/metal/MetalCheckBoxIcon.java:
(paintIcon): Removed unused import statements, lowered cast requirement
from JCheckBox to AbstractButton.

cya
Robert
Index: javax/swing/plaf/metal/MetalCheckBoxIcon.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalCheckBoxIcon.java,v
retrieving revision 1.6
diff -u -r1.6 MetalCheckBoxIcon.java
--- javax/swing/plaf/metal/MetalCheckBoxIcon.java	16 Nov 2005 15:43:34 -	1.6
+++ javax/swing/plaf/metal/MetalCheckBoxIcon.java	1 Sep 2006 18:09:25 -
@@ -1,5 +1,5 @@
 /* MetalCheckBoxIcon.java -- An icon for JCheckBoxes in the Metal LF
-   Copyright (C) 2005 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -42,8 +42,8 @@
 import java.awt.Graphics;
 import java.io.Serializable;
 
+import javax.swing.AbstractButton;
 import javax.swing.Icon;
-import javax.swing.JCheckBox;
 import javax.swing.SwingConstants;
 import javax.swing.UIManager;
 import javax.swing.plaf.UIResource;
@@ -134,8 +134,9 @@
   MetalUtils.paintGradient(g, x, y, getIconWidth(), getIconHeight(),
SwingConstants.VERTICAL, CheckBox.gradient);
 border.paintBorder(c, g, x, y, getIconWidth(), getIconHeight());
-JCheckBox cb = (JCheckBox) c;
-if (cb.isSelected())
-  drawCheck(c, g, x, y);
+
+AbstractButton b = (AbstractButton) c;
+if (b.isSelected())
+  drawCheck(b, g, x, y);
   }
 }


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: DefaultTableMode fix

2006-09-01 Thread Robert Schuster
Hi,
the attached patch fixes a NullPointerException for me.

ChangeLog:

2006-09-01  Robert Schuster  [EMAIL PROTECTED]

* javax/swing/table/DefaultTableModel.java:
(checkSize): Added null check for dataVector.

cya
Robert
Index: javax/swing/table/DefaultTableModel.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/table/DefaultTableModel.java,v
retrieving revision 1.16
diff -u -r1.16 DefaultTableModel.java
--- javax/swing/table/DefaultTableModel.java	17 May 2006 20:52:05 -	1.16
+++ javax/swing/table/DefaultTableModel.java	1 Sep 2006 18:37:47 -
@@ -625,7 +625,7 @@
 if (columnCount  columnIdentifiers.size())
   columnIdentifiers.setSize(columnCount);

-if (rowCount  dataVector.size())
+if (dataVector != null  rowCount  dataVector.size())
   {
 int rowsToAdd = rowCount - dataVector.size();
 addExtraRows(rowsToAdd, columnCount);


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: DefaultButtonModel - expression simplification

2006-08-17 Thread Robert Schuster
Hi,
this small patch simplifies an expression.

ChangeLog:

2006-08-17  Robert Schuster  [EMAIL PROTECTED]

* javax/swing/DefaultButtonModel.java:
(setRollover): Simplified statement.


cya
Robert
Index: javax/swing/DefaultButtonModel.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/DefaultButtonModel.java,v
retrieving revision 1.29
diff -u -r1.29 DefaultButtonModel.java
--- javax/swing/DefaultButtonModel.java	16 Jun 2006 13:44:59 -	1.29
+++ javax/swing/DefaultButtonModel.java	17 Aug 2006 00:03:19 -
@@ -425,7 +425,7 @@
   public void setRollover(boolean r)
   {
 // if this call does not represent a CHANGE in state, then return
-if ((r  isRollover()) || (!r  !isRollover()))
+if (r == isRollover())
   return;
 
 // cannot set ROLLOVER property unless button is enabled


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: BasicTabbedPaneUI fixes

2006-08-16 Thread Robert Schuster
Hi,
here is another small patch which makes JTabbedPane behave more like in the RI.
This fixes:
- changing the placement should result in a specific behavior in regard to the
current scroll location (see comment in PropertyChangeHandler.propertyChange)

- in SCROLL_TAB_LAYOUT mode the tabs are in a sub-component. This means that a
MouseListener installed on the JTabbedPane is normally not triggered if
something happens in that area. I fixed that by adding a logic into the tabbed
pane's own MouseHanlder (which is installed on the internal subcomponent, too)
that recognizes such a situation and redispatches a properly modified MouseEvent
to the JTabbedPane. With that patch my PopupMenu-enhanced JTabbedPane demo
(yay!) works now more like on the RI.

Still need to figure out how they make it react on actions in the content area 
...

2006-08-17  Robert Schuster  [EMAIL PROTECTED]

* javax/swing/plaf/basic/BasicTabbedPaneUI.java:
(MouseHandler.mouseReleased): Implemented.
(MouseHandler.mousePressed): Added delegation to tabbed pane.
(MouseHandler.mouseEntered): Dito.
(MouseHandler.mouseExited): Dito.
(MouseHandler.mouseMoved): Dito.
(MouseHandler.redispatchEvent): New method.
(PropertyChangeHandler.propertyChange): Added extra block level,
added code to handle tab placement changes, added comment.
(updateViewPosition): Set unneeded coordinate to 0, added comment.

cya
Robert
Index: javax/swing/plaf/basic/BasicTabbedPaneUI.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java,v
retrieving revision 1.51
diff -u -r1.51 BasicTabbedPaneUI.java
--- javax/swing/plaf/basic/BasicTabbedPaneUI.java	15 Aug 2006 23:46:47 -	1.51
+++ javax/swing/plaf/basic/BasicTabbedPaneUI.java	16 Aug 2006 22:48:29 -
@@ -252,7 +252,16 @@
   {
 public void mouseReleased(MouseEvent e)
 {
- // Nothing to do here. 
+  Object s = e.getSource();
+
+  // Event may originate from the viewport in
+  // SCROLL_TAB_LAYOUT mode. It is redisptached
+  // through the tabbed pane then.
+  if (tabPane != e.getSource())
+{
+  redispatchEvent(e);
+  e.setSource(s);
+}
 }
 
 /**
@@ -264,6 +273,16 @@
 public void mousePressed(MouseEvent e)
 {
   Object s = e.getSource();
+
+  // Event may originate from the viewport in
+  // SCROLL_TAB_LAYOUT mode. It is redisptached
+  // through the tabbed pane then.
+  if (tabPane != e.getSource())
+{
+  redispatchEvent(e);
+  e.setSource(s);
+}
+  
   int placement = tabPane.getTabPlacement();
 
   if (s == incrButton)
@@ -361,11 +380,22 @@
  * Receives notification when the mouse pointer has entered the tabbed
  * pane.
  *
- * @param ev the mouse event
+ * @param e the mouse event
  */
-public void mouseEntered(MouseEvent ev)
+public void mouseEntered(MouseEvent e)
 {
-  int tabIndex = tabForCoordinate(tabPane, ev.getX(), ev.getY());
+  Object s = e.getSource();
+
+  // Event may originate from the viewport in
+  // SCROLL_TAB_LAYOUT mode. It is redisptached
+  // through the tabbed pane then.
+  if (tabPane != e.getSource())
+{
+  redispatchEvent(e);
+  e.setSource(s);
+}
+  
+  int tabIndex = tabForCoordinate(tabPane, e.getX(), e.getY());
   setRolloverTab(tabIndex);
 }
 
@@ -373,10 +403,21 @@
  * Receives notification when the mouse pointer has exited the tabbed
  * pane.
  *
- * @param ev the mouse event
+ * @param e the mouse event
  */
-public void mouseExited(MouseEvent ev)
+public void mouseExited(MouseEvent e)
 {
+  Object s = e.getSource();
+
+  // Event may originate from the viewport in
+  // SCROLL_TAB_LAYOUT mode. It is redisptached
+  // through the tabbed pane then.
+  if (tabPane != e.getSource())
+{
+  redispatchEvent(e);
+  e.setSource(s);
+}
+  
   setRolloverTab(-1);
 }
 
@@ -388,9 +429,37 @@
  */
 public void mouseMoved(MouseEvent ev)
 {
+  Object s = ev.getSource();
+
+  if (tabPane != ev.getSource())
+{
+  ev.setSource(tabPane);
+  tabPane.dispatchEvent(ev);
+  
+  ev.setSource(s);
+}
+
   int tabIndex = tabForCoordinate(tabPane, ev.getX(), ev.getY());
   setRolloverTab(tabIndex);
 }
+
+/** Modifies the mouse event to originate from 
+ * the tabbed pane and redispatches it.
+ * 
+ * @param me
+ */
+void redispatchEvent(MouseEvent me)
+{
+  me.setSource(tabPane);
+  Point viewPos = viewport.getViewPosition();
+  viewPos.x -= viewport.getX();
+  viewPos.y -= viewport.getY();
+  me.translatePoint(-viewPos.x, -viewPos.y

[cp-patches] FYI: more BasicTabbedPaneUI MetalTabbedPaneUI fixes

2006-08-16 Thread Robert Schuster
Hi,
yet another patch related to the tabbed panes' UI classes. getTabBounds() was
not spec conform in the way that it did not calculated the scroll offset in. By
not doing that subclasses could not properly find out whether a tab may be out
of bounds.

By fixing that tabs painted in the MetalTheme now properly display the broken
line when a tab adjacent to the content area is selected (which is always the
case in scrolling tab layout mode).

Another small fix for MetalTabbedPaneUI corrects an argument value. Now a line
of the left edge is painted completely vertical.

the ChangeLog:

2006-08-17  Robert Schuster  [EMAIL PROTECTED]

* javax/swing/plaf/basic/BasicTabbedPaneUI.java:
(getTabBounds(JTabbedPane, int)): Added code to shift rectangle
by current scroll offset, added method documention.
(getTabBounds(int, Rectangle)): Added method documentation.
* javax/swing/plaf/metal/MetalTabbedPaneUI.java:
(paintContentBorderLeftEdge): Changed y to 1.

cya
Robert
Index: javax/swing/plaf/basic/BasicTabbedPaneUI.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java,v
retrieving revision 1.52
diff -u -r1.52 BasicTabbedPaneUI.java
--- javax/swing/plaf/basic/BasicTabbedPaneUI.java	16 Aug 2006 22:55:02 -	1.52
+++ javax/swing/plaf/basic/BasicTabbedPaneUI.java	16 Aug 2006 23:37:32 -
@@ -3111,8 +3111,13 @@
   }
 
   /**
-   * This method returns the tab bounds for the given index.
-   *
+   * pThis method returns the bounds of a tab for the given index
+   * and shifts it by the current scrolling offset if the tabbed
+   * pane is in scrolling tab layout mode./p
+   * 
+   * pSubclassses should retrievs a tab's bounds by this method
+   * if they want to find out whether the tab is currently visible./p
+   * 
* @param pane The JTabbedPane.
* @param i The index to look for.
*
@@ -3123,6 +3128,26 @@
 // Need to re-layout container if tab does not exist.
 if (i = rects.length)
   layoutManager.layoutContainer(pane);
+
+// Properly shift coordinates if scrolling has taken
+// place.
+if (pane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
+  {
+Rectangle r = new Rectangle(rects[i]);
+
+switch(pane.getTabPlacement())
+{
+  case SwingConstants.TOP:
+  case SwingConstants.BOTTOM:
+r.x -= currentScrollOffset;
+break;
+  default:
+r.y -= currentScrollOffset;
+}
+
+return r;
+  }
+
 return rects[i];
   }
 
@@ -3171,7 +3196,10 @@
   }
 
   /**
-   * This method returns the tab bounds in the given rectangle.
+   * pThis method returns the tab bounds in the given rectangle./p
+   * 
+   * pThe returned rectangle will be shifted by the current scroll
+   * offset if the tabbed pane is in scrolling tab layout mode./p.
*
* @param tabIndex The index to get bounds for.
* @param dest The rectangle to store bounds in.
Index: javax/swing/plaf/metal/MetalTabbedPaneUI.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java,v
retrieving revision 1.21
diff -u -r1.21 MetalTabbedPaneUI.java
--- javax/swing/plaf/metal/MetalTabbedPaneUI.java	27 Jul 2006 01:28:41 -	1.21
+++ javax/swing/plaf/metal/MetalTabbedPaneUI.java	16 Aug 2006 23:37:32 -
@@ -1159,7 +1159,7 @@
 g.drawLine(x + 1, y + 1, x + 1, rect.y + 1);
 if (rect.y + rect.height  y + h - 2)
   {
-g.drawLine(x + y, rect.y + rect.height + 1, x + 1, y + h + 2);
+g.drawLine(x + 1, rect.y + rect.height + 1, x + 1, y + h + 2);
   }
   }
   }


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] FYI: Vector fixlet

2006-08-15 Thread Robert Schuster
Hi Roman,
could you please add a comment to these methods that says that the NPEs are
supposed to be thrown implicitly. Otherwise I find it a bit odd that the javadoc
mentions the exceptions explicitly.

cya
Robert

Roman Kennke wrote:
 This removes 2 explicit null checks in Vector. The Mauve test that I'll
 commit right after this shows that the RI allows null arguments when the
 Vector is empty. In the other case we throw an NPE implicitly anyway.
 
 2006-08-15  Roman Kennke  [EMAIL PROTECTED]
 
 * java/util/Vector.java
 (removeAll): Don't explicitly null-check here. The RI allows
 null arguments when Vector is empty. In other cases we
 implicitly throw an NPE.
 (retainAll): Don't explicitly null-check here. The RI allows
 null arguments when Vector is empty. In other cases we
 implicitly throw an NPE.
 
 /Roman
 


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: MetalBorders and MetalMenuBarUI

2006-08-03 Thread Robert Schuster
Hi,
this fumbles a bit with the way the gradient and the border is painted for JMenu
components.

Still need to find out how 'they' manage to join the painting of a JMenu with a
adjacent JToolBar ...

2006-08-04  Robert Schuster  [EMAIL PROTECTED]

* javax/swing/plaf/metal/MetalMenuBarUI.java:
(update): Check size and paint smaller gradient.
* javax/swing/plaf/metal/MetalBorders.java:
(MenuBarBorder): Removed borderColor field.
(MenuBarBorder.paintBorder): Added note, fetch color from UIManager or
MetalLookAndFeel.


cya
Robert
Index: javax/swing/plaf/metal/MetalMenuBarUI.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java,v
retrieving revision 1.1
diff -u -r1.1 MetalMenuBarUI.java
--- javax/swing/plaf/metal/MetalMenuBarUI.java	16 Nov 2005 15:44:05 -	1.1
+++ javax/swing/plaf/metal/MetalMenuBarUI.java	16 Jun 2006 12:54:19 -
@@ -44,6 +44,7 @@
 import javax.swing.SwingConstants;
 import javax.swing.UIManager;
 import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.UIResource;
 import javax.swing.plaf.basic.BasicMenuBarUI;
 
 /**
@@ -75,7 +76,9 @@
*/
   public void update(Graphics g, JComponent c)
   {
-if (c.isOpaque()  UIManager.get(MenuBar.gradient) != null)
+if (c.isOpaque()
+ UIManager.get(MenuBar.gradient) != null
+ c.getBackground() instanceof UIResource)
   {
 MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
  SwingConstants.VERTICAL, MenuBar.gradient);


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] FYI: MetalBorders and MetalMenuBarUI

2006-08-03 Thread Robert Schuster
Sorry,
I attached the wrong patch. Here is the correct one.

@Mark: This is a small fix which may enter 0.92.

cya
Robert

Robert Schuster wrote:
 Hi,
 this fumbles a bit with the way the gradient and the border is painted for 
 JMenu
 components.
 
 Still need to find out how 'they' manage to join the painting of a JMenu with 
 a
 adjacent JToolBar ...
 
 2006-08-04  Robert Schuster  [EMAIL PROTECTED]
 
 * javax/swing/plaf/metal/MetalMenuBarUI.java:
 (update): Check size and paint smaller gradient.
 * javax/swing/plaf/metal/MetalBorders.java:
 (MenuBarBorder): Removed borderColor field.
 (MenuBarBorder.paintBorder): Added note, fetch color from UIManager or
 MetalLookAndFeel.
 
 
 cya
 Robert
Index: javax/swing/plaf/metal/MetalBorders.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalBorders.java,v
retrieving revision 1.35
diff -u -r1.35 MetalBorders.java
--- javax/swing/plaf/metal/MetalBorders.java	18 May 2006 17:07:36 -	1.35
+++ javax/swing/plaf/metal/MetalBorders.java	3 Aug 2006 22:21:18 -
@@ -926,15 +926,11 @@
 /** The border insets. */
 protected static Insets borderInsets = new Insets(1, 0, 1, 0);
 
-// TODO: find where this color really comes from
-private static Color borderColor = new Color(153, 153, 153);
-
 /**
  * Creates a new border instance.
  */
 public MenuBarBorder()
 {
-  // Nothing to do here.
 }
 
 /**
@@ -951,7 +947,17 @@
 public void paintBorder(Component c, Graphics g, int x, int y, int w,
 int h)
 {
-  g.setColor(borderColor);
+  // Although it is not correct to decide on the static property
+  // currentTheme which color to use the RI does it like that.
+  // The trouble is that by simply changing the current theme to
+  // e.g. DefaultMetalLookAndFeel this method will use another color
+  // although a change in painting behavior should be expected only
+  // after setting a new look and feel and updating all components.
+  if(MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme)
+g.setColor(UIManager.getColor(MenuBar.borderColor));
+  else
+g.setColor(MetalLookAndFeel.getControlShadow());
+  
   g.drawLine(x, y + h - 1, x + w, y + h - 1);
 }
 
Index: javax/swing/plaf/metal/MetalMenuBarUI.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java,v
retrieving revision 1.2
diff -u -r1.2 MetalMenuBarUI.java
--- javax/swing/plaf/metal/MetalMenuBarUI.java	16 Jun 2006 12:54:46 -	1.2
+++ javax/swing/plaf/metal/MetalMenuBarUI.java	3 Aug 2006 22:21:18 -
@@ -1,5 +1,5 @@
 /* MetalMenuBarUI.java -- MenuBar UI for the Metal LF
-   Copyright (C) 2005 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -76,12 +76,15 @@
*/
   public void update(Graphics g, JComponent c)
   {
+int height = c.getHeight();
 if (c.isOpaque()
  UIManager.get(MenuBar.gradient) != null
- c.getBackground() instanceof UIResource)
+ c.getBackground() instanceof UIResource
+ height  2)
   {
-MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
+MetalUtils.paintGradient(g, 0, 0, c.getWidth(), height - 2,
  SwingConstants.VERTICAL, MenuBar.gradient);
+
 paint(g, c);
   }
 else


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: DomIterator fix

2006-08-03 Thread Robert Schuster
Hi,
this small patchlet, suggested by Henrik Gulbrandsen, fixes another case of 
PR27864.

2006-08-04  Robert Schuster  [EMAIL PROTECTED]
Reported by Henrik Gulbrandsen [EMAIL PROTECTED]
Fixes PR27864.
* gnu/xml/dom/DomIterator.java:
(successor): Added if-statement.

cya
Robert
Index: gnu/xml/dom/DomIterator.java
===
RCS file: /cvsroot/classpath/classpath/gnu/xml/dom/DomIterator.java,v
retrieving revision 1.5
diff -u -r1.5 DomIterator.java
--- gnu/xml/dom/DomIterator.java	8 Jun 2006 09:36:02 -	1.5
+++ gnu/xml/dom/DomIterator.java	3 Aug 2006 23:59:25 -
@@ -253,7 +253,13 @@
   {
 return here.getFirstChild();
   }
-
+
+// There's no way up or sideways from the root, so if we
+// couldn't move down to a child, there's nowhere to go.
+//
+if (here == root)
+  return null;
+
 //
 // Siblings ... if forward, we visit them, if backwards
 // we visit their children first.


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] FYI: JTabbedPane fixes

2006-07-26 Thread Robert Schuster
Ok,
I revert this and look for another way to resolve this.

Thanks Mark for finding this!

@Roman: The doc for setSelectedComponent() says it does the hiding and showing
of the old and new selected component. However I saw no code in that method
which does it. That is why I thought it should be added here. Please add notes
to code which relies on a certain behavior of the UI.

cya
Robert

Mark Wielaard wrote:
 Hi Robert,
 
 On Tue, 2006-07-25 at 21:21 +0200, Robert Schuster wrote:
 
Hi,
this patch fixes some minor JTabbedPane issues.

2006-07-25  Robert Schuster [EMAIL PROTECTED]

* javax/swing/JTabbedPane.java:
(remove(Component)): Rewritten.
(setSelectedIndex): Implemented updating of component visibility 
 state.
 
 
 This seems to revert part of a patch from Roman:
 
 2006-06-09  Roman Kennke  [EMAIL PROTECTED]
 
 * javax/swing/JTabbedPane.java
 (setSelectedIndex): Don't change the visibility of the components,
 this is done by the UI class.
 * javax/swing/plaf/basic/BasicTabbedPaneUI.java
 (TabbedPaneLayout.layoutContainer): Change visibility of component
 here, depending on the selected index. Only do this if the new
 selected component is not null. Some programs seem to expect
 this.
 (visibleComponent): New field.
 (getVisibleComponent): Changed to return visibleComponent field.
 (setVisibleComponent): Changed to set the visibility of
 the old and new visible component.
 
 And it does indeed seem to break the showcase application Roman posted
 about: http://kennke.org/blog/?p=9
 
 Could you coordinate on a correct fix?
 
 Thanks,
 
 Mark
 
 


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: revert JTabbedPane.setSelectedIndex patch

2006-07-26 Thread Robert Schuster
Hi,
this reverts yesterdays change to JTabbedPane.setSelectedIndex and adds a note.

ChangeLog:

2006-07-26  Robert Schuster [EMAIL PROTECTED]

* javax/swing/JTabbedPane.java:
(setSelectedIndex): Removed updating of component visibility status,
added note.

cya
Robert
Index: javax/swing/JTabbedPane.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JTabbedPane.java,v
retrieving revision 1.42
diff -u -r1.42 JTabbedPane.java
--- javax/swing/JTabbedPane.java	25 Jul 2006 19:20:28 -	1.42
+++ javax/swing/JTabbedPane.java	26 Jul 2006 13:59:24 -
@@ -991,16 +991,8 @@
 if (index != getSelectedIndex())
   {
 // Hiding and showing the involved components
-// is important for the focus traversal mechanism
-// to report the correct source and destination
-// components.
-Component c = getSelectedComponent();
-if (c != null)
-  c.setVisible(false);
-
+// is done by the JTabbedPane's UI.
 	model.setSelectedIndex(index);
-
-getSelectedComponent().setVisible(true);
   }
   }
 


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] FYI: revert JTabbedPane.setSelectedIndex patch

2006-07-26 Thread Robert Schuster
Hi,
actually the patch was applied in the following way:


2006-07-26  Robert Schuster [EMAIL PROTECTED]

* javax/swing/JTabbedPane.java:
(setSelectedIndex): Removed updating of component visibility status,
added note.
(remove(Component)): Use indexOfComponent() to find whether we have
to use super.remove(int) or removeTabAt().

cya
Robert

Robert Schuster wrote:
 Hi,
 this reverts yesterdays change to JTabbedPane.setSelectedIndex and adds a 
 note.
 
 ChangeLog:
 
 2006-07-26  Robert Schuster [EMAIL PROTECTED]
 
 * javax/swing/JTabbedPane.java:
 (setSelectedIndex): Removed updating of component visibility status,
 added note.
 
 cya
 Robert
 
 

Index: javax/swing/JTabbedPane.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JTabbedPane.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- javax/swing/JTabbedPane.java	25 Jul 2006 19:20:28 -	1.42
+++ javax/swing/JTabbedPane.java	26 Jul 2006 14:45:33 -	1.43
@@ -991,16 +991,8 @@
 if (index != getSelectedIndex())
   {
 // Hiding and showing the involved components
-// is important for the focus traversal mechanism
-// to report the correct source and destination
-// components.
-Component c = getSelectedComponent();
-if (c != null)
-  c.setVisible(false);
-
+// is done by the JTabbedPane's UI.
 	model.setSelectedIndex(index);
-
-getSelectedComponent().setVisible(true);
   }
   }
 
@@ -1257,17 +1249,24 @@
*/
   public void remove(Component component)
   {
-// Container.remove(Component) is implemented in a
-// way that it calls Container.remove(int). Since
-// JTabbedPane's remove(int) is overridden to
-// remove tabs and this in turn should not happen
-// with components implementing UIResource
-// we find out the component's index and
-// call the superclass' remove(int) method
+// Since components implementing UIResource
+// are not added as regular tabs by the add()
+// methods we have to take special care when
+// removing these object. Especially 
+// Container.remove(Component) cannot be used
+// because it will call JTabbedPane.remove(int)
+// later which is overridden and can only
+// handle tab components.
+// This implementation can even cope with a
+// situation that someone called insertTab()
+// with a component that implements UIResource.
+int index = indexOfComponent(component);
+
+// If the component is not a tab component
+// find out its Container-given index
+// and call that class' implementation
 // directly.
-// For non-UIResource implementing components
-// the normal implementation is suitable.
-if (component instanceof UIResource)
+if (index == -1)
   {
 Component[] cs = getComponents();
 for (int i = 0; i cs.length; i++)
@@ -1275,7 +1274,7 @@
 super.remove(i);
   }
 else
-  super.remove(component);
+  removeTabAt(index);
   }
 
   /**



signature.asc
Description: PGP signature


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] RFC: Stroking fix

2006-07-26 Thread Robert Schuster
Hi,
unfortunately I cannot say whether your fixes are mathematically right. However
I tried some piccolo apps[0] which I wrote years ago. Some of them worked
already but the ones that indirectly make use of BasicStroke did not work yet.
With your patch these problems are solved.

The piccolo distribution[1] contains an example application. With your patch
most of them work now!

Great stuff.

cya
Robert

[0] - http://www.inf.fu-berlin.de/~rschuste/picoapps.tar.gz
[1] - http://www.cs.umd.edu/hcil/jazz/

Francis Kung wrote:
 Hello,
 
 Attached is a patch to implement, fix, and clean up aspects of
 BasicStroke.createStrokedShape()
 
 I would appreciate any comments anyone might have.
 
 Thanks,
 Francis
 
 
 2006-07-25  Francis Kung  [EMAIL PROTECTED]
 
   * gnu/java/awt/java2d/CubicSegment.java: Added import.
   (cp1): Renamed from first().
   (c2): Renamed from last().
   (first): Renamed to cp1().
   (getDisplacedSegments): Implemented.
   (last): Renamed to cp2().
   * gnu/java/awt/java2d/LineSegment.java
   (cp1): Renamed from first().
   (c2): Renamed from last().
   (first): Renamed to cp1().
   (last): Renamed to cp2().
   * gnu/java/awt/java2d/QuadSegment.java
   (cp1): Renamed from first().
   (c2): Renamed from last().
   (first): Renamed to cp1().
   (last): Renamed to cp2().
   * gnu/java/awt/java2d/Segment.java: Added comments.
   (first): New field.
   (Segment): Keep track of first element in list.
   (add): Update first  last element variables.
   (cp1): Renamed from first().
   (c2): Renamed from last().
   (first()): Renamed to cp1() to reduce ambiguity.
   (last()): Renamed to cp2() to reduce ambiguity.
   (reverseAll): Update first element variable..
   * gnu/java/awt/peer/gtk/CairoGraphics2D.java
   (draw): Remove flattening path iterator.
   * java/awt/BasicStroke.java: Clarified comments.
   (addSegments): Refactored some code into joinSegments and 
   joinInnerSegments.
   (capEnd): Rename of Segment.first() and Segment.end().
   (joinInnerSegments): New method.
   (joinOuterSegments): New method.
   (joinSegments): Refactored some code into joinOuterSegments.
   (solidStroke): Connect segments together properly.
 
 
 
 
 
 Index: gnu/java/awt/java2d/CubicSegment.java
 ===
 RCS file: /cvsroot/classpath/classpath/gnu/java/awt/java2d/CubicSegment.java,v
 retrieving revision 1.2
 diff -u -r1.2 CubicSegment.java
 --- gnu/java/awt/java2d/CubicSegment.java 10 Jul 2006 18:43:38 -  
 1.2
 +++ gnu/java/awt/java2d/CubicSegment.java 25 Jul 2006 21:38:29 -
 @@ -39,6 +39,7 @@
  package gnu.java.awt.java2d;
  
  
 +import java.awt.geom.CubicCurve2D;
  import java.awt.geom.Point2D;
  
  /**
 @@ -100,28 +101,67 @@
}
  
/**
 -   * Get the top and bottom segments of this segment.
 -   * First array element is p0 + normal, second is p0 - normal.
 +   * Get the top and bottom segments of this segment. First array 
 element is
 +   * p0 + normal, second is p0 - normal.
 */
public Segment[] getDisplacedSegments(double radius)
{
 +// It is, apparently, impossible to derive a curve parallel to a bezier
 +// curve (unless it's a straight line), so we have no choice but to
 +// approximate the displaced segments. Similar to FlattenPathIterator.
 +
 +Segment segmentTop = null;
 +Segment segmentBottom = null;
  this.radius = radius;
 -double x0 = P1.getX();
 -double y0 = P1.getY();
 -double x1 = cp1.getX();
 -double y1 = cp1.getY();
 -double x2 = cp2.getX();
 -double y2 = cp2.getY();
 -double x3 = P2.getX();
 -double y3 = P2.getY();
 -double[] p1 = normal(x0, y0, x1, y1);
 -double[] p2 = normal(x2, y2, x3, y3);
 -
 -// FIXME: Doesn't compile.
 -// return new Segment[]{s1, s2};
 -return new Segment[0];
 -  }
  
 +CubicCurve2D[] curves = new CubicCurve2D[10];
 +curves[0] = new CubicCurve2D.Double(P1.getX(), P1.getY(), cp1.getX(),
 +cp1.getY(), cp2.getX(), cp2.getY(),
 +P2.getX(), P2.getY());
 +int numCurves = 1;
 +
 +// Hard-coded a recursion limit of 10 and flatness of 1... should we make
 +// this an option somewhere?
 +while (numCurves  0)
 +  {
 +// The curve is flat enough, or we've reached our recursion limit,
 +// so take the current start/end points and add it as a line segment
 +// to our final approximated curves
 +if (curves[numCurves - 1].getFlatness() = 1 || numCurves == 10)
 +  {
 +Segment[] displaced = new LineSegment(
 +  curves[numCurves - 
 1].getP1(),
 +  

[cp-patches] FYI: CairoGraphics2D.drawLine fix

2006-07-26 Thread Robert Schuster
Hi,
Roman asked me to look again at the drawLine issue and I now changed the code to
unconditionally apply a shift to all non-1-pixel lines. With that Swing compos
look good again and 1-pixel lines still work.

ChangeLog:

2006-07-26  Robert Schuster [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/CairoGraphics2D.java:
(drawLine): Apply shift to line coordinates.

cya
Robert
Index: gnu/java/awt/peer/gtk/CairoGraphics2D.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- gnu/java/awt/peer/gtk/CairoGraphics2D.java	25 Jul 2006 20:58:19 -	1.33
+++ gnu/java/awt/peer/gtk/CairoGraphics2D.java	26 Jul 2006 18:20:11 -	1.34
@@ -1044,7 +1044,7 @@
 if (x1 == x2  y1 == y2)
   cairoFillRect(nativePointer, x1, y1, 1, 1);
 else
-  cairoDrawLine(nativePointer, x1, y1, x2, y2);
+  cairoDrawLine(nativePointer, x1 + 0.5, y1 + 0.5, x2 + 0.5, y2 + 0.5);
   }
 
   public void drawRect(int x, int y, int width, int height)


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: BasicLookAndFeel in Swing Demo

2006-07-25 Thread Robert Schuster
Hi,
this patch makes it possible to see the basic look and feel in action in our
Swing demo.

In the future this may help to get customs LaFs working which directly build
upon the Basic Look And Feel.

2006-07-25  Robert Schuster [EMAIL PROTECTED]

* examples/gnu/classpath/examples/swing/Demo.java:
(mkMenuBar): Install instantiable basic look and feel.
(InstantiableBasicLookAndFeel): New inner class.

cya
Robert
Index: examples/gnu/classpath/examples/swing/Demo.java
===
RCS file: /cvsroot/classpath/classpath/examples/gnu/classpath/examples/swing/Demo.java,v
retrieving revision 1.48
diff -u -r1.48 Demo.java
--- examples/gnu/classpath/examples/swing/Demo.java	16 Jun 2006 20:46:54 -	1.48
+++ examples/gnu/classpath/examples/swing/Demo.java	25 Jul 2006 10:46:40 -
@@ -30,6 +30,7 @@
 import javax.swing.*;
 import javax.swing.tree.*;
 
+import javax.swing.plaf.basic.BasicLookAndFeel;
 import javax.swing.plaf.metal.DefaultMetalTheme;
 import javax.swing.plaf.metal.MetalLookAndFeel;
 import javax.swing.plaf.metal.MetalTheme;
@@ -192,6 +193,10 @@
 }
   });
 
+// Installs the BasicLookAndFeel.
+UIManager.installLookAndFeel((Basic Look And Feel),
+ InstantiableBasicLookAndFeel.class.getName());
+
 // Create LF menu.
 JMenu lafMenu = new JMenu(Look and Feel);
 ButtonGroup lafGroup = new ButtonGroup();
@@ -662,10 +667,45 @@
 {
   ex.printStackTrace();
 }
+  
   SwingUtilities.updateComponentTreeUI(frame);
   themesMenu.setEnabled(laf.getClassName()
.equals(javax.swing.plaf.metal.MetalLookAndFeel));
 }
+  }
 
+  /**
+   * An implementation of BasicLookAndFeel which can be instantiated.
+   * 
+   * @author Robert Schuster ([EMAIL PROTECTED])
+   *
+   */
+  public static class InstantiableBasicLookAndFeel extends BasicLookAndFeel
+  {
+public String getDescription()
+{
+  return An instantiable implementation of BasicLookAndFeel;
+}
+
+public String getID()
+{ 
+  return instantiableBasicLookAndFeel;
+}
+
+public String getName()
+{
+  return Instantiable Basic Look And Feel;
+}
+
+public boolean isNativeLookAndFeel()
+{
+  return false;
+}
+
+public boolean isSupportedLookAndFeel()
+{
+  return true;
+}
   }
+
 }


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: JTabbedPane fixes

2006-07-25 Thread Robert Schuster
Hi,
this patch fixes some minor JTabbedPane issues.

2006-07-25  Robert Schuster [EMAIL PROTECTED]

* javax/swing/JTabbedPane.java:
(remove(Component)): Rewritten.
(setSelectedIndex): Implemented updating of component visibility state.

cya
Robert
Index: javax/swing/JTabbedPane.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JTabbedPane.java,v
retrieving revision 1.41
diff -u -r1.41 JTabbedPane.java
--- javax/swing/JTabbedPane.java	9 Jun 2006 23:34:34 -	1.41
+++ javax/swing/JTabbedPane.java	25 Jul 2006 19:17:46 -
@@ -990,7 +990,17 @@
 checkIndex(index, -1, tabs.size());
 if (index != getSelectedIndex())
   {
+// Hiding and showing the involved components
+// is important for the focus traversal mechanism
+// to report the correct source and destination
+// components.
+Component c = getSelectedComponent();
+if (c != null)
+  c.setVisible(false);
+
 	model.setSelectedIndex(index);
+
+getSelectedComponent().setVisible(true);
   }
   }
 
@@ -1247,7 +1257,25 @@
*/
   public void remove(Component component)
   {
-super.remove(component);
+// Container.remove(Component) is implemented in a
+// way that it calls Container.remove(int). Since
+// JTabbedPane's remove(int) is overridden to
+// remove tabs and this in turn should not happen
+// with components implementing UIResource
+// we find out the component's index and
+// call the superclass' remove(int) method
+// directly.
+// For non-UIResource implementing components
+// the normal implementation is suitable.
+if (component instanceof UIResource)
+  {
+Component[] cs = getComponents();
+for (int i = 0; i cs.length; i++)
+  if (cs[i] == component)
+super.remove(i);
+  }
+else
+  super.remove(component);
   }
 
   /**
@@ -1257,7 +1285,6 @@
*/
   public void remove(int index)
   {
-super.remove(index);
 removeTabAt(index);
   }
 


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: Fix for PR27844

2006-07-25 Thread Robert Schuster
Hi,
the attached patch fixes the drawing problem for one pixel sized lines.

ChangeLog:

2006-07-25  Robert Schuster [EMAIL PROTECTED]

Fixes PR27844.
* java/awt/peer/gtk/CairoGraphics.java:
(drawLine): Removed calls to shifted().

cya
Robert
Index: gnu/java/awt/peer/gtk/CairoGraphics2D.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java,v
retrieving revision 1.31
diff -u -r1.31 CairoGraphics2D.java
--- gnu/java/awt/peer/gtk/CairoGraphics2D.java	24 Jul 2006 11:01:12 -	1.31
+++ gnu/java/awt/peer/gtk/CairoGraphics2D.java	25 Jul 2006 20:12:59 -
@@ -1038,9 +1038,7 @@
 
   public void drawLine(int x1, int y1, int x2, int y2)
   {
-cairoDrawLine(nativePointer, shifted(x1, shiftDrawCalls),
-  shifted(y1, shiftDrawCalls), shifted(x2, shiftDrawCalls),
-  shifted(y2, shiftDrawCalls));
+cairoDrawLine(nativePointer, x1, y1, x2 + 0.5, y2 + 0.5);
   }
 
   public void drawRect(int x, int y, int width, int height)


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] RFC: fix for PR28350

2006-07-11 Thread Robert Schuster
Hi,
thanks for looking at it.

Committed with this ChangeLog:


2006-07-11  Robert Schuster  [EMAIL PROTECTED]

Fixes PR28350.
* native/jni/gconf-peer/GConfNativePeer.c:

(Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1set_1string):
Changed if-expression.

(Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1get_1string):
Added check for _value not being NULL.

cya  happy hacking :)
Robert

Mario Torre wrote:
 Il giorno mar, 11/07/2006 alle 23.24 +0200, Robert Schuster ha scritto:
 
Hi,
this patch fixes PR28350 for me.

Ok to commit?
 
 
 Actually I'm unable to test as my eclipse is doing strange things :)
 But looks ok to me, please commit :)
 
 Thanks for the fix :)
 Mario
 
 
ChangeLog:

2006-07-11  Robert Schuster  [EMAIL PROTECTED]

* native/jni/gconf-peer/GConfNativePeer.c:
(Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1set_1string):
Changed if-expression.
(Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1get_1string):
Added check for _value not being NULL.

Function name doesnt fit into 80 columns ... hmm.
 
 
 :) This will be the next refactoring, for example removing 'client' :)
 
 
cya
Robert


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] FYI: Generate name the same way as Sun

2006-07-08 Thread Robert Schuster
Hi Tania

+if (type == 0)
+  name = Default Cursor;
+else if (type == 1)
+  name = Crosshair Cursor;
+else if (type == 2)
+  name = Text Cursor;
+else if (type == 3)
+  name = Wait Cursor;
+else if (type == 4)
+  name = Southwest Resize Cursor;
+else if (type == 5)
+  name = Southeast Resize Cursor;
+else if (type == 6)
+  name = Northwest Resize Cursor;
+else if (type == 7)
+  name = Northeast Resize Cursor;
+else if (type == 8)
+  name = North Resize Cursor;
+else if (type == 9)
+  name = South Resize Cursor;
+else if (type == 10)
+  name = West Resize Cursor;
+else if (type == 11)
+  name = East Resize Cursor;
+else if (type == 12)
+  name = Hand Cursor;
+else if (type == 13)
+  name = Move Cursor;
+  
+// FIXME: lookup?
There are names for these constants and I see a pattern how you could implement
this much more efficiently:

String[] NAMES = { Default Cursor, Crosshair Cursor, ... };

if (type = 0  type  NAMES.length
name = NAMES[type];
else
// dont know. Try on the RI :)


cya
Robert


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: BasicArrowButton paint fix

2006-07-05 Thread Robert Schuster
Hi,
the following patch fixes the painting of the BasicArrowButton. The main problem
was that the center point was calculated with the use of getBounds().x and that
value is in the coordinate space of the parent's component. I removed that and
simplified the method a bit.

ChangeLog:
2006-07-05  Robert Schuster  [EMAIL PROTECTED]

* javax/swing/plaf/basic/BasicArrowButton.java:
(paint): Removed getBounds() call, changed center point
calculation.
Index: javax/swing/plaf/basic/BasicArrowButton.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicArrowButton.java,v
retrieving revision 1.20
diff -u -r1.20 BasicArrowButton.java
--- javax/swing/plaf/basic/BasicArrowButton.java	15 Jun 2006 18:33:31 -	1.20
+++ javax/swing/plaf/basic/BasicArrowButton.java	5 Jul 2006 13:37:25 -
@@ -1,5 +1,5 @@
 /* BasicArrowButton.java --
-   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -162,16 +162,20 @@
   public void paint(Graphics g)
   {
 super.paint(g);
-Rectangle bounds = getBounds();
-int size = bounds.height / 4;
-int x = bounds.x + (bounds.width - size) / 2;
-int y = (bounds.height - size) / 4;
+
+int height = getHeight();
+int size = height / 4;
+
+int x = (getWidth() - size) / 2;
+int y = (height - size) / 2;
+
 ButtonModel m = getModel();
 if (m.isArmed())
   {
 x++;
 y++;
   }
+
 paintTriangle(g, x, y, size, direction, isEnabled());
   }
 


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: fix NPE in JMenu

2006-06-22 Thread Robert Schuster
Hi,
this patch fixes a NullPointerException which happens in JMenu.removeAll. This
problem was easily spotable using our Swing demo.

The ChangeLog:

2006-06-22  Robert Schuster  [EMAIL PROTECTED]

* javax/swing/JMenu.java:
(removeAll): Added check for popupMenu not being null.


cya
Robert
Index: javax/swing/JMenu.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JMenu.java,v
retrieving revision 1.28
diff -u -r1.28 JMenu.java
--- javax/swing/JMenu.java	21 Jun 2006 14:55:03 -	1.28
+++ javax/swing/JMenu.java	22 Jun 2006 13:20:36 -
@@ -250,7 +250,8 @@
*/
   public void removeAll()
   {
-popupMenu.removeAll();
+if (popupMenu != null)
+  popupMenu.removeAll();
   }
 
   /**


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: Insets.toString fix

2006-06-22 Thread Robert Schuster
Hi,
this small patch makes Insets.toString() return the information formatted in the
same way as on the RI.

ChangeLog:

2006-06-22  Robert Schuster  [EMAIL PROTECTED]

* java/awt/Insets.java: Updated copyright year.
(toString): Changed string, removed a line from the
documentation.

cya
Robert
Index: java/awt/Insets.java
===
RCS file: /cvsroot/classpath/classpath/java/awt/Insets.java,v
retrieving revision 1.9
diff -u -r1.9 Insets.java
--- java/awt/Insets.java	3 Mar 2006 23:22:21 -	1.9
+++ java/awt/Insets.java	22 Jun 2006 15:15:59 -
@@ -1,5 +1,5 @@
 /* Insets.java -- information about a container border
-   Copyright (C) 1999, 2000, 2002, 2005  Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2002, 2005, 2006  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -149,14 +149,13 @@
 
   /**
* Returns a string representation of this object, which will be non-null.
-   * The format is unspecified, but appears to be codeXXX what is it?/code.
*
* @return a string representation of this object
*/
   public String toString()
   {
-return getClass().getName() + (top= + top + ,bottom= + bottom +
-  ,left= + left + ,right= + right + ')';
+return getClass().getName() + [top= + top + ,left= + left
+  + ,bottom= + bottom + ,right= + right + ']';
   }
 
   /**


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: fix for MetalMenuBarUI

2006-06-16 Thread Robert Schuster
Hi,
when a custom background color is set on a JMenuBar gradient painting should not
 be done. I fixed this by checking whether the curent background color is an
instanceof of UIResource (this is done in other locations in plaf/metal too with
the same purpose).

Now custom JMenuBar colors work. :)

ChangeLog:

2006-06-16  Robert Schuster  [EMAIL PROTECTED]

* javax/swing/plaf/metal/MetalMenuBarUI.java:
(update): Added subexpression to if-statement.

cya
Robert
Index: javax/swing/plaf/metal/MetalMenuBarUI.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java,v
retrieving revision 1.1
diff -u -r1.1 MetalMenuBarUI.java
--- javax/swing/plaf/metal/MetalMenuBarUI.java	16 Nov 2005 15:44:05 -	1.1
+++ javax/swing/plaf/metal/MetalMenuBarUI.java	16 Jun 2006 12:54:19 -
@@ -44,6 +44,7 @@
 import javax.swing.SwingConstants;
 import javax.swing.UIManager;
 import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.UIResource;
 import javax.swing.plaf.basic.BasicMenuBarUI;
 
 /**
@@ -75,7 +76,9 @@
*/
   public void update(Graphics g, JComponent c)
   {
-if (c.isOpaque()  UIManager.get(MenuBar.gradient) != null)
+if (c.isOpaque()
+ UIManager.get(MenuBar.gradient) != null
+ c.getBackground() instanceof UIResource)
   {
 MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
  SwingConstants.VERTICAL, MenuBar.gradient);


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: fix for BasicRadioButtonUI

2006-06-16 Thread Robert Schuster
Hi,
this is my 2nd attempt to fix the RadioButton issue.

I found out that BasicRadioButtonUI is supposed to override getPrefferedSize.
This makes it possible to implement the layout stuff which properly notices the
default icon which is used when the icon property is not set.

ChangeLog:

2006-06-16  Robert Schuster  [EMAIL PROTECTED]

* javax/swing/plaf/basic/BasicRadioButtonUI.java:
(installDefaults): Removed unneccessary code.
(paint): Removed complex if-cascade, revert to default icon if
icon property is not set.
(getPreferredSize): New method.

cya
Robert
Index: javax/swing/plaf/basic/BasicRadioButtonUI.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java,v
retrieving revision 1.18
diff -u -r1.18 BasicRadioButtonUI.java
--- javax/swing/plaf/basic/BasicRadioButtonUI.java	13 Jun 2006 09:28:57 -	1.18
+++ javax/swing/plaf/basic/BasicRadioButtonUI.java	16 Jun 2006 12:26:50 -
@@ -42,6 +42,7 @@
 import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.Graphics;
+import java.awt.Insets;
 import java.awt.Rectangle;
 
 import javax.swing.AbstractButton;
@@ -92,14 +93,6 @@
   protected void installDefaults(AbstractButton b)
   {
 super.installDefaults(b);
-if (b.getIcon() == null)
-  b.setIcon(icon);
-if (b.getSelectedIcon() == null)
-  b.setSelectedIcon(icon);
-if (b.getDisabledIcon() == null)
-  b.setDisabledIcon(icon);
-if (b.getDisabledSelectedIcon() == null)
-  b.setDisabledSelectedIcon(icon);
   }
 
   /**
@@ -145,16 +138,17 @@
 g.setFont(f);
 
 ButtonModel m = b.getModel();
-Icon currentIcon = null;
-if (m.isSelected()  m.isEnabled())
-  currentIcon = b.getSelectedIcon();
-else if (! m.isSelected()  m.isEnabled())
-  currentIcon = b.getIcon();
-else if (m.isSelected()  ! m.isEnabled())
-  currentIcon = b.getDisabledSelectedIcon();
-else // (!m.isSelected()  ! m.isEnabled())
-  currentIcon = b.getDisabledIcon();
+// FIXME: Do a filtering on any customized icon if the following property
+// is set.
+boolean enabled = b.isEnabled();
+
+Icon currentIcon = b.getIcon();
 
+if (currentIcon == null)
+  {
+currentIcon = getDefaultIcon();
+  }
+
 SwingUtilities.calculateInnerArea(b, vr);
 String text = SwingUtilities.layoutCompoundLabel(c, g.getFontMetrics(f), 
b.getText(), currentIcon,
@@ -162,15 +156,57 @@
b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
vr, ir, tr, b.getIconTextGap() + defaultTextShiftOffset);
 
-if (currentIcon != null)
-  {
-currentIcon.paintIcon(c, g, ir.x, ir.y);
-  }
+currentIcon.paintIcon(c, g, ir.x, ir.y);
+
 if (text != null)
   paintText(g, b, tr, text);
 if (b.hasFocus()  b.isFocusPainted()  m.isEnabled())
   paintFocus(g, tr, c.getSize());
   }
+  
+  public Dimension getPreferredSize(JComponent c)
+  {
+// This is basically the same code as in
+// BasicGraphicsUtils.getPreferredButtonSize() but takes the default icon
+// property into account. JRadioButton and subclasses always have an icon:
+// the check box. If the user explicitly changes it with setIcon() that
+// one will be used for layout calculations and painting instead.
+// The other icon properties are ignored.
+AbstractButton b = (AbstractButton) c;
+
+Rectangle contentRect;
+Rectangle viewRect;
+Rectangle iconRect = new Rectangle();
+Rectangle textRect = new Rectangle();
+Insets insets = b.getInsets();
+
+Icon i = b.getIcon();
+if (i == null)
+  i = getDefaultIcon(); 
+
+viewRect = new Rectangle();
+
+SwingUtilities.layoutCompoundLabel(
+  b, // for the component orientation
+  b.getFontMetrics(b.getFont()),
+  b.getText(),
+  i,
+  b.getVerticalAlignment(), 
+  b.getHorizontalAlignment(),
+  b.getVerticalTextPosition(),
+  b.getHorizontalTextPosition(),
+  viewRect, iconRect, textRect,
+  defaultTextIconGap + defaultTextShiftOffset);
+
+contentRect = textRect.union(iconRect);
+
+return new Dimension(insets.left
+ + contentRect.width 
+ + insets.right + b.getHorizontalAlignment(),
+ insets.top
+ + contentRect.height 
+ + insets.bottom);
+  }
 
   /**
* Paints the focus indicator for JRadioButtons.


signature.asc
Description: OpenPGP digital signature


[cp-patches] RFC: change painting and layouting of buttons and radiobuttons

2006-06-15 Thread Robert Schuster
Hi,
I need help for this one.

I had the following problem:
BasicRadioButtonUI.installDefaults sets default values for the icon,
selectedIcon, disabledIcon etc properties. This is wrong, as the RI does not do
this. Minitestcase: assert(new JRadioButton().getIcon() == null)

I changed this and modified the paint() method within BasicRadioButtonUI in a
way that it draws the default icon (the checkbox thingie) if no explicit icon
was set (Btw: The RI seems to ignore the selectedIcon, disabledSelectedIcon and
disabledIcon property. It only takes the icon property into account.).

With this change I got a problem with layouting because getPreferredSize() needs
to know the icon which will be drawn beside the text. Currently this is handled
by BasicGraphicUtils.getPreferredButtonSize(). With the current implementation
it used getIcon() on the button which will be null for fresh unmodified radio
buttons and therefore the default icon is not taken into account for them.

I changed the code to make it aware of the default icon setting which radio
buttons can have but am not sure whether this is the right approach.

For the application I am debugging this patch fixes the issues.

No ChangeLog as I am waiting for further input.

cya
Robert
Index: javax/swing/plaf/basic/BasicGraphicsUtils.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicGraphicsUtils.java,v
retrieving revision 1.17
diff -u -r1.17 BasicGraphicsUtils.java
--- javax/swing/plaf/basic/BasicGraphicsUtils.java	18 Oct 2005 22:10:32 -	1.17
+++ javax/swing/plaf/basic/BasicGraphicsUtils.java	15 Jun 2006 17:28:51 -
@@ -54,6 +54,7 @@
 import javax.swing.Icon;
 import javax.swing.JComponent;
 import javax.swing.SwingUtilities;
+import javax.swing.plaf.ButtonUI;
 
 
 /**
@@ -603,18 +604,20 @@
 
 viewRect = new Rectangle();
 
- /* java.awt.Toolkit.getFontMetrics is deprecated. However, it
- * seems not obvious how to get to the correct FontMetrics object
- * otherwise. The real problem probably is that the method
- * javax.swing.SwingUtilities.layoutCompundLabel should take a
- * LineMetrics, not a FontMetrics argument. But fixing this that
- * would change the public API.
- */
+// Retrieve the icon fitting to the current button state.
+Icon i = BasicButtonUI.currentIcon(b);
+
+// If no icon is given and we have a BasicRadioButtonUI
+// we can ask it for the default icon.
+ButtonUI ui = b.getUI();
+if(i == null  ui instanceof BasicRadioButtonUI)
+  i = ((BasicRadioButtonUI) ui).getDefaultIcon();
+
SwingUtilities.layoutCompoundLabel(
   b, // for the component orientation
-  b.getToolkit().getFontMetrics(b.getFont()), // see comment above
+  b.getFontMetrics(b.getFont()),
   b.getText(),
-  b.getIcon(),
+  i,
   b.getVerticalAlignment(), 
   b.getHorizontalAlignment(),
   b.getVerticalTextPosition(),
Index: javax/swing/plaf/basic/BasicRadioButtonUI.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java,v
retrieving revision 1.18
diff -u -r1.18 BasicRadioButtonUI.java
--- javax/swing/plaf/basic/BasicRadioButtonUI.java	13 Jun 2006 09:28:57 -	1.18
+++ javax/swing/plaf/basic/BasicRadioButtonUI.java	15 Jun 2006 17:28:51 -
@@ -92,14 +92,6 @@
   protected void installDefaults(AbstractButton b)
   {
 super.installDefaults(b);
-if (b.getIcon() == null)
-  b.setIcon(icon);
-if (b.getSelectedIcon() == null)
-  b.setSelectedIcon(icon);
-if (b.getDisabledIcon() == null)
-  b.setDisabledIcon(icon);
-if (b.getDisabledSelectedIcon() == null)
-  b.setDisabledSelectedIcon(icon);
   }
 
   /**
@@ -145,16 +137,17 @@
 g.setFont(f);
 
 ButtonModel m = b.getModel();
-Icon currentIcon = null;
-if (m.isSelected()  m.isEnabled())
-  currentIcon = b.getSelectedIcon();
-else if (! m.isSelected()  m.isEnabled())
-  currentIcon = b.getIcon();
-else if (m.isSelected()  ! m.isEnabled())
-  currentIcon = b.getDisabledSelectedIcon();
-else // (!m.isSelected()  ! m.isEnabled())
-  currentIcon = b.getDisabledIcon();
+// FIXME: Do a filtering on any customized icon if the following property
+// is set.
+boolean enabled = b.isEnabled();
+
+Icon currentIcon = b.getIcon();
 
+if (currentIcon == null)
+  {
+currentIcon = icon;
+  }
+
 SwingUtilities.calculateInnerArea(b, vr);
 String text = SwingUtilities.layoutCompoundLabel(c, g.getFontMetrics(f), 
b.getText(), currentIcon,
@@ -162,10 +155,8 @@
b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
vr, ir, tr, b.getIconTextGap() + defaultTextShiftOffset);
 
-if (currentIcon != null)
-  {
-currentIcon.paintIcon(c, g, ir.x, ir.y);
-  }
+currentIcon.paintIcon(c, 

[cp-patches] FYI: fix for PR27864

2006-06-08 Thread Robert Schuster
Hi,
after talking to Casey this was approved.

ChangeLog:

2006-06-08  Robert Schuster  [EMAIL PROTECTED]

Fixes PR27864.
* gnu/xml/dom/DomIterator.java:
(successor): Changed expression.


cya
Robert
Index: gnu/xml/dom/DomIterator.java
===
RCS file: /cvsroot/classpath/classpath/gnu/xml/dom/DomIterator.java,v
retrieving revision 1.4
diff -u -r1.4 DomIterator.java
--- gnu/xml/dom/DomIterator.java	2 Jul 2005 20:32:15 -	1.4
+++ gnu/xml/dom/DomIterator.java	8 Jun 2006 09:35:30 -
@@ -1,5 +1,5 @@
 /* DomIterator.java -- 
-   Copyright (C) 1999,2000,2001 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -297,7 +297,9 @@
   {
 next = next.getParentNode();
   }
-if (next == root)
+
+// If we have exceeded the root node then stop traversing.
+if (next == root.getParentNode())
   {
 return null;
   }


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: allow null tileIcon for MatteBorder

2006-06-08 Thread Robert Schuster
HI,
an app written by me years ago demonstrates that MatteBorder can accept a null
tileIcon. Classpath' implementation throw an exception in that case. The
attached patch fixes that and make the paintBorder method aware of a possibly
null tileIcon.

ChangeLog:

2006-06-08  Robert Schuster  [EMAIL PROTECTED]

* javax/swing/border/MatteBorder.java:
(MatteBorder(int,int,int,int,Icon)): Removed if-statement and exception
throwing.
(paintBorder): Added if-statement to abort painting early.

cya
Robert
Index: javax/swing/border/MatteBorder.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/border/MatteBorder.java,v
retrieving revision 1.11
diff -u -r1.11 MatteBorder.java
--- javax/swing/border/MatteBorder.java	21 Apr 2006 11:26:33 -	1.11
+++ javax/swing/border/MatteBorder.java	8 Jun 2006 10:45:11 -
@@ -1,5 +1,5 @@
 /* MatteBorder.java -- 
-   Copyright (C) 2003, 2004  Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2006  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -147,9 +147,6 @@
   {
 super(top, left, bottom, right);
 
-if (tileIcon == null)
-  throw new IllegalArgumentException();
-
 this.tileIcon = tileIcon;
   }
 
@@ -375,6 +372,10 @@
   }
   return;
 }
+
+// If this border has no icon end painting here.
+if (tileIcon == null)
+  return;
 
 /* Determine the width and height of the icon. Some icons return
  * -1 if it is an image whose dimensions have not yet been


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: small Swing demo fix

2006-06-07 Thread Robert Schuster
Hi,
with this patch the Look and Feel radion buttons in the Swing demo are put into
the same button group.

ChangeLog:

2006-06-07  Robert Schuster  [EMAIL PROTECTED]

* examples/gnu/classpath/examples/swing/Demo.java:
(mkMenuBar): Put look and feel radio buttons into
appropriate button group.


cya
Robert
Index: examples/gnu/classpath/examples/swing/Demo.java
===
RCS file: /cvsroot/classpath/classpath/examples/gnu/classpath/examples/swing/Demo.java,v
retrieving revision 1.46
diff -u -r1.46 Demo.java
--- examples/gnu/classpath/examples/swing/Demo.java	25 May 2006 20:39:41 -	1.46
+++ examples/gnu/classpath/examples/swing/Demo.java	7 Jun 2006 10:23:31 -
@@ -203,6 +203,8 @@
 boolean selected = laf.getClassName().equals(currentLaf);
 lafItem.setSelected(selected);
 lafMenu.add(lafItem);
+
+lafGroup.add(lafItem);
   }
 
 // Create themes menu.


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] RFC: fix for PR27864

2006-06-07 Thread Robert Schuster
Hi,
unfortunately the fix you proposed yesterday on IRC did not work. I have further
investigate the problem to find out about your consideration about an NPE
happening because of my patch: I found out that if root is null, the code will
not reach that code location because then 'here' would be null too and this is
handled in line 243.

cya
Robert

Robert Schuster wrote:
 Hi,
 this patch fixes PR27864 for me.
 
 Ok to commit?
 
 ChangeLog:
 
 2006-06-01  Robert Schuster  [EMAIL PROTECTED]
 
 Fixes PR27864.
 * gnu/xml/dom/DomIterator.java:
 (successor): Changed expression.
 
 cya
 Robert
 
 
 
 
 Index: gnu/xml/dom/DomIterator.java
 ===
 RCS file: /cvsroot/classpath/classpath/gnu/xml/dom/DomIterator.java,v
 retrieving revision 1.4
 diff -u -r1.4 DomIterator.java
 --- gnu/xml/dom/DomIterator.java  2 Jul 2005 20:32:15 -   1.4
 +++ gnu/xml/dom/DomIterator.java  1 Jun 2006 17:13:03 -
 @@ -297,7 +297,10 @@
{
  next = next.getParentNode();
}
 -if (next == root)
 +
 +/* If we have exceeded the root node then stop traversing.
 + */
 +if (next == root.getParentNode())
{
  return null;
}


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: added 4th 8 to bits4 field in BufferedImage

2006-06-06 Thread Robert Schuster
Hi,
the attached patch adds the 4th 8 to the bits4 field in BufferedImage. With that
patch I could fix a lot of ArrayIndexOutOfBoundsExceptions in
ColorComponentModel and ColorModel.

I wrote that from my basic understanding of color modells and hope it is
correct. At least the app which is depending on this runs much better.

The ChangeLog:

2006-06-06  Robert Schuster  [EMAIL PROTECTED]

* java/awt/BufferedImage.java: Added fourth 8 to bits4 field.

cya
Robert
Index: java/awt/image/BufferedImage.java
===
RCS file: /cvsroot/classpath/classpath/java/awt/image/BufferedImage.java,v
retrieving revision 1.13
diff -u -r1.13 BufferedImage.java
--- java/awt/image/BufferedImage.java	4 Nov 2005 21:39:52 -	1.13
+++ java/awt/image/BufferedImage.java	6 Jun 2006 07:38:19 -
@@ -80,7 +80,7 @@
   TYPE_BYTE_INDEXED   = 13;
   
   static final int[] bits3 = { 8, 8, 8 };
-  static final int[] bits4 = { 8, 8, 8 };
+  static final int[] bits4 = { 8, 8, 8, 8 };
   static final int[] bits1byte = { 8 };
   static final int[] bits1ushort = { 16 };
   


signature.asc
Description: OpenPGP digital signature


[cp-patches] RFC: attempt to fix NPEs in flipbufferstrategy

2006-06-06 Thread Robert Schuster
Hi,
this is a small patch to the FlipBufferStrategy class which lives inside
Component. I do not fully understand how it should work and how the
implementation is supposed to work and therefore simply fixed the apparent
issue: When someone requests a real (# of buffers  1) back buffer strategy the
drawVBuffer field is not initialized and NPEs are thrown on access.

I prevented these exceptions and implemented getGraphics in a way that actual
painting will be visible.

Comments?

No ChangeLog so far as I am waiting for input from others.

cya
Robert
Index: java/awt/Component.java
===
RCS file: /cvsroot/classpath/classpath/java/awt/Component.java,v
retrieving revision 1.120
diff -u -r1.120 Component.java
--- java/awt/Component.java	4 Jun 2006 20:21:39 -	1.120
+++ java/awt/Component.java	6 Jun 2006 08:07:43 -
@@ -6332,7 +6332,7 @@
  */
 public Graphics getDrawGraphics()
 {
-  return drawVBuffer.getGraphics();
+  return (drawVBuffer != null) ? drawVBuffer.getGraphics() : peer.getGraphics();
 }
 
 /**
@@ -6357,7 +6357,7 @@
  */
 public boolean contentsLost()
 {
-  if (drawVBuffer.contentsLost())
+  if (drawVBuffer != null  drawVBuffer.contentsLost())
 	{
 	  validatedContents = false;
 	  return true;


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: GdkScreenGraphicsDevice and friends implemented

2006-06-06 Thread Robert Schuster
Hi,
this patch implements the GdkScreenGraphicsDevice and related classes.

ChangeLog:
2006-06-06  Robert Schuster  [EMAIL PROTECTED]

* include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h: Regenerated.
* include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h: New file.
* include/Makefile.am: Added
gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.
* gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java:
(GdkGraphicsConfiguration): Rewritten.
(getColorModel): Rewritten.
(getColorModel(int)): Rewritten.
(getBounds): Rewritten.
(createCompatibleVolatileImage): Implemented.
* gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java: Added static
initializer.
(getDefaultScreenDevice): Rewritten.
(nativeGetDefaultScreenDevice): New method.
(getScreenDevices): Rewritten.
(nativeGetScreenDevices): New method.
(nativeInitState): New method.
* gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java: Entirely
rewritten.
(X11DisplayMode): New inner class.
* native/jni/gtk-peer/Makefile.am: Added gdkdisplay.h and
gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c
* native/jni/gtk-peer/gdkdisplay.h: New file.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c:
(Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_initStaticState):
New function.
(Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeInitState):
New function.
(Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment
_nativeGetScreenDevices):
New function.
(Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment
_nativeGetDefaultScreenDevice):
New function.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c:
New file.
* configure.ac: Added check for Xrandr library.

Index: include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h
===
RCS file: /cvsroot/classpath/classpath/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h,v
retrieving revision 1.3
diff -u -r1.3 gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h
--- include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h	30 Apr 2006 10:37:36 -	1.3
+++ include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h	6 Jun 2006 09:22:01 -
@@ -10,6 +10,10 @@
 {
 #endif
 
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_initStaticState (JNIEnv *env, jclass);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeInitState (JNIEnv *env, jobject);
+JNIEXPORT jobjectArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetScreenDevices (JNIEnv *env, jobject);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetDefaultScreenDevice (JNIEnv *env, jobject);
 JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetNumFontFamilies (JNIEnv *env, jobject);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetFontFamilies (JNIEnv *env, jobject, jobjectArray);
 
Index: include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h
===
RCS file: include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h
diff -N include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h
--- /dev/null	1 Jan 1970 00:00:00 -
+++ include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h	6 Jun 2006 09:22:01 -
@@ -0,0 +1,26 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice__
+#define __gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice__
+
+#include jni.h
+
+#ifdef __cplusplus
+extern C
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_initStaticState (JNIEnv *env, jclass);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetFixedDisplayMode (JNIEnv *env, jobject, jobject);
+JNIEXPORT jstring JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetIDString (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetDisplayModeIndex (JNIEnv *env, jobject, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetDisplayModeRate (JNIEnv *env, jobject, jobject);
+JNIEXPORT jobjectArray JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetDisplayModes (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeSetDisplayMode (JNIEnv *env, jobject, jobject, jint, jshort);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetBounds (JNIEnv *env, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice__ */
Index

[cp-patches] FYI: build fix for GdkGraphicsEnvironment

2006-06-06 Thread Robert Schuster
Hi,
this patch adds an explicit cast to GraphicsDevice[] in GdkGraphicsEnvironment
and makes the compilation (with a 1.4-style compiler) succeed again.

ChangeLog:

2006-06-06  Robert Schuster  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java:
(getScreenDevices): Added explicit cast.

cya
Robert
Index: gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java,v
retrieving revision 1.12
diff -u -r1.12 GdkGraphicsEnvironment.java
--- gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java	6 Jun 2006 10:04:15 -	1.12
+++ gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java	6 Jun 2006 10:55:54 -
@@ -78,7 +78,7 @@
 devices = nativeGetScreenDevices();
   }
 
-return devices.clone();
+return (GraphicsDevice[]) devices.clone();
   }
   
   private native GdkScreenGraphicsDevice[] nativeGetScreenDevices();


signature.asc
Description: OpenPGP digital signature


[cp-patches] RFC: fix for PR27864

2006-06-01 Thread Robert Schuster
Hi,
this patch fixes PR27864 for me.

Ok to commit?

ChangeLog:

2006-06-01  Robert Schuster  [EMAIL PROTECTED]

Fixes PR27864.
* gnu/xml/dom/DomIterator.java:
(successor): Changed expression.

cya
Robert
Index: gnu/xml/dom/DomIterator.java
===
RCS file: /cvsroot/classpath/classpath/gnu/xml/dom/DomIterator.java,v
retrieving revision 1.4
diff -u -r1.4 DomIterator.java
--- gnu/xml/dom/DomIterator.java	2 Jul 2005 20:32:15 -	1.4
+++ gnu/xml/dom/DomIterator.java	1 Jun 2006 17:13:03 -
@@ -297,7 +297,10 @@
   {
 next = next.getParentNode();
   }
-if (next == root)
+
+/* If we have exceeded the root node then stop traversing.
+ */
+if (next == root.getParentNode())
   {
 return null;
   }


signature.asc
Description: OpenPGP digital signature


[cp-patches] RFC: BasicSplitPaneUI layout manager fix

2006-06-01 Thread Robert Schuster
Hi,
the attached patch will make the layout manager classes inside BasicSplitPaneUI
return fixed values instead of asking the component.

The reason why I did that is that without the patch doing a
JSplitPane.getAlignmentX() will result in a StackOverflow. A JSplitPane has its
own layout classes as layout manager, those will be asked then (see
Container.getAlignmentX) and from there the component (JSplitPane) was asked 
again.

The same number was returned in the RI.

Ok, to commit?

The ChangeLog:

2006-06-01  Robert Schuster  [EMAIL PROTECTED]

* javax/swing/plaf/basic/BasicSplitPaneUI.java:
(BasicHorizontalLayout.getAlignmentX): Return fixed value.
(BasicHorizontalLayout.getAlignmentY): Return fixed value.

cya
Robert
Index: javax/swing/plaf/basic/BasicSplitPaneUI.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java,v
retrieving revision 1.28
diff -u -r1.28 BasicSplitPaneUI.java
--- javax/swing/plaf/basic/BasicSplitPaneUI.java	17 Apr 2006 07:41:05 -	1.28
+++ javax/swing/plaf/basic/BasicSplitPaneUI.java	1 Jun 2006 19:43:58 -
@@ -191,7 +191,7 @@
  */
 public float getLayoutAlignmentX(Container target)
 {
-  return target.getAlignmentX();
+  return 0.0f;
 }
 
 /**
@@ -204,7 +204,7 @@
  */
 public float getLayoutAlignmentY(Container target)
 {
-  return target.getAlignmentY();
+  return 0.0f;
 }
 
 /**


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] FYI: different Container.removeAll() implementation - first patch

2006-05-30 Thread Robert Schuster
Hi,
thanks to my confusion I applied this patch though.

I left it in and added corrected the changelog. Now both patches are in, where
the 2nd changes what was implemented by the first.

Sorry for the noise.

cya
Robert

Robert Schuster wrote:
 Hi,
 forget about this patch. I prepare a different one.
 
 Robert Schuster wrote:
 
Hi,
I am currently working to get an application running which depends on
implementation details of the RI.

This changes Container.removeAll() to make it work in a special case
(see added note in patch).

ChangeLog:

2006-05-30  Robert Schuster  [EMAIL PROTECTED]

* java/awt/Container.java:
(removeAll): Implemented different removal mechanism, added note.

cya
Robert




Index: java/awt/Container.java
===
RCS file: /cvsroot/classpath/classpath/java/awt/Container.java,v
retrieving revision 1.91
diff -u -r1.91 Container.java
--- java/awt/Container.java   5 Apr 2006 10:31:26 -   1.91
+++ java/awt/Container.java   30 May 2006 17:40:36 -
@@ -457,8 +457,15 @@
   {
 synchronized (getTreeLock ())
   {
-while (ncomponents  0)
+// In order to allow the same bad tricks to be used as in RI
+// this code has to stay exactly that way: In a real-life app
+// a Container subclass implemented its own vector for
+// subcomponents, supplied additional addXYZ() methods
+// and overrode remove(int) (but not removeAll).
+for ( int i=0; incomponents; i++)
   remove(0);
+
+ncomponents = 0;
   }
   }
 


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: Switching resolutions demo

2006-05-23 Thread Robert Schuster
Hi,
this patch adds a subdemo to the AWT Demo application which shows how nice we
can switch the screen resolution (soon :) ).

ChangeLog:

2006-05-23  Robert Schuster  [EMAIL PROTECTED]

* examples/gnu/classpath/examples/awt/Demo.java:
(MainWindow.MainWindow): Added ResolutionWindow instance as subframe.
(ResolutionWindow): New inner class.

cya
Robert
Index: examples/gnu/classpath/examples/awt/Demo.java
===
RCS file: /cvsroot/classpath/classpath/examples/gnu/classpath/examples/awt/Demo.java,v
retrieving revision 1.5
diff -u -r1.5 Demo.java
--- examples/gnu/classpath/examples/awt/Demo.java	16 Mar 2006 03:28:12 -	1.5
+++ examples/gnu/classpath/examples/awt/Demo.java	23 May 2006 10:33:13 -
@@ -154,6 +154,7 @@
   addSubWindow (RandomTests, new TestWindow (this));
   addSubWindow (RoundRect, new RoundRectWindow ());
   addSubWindow (Animation, new AnimationWindow ());
+  addSubWindow (Resolution, new ResolutionWindow ());
 
   Panel sp = new Panel();
   PrettyPanel p = new PrettyPanel();
@@ -744,6 +745,56 @@
   t.beep();
 }
   }
+  
+  static class ResolutionWindow extends SubFrame
+  {
+GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
+
+public void init ()
+{
+  setTitle(Change Screen Resolution);
+  final List list = new List();
+  DisplayMode[] modes = gd.getDisplayModes();
+  
+  for (int i=0;imodes.length;i++ )
+list.add(modes[i].getWidth()  + x
+ + modes[i].getHeight()
+ + ((modes[i].getBitDepth() != DisplayMode.BIT_DEPTH_MULTI)
+   ? x + modes[i].getBitDepth() + bpp
+   : )
+ + ((modes[i].getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN)
+   ? @ + modes[i].getRefreshRate() + Hz
+   : ));
+  
+  ActionListener al = new ActionListener()
+  {
+public void actionPerformed(ActionEvent ae)
+{
+  int i = list.getSelectedIndex();
+  gd.setDisplayMode(gd.getDisplayModes()[i]);
+}
+  };
+  
+  Button b = new Button(Switch);
+  Button c = new Button(Close);
+  
+  list.addActionListener(al);
+  b.addActionListener(al);
+  
+  c.addActionListener(new ActionListener () {
+public void actionPerformed (ActionEvent e) {
+  dispose();
+}
+  });
+  
+  setLayout(new GridLayout(3, 1, 5, 5));
+  add(list);
+  add(b);
+  add(c);
+  
+  pack();
+}
+  }
 
   static class RoundRectWindow extends SubFrame
   {


signature.asc
Description: OpenPGP digital signature


[cp-patches] FYI: Switching resolutions ( fullscreen exclusive mode) demo

2006-05-23 Thread Robert Schuster
Hi,
this patch adds a subdemo to the AWT Demo application which shows how nice we
can switch the screen resolution and use the Full Screen Exclusive Mode API
(soon :) )

ChangeLog:

2006-05-23  Robert Schuster  [EMAIL PROTECTED]

* examples/gnu/classpath/examples/awt/Demo.java:
(MainWindow.MainWindow): Added ResolutionWindow and FullscreenWindow
instance as subframe.
(ResolutionWindow): New inner class.
(FullscreenWindow): New inner class.

cya
Robert

Index: examples/gnu/classpath/examples/awt/Demo.java
===
RCS file: /cvsroot/classpath/classpath/examples/gnu/classpath/examples/awt/Demo.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- examples/gnu/classpath/examples/awt/Demo.java	16 Mar 2006 03:28:12 -	1.5
+++ examples/gnu/classpath/examples/awt/Demo.java	23 May 2006 10:45:33 -	1.6
@@ -154,6 +154,8 @@
   addSubWindow (RandomTests, new TestWindow (this));
   addSubWindow (RoundRect, new RoundRectWindow ());
   addSubWindow (Animation, new AnimationWindow ());
+  addSubWindow (Resolution, new ResolutionWindow ());
+  addSubWindow (Fullscreen, new FullscreenWindow ());
 
   Panel sp = new Panel();
   PrettyPanel p = new PrettyPanel();
@@ -744,6 +746,99 @@
   t.beep();
 }
   }
+  
+  static class ResolutionWindow extends SubFrame
+  {
+GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
+
+public void init ()
+{
+  initted = true;
+  
+  setTitle(Change Screen Resolution);
+  final List list = new List();
+  DisplayMode[] modes = gd.getDisplayModes();
+  
+  for (int i=0;imodes.length;i++ )
+list.add(modes[i].getWidth()  + x
+ + modes[i].getHeight()
+ + ((modes[i].getBitDepth() != DisplayMode.BIT_DEPTH_MULTI)
+   ? x + modes[i].getBitDepth() + bpp
+   : )
+ + ((modes[i].getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN)
+   ? @ + modes[i].getRefreshRate() + Hz
+   : ));
+  
+  ActionListener al = new ActionListener()
+  {
+public void actionPerformed(ActionEvent ae)
+{
+  int i = list.getSelectedIndex();
+  gd.setDisplayMode(gd.getDisplayModes()[i]);
+}
+  };
+  
+  Button b = new Button(Switch);
+  Button c = new Button(Close);
+  
+  list.addActionListener(al);
+  b.addActionListener(al);
+  
+  c.addActionListener(new ActionListener () {
+public void actionPerformed (ActionEvent e) {
+  dispose();
+}
+  });
+  
+  setLayout(new GridLayout(3, 1, 5, 5));
+  add(list);
+  add(b);
+  add(c);
+  
+  pack();
+}
+  }
+
+  static class FullscreenWindow extends SubFrame
+  {
+GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
+
+public void init ()
+{
+  initted = true;
+  
+  setTitle(Fullscreen Exclusive Mode);
+
+  ActionListener al = new ActionListener()
+  {
+public void actionPerformed(ActionEvent ae)
+{
+  if (gd.getFullScreenWindow() == FullscreenWindow.this)
+gd.setFullScreenWindow(null);
+  else
+gd.setFullScreenWindow(FullscreenWindow.this);
+}
+  };
+  
+  Button b = new Button(Toggle Fullscreen);
+  Button c = new Button(Close);
+  
+  b.addActionListener(al);
+  
+  c.addActionListener(new ActionListener () {
+public void actionPerformed (ActionEvent e) {
+  gd.setFullScreenWindow(null);
+  dispose();
+}
+  });
+  
+  setLayout(new GridLayout(3, 1, 5, 5));
+  add(b);
+  add(c);
+  
+  pack();
+}
+  }
 
   static class RoundRectWindow extends SubFrame
   {


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] FYI: Switching resolutions demo

2006-05-23 Thread Robert Schuster
Hi,
this patch was discarded. I committed a different one.

cya
Robert

Robert Schuster wrote:
 Hi,
 this patch adds a subdemo to the AWT Demo application which shows how nice we
 can switch the screen resolution (soon :) ).
 
 ChangeLog:
 
 2006-05-23  Robert Schuster  [EMAIL PROTECTED]
 
 * examples/gnu/classpath/examples/awt/Demo.java:
 (MainWindow.MainWindow): Added ResolutionWindow instance as subframe.
 (ResolutionWindow): New inner class.
 
 cya
 Robert
 
 
 
 
 Index: examples/gnu/classpath/examples/awt/Demo.java
 ===
 RCS file: 
 /cvsroot/classpath/classpath/examples/gnu/classpath/examples/awt/Demo.java,v
 retrieving revision 1.5
 diff -u -r1.5 Demo.java
 --- examples/gnu/classpath/examples/awt/Demo.java 16 Mar 2006 03:28:12 
 -  1.5
 +++ examples/gnu/classpath/examples/awt/Demo.java 23 May 2006 10:33:13 
 -
 @@ -154,6 +154,7 @@
addSubWindow (RandomTests, new TestWindow (this));
addSubWindow (RoundRect, new RoundRectWindow ());
addSubWindow (Animation, new AnimationWindow ());
 +  addSubWindow (Resolution, new ResolutionWindow ());
  
Panel sp = new Panel();
PrettyPanel p = new PrettyPanel();
 @@ -744,6 +745,56 @@
t.beep();
  }
}
 +  
 +  static class ResolutionWindow extends SubFrame
 +  {
 +GraphicsDevice gd = 
 GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
 +
 +public void init ()
 +{
 +  setTitle(Change Screen Resolution);
 +  final List list = new List();
 +  DisplayMode[] modes = gd.getDisplayModes();
 +  
 +  for (int i=0;imodes.length;i++ )
 +list.add(modes[i].getWidth()  + x
 + + modes[i].getHeight()
 + + ((modes[i].getBitDepth() != DisplayMode.BIT_DEPTH_MULTI)
 +   ? x + modes[i].getBitDepth() + bpp
 +   : )
 + + ((modes[i].getRefreshRate() != 
 DisplayMode.REFRESH_RATE_UNKNOWN)
 +   ? @ + modes[i].getRefreshRate() + Hz
 +   : ));
 +  
 +  ActionListener al = new ActionListener()
 +  {
 +public void actionPerformed(ActionEvent ae)
 +{
 +  int i = list.getSelectedIndex();
 +  gd.setDisplayMode(gd.getDisplayModes()[i]);
 +}
 +  };
 +  
 +  Button b = new Button(Switch);
 +  Button c = new Button(Close);
 +  
 +  list.addActionListener(al);
 +  b.addActionListener(al);
 +  
 +  c.addActionListener(new ActionListener () {
 +public void actionPerformed (ActionEvent e) {
 +  dispose();
 +}
 +  });
 +  
 +  setLayout(new GridLayout(3, 1, 5, 5));
 +  add(list);
 +  add(b);
 +  add(c);
 +  
 +  pack();
 +}
 +  }
  
static class RoundRectWindow extends SubFrame
{


signature.asc
Description: OpenPGP digital signature


Re: [cp-patches] RFC: GdkScreenGraphicsDevice et all implementation - preview patch

2006-05-23 Thread Robert Schuster
I have no problem with that.

How is that Pointer API supposed to be used?

cya
Robert

Sven de Marothy wrote:
 On Mon, 2006-05-22 at 22:53 +0200, Robert Schuster wrote:
 
 
The way its done now is pretty simple and there is much room for enhancement.
However I want to have some feedback on the current state because I am new to
Gdk/Gtk+ and Xlib/XRandR programming and had to work myself into the goodness 
of
Classpath' Magical NSA API ... ;)
 
 
 I'm not sure we should use the NSA stuff for new code. I personally
 don't think it's a very good solution. It obfuscates where the actual
 data is at behind an undocumented and unintuitive set of macros. It also
 makes it harder to see what native data structures the java classes map
 to. It's one of the things that makes understanding and working on the
 Gtk peers more difficult. The Pointer/Pointer32/Pointer64 classes also
 do their job in contributing. 
 
 Storing the native pointer as a simple long field works just fine on any
 platform. I don't see the point of not Keeping It Simple.
 
 /Sven
 
 
 


signature.asc
Description: OpenPGP digital signature


[cp-patches] RFC: GdkScreenGraphicsDevice et all implementation - preview patch

2006-05-22 Thread Robert Schuster
Hi,
I started to work on PR23874[0] and came to the point where some of the basic
functionality works:
- getting the local graphics environment
- getting the available screen devices
- getting the default screen device
- getting a screen device's display mode (via XRandR extension)
- getting a screen device's current display mode (via XRandR extension)
- setting a screen device's current display mode (via XRandR extension)

The way its done now is pretty simple and there is much room for enhancement.
However I want to have some feedback on the current state because I am new to
Gdk/Gtk+ and Xlib/XRandR programming and had to work myself into the goodness of
Classpath' Magical NSA API ... ;)

So its very likely that I did something completely wrong.

No ChangeLog as this is work in progress!

cya
Robert

[0] - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23874
Index: gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java,v
retrieving revision 1.10
diff -u -r1.10 GdkGraphicsEnvironment.java
--- gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java	19 Aug 2005 01:29:26 -	1.10
+++ gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java	22 May 2006 20:39:22 -
@@ -38,34 +38,72 @@
 
 package gnu.java.awt.peer.gtk;
 
+import gnu.classpath.Configuration;
+
 import java.awt.Font;
 import java.awt.Graphics2D;
 import java.awt.GraphicsDevice;
 import java.awt.GraphicsEnvironment;
 import java.awt.HeadlessException;
-import java.awt.Toolkit;
 import java.awt.image.BufferedImage;
 import java.util.Locale;
 
 public class GdkGraphicsEnvironment extends GraphicsEnvironment
 {
+  private final int native_state = GtkGenericPeer.getUniqueInteger ();
+  
+  private GdkScreenGraphicsDevice defaultDevice;
+  
+  private GdkScreenGraphicsDevice[] devices;
+  
+  static
+  {
+if (Configuration.INIT_LOAD_LIBRARY)
+  {
+System.loadLibrary(gtkpeer);
+  }
+
+initStaticState ();
+  }
+  
+  static native void initStaticState();
+  
   public GdkGraphicsEnvironment ()
   {
+nativeInitState();
   }
+  
+  native void nativeInitState();
 
   public GraphicsDevice[] getScreenDevices ()
   {
-// FIXME: Support multiple screens, since GDK can.
-return new GraphicsDevice[] { new GdkScreenGraphicsDevice (this) };
+if (devices == null)
+  {
+devices = nativeGetScreenDevices();
+  }
+
+return devices.clone();
   }
+  
+  private native GdkScreenGraphicsDevice[] nativeGetScreenDevices();
 
   public GraphicsDevice getDefaultScreenDevice ()
   {
 if (GraphicsEnvironment.isHeadless ())
   throw new HeadlessException ();
-
-return new GdkScreenGraphicsDevice (this);
+
+synchronized (GdkGraphicsEnvironment.class)
+  {
+if (defaultDevice == null)
+  {
+defaultDevice = nativeGetDefaultScreenDevice();
+  }
+  }
+
+return defaultDevice;
   }
+  
+  private native GdkScreenGraphicsDevice nativeGetDefaultScreenDevice();
 
   public Graphics2D createGraphics (BufferedImage image)
   {
Index: gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java
===
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java,v
retrieving revision 1.6
diff -u -r1.6 GdkScreenGraphicsDevice.java
--- gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java	19 Aug 2005 01:29:26 -	1.6
+++ gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java	22 May 2006 20:39:22 -
@@ -1,5 +1,5 @@
 /* GdkScreenGraphicsDevice.java -- information about a screen device
-   Copyright (C) 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,6 +38,8 @@
 
 package gnu.java.awt.peer.gtk;
 
+import gnu.classpath.Configuration;
+
 import java.awt.Dimension;
 import java.awt.DisplayMode;
 import java.awt.GraphicsConfiguration;
@@ -46,24 +48,47 @@
 
 public class GdkScreenGraphicsDevice extends GraphicsDevice
 {
+  private final int native_state = GtkGenericPeer.getUniqueInteger ();
+  
   GdkGraphicsEnvironment env;
-
-  public GdkScreenGraphicsDevice (GdkGraphicsEnvironment e)
-  {
-super ();
+  
+  String idString;
+  
+  DisplayMode[] displayModes;
+  
+  static
+  {
+if (Configuration.INIT_LOAD_LIBRARY)
+  {
+System.loadLibrary(gtkpeer);
+  }
+
+initStaticState ();
+  }
+  
+  static native void initStaticState();
+  
+  GdkScreenGraphicsDevice (GdkGraphicsEnvironment e)
+  {
+super();
 env = e;
   }
 
   public int getType ()
   {
+// Gdk's manages only raster screens.
 return GraphicsDevice.TYPE_RASTER_SCREEN;
   }
 
   public String getIDstring ()
   {
-// FIXME: query X for this string
-return default GDK device ID string;
+if (idString == null)
+  idString = 

[cp-patches] RFC: toolbar button painting

2006-05-19 Thread Robert Schuster
Hi,
here is my proposal for a slight rewrite of the MetalButtonUI.update method: It
first finds out whether gradient painting is needed or not and calls a specific
private method which works out all the details.

The comments should explain it all.

Note: Some change to the lightweightdispatcher is still needed. Currently you
can click and hold on a toolbar button, move to another and it will not set the
rollover state to true. However if you click on another mouse button (while
still holding down the left one) the button under the cursor will receive focus
and everything gets messed up. In the RI the focus traversal is prevented 
somehow.

Ok to commit?

The ChangeLog:

2006-05-19  Robert Schuster  [EMAIL PROTECTED]

* javax/swing/metal/MetalButtonUI.java:
(update): Removed some subexpression from if-clause and call
updateWithGradient.
(updateWithGradient): New method.

cya
Robert
Index: javax/swing/plaf/metal/MetalButtonUI.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalButtonUI.java,v
retrieving revision 1.17
diff -u -r1.17 MetalButtonUI.java
--- javax/swing/plaf/metal/MetalButtonUI.java	11 May 2006 17:05:55 -	1.17
+++ javax/swing/plaf/metal/MetalButtonUI.java	19 May 2006 09:08:04 -
@@ -39,6 +39,7 @@
 package javax.swing.plaf.metal;
 
 import java.awt.Color;
+import java.awt.Container;
 import java.awt.Font;
 import java.awt.FontMetrics;
 import java.awt.Graphics;
@@ -48,7 +49,9 @@
 import javax.swing.ButtonModel;
 import javax.swing.JButton;
 import javax.swing.JComponent;
+import javax.swing.JToolBar;
 import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.UIResource;
@@ -237,19 +240,63 @@
   public void update(Graphics g, JComponent c)
   {
 AbstractButton b = (AbstractButton) c;
-ButtonModel m = b.getModel();
 if (b.isContentAreaFilled()
  (UIManager.get(getPropertyPrefix() + gradient) != null)
- ! m.isPressed()  ! m.isArmed()
  b.isEnabled()
  (b.getBackground() instanceof UIResource))
+  updateWidthGradient(g, b, b.getParent());
+else
+  super.update(g, c);
+  }
+  
+  private void updateWidthGradient(Graphics g, AbstractButton b, Container parent)
+  {
+ButtonModel m = b.getModel();
+String gradientPropertyName = getPropertyPrefix() + gradient;
+
+// Gradient painting behavior depends on whether the button is part of a
+// JToolBar.
+if (parent instanceof JToolBar)
+  {
+if (! m.isPressed()  ! m.isArmed())
+  {
+if (m.isRollover())
+  {
+// Paint the gradient when the mouse cursor hovers over the
+// button but is not pressed down.
+MetalUtils.paintGradient(g, 0, 0, b.getWidth(), b.getHeight(),
+ SwingConstants.VERTICAL,
+ gradientPropertyName);
+  }
+else
+  {
+// If mouse does not hover over the button let the JToolBar
+// paint itself at the location where the button is (the button
+// is transparent).
+
+// There where cases where the button was not repainted and
+// therefore showed its old state. With this statement it does
+// not happen.
+b.repaint();
+
+Rectangle area = new Rectangle();
+SwingUtilities.calculateInnerArea(b, area);
+SwingUtilities.convertRectangle(b, area, b.getParent());
+b.getParent().repaint(area.x, area.y, area.width, area.height);
+  }
+  }
+
+  }
+else if (! m.isPressed()  ! m.isArmed())
   {
-MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
+// When the button is not part of a JToolBar just paint itself with a
+// gradient and everything is fine.
+MetalUtils.paintGradient(g, 0, 0, b.getWidth(), b.getHeight(),
  SwingConstants.VERTICAL,
- getPropertyPrefix() + gradient);
-paint(g, c);
+ gradientPropertyName);
   }
-else
-  super.update(g, c);
+
+paint(g, b);
   }
+  
 }


signature.asc
Description: OpenPGP digital signature


  1   2   3   >