summaryrefslogtreecommitdiff
path: root/transcode_data.h
diff options
context:
space:
mode:
authorduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-28 09:26:55 +0000
committerduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-28 09:26:55 +0000
commit793e9423cd4c4c679959b7dd011040b5aba2d169 (patch)
tree034b079d1e8a3b856e8cc5cc96dc3fd185f5d4a8 /transcode_data.h
parent48af602e38293f53e7c9afa7b41ba778714220f4 (diff)
downloadruby-793e9423cd4c4c679959b7dd011040b5aba2d169.tar.gz
Fri Dec 28 01:55:04 2007 Martin Duerst <duerst@it.aoyama.ac.jp>
* transcode.c (transcode_dispatch): reverted some of the changes in r14746. * transcode.c, enc/trans/single_byte.c: Added conversions to/from US-ASCII and ASCII-8BIT (using data tables). * enc/trans/single_byte.c: Some spacing/ordering changes due to automatic data file generation. * transcode_data.h, transcode.c: Preliminary code for using micro-conversion functions. * test/ruby/test_transcode.rb: Added some tests for US-ASCII and ASCII-8BIT conversions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'transcode_data.h')
-rw-r--r--transcode_data.h40
1 files changed, 22 insertions, 18 deletions
diff --git a/transcode_data.h b/transcode_data.h
index 862e37eae5..6d3d210cbe 100644
--- a/transcode_data.h
+++ b/transcode_data.h
@@ -27,24 +27,27 @@ typedef struct byte_lookup {
#define PType (const BYTE_LOOKUP *)
#endif
-#define NOMAP (PType 0x01) /* single byte direct map */
-#define ONEbt (0x02) /* one byte payload */
-#define TWObt (0x03) /* two bytes payload */
-#define THREEbt (0x05) /* three bytes payload */
-#define FOURbt (0x06) /* four bytes payload, UTF-8 only, macros start at getBT0 */
-#define INVALID (PType 0x07) /* invalid byte sequence */
-#define UNDEF (PType 0x09) /* legal but undefined */
-#define ZERObt (PType 0x0A) /* zero bytes of payload, i.e. remove */
-
-#define o1(b1) ((const BYTE_LOOKUP *)((((unsigned char)(b1))<<8)|ONEbt))
-#define o2(b1,b2) ((const BYTE_LOOKUP *)((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|TWObt))
-#define o3(b1,b2,b3) ((const BYTE_LOOKUP *)((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|(((unsigned char)(b3))<<24)|THREEbt))
-#define o4(b0,b1,b2,b3) ((const BYTE_LOOKUP *)((((unsigned char)(b1))<< 8)|(((unsigned char)(b2))<<16)|(((unsigned char)(b3))<<24)|((((unsigned char)(b0))&0x07)<<5)|FOURbt))
-
-#define getBT1(a) (((a)>> 8)&0xFF)
-#define getBT2(a) (((a)>>16)&0xFF)
-#define getBT3(a) (((a)>>24)&0xFF)
-#define getBT0(a) ((((a)>> 5)&0x07)|0xF0) /* for UTF-8 only!!! */
+#define NOMAP (PType 0x01) /* single byte direct map */
+#define ONEbt (0x02) /* one byte payload */
+#define TWObt (0x03) /* two bytes payload */
+#define THREEbt (0x05) /* three bytes payload */
+#define FOURbt (0x06) /* four bytes payload, UTF-8 only, macros start at getBT0 */
+#define INVALID (PType 0x07) /* invalid byte sequence */
+#define UNDEF (PType 0x09) /* legal but undefined */
+#define ZERObt (PType 0x0A) /* zero bytes of payload, i.e. remove */
+#define FUNii (PType 0x0B) /* function from info to info */
+
+#define o1(b1) (PType((((unsigned char)(b1))<<8)|ONEbt))
+#define o2(b1,b2) (PType((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|TWObt))
+#define o3(b1,b2,b3) (PType((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|(((unsigned char)(b3))<<24)|THREEbt))
+#define o4(b0,b1,b2,b3) (PType((((unsigned char)(b1))<< 8)|(((unsigned char)(b2))<<16)|(((unsigned char)(b3))<<24)|((((unsigned char)(b0))&0x07)<<5)|FOURbt))
+
+#define getBT1(a) (((a)>> 8)&0xFF)
+#define getBT2(a) (((a)>>16)&0xFF)
+#define getBT3(a) (((a)>>24)&0xFF)
+#define getBT0(a) ((((a)>> 5)&0x07)|0xF0) /* for UTF-8 only!!! */
+
+#define o2FUNii(b1,b2) (PType((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|FUNii))
/* do we need these??? maybe not, can be done with simple tables */
#define ONETRAIL /* legal but undefined if one more trailing UTF-8 */
@@ -70,6 +73,7 @@ typedef struct rb_transcoder {
struct rb_transcoder *, struct rb_transcoding *);
void (*postprocessor)(char**, char**, char*, char*,
struct rb_transcoder *, struct rb_transcoding *);
+ VALUE (*func_ii)(VALUE); /* function from info to info */
} rb_transcoder;
void rb_declare_transcoder(const char *enc1, const char *enc2, const char *lib);