List:Commits« Previous MessageNext Message »
From:John David Duncan Date:October 19 2010 6:14am
Subject:bzr commit into mysql-5.1-telco-7.1 branch (jdd:3894)
View as plain text  
#At file:///Volumes/Rugged/bzr-repo/working/mbcharsets/ based on revid:magnus.blaudd@stripped

 3894 John David Duncan	2010-10-18
      Change signature of CharsetMap::isMultibyte() to return Java boolean[] 

    modified:
      storage/ndb/src/ndbjtie/MysqlUtilsWrapper.hpp
      storage/ndb/src/ndbjtie/com/mysql/ndbjtie/mysql/CharsetMap.java
      storage/ndb/src/ndbjtie/com/mysql/ndbjtie/mysql/CharsetMapConst.java
      storage/ndb/src/ndbjtie/mysql/CharsetMap.cpp
      storage/ndb/src/ndbjtie/mysql/CharsetMap.hpp
      storage/ndb/src/ndbjtie/mysql/test/mysql_utils_test.cpp
      storage/ndb/src/ndbjtie/mysql_utils_jtie.hpp
      storage/ndb/src/ndbjtie/test/test/MySqlUtilsCharsetMapTest.java
=== modified file 'storage/ndb/src/ndbjtie/MysqlUtilsWrapper.hpp'
--- a/storage/ndb/src/ndbjtie/MysqlUtilsWrapper.hpp	2010-10-14 18:31:53 +0000
+++ b/storage/ndb/src/ndbjtie/MysqlUtilsWrapper.hpp	2010-10-19 06:13:29 +0000
@@ -67,7 +67,7 @@ struct MysqlUtilsWrapper {
         return obj.getUTF16CharsetNumber();
     }
     
-    static bool 
+    static const bool *  
     CharsetMap__isMultibyte
     ( const CharsetMap & obj, int p0 )
     {

=== modified file 'storage/ndb/src/ndbjtie/com/mysql/ndbjtie/mysql/CharsetMap.java'
--- a/storage/ndb/src/ndbjtie/com/mysql/ndbjtie/mysql/CharsetMap.java	2010-10-14 18:31:53 +0000
+++ b/storage/ndb/src/ndbjtie/com/mysql/ndbjtie/mysql/CharsetMap.java	2010-10-19 06:13:29 +0000
@@ -32,7 +32,7 @@ public class CharsetMap extends Wrapper 
     public final native int getCharsetNumber(String/*_const char *_*/ mysql_name) /*_const_*/;
     public final native int getUTF8CharsetNumber() /*_const_*/;
     public final native int getUTF16CharsetNumber() /*_const_*/;
-    public final native boolean isMultibyte(int cs_number) /*_const_*/;
+    public final native boolean[] isMultibyte(int cs_number) /*_const_*/;
     public final native int recode(int[]/*_int32_t *_*/ lengths, int cs_from, int cs_to, ByteBuffer/*_const void *_*/ src, ByteBuffer/*_void *_*/ dest) /*_const_*/;
     static public final native CharsetMap create();
     static public final native void delete(CharsetMap p0);

=== modified file 'storage/ndb/src/ndbjtie/com/mysql/ndbjtie/mysql/CharsetMapConst.java'
--- a/storage/ndb/src/ndbjtie/com/mysql/ndbjtie/mysql/CharsetMapConst.java	2010-10-14 18:31:53 +0000
+++ b/storage/ndb/src/ndbjtie/com/mysql/ndbjtie/mysql/CharsetMapConst.java	2010-10-19 06:13:29 +0000
@@ -40,6 +40,6 @@ public interface CharsetMapConst
     int getCharsetNumber(String/*_const char *_*/ mysql_name) /*_const_*/;
     int getUTF8CharsetNumber() /*_const_*/;
     int getUTF16CharsetNumber() /*_const_*/;
-    boolean isMultibyte(int cs_number) /*_const_*/;
+    boolean[] isMultibyte(int cs_number) /*_const_*/;
     int/*_RecodeStatus_*/ recode(int[]/*_int32_t *_*/ lengths, int cs_from, int cs_to, ByteBuffer/*_const void *_*/ src, ByteBuffer/*_void *_*/ dest) /*_const_*/;
 }

=== modified file 'storage/ndb/src/ndbjtie/mysql/CharsetMap.cpp'
--- a/storage/ndb/src/ndbjtie/mysql/CharsetMap.cpp	2010-10-14 18:31:53 +0000
+++ b/storage/ndb/src/ndbjtie/mysql/CharsetMap.cpp	2010-10-19 06:13:29 +0000
@@ -26,6 +26,9 @@
 #include "mysql.h"
 #include "my_sys.h"
 
+bool m_false_result = false;
+bool m_true_result = true;
+
 /* _map is a static pointer visible only within the scope of this file.
    A singleton CharsetMapImpl serves every instance of CharsetMap.
 */
@@ -95,10 +98,11 @@ int CharsetMap::getCharsetNumber(const c
     return get_charset_number(name, MY_CS_AVAILABLE);
 }
 
-bool CharsetMap::isMultibyte(int cs_number) const
+const bool * CharsetMap::isMultibyte(int cs_number) const
 {
   CHARSET_INFO * cset = get_charset(cs_number, MYF(0));
-  return use_mb(cset);
+  if(cset == 0) return 0;
+  return use_mb(cset) ? & m_true_result : & m_false_result;
 }
 
 

=== modified file 'storage/ndb/src/ndbjtie/mysql/CharsetMap.hpp'
--- a/storage/ndb/src/ndbjtie/mysql/CharsetMap.hpp	2010-10-14 18:31:53 +0000
+++ b/storage/ndb/src/ndbjtie/mysql/CharsetMap.hpp	2010-10-19 06:13:29 +0000
@@ -108,7 +108,7 @@ public:
      * Returns true if this charset number refers to a multibyte charset;
      * otherwise false.
      */
-  bool isMultibyte(int cs_number) const;
+  const bool * isMultibyte(int cs_number) const;
 
     /**
      * Recodes the content of a source buffer into destination buffer.
@@ -129,6 +129,7 @@ public:
     RecodeStatus recode(int32_t *lengths /* IN/OUT */,
                         int cs_from, int cs_to, const void *src,
                         void *dest) const;
+                        
 };
 
 #endif // CharsetMap_hpp

=== modified file 'storage/ndb/src/ndbjtie/mysql/test/mysql_utils_test.cpp'
--- a/storage/ndb/src/ndbjtie/mysql/test/mysql_utils_test.cpp	2010-10-14 18:31:53 +0000
+++ b/storage/ndb/src/ndbjtie/mysql/test/mysql_utils_test.cpp	2010-10-19 06:13:29 +0000
@@ -176,17 +176,20 @@ int main()
 
   
     printf("isMultibyte TEST: ");
-    bool result1, result2, result3;
+    const bool * result1, * result2, * result3;
     result1 = csmap.isMultibyte(latin1_num);
     result2 = csmap.isMultibyte(utf16_num);
     result3 = csmap.isMultibyte(utf8_num);
     printf("latin 1: %s      UTF16: %s       UTF8: %s\n",
-           result1 ? "Yes" : "No" , result2 ? "Yes" : "No" ,result3 ? "Yes" : "No");
-    assert(!result1);
-    assert(result2);
-    assert(result3);
+           *result1 ? "Yes" : "No" , 
+           *result2 ? "Yes" : "No" ,
+           *result3 ? "Yes" : "No");
+    assert(! *result1);
+    assert(*result2);
+    assert(*result3);
+    /* Can you check every charset without getting a segfault? */
+    for(int i = 0 ; i < 256 ; i++) 
+      result1 = csmap.isMultibyte(i);
   
-  
-
     CharsetMap::unload();
 }

=== modified file 'storage/ndb/src/ndbjtie/mysql_utils_jtie.hpp'
--- a/storage/ndb/src/ndbjtie/mysql_utils_jtie.hpp	2010-10-14 18:31:53 +0000
+++ b/storage/ndb/src/ndbjtie/mysql_utils_jtie.hpp	2010-10-19 06:13:29 +0000
@@ -179,16 +179,16 @@ Java_com_mysql_ndbjtie_mysql_CharsetMap_
 /*
  * Class:     com_mysql_ndbjtie_mysql_CharsetMap
  * Method:    isMultibyte
- * Signature: (I)Z
+ * Signature: (I)[Z
  */
-JNIEXPORT jboolean JNICALL
+JNIEXPORT jbooleanArray JNICALL
 Java_com_mysql_ndbjtie_mysql_CharsetMap_isMultibyte(JNIEnv * env, jobject jobj, jint p0)
 {
   TRACE("Java_com_mysql_ndbjtie_mysql_CharsetMap_isMultibyte(JNIEnv *, jobject, jint)");
 #ifndef NDBJTIE_USE_WRAPPED_VARIANT_FOR_FUNCTION
-  return gcall_mfr< ttrait_c_m_n_m_CharsetMap_ct, ttrait_bool, ttrait_int, &CharsetMap::isMultibyte >(env, jobj, p0);
+  return gcall_mfr< ttrait_c_m_n_m_CharsetMap_ct, ttrait_bool_1cp_a, ttrait_int, &CharsetMap::isMultibyte >(env, jobj, p0);
 #else
-  return gcall_fr< ttrait_bool, ttrait_c_m_n_m_CharsetMap_cr, ttrait_int, &MysqlUtilsWrapper::CharsetMap__isMultibyte >(env, NULL, jobj, p0);
+  return gcall_fr< ttrait_bool_1cp_a, ttrait_c_m_n_m_CharsetMap_cr, ttrait_int, &MysqlUtilsWrapper::CharsetMap__isMultibyte >(env, NULL, jobj, p0);
 #endif // NDBJTIE_USE_WRAPPED_VARIANT_FOR_FUNCTION
 }
    

=== modified file 'storage/ndb/src/ndbjtie/test/test/MySqlUtilsCharsetMapTest.java'
--- a/storage/ndb/src/ndbjtie/test/test/MySqlUtilsCharsetMapTest.java	2010-10-14 18:31:53 +0000
+++ b/storage/ndb/src/ndbjtie/test/test/MySqlUtilsCharsetMapTest.java	2010-10-19 06:13:29 +0000
@@ -243,12 +243,12 @@ public class MySqlUtilsCharsetMapTest ex
         
         {
             out.println("     --> IS MULTIBYTE TEST");
-            boolean result = csmap.isMultibyte(latin1_num);
-            assert(!result);
+            boolean[] result = csmap.isMultibyte(latin1_num);
+            assert(!result[0]);
             result = csmap.isMultibyte(utf16_num);
-            assert(result);
+            assert(result[0]);
             result = csmap.isMultibyte(utf8_num);
-            assert(result);
+            assert(result[0]);
             out.println("     <-- IS MULTIBYTE TEST");            
         }
         


Attachment: [text/bzr-bundle] bzr/jdd@mysql.com-20101019061329-j3bvjjtb4w4i3kh5.bundle
Thread
bzr commit into mysql-5.1-telco-7.1 branch (jdd:3894) John David Duncan19 Oct