Ruby  2.5.0dev(2017-10-22revision60238)
Data Structures | Macros | Typedefs | Enumerations | Functions
transcode_data.h File Reference
#include "ruby/ruby.h"

Go to the source code of this file.

Data Structures

struct  rb_transcoder
 

Macros

#define WORDINDEX_SHIFT_BITS   2
 
#define WORDINDEX2INFO(widx)   ((widx) << WORDINDEX_SHIFT_BITS)
 
#define INFO2WORDINDEX(info)   ((info) >> WORDINDEX_SHIFT_BITS)
 
#define BYTE_LOOKUP_BASE(bl)   ((bl)[0])
 
#define BYTE_LOOKUP_INFO(bl)   ((bl)[1])
 
#define PType   (unsigned int)
 
#define NOMAP   (PType 0x01) /* 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 FUNsi   (PType 0x0D) /* function from start to info */
 
#define FUNio   (PType 0x0E) /* function from info to output */
 
#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)
 
#define makeSTR1(bi)   (((bi) << 6) | STR1)
 
#define makeSTR1LEN(len)   ((len)-4)
 
#define o1(b1)   (PType((((unsigned char)(b1))<<8)|ONEbt))
 
#define o2(b1, b2)
 
#define o3(b1, b2, b3)
 
#define o4(b0, b1, b2, b3)
 
#define g4(b0, b1, b2, b3)
 
#define funsio(diff)   (PType((((unsigned int)(diff))<<8)|FUNsio))
 
#define getBT1(a)   ((unsigned char)((a)>> 8))
 
#define getBT2(a)   ((unsigned char)((a)>>16))
 
#define getBT3(a)   ((unsigned char)((a)>>24))
 
#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 getGB4bt2(a)   ((unsigned char)((a)>>16))
 
#define getGB4bt3(a)   (((unsigned char)((a)>>28)&0x0F)|0x30)
 
#define o2FUNii(b1, b2)   (PType((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|FUNii))
 
#define ONETRAIL   /* legal but undefined if one more trailing UTF-8 */
 
#define TWOTRAIL   /* legal but undefined if two more trailing UTF-8 */
 
#define THREETRAIL   /* legal but undefined if three more trailing UTF-8 */
 
#define TRANS_INIT(name)   void Init_ ## name(void)
 

Typedefs

typedef struct rb_transcoder rb_transcoder
 

Enumerations

enum  rb_transcoder_asciicompat_type_t { asciicompat_converter, asciicompat_decoder, asciicompat_encoder }
 

Functions

void rb_declare_transcoder (const char *enc1, const char *enc2, const char *lib)
 
void rb_register_transcoder (const rb_transcoder *)
 

Macro Definition Documentation

◆ BYTE_LOOKUP_BASE

#define BYTE_LOOKUP_BASE (   bl)    ((bl)[0])

Definition at line 22 of file transcode_data.h.

◆ BYTE_LOOKUP_INFO

#define BYTE_LOOKUP_INFO (   bl)    ((bl)[1])

Definition at line 23 of file transcode_data.h.

◆ FOURbt

#define FOURbt   (0x06) /* four bytes payload, UTF-8 only, macros start at getBT0 */

Definition at line 31 of file transcode_data.h.

◆ FUNii

#define FUNii   (PType 0x0B) /* function from info to info */

Definition at line 35 of file transcode_data.h.

◆ FUNio

#define FUNio   (PType 0x0E) /* function from info to output */

Definition at line 37 of file transcode_data.h.

◆ FUNsi

#define FUNsi   (PType 0x0D) /* function from start to info */

Definition at line 36 of file transcode_data.h.

◆ FUNsio

#define FUNsio   (PType 0x13) /* function from start and info to output */

Definition at line 41 of file transcode_data.h.

◆ funsio

#define funsio (   diff)    (PType((((unsigned int)(diff))<<8)|FUNsio))

Definition at line 69 of file transcode_data.h.

◆ FUNso

#define FUNso   (PType 0x0F) /* function from start to output */

Definition at line 38 of file transcode_data.h.

◆ g4

#define g4 (   b0,
  b1,
  b2,
  b3 
)
Value:
(PType(((((unsigned char)(b0))<<8)|\
(((unsigned char)(b2))<<16)|\
((((unsigned char)(b1))&0x0f)<<24)|\
((((unsigned int)(unsigned char)(b3))&0x0f)<<28)|\
GB4bt)&\
0xffffffffU))
#define GB4bt
#define PType

Definition at line 63 of file transcode_data.h.

◆ GB4bt

#define GB4bt   (PType 0x12) /* GB18030 four bytes payload */

Definition at line 40 of file transcode_data.h.

◆ getBT0

#define getBT0 (   a)    (((unsigned char)((a)>> 5)&0x07)|0xF0) /* for UTF-8 only!!! */

Definition at line 74 of file transcode_data.h.

◆ getBT1

#define getBT1 (   a)    ((unsigned char)((a)>> 8))

Definition at line 71 of file transcode_data.h.

◆ getBT2

#define getBT2 (   a)    ((unsigned char)((a)>>16))

Definition at line 72 of file transcode_data.h.

◆ getBT3

#define getBT3 (   a)    ((unsigned char)((a)>>24))

Definition at line 73 of file transcode_data.h.

◆ getGB4bt0

#define getGB4bt0 (   a)    ((unsigned char)((a)>> 8))

Definition at line 76 of file transcode_data.h.

◆ getGB4bt1

#define getGB4bt1 (   a)    (((unsigned char)((a)>>24)&0x0F)|0x30)

Definition at line 77 of file transcode_data.h.

◆ getGB4bt2

#define getGB4bt2 (   a)    ((unsigned char)((a)>>16))

Definition at line 78 of file transcode_data.h.

◆ getGB4bt3

#define getGB4bt3 (   a)    (((unsigned char)((a)>>28)&0x0F)|0x30)

Definition at line 79 of file transcode_data.h.

◆ INFO2WORDINDEX

#define INFO2WORDINDEX (   info)    ((info) >> WORDINDEX_SHIFT_BITS)

Definition at line 21 of file transcode_data.h.

◆ INVALID

#define INVALID   (PType 0x07) /* invalid byte sequence */

Definition at line 32 of file transcode_data.h.

◆ makeSTR1

#define makeSTR1 (   bi)    (((bi) << 6) | STR1)

Definition at line 45 of file transcode_data.h.

◆ makeSTR1LEN

#define makeSTR1LEN (   len)    ((len)-4)

Definition at line 46 of file transcode_data.h.

◆ NOMAP

#define NOMAP   (PType 0x01) /* direct map */

Definition at line 27 of file transcode_data.h.

◆ o1

#define o1 (   b1)    (PType((((unsigned char)(b1))<<8)|ONEbt))

Definition at line 48 of file transcode_data.h.

◆ o2

#define o2 (   b1,
  b2 
)
Value:
(PType((((unsigned char)(b1))<<8)|\
(((unsigned char)(b2))<<16)|\
#define PType
#define TWObt

Definition at line 49 of file transcode_data.h.

◆ o2FUNii

#define o2FUNii (   b1,
  b2 
)    (PType((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|FUNii))

Definition at line 81 of file transcode_data.h.

◆ o3

#define o3 (   b1,
  b2,
  b3 
)
Value:
(PType(((((unsigned char)(b1))<<8)|\
(((unsigned char)(b2))<<16)|\
(((unsigned int)(unsigned char)(b3))<<24)|\
0xffffffffU))
#define PType
#define THREEbt

Definition at line 52 of file transcode_data.h.

◆ o4

#define o4 (   b0,
  b1,
  b2,
  b3 
)
Value:
(PType(((((unsigned char)(b1))<<8)|\
(((unsigned char)(b2))<<16)|\
(((unsigned int)(unsigned char)(b3))<<24)|\
((((unsigned char)(b0))&0x07)<<5)|\
FOURbt)&\
0xffffffffU))
#define FOURbt
#define PType

Definition at line 57 of file transcode_data.h.

◆ ONEbt

#define ONEbt   (0x02) /* one byte payload */

Definition at line 28 of file transcode_data.h.

◆ ONETRAIL

#define ONETRAIL   /* legal but undefined if one more trailing UTF-8 */

Definition at line 84 of file transcode_data.h.

◆ PType

#define PType   (unsigned int)

Definition at line 25 of file transcode_data.h.

◆ STR1

#define STR1   (PType 0x11) /* string 4 <= len <= 259 bytes: 1byte length + content */

Definition at line 39 of file transcode_data.h.

◆ STR1_BYTEINDEX

#define STR1_BYTEINDEX (   w)    ((w) >> 6)

Definition at line 44 of file transcode_data.h.

◆ STR1_LENGTH

#define STR1_LENGTH (   byte_addr)    (unsigned int)(*(byte_addr) + 4)

Definition at line 43 of file transcode_data.h.

◆ THREEbt

#define THREEbt   (0x05) /* three bytes payload */

Definition at line 30 of file transcode_data.h.

◆ THREETRAIL

#define THREETRAIL   /* legal but undefined if three more trailing UTF-8 */

Definition at line 86 of file transcode_data.h.

◆ TRANS_INIT

#define TRANS_INIT (   name)    void Init_ ## name(void)

Definition at line 134 of file transcode_data.h.

◆ TWObt

#define TWObt   (0x03) /* two bytes payload */

Definition at line 29 of file transcode_data.h.

◆ TWOTRAIL

#define TWOTRAIL   /* legal but undefined if two more trailing UTF-8 */

Definition at line 85 of file transcode_data.h.

◆ UNDEF

#define UNDEF   (PType 0x09) /* legal but undefined */

Definition at line 33 of file transcode_data.h.

◆ WORDINDEX2INFO

#define WORDINDEX2INFO (   widx)    ((widx) << WORDINDEX_SHIFT_BITS)

Definition at line 20 of file transcode_data.h.

◆ WORDINDEX_SHIFT_BITS

#define WORDINDEX_SHIFT_BITS   2

Definition at line 19 of file transcode_data.h.

◆ ZERObt

#define ZERObt   (PType 0x0A) /* zero bytes of payload, i.e. remove */

Definition at line 34 of file transcode_data.h.

Typedef Documentation

◆ rb_transcoder

typedef struct rb_transcoder rb_transcoder

Definition at line 95 of file transcode_data.h.

Enumeration Type Documentation

◆ rb_transcoder_asciicompat_type_t

Enumerator
asciicompat_converter 
asciicompat_decoder 
asciicompat_encoder 

Definition at line 88 of file transcode_data.h.

Function Documentation

◆ rb_declare_transcoder()

void rb_declare_transcoder ( const char *  enc1,
const char *  enc2,
const char *  lib 
)

Definition at line 231 of file transcode.c.

References rb_eArgError, and rb_raise().

◆ rb_register_transcoder()

void rb_register_transcoder ( const rb_transcoder )

Definition at line 203 of file transcode.c.

References rb_transcoder::dst_encoding, and rb_transcoder::src_encoding.