blob: 18cc02f8c2d8e73d555b9dcd6767f98f30b6613b [file] [log] [blame]
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +00001/*
2 * cjkcodecs.h: common header for cjkcodecs
3 *
4 * Written by Hye-Shik Chang <perky@FreeBSD.org>
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +00005 */
6
7#ifndef _CJKCODECS_H_
8#define _CJKCODECS_H_
9
Hye-Shik Chang4b96c132006-03-04 16:08:19 +000010#define PY_SSIZE_T_CLEAN
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +000011#include "Python.h"
12#include "multibytecodec.h"
13
14
Hye-Shik Chang331649a2005-10-06 15:51:59 +000015/* a unicode "undefined" codepoint */
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000016#define UNIINV 0xFFFE
Hye-Shik Chang331649a2005-10-06 15:51:59 +000017
18/* internal-use DBCS codepoints which aren't used by any charsets */
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000019#define NOCHAR 0xFFFF
20#define MULTIC 0xFFFE
21#define DBCINV 0xFFFD
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +000022
23/* shorter macros to save source size of mapping tables */
24#define U UNIINV
25#define N NOCHAR
26#define M MULTIC
27#define D DBCINV
28
29struct dbcs_index {
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000030 const ucs2_t *map;
31 unsigned char bottom, top;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +000032};
33typedef struct dbcs_index decode_map;
34
35struct widedbcs_index {
Victor Stinnera0dd0212013-04-11 22:09:04 +020036 const Py_UCS4 *map;
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000037 unsigned char bottom, top;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +000038};
39typedef struct widedbcs_index widedecode_map;
40
41struct unim_index {
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000042 const DBCHAR *map;
43 unsigned char bottom, top;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +000044};
45typedef struct unim_index encode_map;
46
47struct unim_index_bytebased {
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000048 const unsigned char *map;
49 unsigned char bottom, top;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +000050};
51
52struct dbcs_map {
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000053 const char *charset;
54 const struct unim_index *encmap;
55 const struct dbcs_index *decmap;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +000056};
57
58struct pair_encodemap {
Victor Stinnera0dd0212013-04-11 22:09:04 +020059 Py_UCS4 uniseq;
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000060 DBCHAR code;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +000061};
62
Hye-Shik Chang64a9e382004-07-18 15:02:45 +000063static const MultibyteCodec *codec_list;
64static const struct dbcs_map *mapping_list;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +000065
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000066#define CODEC_INIT(encoding) \
67 static int encoding##_codec_init(const void *config)
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +000068
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000069#define ENCODER_INIT(encoding) \
70 static int encoding##_encode_init( \
71 MultibyteCodec_State *state, const void *config)
72#define ENCODER(encoding) \
73 static Py_ssize_t encoding##_encode( \
74 MultibyteCodec_State *state, const void *config, \
Victor Stinnerd9491262013-04-14 02:06:32 +020075 int kind, void *data, \
76 Py_ssize_t *inpos, Py_ssize_t inlen, \
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000077 unsigned char **outbuf, Py_ssize_t outleft, int flags)
78#define ENCODER_RESET(encoding) \
79 static Py_ssize_t encoding##_encode_reset( \
80 MultibyteCodec_State *state, const void *config, \
81 unsigned char **outbuf, Py_ssize_t outleft)
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +000082
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000083#define DECODER_INIT(encoding) \
84 static int encoding##_decode_init( \
85 MultibyteCodec_State *state, const void *config)
86#define DECODER(encoding) \
87 static Py_ssize_t encoding##_decode( \
88 MultibyteCodec_State *state, const void *config, \
89 const unsigned char **inbuf, Py_ssize_t inleft, \
Victor Stinnera0dd0212013-04-11 22:09:04 +020090 _PyUnicodeWriter *writer)
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000091#define DECODER_RESET(encoding) \
92 static Py_ssize_t encoding##_decode_reset( \
93 MultibyteCodec_State *state, const void *config)
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +000094
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000095#define NEXT_IN(i) \
Victor Stinnera0dd0212013-04-11 22:09:04 +020096 do { \
97 (*inbuf) += (i); \
98 (inleft) -= (i); \
99 } while (0)
Victor Stinnerd9491262013-04-14 02:06:32 +0200100#define NEXT_INCHAR(i) \
101 do { \
102 (*inpos) += (i); \
103 } while (0)
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000104#define NEXT_OUT(o) \
Victor Stinnerd9491262013-04-14 02:06:32 +0200105 do { \
106 (*outbuf) += (o); \
107 (outleft) -= (o); \
108 } while (0)
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000109#define NEXT(i, o) \
Victor Stinnerd9491262013-04-14 02:06:32 +0200110 do { \
111 NEXT_INCHAR(i); \
112 NEXT_OUT(o); \
113 } while (0)
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000114
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000115#define REQUIRE_INBUF(n) \
116 if (inleft < (n)) \
117 return MBERR_TOOFEW;
118#define REQUIRE_OUTBUF(n) \
119 if (outleft < (n)) \
120 return MBERR_TOOSMALL;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000121
Victor Stinnerd9491262013-04-14 02:06:32 +0200122#define INBYTE1 ((*inbuf)[0])
123#define INBYTE2 ((*inbuf)[1])
124#define INBYTE3 ((*inbuf)[2])
125#define INBYTE4 ((*inbuf)[3])
126
127#define INCHAR1 PyUnicode_READ(kind, data, *inpos)
128#define INCHAR2 PyUnicode_READ(kind, data, *inpos + 1)
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000129
Victor Stinnera0dd0212013-04-11 22:09:04 +0200130#define OUTCHAR(c) \
131 do { \
132 if (_PyUnicodeWriter_WriteChar(writer, (c)) < 0) \
133 return MBERR_TOOSMALL; \
134 } while (0)
135
136#define OUTCHAR2(c1, c2) \
137 do { \
138 Py_UCS4 _c1 = (c1); \
139 Py_UCS4 _c2 = (c2); \
140 if (_PyUnicodeWriter_Prepare(writer, 2, Py_MAX(_c1, c2)) < 0) \
141 return MBERR_TOOSMALL; \
142 PyUnicode_WRITE(writer->kind, writer->data, writer->pos, _c1); \
143 PyUnicode_WRITE(writer->kind, writer->data, writer->pos + 1, _c2); \
144 writer->pos += 2; \
145 } while (0)
146
Victor Stinnerd9491262013-04-14 02:06:32 +0200147#define OUTBYTE1(c) ((*outbuf)[0]) = (c);
148#define OUTBYTE2(c) ((*outbuf)[1]) = (c);
149#define OUTBYTE3(c) ((*outbuf)[2]) = (c);
150#define OUTBYTE4(c) ((*outbuf)[3]) = (c);
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000151
Victor Stinnerd9491262013-04-14 02:06:32 +0200152#define WRITEBYTE1(c1) \
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000153 REQUIRE_OUTBUF(1) \
154 (*outbuf)[0] = (c1);
Victor Stinnerd9491262013-04-14 02:06:32 +0200155#define WRITEBYTE2(c1, c2) \
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000156 REQUIRE_OUTBUF(2) \
157 (*outbuf)[0] = (c1); \
158 (*outbuf)[1] = (c2);
Victor Stinnerd9491262013-04-14 02:06:32 +0200159#define WRITEBYTE3(c1, c2, c3) \
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000160 REQUIRE_OUTBUF(3) \
161 (*outbuf)[0] = (c1); \
162 (*outbuf)[1] = (c2); \
163 (*outbuf)[2] = (c3);
Victor Stinnerd9491262013-04-14 02:06:32 +0200164#define WRITEBYTE4(c1, c2, c3, c4) \
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000165 REQUIRE_OUTBUF(4) \
166 (*outbuf)[0] = (c1); \
167 (*outbuf)[1] = (c2); \
168 (*outbuf)[2] = (c3); \
169 (*outbuf)[3] = (c4);
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000170
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000171#define _TRYMAP_ENC(m, assi, val) \
172 ((m)->map != NULL && (val) >= (m)->bottom && \
173 (val)<= (m)->top && ((assi) = (m)->map[(val) - \
174 (m)->bottom]) != NOCHAR)
175#define TRYMAP_ENC_COND(charset, assi, uni) \
176 _TRYMAP_ENC(&charset##_encmap[(uni) >> 8], assi, (uni) & 0xff)
177#define TRYMAP_ENC(charset, assi, uni) \
178 if TRYMAP_ENC_COND(charset, assi, uni)
Thomas Wouters89f507f2006-12-13 04:49:30 +0000179
Victor Stinnera0dd0212013-04-11 22:09:04 +0200180Py_LOCAL_INLINE(int)
181_TRYMAP_DEC_WRITE(_PyUnicodeWriter *writer, Py_UCS4 c)
182{
183 if (c == UNIINV || _PyUnicodeWriter_WriteChar(writer, c) < 0)
184 return UNIINV;
185 else
186 return c;
187}
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000188
Victor Stinnera0dd0212013-04-11 22:09:04 +0200189#define _TRYMAP_DEC(m, writer, val) \
190 ((m)->map != NULL && \
191 (val) >= (m)->bottom && \
192 (val)<= (m)->top && \
193 _TRYMAP_DEC_WRITE(writer, (m)->map[(val) - (m)->bottom]) != UNIINV)
194#define _TRYMAP_DEC_CHAR(m, assi, val) \
195 ((m)->map != NULL && \
196 (val) >= (m)->bottom && \
197 (val)<= (m)->top && \
198 ((assi) = (m)->map[(val) - (m)->bottom]) != UNIINV)
199#define TRYMAP_DEC(charset, writer, c1, c2) \
200 if _TRYMAP_DEC(&charset##_decmap[c1], writer, c2)
201#define TRYMAP_DEC_CHAR(charset, assi, c1, c2) \
202 if _TRYMAP_DEC_CHAR(&charset##_decmap[c1], assi, c2)
203
204#define _TRYMAP_ENC_MPLANE(m, assplane, asshi, asslo, val) \
205 ((m)->map != NULL && (val) >= (m)->bottom && \
206 (val)<= (m)->top && \
207 ((assplane) = (m)->map[((val) - (m)->bottom)*3]) != 0 && \
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000208 (((asshi) = (m)->map[((val) - (m)->bottom)*3 + 1]), 1) && \
209 (((asslo) = (m)->map[((val) - (m)->bottom)*3 + 2]), 1))
210#define TRYMAP_ENC_MPLANE(charset, assplane, asshi, asslo, uni) \
211 if _TRYMAP_ENC_MPLANE(&charset##_encmap[(uni) >> 8], \
212 assplane, asshi, asslo, (uni) & 0xff)
Victor Stinnera0dd0212013-04-11 22:09:04 +0200213#define TRYMAP_DEC_MPLANE(charset, writer, plane, c1, c2) \
214 if _TRYMAP_DEC(&charset##_decmap[plane][c1], writer, c2)
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000215
Hye-Shik Chang64a9e382004-07-18 15:02:45 +0000216#define BEGIN_MAPPINGS_LIST static const struct dbcs_map _mapping_list[] = {
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000217#define MAPPING_ENCONLY(enc) {#enc, (void*)enc##_encmap, NULL},
218#define MAPPING_DECONLY(enc) {#enc, NULL, (void*)enc##_decmap},
219#define MAPPING_ENCDEC(enc) {#enc, (void*)enc##_encmap, (void*)enc##_decmap},
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000220#define END_MAPPINGS_LIST \
221 {"", NULL, NULL} }; \
222 static const struct dbcs_map *mapping_list = \
223 (const struct dbcs_map *)_mapping_list;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000224
Hye-Shik Chang64a9e382004-07-18 15:02:45 +0000225#define BEGIN_CODECS_LIST static const MultibyteCodec _codec_list[] = {
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000226#define _STATEFUL_METHODS(enc) \
227 enc##_encode, \
228 enc##_encode_init, \
229 enc##_encode_reset, \
230 enc##_decode, \
231 enc##_decode_init, \
232 enc##_decode_reset,
233#define _STATELESS_METHODS(enc) \
234 enc##_encode, NULL, NULL, \
235 enc##_decode, NULL, NULL,
236#define CODEC_STATEFUL(enc) { \
237 #enc, NULL, NULL, \
238 _STATEFUL_METHODS(enc) \
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000239},
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000240#define CODEC_STATELESS(enc) { \
241 #enc, NULL, NULL, \
242 _STATELESS_METHODS(enc) \
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000243},
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000244#define CODEC_STATELESS_WINIT(enc) { \
245 #enc, NULL, \
246 enc##_codec_init, \
247 _STATELESS_METHODS(enc) \
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000248},
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000249#define END_CODECS_LIST \
250 {"", NULL,} }; \
251 static const MultibyteCodec *codec_list = \
252 (const MultibyteCodec *)_codec_list;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000253
Benjamin Petersonb173f782009-05-05 22:31:58 +0000254
255
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000256static PyObject *
257getmultibytecodec(void)
258{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000259 static PyObject *cofunc = NULL;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000260
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000261 if (cofunc == NULL) {
262 PyObject *mod = PyImport_ImportModuleNoBlock("_multibytecodec");
263 if (mod == NULL)
264 return NULL;
265 cofunc = PyObject_GetAttrString(mod, "__create_codec");
266 Py_DECREF(mod);
267 }
268 return cofunc;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000269}
270
271static PyObject *
272getcodec(PyObject *self, PyObject *encoding)
273{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000274 PyObject *codecobj, *r, *cofunc;
275 const MultibyteCodec *codec;
276 const char *enc;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000277
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000278 if (!PyUnicode_Check(encoding)) {
279 PyErr_SetString(PyExc_TypeError,
280 "encoding name must be a string.");
281 return NULL;
282 }
283 enc = _PyUnicode_AsString(encoding);
284 if (enc == NULL)
285 return NULL;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000286
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000287 cofunc = getmultibytecodec();
288 if (cofunc == NULL)
289 return NULL;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000290
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000291 for (codec = codec_list; codec->encoding[0]; codec++)
292 if (strcmp(codec->encoding, enc) == 0)
293 break;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000294
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000295 if (codec->encoding[0] == '\0') {
296 PyErr_SetString(PyExc_LookupError,
297 "no such codec is supported.");
298 return NULL;
299 }
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000300
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000301 codecobj = PyCapsule_New((void *)codec, PyMultibyteCodec_CAPSULE_NAME, NULL);
302 if (codecobj == NULL)
303 return NULL;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000304
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000305 r = PyObject_CallFunctionObjArgs(cofunc, codecobj, NULL);
306 Py_DECREF(codecobj);
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000307
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000308 return r;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000309}
310
311static struct PyMethodDef __methods[] = {
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000312 {"getcodec", (PyCFunction)getcodec, METH_O, ""},
313 {NULL, NULL},
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000314};
315
316static int
317register_maps(PyObject *module)
318{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000319 const struct dbcs_map *h;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000320
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000321 for (h = mapping_list; h->charset[0] != '\0'; h++) {
322 char mhname[256] = "__map_";
323 int r;
324 strcpy(mhname + sizeof("__map_") - 1, h->charset);
325 r = PyModule_AddObject(module, mhname,
326 PyCapsule_New((void *)h, PyMultibyteCodec_CAPSULE_NAME, NULL));
327 if (r == -1)
328 return -1;
329 }
330 return 0;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000331}
332
333#ifdef USING_BINARY_PAIR_SEARCH
334static DBCHAR
335find_pairencmap(ucs2_t body, ucs2_t modifier,
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000336 const struct pair_encodemap *haystack, int haystacksize)
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000337{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000338 int pos, min, max;
Victor Stinnera0dd0212013-04-11 22:09:04 +0200339 Py_UCS4 value = body << 16 | modifier;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000340
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000341 min = 0;
342 max = haystacksize;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000343
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000344 for (pos = haystacksize >> 1; min != max; pos = (min + max) >> 1)
345 if (value < haystack[pos].uniseq) {
346 if (max == pos) break;
347 else max = pos;
348 }
349 else if (value > haystack[pos].uniseq) {
350 if (min == pos) break;
351 else min = pos;
352 }
353 else
354 break;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000355
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000356 if (value == haystack[pos].uniseq)
357 return haystack[pos].code;
358 else
359 return DBCINV;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000360}
361#endif
362
363#ifdef USING_IMPORTED_MAPS
364#define IMPORT_MAP(locale, charset, encmap, decmap) \
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000365 importmap("_codecs_" #locale, "__map_" #charset, \
366 (const void**)encmap, (const void**)decmap)
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000367
368static int
369importmap(const char *modname, const char *symbol,
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000370 const void **encmap, const void **decmap)
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000371{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000372 PyObject *o, *mod;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000373
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000374 mod = PyImport_ImportModule((char *)modname);
375 if (mod == NULL)
376 return -1;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000377
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000378 o = PyObject_GetAttrString(mod, (char*)symbol);
379 if (o == NULL)
380 goto errorexit;
381 else if (!PyCapsule_IsValid(o, PyMultibyteCodec_CAPSULE_NAME)) {
382 PyErr_SetString(PyExc_ValueError,
383 "map data must be a Capsule.");
384 goto errorexit;
385 }
386 else {
387 struct dbcs_map *map;
388 map = PyCapsule_GetPointer(o, PyMultibyteCodec_CAPSULE_NAME);
389 if (encmap != NULL)
390 *encmap = map->encmap;
391 if (decmap != NULL)
392 *decmap = map->decmap;
393 Py_DECREF(o);
394 }
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000395
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000396 Py_DECREF(mod);
397 return 0;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000398
399errorexit:
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000400 Py_DECREF(mod);
401 return -1;
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000402}
403#endif
404
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000405#define I_AM_A_MODULE_FOR(loc) \
406 static struct PyModuleDef __module = { \
407 PyModuleDef_HEAD_INIT, \
408 "_codecs_"#loc, \
409 NULL, \
410 0, \
411 __methods, \
412 NULL, \
413 NULL, \
414 NULL, \
415 NULL \
416 }; \
417 PyObject* \
418 PyInit__codecs_##loc(void) \
419 { \
420 PyObject *m = PyModule_Create(&__module); \
421 if (m != NULL) \
422 (void)register_maps(m); \
423 return m; \
424 }
Hye-Shik Chang2bb146f2004-07-18 03:06:29 +0000425
426#endif