harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r438006 - in /incubator/harmony/enhanced/classlib/trunk/modules/text/src: main/java/java/text/ main/java/org/apache/harmony/text/ main/native/text/linux/ main/native/text/shared/ main/native/text/windows/ test/java/org/apache/harmony/text/t...
Date Tue, 29 Aug 2006 08:27:05 GMT
Author: hindessm
Date: Tue Aug 29 01:27:03 2006
New Revision: 438006

URL: http://svn.apache.org/viewvc?rev=438006&view=rev
Log:
Applied patch from "[#HARMONY-1028] [classlib][text] Bidi returns directional
runs in visual order as opposed to logical".

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/org/apache/harmony/text/BidiWrapper.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/linux/libhytext.exp
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/shared/BidiWrapper.c
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/shared/BidiWrapper.h
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/windows/hytext.def
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java?rev=438006&r1=438005&r2=438006&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Bidi.java
Tue Aug 29 01:27:03 2006
@@ -238,10 +238,7 @@
 			runCount = 0;
 			runs = null;
 		} else {
-			runs = new BidiRun[runCount];
-			for (int i = 0; i < runs.length; i++) {
-				runs[i] = BidiWrapper.ubidi_getRun(pBidi, i);
-			}
+			runs = BidiWrapper.ubidi_getRuns(pBidi);
 		}
 
 		direction = BidiWrapper.ubidi_getDirection(pBidi);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/org/apache/harmony/text/BidiWrapper.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/org/apache/harmony/text/BidiWrapper.java?rev=438006&r1=438005&r2=438006&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/org/apache/harmony/text/BidiWrapper.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/org/apache/harmony/text/BidiWrapper.java
Tue Aug 29 01:27:03 2006
@@ -79,8 +79,8 @@
 	// Get the number of runs.
 	public static native int ubidi_countRuns(long pBiDi);
 
-	// Get the BidiRun of the nth logical run
-	public static native BidiRun ubidi_getRun(long pBidi, int index);
+	// Get the BidiRuns
+	public static native BidiRun[] ubidi_getRuns(long pBidi);
 
 	// This is a convenience function that does not use a UBiDi object
 	public static native int[] ubidi_reorderVisual(byte[] levels, int length);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/linux/libhytext.exp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/linux/libhytext.exp?rev=438006&r1=438005&r2=438006&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/linux/libhytext.exp
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/linux/libhytext.exp
Tue Aug 29 01:27:03 2006
@@ -6,7 +6,7 @@
 		Java_org_apache_harmony_text_BidiWrapper_ubidi_1getLength;
 		Java_org_apache_harmony_text_BidiWrapper_ubidi_1getLevels;
 		Java_org_apache_harmony_text_BidiWrapper_ubidi_1getParaLevel;
-		Java_org_apache_harmony_text_BidiWrapper_ubidi_1getRun;
+		Java_org_apache_harmony_text_BidiWrapper_ubidi_1getRuns;
 		Java_org_apache_harmony_text_BidiWrapper_ubidi_1open;
 		Java_org_apache_harmony_text_BidiWrapper_ubidi_1reorderVisual;
 		Java_org_apache_harmony_text_BidiWrapper_ubidi_1setLine;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/shared/BidiWrapper.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/shared/BidiWrapper.c?rev=438006&r1=438005&r2=438006&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/shared/BidiWrapper.c
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/shared/BidiWrapper.c
Tue Aug 29 01:27:03 2006
@@ -123,26 +123,34 @@
   return count;
 }
 
-JNIEXPORT jobject JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1getRun
-  (JNIEnv * env, jclass clazz, jlong pBiDi, jint index)
+JNIEXPORT jobjectArray JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1getRuns
+  (JNIEnv * env, jclass clz, jlong pBiDi)
 {
+  int runCount = 0;
   int start = 0;
-  int length = 0;
+  int limit = 0;
+  int i = 0;
   UBiDiLevel level = 0;
   jclass run_clazz = 0;
   jmethodID initID = 0;
   jobject run = 0;
-
-  ubidi_getVisualRun ((UBiDi *) ((IDATA) pBiDi), index, &start, &length);
-  ubidi_getLogicalRun ((const UBiDi *) ((IDATA) pBiDi), start, NULL, &level);
+  jobjectArray runs;
+  UErrorCode err = 0;
 
   run_clazz = (*env)->FindClass (env, "org/apache/harmony/text/BidiRun");
   initID = (*env)->GetMethodID (env, run_clazz, "<init>", "(III)V");
 
-  run =
-    (*env)->NewObject (env, run_clazz, initID, start, start + length, level);
-
-  return run;
+  runCount = ubidi_countRuns ((UBiDi *) ((IDATA) pBiDi), &err);
+  check_fail (env, err);
+  
+  runs = (*env)->NewObjectArray(env, runCount,run_clazz, NULL);  
+  for (i = 0; i < runCount; i++) {
+      ubidi_getLogicalRun ((const UBiDi *)pBiDi, start, &limit, &level);
+	  run = (*env)->NewObject (env, run_clazz, initID, start, limit, level);
+      (*env)->SetObjectArrayElement(env, runs, i, run);
+	  start = limit;	  
+  }
+  return runs;
 }
 
 void

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/shared/BidiWrapper.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/shared/BidiWrapper.h?rev=438006&r1=438005&r2=438006&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/shared/BidiWrapper.h
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/shared/BidiWrapper.h
Tue Aug 29 01:27:03 2006
@@ -111,11 +111,11 @@
     (JNIEnv *, jclass, jlong);
 /*
  * Class:     org_apache_harmony_text_BidiWrapper
- * Method:    ubidi_getRun
- * Signature: (JI)Lorg/apache/harmony/text/BidiRun;
+ * Method:    ubidi_getRuns
+ * Signature: (J)[Lorg/apache/harmony/text/BidiRun;
  */
-  JNIEXPORT jobject JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1getRun
-    (JNIEnv *, jclass, jlong, jint);
+JNIEXPORT jobjectArray JNICALL Java_org_apache_harmony_text_BidiWrapper_ubidi_1getRuns
+  (JNIEnv *, jclass, jlong);
 /*
  * Class:     org_apache_harmony_text_BidiWrapper
  * Method:    ubidi_reorderVisual

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/windows/hytext.def
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/windows/hytext.def?rev=438006&r1=438005&r2=438006&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/windows/hytext.def
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/native/text/windows/hytext.def
Tue Aug 29 01:27:03 2006
@@ -11,7 +11,7 @@
 	Java_org_apache_harmony_text_BidiWrapper_ubidi_1getLength
 	Java_org_apache_harmony_text_BidiWrapper_ubidi_1getLevels
 	Java_org_apache_harmony_text_BidiWrapper_ubidi_1getParaLevel
-	Java_org_apache_harmony_text_BidiWrapper_ubidi_1getRun
+	Java_org_apache_harmony_text_BidiWrapper_ubidi_1getRuns
 	Java_org_apache_harmony_text_BidiWrapper_ubidi_1open
 	Java_org_apache_harmony_text_BidiWrapper_ubidi_1reorderVisual
 	Java_org_apache_harmony_text_BidiWrapper_ubidi_1setLine

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java?rev=438006&r1=438005&r2=438006&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java
Tue Aug 29 01:27:03 2006
@@ -923,4 +923,28 @@
 			// expected
 		}
 	}
+    
+    public void testGetRuns() {
+        //Regression test for Harmony-1028
+        
+        String LTR = "\u0061\u0062";
+        String RTL = "\u05DC\u05DD";
+        String newLine = "\n";
+        String defText = LTR + newLine + RTL + LTR + RTL;
+        
+        int[][] expectedRuns = {
+                {0, 3},
+                {3, 5},
+                {5, 7},
+                {7, 9},
+        };
+        
+        Bidi bi = new Bidi(defText, 0);
+        final int count = bi.getRunCount();
+        for (int i = 0; i < count; i++) {
+            assertEquals(expectedRuns[i][0], bi.getRunStart(i));
+            assertEquals(expectedRuns[i][1], bi.getRunLimit(i));
+        }
+    }
+
 }



Mime
View raw message