1 #ifndef RUBY_TRANSCODE_DATA_H
2 #define RUBY_TRANSCODE_DATA_H 1
16 RUBY_SYMBOL_EXPORT_BEGIN
18 #define WORDINDEX_SHIFT_BITS 2
19 #define WORDINDEX2INFO(widx) ((widx) << WORDINDEX_SHIFT_BITS)
20 #define INFO2WORDINDEX(info) ((info) >> WORDINDEX_SHIFT_BITS)
21 #define BYTE_LOOKUP_BASE(bl) ((bl)[0])
22 #define BYTE_LOOKUP_INFO(bl) ((bl)[1])
24 #define PType (unsigned int)
26 #define NOMAP (PType 0x01)
29 #define THREEbt (0x05)
31 #define INVALID (PType 0x07)
32 #define UNDEF (PType 0x09)
33 #define ZERObt (PType 0x0A)
34 #define FUNii (PType 0x0B)
35 #define FUNsi (PType 0x0D)
36 #define FUNio (PType 0x0E)
37 #define FUNso (PType 0x0F)
38 #define STR1 (PType 0x11)
39 #define GB4bt (PType 0x12)
40 #define FUNsio (PType 0x13)
42 #define STR1_LENGTH(byte_addr) (unsigned int)(*(byte_addr) + 4)
43 #define STR1_BYTEINDEX(w) ((w) >> 6)
44 #define makeSTR1(bi) (((bi) << 6) | STR1)
45 #define makeSTR1LEN(len) ((len)-4)
47 #define o1(b1) (PType((((unsigned char)(b1))<<8)|ONEbt))
48 #define o2(b1,b2) (PType((((unsigned char)(b1))<<8)|\
49 (((unsigned char)(b2))<<16)|\
51 #define o3(b1,b2,b3) (PType(((((unsigned char)(b1))<<8)|\
52 (((unsigned char)(b2))<<16)|\
53 (((unsigned int)(unsigned char)(b3))<<24)|\
56 #define o4(b0,b1,b2,b3) (PType(((((unsigned char)(b1))<<8)|\
57 (((unsigned char)(b2))<<16)|\
58 (((unsigned int)(unsigned char)(b3))<<24)|\
59 ((((unsigned char)(b0))&0x07)<<5)|\
62 #define g4(b0,b1,b2,b3) (PType(((((unsigned char)(b0))<<8)|\
63 (((unsigned char)(b2))<<16)|\
64 ((((unsigned char)(b1))&0x0f)<<24)|\
65 ((((unsigned int)(unsigned char)(b3))&0x0f)<<28)|\
68 #define funsio(diff) (PType((((unsigned int)(diff))<<8)|FUNsio))
70 #define getBT1(a) ((unsigned char)((a)>> 8))
71 #define getBT2(a) ((unsigned char)((a)>>16))
72 #define getBT3(a) ((unsigned char)((a)>>24))
73 #define getBT0(a) (((unsigned char)((a)>> 5)&0x07)|0xF0)
75 #define getGB4bt0(a) ((unsigned char)((a)>> 8))
76 #define getGB4bt1(a) (((unsigned char)((a)>>24)&0x0F)|0x30)
77 #define getGB4bt2(a) ((unsigned char)((a)>>16))
78 #define getGB4bt3(a) (((unsigned char)((a)>>28)&0x0F)|0x30)
80 #define o2FUNii(b1,b2) (PType((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|FUNii))
88 asciicompat_converter,
92 } rb_transcoder_asciicompat_type_t;
98 const char *src_encoding;
99 const char *dst_encoding;
100 unsigned int conv_tree_start;
101 const unsigned char *byte_array;
102 unsigned int byte_array_length;
103 const unsigned int *word_array;
104 unsigned int word_array_length;
106 int input_unit_length;
109 rb_transcoder_asciicompat_type_t asciicompat_type;
111 int (*state_init_func)(
void*);
112 int (*state_fini_func)(
void*);
114 VALUE (*func_si)(
void*,
const unsigned char*, size_t);
115 ssize_t (*func_io)(
void*,
VALUE,
const unsigned char*, size_t);
116 ssize_t (*func_so)(
void*,
const unsigned char*, size_t,
unsigned char*, size_t);
117 ssize_t (*finish_func)(
void*,
unsigned char*, size_t);
118 ssize_t (*resetsize_func)(
void*);
119 ssize_t (*resetstate_func)(
void*,
unsigned char*, size_t);
120 ssize_t (*func_sio)(
void*,
const unsigned char*, size_t,
VALUE,
unsigned char*, size_t);
123 void rb_declare_transcoder(
const char *enc1,
const char *enc2,
const char *lib);
130 #if defined(EXTSTATIC) && EXTSTATIC
131 # define TRANS_INIT(name) void Init_trans_ ## name(void)
133 # define TRANS_INIT(name) void Init_ ## name(void)
136 RUBY_SYMBOL_EXPORT_END
uintptr_t VALUE
Type that represents a Ruby object.