diff options
Diffstat (limited to 'transcode_data.h')
| -rw-r--r-- | transcode_data.h | 56 |
1 files changed, 44 insertions, 12 deletions
diff --git a/transcode_data.h b/transcode_data.h index 8b320c39eb..416e50d3cc 100644 --- a/transcode_data.h +++ b/transcode_data.h @@ -1,3 +1,5 @@ +#ifndef RUBY_TRANSCODE_DATA_H +#define RUBY_TRANSCODE_DATA_H 1 /********************************************************************** transcode_data.h - @@ -11,8 +13,7 @@ #include "ruby/ruby.h" -#ifndef RUBY_TRANSCODE_DATA_H -#define RUBY_TRANSCODE_DATA_H 1 +RUBY_SYMBOL_EXPORT_BEGIN #define WORDINDEX_SHIFT_BITS 2 #define WORDINDEX2INFO(widx) ((widx) << WORDINDEX_SHIFT_BITS) @@ -36,6 +37,7 @@ #define FUNso (PType 0x0F) /* function from start to output */ #define STR1 (PType 0x11) /* string 4 <= len <= 259 bytes: 1byte length + content */ #define GB4bt (PType 0x12) /* GB18030 four bytes payload */ +#define FUNsio (PType 0x13) /* function from start and info to output */ #define STR1_LENGTH(byte_addr) (unsigned int)(*(byte_addr) + 4) #define STR1_BYTEINDEX(w) ((w) >> 6) @@ -43,10 +45,27 @@ #define makeSTR1LEN(len) ((len)-4) #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 int)(unsigned char)(b3))<<24)|THREEbt)&0xffffffffU)) -#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)&0xffffffffU)) -#define g4(b0,b1,b2,b3) (PType(((((unsigned char)(b0))<<8)|(((unsigned char)(b2))<<16)|((((unsigned char)(b1))&0x0f)<<24)|((((unsigned int)(unsigned char)(b3))&0x0f)<<28)|GB4bt)&0xffffffffU)) +#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 int)(unsigned char)(b3))<<24)|\ + THREEbt)&\ + 0xffffffffU)) +#define o4(b0,b1,b2,b3) (PType(((((unsigned char)(b1))<<8)|\ + (((unsigned char)(b2))<<16)|\ + (((unsigned int)(unsigned char)(b3))<<24)|\ + ((((unsigned char)(b0))&0x07)<<5)|\ + FOURbt)&\ + 0xffffffffU)) +#define g4(b0,b1,b2,b3) (PType(((((unsigned char)(b0))<<8)|\ + (((unsigned char)(b2))<<16)|\ + ((((unsigned char)(b1))&0x0f)<<24)|\ + ((((unsigned int)(unsigned char)(b3))&0x0f)<<28)|\ + GB4bt)&\ + 0xffffffffU)) +#define funsio(diff) (PType((((unsigned int)(diff))<<8)|FUNsio)) #define getBT1(a) ((unsigned char)((a)>> 8)) #define getBT2(a) ((unsigned char)((a)>>16)) @@ -54,9 +73,9 @@ #define getBT0(a) (((unsigned char)((a)>> 5)&0x07)|0xF0) /* for UTF-8 only!!! */ #define getGB4bt0(a) ((unsigned char)((a)>> 8)) -#define getGB4bt1(a) ((unsigned char)((a)>>24)&0x0F|0x30) +#define getGB4bt1(a) (((unsigned char)((a)>>24)&0x0F)|0x30) #define getGB4bt2(a) ((unsigned char)((a)>>16)) -#define getGB4bt3(a) ((unsigned char)((a)>>28)&0x0F|0x30) +#define getGB4bt3(a) (((unsigned char)((a)>>28)&0x0F)|0x30) #define o2FUNii(b1,b2) (PType((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|FUNii)) @@ -66,10 +85,10 @@ #define THREETRAIL /* legal but undefined if three more trailing UTF-8 */ typedef enum { - asciicompat_converter, /* ASCII-compatible -> ASCII-compatible */ - asciicompat_decoder, /* ASCII-incompatible -> ASCII-compatible */ - asciicompat_encoder /* ASCII-compatible -> ASCII-incompatible */ - /* ASCII-incompatible -> ASCII-incompatible is intentionally ommitted. */ + asciicompat_converter, /* ASCII-compatible -> ASCII-compatible */ + asciicompat_decoder, /* ASCII-incompatible -> ASCII-compatible */ + asciicompat_encoder /* ASCII-compatible -> ASCII-incompatible */ + /* ASCII-incompatible -> ASCII-incompatible is intentionally omitted. */ } rb_transcoder_asciicompat_type_t; typedef struct rb_transcoder rb_transcoder; @@ -98,9 +117,22 @@ struct rb_transcoder { ssize_t (*finish_func)(void*, unsigned char*, size_t); /* -> output */ ssize_t (*resetsize_func)(void*); /* -> len */ ssize_t (*resetstate_func)(void*, unsigned char*, size_t); /* -> output */ + ssize_t (*func_sio)(void*, const unsigned char*, size_t, VALUE, unsigned char*, size_t); /* start -> output */ }; void rb_declare_transcoder(const char *enc1, const char *enc2, const char *lib); void rb_register_transcoder(const rb_transcoder *); +/* + * To get rid of collision of initializer symbols in statically-linked encodings + * and transcoders + */ +#if defined(EXTSTATIC) && EXTSTATIC +# define TRANS_INIT(name) void Init_trans_ ## name(void) +#else +# define TRANS_INIT(name) void Init_ ## name(void) +#endif + +RUBY_SYMBOL_EXPORT_END + #endif /* RUBY_TRANSCODE_DATA_H */ |
