[前][次][番号順一覧][スレッド一覧]

ruby-changes:7549

From: akr <ko1@a...>
Date: Tue, 2 Sep 2008 22:26:20 +0900 (JST)
Subject: [ruby-changes:7549] Ruby:r19070 (trunk): * transcode_data.h (base_element): removed.

akr	2008-09-02 22:26:02 +0900 (Tue, 02 Sep 2008)

  New Revision: 19070

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19070

  Log:
    * transcode_data.h (base_element): removed.
      (BYTE_LOOKUP): removed.
      (BYTE_LOOKUP_BASE): don't cast.
      (BYTE_LOOKUP_INFO): ditto.
      (PType): unsigned int, instead of uintptr_t.
      (rb_transcoding): change type of next_field, conv_tree_start and
      word_array.
    
    * tool/transcode-tblgen.rb: generate word_array as array of unsigned
      int.
    
    * transcode.c (transcode_restartable0): follow the above type change.

  Modified files:
    trunk/ChangeLog
    trunk/tool/transcode-tblgen.rb
    trunk/transcode.c
    trunk/transcode_data.h

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 19069)
+++ ChangeLog	(revision 19070)
@@ -1,3 +1,18 @@
+Tue Sep  2 22:20:26 2008  Tanaka Akira  <akr@f...>
+
+	* transcode_data.h (base_element): removed.
+	  (BYTE_LOOKUP): removed.
+	  (BYTE_LOOKUP_BASE): don't cast.
+	  (BYTE_LOOKUP_INFO): ditto.
+	  (PType): unsigned int, instead of uintptr_t.
+	  (rb_transcoding): change type of next_field, conv_tree_start and
+	  word_array.
+
+	* tool/transcode-tblgen.rb: generate word_array as array of unsigned
+	  int.
+
+	* transcode.c (transcode_restartable0): follow the above type change.
+
 Tue Sep  2 21:22:22 2008  Tanaka Akira  <akr@f...>
 
 	* tool/transcode-tblgen.rb: add prefix for byte_array and word_array.
Index: transcode_data.h
===================================================================
--- transcode_data.h	(revision 19069)
+++ transcode_data.h	(revision 19070)
@@ -14,16 +14,12 @@
 #ifndef RUBY_TRANSCODE_DATA_H
 #define RUBY_TRANSCODE_DATA_H 1
 
-typedef unsigned char base_element;
+#define BYTE_LOOKUP_BASE(bl) ((bl)[0])
+#define BYTE_LOOKUP_INFO(bl) ((bl)[1])
 
-typedef uintptr_t BYTE_LOOKUP[2];
-
-#define BYTE_LOOKUP_BASE(bl) (((uintptr_t *)(bl))[0])
-#define BYTE_LOOKUP_INFO(bl) (((uintptr_t *)(bl))[1])
-
 #ifndef PType
 /* data file needs to treat this as a pointer, to remove warnings */
-#define PType (uintptr_t)
+#define PType (unsigned int)
 #endif
 
 #define NOMAP	(PType 0x01)	/* single byte direct map */
@@ -73,7 +69,7 @@
     int flags;
 
     int resume_position;
-    uintptr_t next_table;
+    unsigned int next_table;
     VALUE next_info;
     unsigned char next_byte;
 
@@ -106,9 +102,9 @@
 struct rb_transcoder {
     const char *from_encoding;
     const char *to_encoding;
-    uintptr_t conv_tree_start;
+    unsigned int conv_tree_start;
     const unsigned char *byte_array;
-    const uintptr_t *word_array;
+    const unsigned int *word_array;
     int word_size;
     int input_unit_length;
     int max_input;
Index: tool/transcode-tblgen.rb
===================================================================
--- tool/transcode-tblgen.rb	(revision 19069)
+++ tool/transcode-tblgen.rb	(revision 19070)
@@ -344,7 +344,7 @@
 
     if words_code.empty?
       words_code << <<"End"
-static const uintptr_t
+static const unsigned int
 #{OUTPUT_PREFIX}word_array[0] = {
 };
 End
@@ -358,7 +358,7 @@
 
       size = words_code[/\[\d+\]/][1...-1].to_i
       words_code.sub!(/^(\};\n\z)/) {
-        "\#define #{infos_name} (sizeof(uintptr_t)*#{size})\n" +
+        "\#define #{infos_name} (sizeof(unsigned int)*#{size})\n" +
         format_infos(infos) + "\n" +
         $1
       }
@@ -368,7 +368,7 @@
 
     size = words_code[/\[\d+\]/][1...-1].to_i
     words_code.sub!(/^(\};\n\z)/) {
-      "\#define #{name} (sizeof(uintptr_t)*#{size})\n" +
+      "\#define #{name} (sizeof(unsigned int)*#{size})\n" +
       <<"End" + "\n" + $1
     #{offsets_name},
     #{infos_name},
@@ -609,7 +609,7 @@
 def transcode_generated_code
   TRANSCODE_GENERATED_BYTES_CODE +
     TRANSCODE_GENERATED_WORDS_CODE +
-    "\#define TRANSCODE_TABLE_INFO #{OUTPUT_PREFIX}byte_array, #{OUTPUT_PREFIX}word_array, sizeof(uintptr_t)\n" +
+    "\#define TRANSCODE_TABLE_INFO #{OUTPUT_PREFIX}byte_array, #{OUTPUT_PREFIX}word_array, sizeof(unsigned int)\n" +
     TRANSCODE_GENERATED_TRANSCODER_CODE
 end
 
Index: transcode.c
===================================================================
--- transcode.c	(revision 19069)
+++ transcode.c	(revision 19070)
@@ -480,7 +480,7 @@
     while (1) {
         inchar_start = in_p;
         tc->recognized_len = 0;
-	next_table = ((uintptr_t)tr->word_array) + tr->conv_tree_start;
+	next_table = tr->conv_tree_start;
 
         SUSPEND_OUTPUT_FOLLOWED_BY_INPUT(24);
 
@@ -493,12 +493,14 @@
 
 	next_byte = (unsigned char)*in_p++;
       follow_byte:
-#define BL_BASE(next_table) (tr->byte_array + BYTE_LOOKUP_BASE(next_table))
+#define BL_BASE(next_table) \
+        (tr->byte_array + BYTE_LOOKUP_BASE(tr->word_array + next_table/sizeof(*tr->word_array)))
         if (next_byte < BL_BASE(next_table)[0] || BL_BASE(next_table)[1] < next_byte)
             next_info = INVALID;
         else {
             unsigned int next_offset = BL_BASE(next_table)[2+next_byte-BL_BASE(next_table)[0]];
-#define BL_INFO(next_table) ((const struct byte_lookup *const *)(((uintptr_t)tr->word_array) + BYTE_LOOKUP_INFO(next_table)))
+#define BL_INFO(next_table) \
+            (tr->word_array + BYTE_LOOKUP_INFO(tr->word_array + next_table/sizeof(*tr->word_array))/sizeof(*tr->word_array))
             next_info = (VALUE)BL_INFO(next_table)[next_offset];
         }
       follow_info:
@@ -515,7 +517,7 @@
                 SUSPEND(econv_source_buffer_empty, 5);
 	    }
 	    next_byte = (unsigned char)*in_p++;
-	    next_table = ((uintptr_t)tr->word_array) + next_info;
+	    next_table = next_info;
 	    goto follow_byte;
 	  case ZERObt: /* drop input */
 	    continue;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]