@@ -70,67 +70,20 @@ typedef struct previous_version {
7070
7171#define get_old_record (self , v ) ((((PreviousDBVersion*)self)->getrecord)(v))
7272
73- /* Forward declaration */
74- static PyMethodDef unicodedata_functions [];
75-
7673static PyMemberDef DB_members [] = {
7774 {"unidata_version" , T_STRING , offsetof(PreviousDBVersion , name ), READONLY },
7875 {NULL }
7976};
8077
81- static PyTypeObject Xxo_Type = {
82- /* The ob_type field must be initialized in the module init function
83- * to be portable to Windows without using C++. */
84- PyObject_HEAD_INIT (NULL )
85- 0 , /*ob_size*/
86- "unicodedata.DB" , /*tp_name*/
87- sizeof (PreviousDBVersion ), /*tp_basicsize*/
88- 0 , /*tp_itemsize*/
89- /* methods */
90- (destructor )PyObject_Del , /*tp_dealloc*/
91- 0 , /*tp_print*/
92- 0 , /*tp_getattr*/
93- 0 , /*tp_setattr*/
94- 0 , /*tp_compare*/
95- 0 , /*tp_repr*/
96- 0 , /*tp_as_number*/
97- 0 , /*tp_as_sequence*/
98- 0 , /*tp_as_mapping*/
99- 0 , /*tp_hash*/
100- 0 , /*tp_call*/
101- 0 , /*tp_str*/
102- PyObject_GenericGetAttr ,/*tp_getattro*/
103- 0 , /*tp_setattro*/
104- 0 , /*tp_as_buffer*/
105- Py_TPFLAGS_DEFAULT , /*tp_flags*/
106- 0 , /*tp_doc*/
107- 0 , /*tp_traverse*/
108- 0 , /*tp_clear*/
109- 0 , /*tp_richcompare*/
110- 0 , /*tp_weaklistoffset*/
111- 0 , /*tp_iter*/
112- 0 , /*tp_iternext*/
113- unicodedata_functions , /*tp_methods*/
114- DB_members , /*tp_members*/
115- 0 , /*tp_getset*/
116- 0 , /*tp_base*/
117- 0 , /*tp_dict*/
118- 0 , /*tp_descr_get*/
119- 0 , /*tp_descr_set*/
120- 0 , /*tp_dictoffset*/
121- 0 , /*tp_init*/
122- 0 , /*tp_alloc*/
123- 0 , /*tp_new*/
124- 0 , /*tp_free*/
125- 0 , /*tp_is_gc*/
126- };
78+ // forward declaration
79+ static PyTypeObject UCD_Type ;
12780
12881static PyObject *
12982new_previous_version (const char * name , const change_record * (* getrecord )(Py_UCS4 ),
13083 Py_UCS4 (* normalization )(Py_UCS4 ))
13184{
13285 PreviousDBVersion * self ;
133- self = PyObject_New (PreviousDBVersion , & Xxo_Type );
86+ self = PyObject_New (PreviousDBVersion , & UCD_Type );
13487 if (self == NULL )
13588 return NULL ;
13689 self -> name = name ;
@@ -1163,7 +1116,52 @@ static PyMethodDef unicodedata_functions[] = {
11631116 {NULL , NULL } /* sentinel */
11641117};
11651118
1166-
1119+ static PyTypeObject UCD_Type = {
1120+ /* The ob_type field must be initialized in the module init function
1121+ * to be portable to Windows without using C++. */
1122+ PyObject_HEAD_INIT (NULL )
1123+ 0 , /*ob_size*/
1124+ "unicodedata.UCD" , /*tp_name*/
1125+ sizeof (PreviousDBVersion ), /*tp_basicsize*/
1126+ 0 , /*tp_itemsize*/
1127+ /* methods */
1128+ (destructor )PyObject_Del , /*tp_dealloc*/
1129+ 0 , /*tp_print*/
1130+ 0 , /*tp_getattr*/
1131+ 0 , /*tp_setattr*/
1132+ 0 , /*tp_compare*/
1133+ 0 , /*tp_repr*/
1134+ 0 , /*tp_as_number*/
1135+ 0 , /*tp_as_sequence*/
1136+ 0 , /*tp_as_mapping*/
1137+ 0 , /*tp_hash*/
1138+ 0 , /*tp_call*/
1139+ 0 , /*tp_str*/
1140+ PyObject_GenericGetAttr ,/*tp_getattro*/
1141+ 0 , /*tp_setattro*/
1142+ 0 , /*tp_as_buffer*/
1143+ Py_TPFLAGS_DEFAULT , /*tp_flags*/
1144+ 0 , /*tp_doc*/
1145+ 0 , /*tp_traverse*/
1146+ 0 , /*tp_clear*/
1147+ 0 , /*tp_richcompare*/
1148+ 0 , /*tp_weaklistoffset*/
1149+ 0 , /*tp_iter*/
1150+ 0 , /*tp_iternext*/
1151+ unicodedata_functions , /*tp_methods*/
1152+ DB_members , /*tp_members*/
1153+ 0 , /*tp_getset*/
1154+ 0 , /*tp_base*/
1155+ 0 , /*tp_dict*/
1156+ 0 , /*tp_descr_get*/
1157+ 0 , /*tp_descr_set*/
1158+ 0 , /*tp_dictoffset*/
1159+ 0 , /*tp_init*/
1160+ 0 , /*tp_alloc*/
1161+ 0 , /*tp_new*/
1162+ 0 , /*tp_free*/
1163+ 0 , /*tp_is_gc*/
1164+ };
11671165
11681166PyDoc_STRVAR (unicodedata_docstring ,
11691167"This module provides access to the Unicode Character Database which\n\
@@ -1180,17 +1178,20 @@ initunicodedata(void)
11801178{
11811179 PyObject * m , * v ;
11821180
1181+ UCD_Type .ob_type = & PyType_Type ;
1182+
11831183 m = Py_InitModule3 (
11841184 "unicodedata" , unicodedata_functions , unicodedata_docstring );
11851185 if (!m )
11861186 return ;
11871187
11881188 PyModule_AddStringConstant (m , "unidata_version" , UNIDATA_VERSION );
1189+ PyModule_AddObject (m , "UCD" , (PyObject * )& UCD_Type );
11891190
11901191 /* Previous versions */
11911192 v = new_previous_version ("3.2.0" , get_change_3_2_0 , normalization_3_2_0 );
11921193 if (v != NULL )
1193- PyModule_AddObject (m , "db_3_2_0 " , v );
1194+ PyModule_AddObject (m , "ucd_3_2_0 " , v );
11941195
11951196 /* Export C API */
11961197 v = PyCObject_FromVoidPtr ((void * ) & hashAPI , NULL );
0 commit comments