blob: d520c1e3dd4064d73a6ca205473fd769d6d97004 [file] [log] [blame]
Serhiy Storchaka1009bf12015-04-03 23:53:51 +03001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(unicodedata_UCD_decimal__doc__,
Serhiy Storchaka63596412015-04-17 21:18:49 +03006"decimal($self, chr, default=None, /)\n"
Serhiy Storchaka1009bf12015-04-03 23:53:51 +03007"--\n"
8"\n"
9"Converts a Unicode character into its equivalent decimal value.\n"
10"\n"
Serhiy Storchaka63596412015-04-17 21:18:49 +030011"Returns the decimal value assigned to the character chr as integer.\n"
12"If no such value is defined, default is returned, or, if not given,\n"
13"ValueError is raised.");
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030014
15#define UNICODEDATA_UCD_DECIMAL_METHODDEF \
16 {"decimal", (PyCFunction)unicodedata_UCD_decimal, METH_VARARGS, unicodedata_UCD_decimal__doc__},
17
18static PyObject *
Serhiy Storchaka63596412015-04-17 21:18:49 +030019unicodedata_UCD_decimal_impl(PyObject *self, int chr,
Larry Hastings89964c42015-04-14 18:07:59 -040020 PyObject *default_value);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030021
22static PyObject *
Serhiy Storchaka63596412015-04-17 21:18:49 +030023unicodedata_UCD_decimal(PyObject *self, PyObject *args)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030024{
25 PyObject *return_value = NULL;
Serhiy Storchaka63596412015-04-17 21:18:49 +030026 int chr;
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030027 PyObject *default_value = NULL;
28
Serhiy Storchaka247789c2015-04-24 00:40:51 +030029 if (!PyArg_ParseTuple(args, "C|O:decimal",
Serhiy Storchaka63596412015-04-17 21:18:49 +030030 &chr, &default_value))
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030031 goto exit;
Serhiy Storchaka63596412015-04-17 21:18:49 +030032 return_value = unicodedata_UCD_decimal_impl(self, chr, default_value);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030033
34exit:
35 return return_value;
36}
Serhiy Storchaka63596412015-04-17 21:18:49 +030037
38PyDoc_STRVAR(unicodedata_UCD_digit__doc__,
39"digit($self, chr, default=None, /)\n"
40"--\n"
41"\n"
42"Converts a Unicode character into its equivalent digit value.\n"
43"\n"
44"Returns the digit value assigned to the character chr as integer.\n"
45"If no such value is defined, default is returned, or, if not given,\n"
46"ValueError is raised.");
47
48#define UNICODEDATA_UCD_DIGIT_METHODDEF \
49 {"digit", (PyCFunction)unicodedata_UCD_digit, METH_VARARGS, unicodedata_UCD_digit__doc__},
50
51static PyObject *
52unicodedata_UCD_digit_impl(PyObject *self, int chr, PyObject *default_value);
53
54static PyObject *
55unicodedata_UCD_digit(PyObject *self, PyObject *args)
56{
57 PyObject *return_value = NULL;
58 int chr;
59 PyObject *default_value = NULL;
60
Serhiy Storchaka247789c2015-04-24 00:40:51 +030061 if (!PyArg_ParseTuple(args, "C|O:digit",
Serhiy Storchaka63596412015-04-17 21:18:49 +030062 &chr, &default_value))
63 goto exit;
64 return_value = unicodedata_UCD_digit_impl(self, chr, default_value);
65
66exit:
67 return return_value;
68}
69
70PyDoc_STRVAR(unicodedata_UCD_numeric__doc__,
71"numeric($self, chr, default=None, /)\n"
72"--\n"
73"\n"
74"Converts a Unicode character into its equivalent numeric value.\n"
75"\n"
76"Returns the numeric value assigned to the character chr as float.\n"
77"If no such value is defined, default is returned, or, if not given,\n"
78"ValueError is raised.");
79
80#define UNICODEDATA_UCD_NUMERIC_METHODDEF \
81 {"numeric", (PyCFunction)unicodedata_UCD_numeric, METH_VARARGS, unicodedata_UCD_numeric__doc__},
82
83static PyObject *
84unicodedata_UCD_numeric_impl(PyObject *self, int chr,
85 PyObject *default_value);
86
87static PyObject *
88unicodedata_UCD_numeric(PyObject *self, PyObject *args)
89{
90 PyObject *return_value = NULL;
91 int chr;
92 PyObject *default_value = NULL;
93
Serhiy Storchaka247789c2015-04-24 00:40:51 +030094 if (!PyArg_ParseTuple(args, "C|O:numeric",
Serhiy Storchaka63596412015-04-17 21:18:49 +030095 &chr, &default_value))
96 goto exit;
97 return_value = unicodedata_UCD_numeric_impl(self, chr, default_value);
98
99exit:
100 return return_value;
101}
102
103PyDoc_STRVAR(unicodedata_UCD_category__doc__,
104"category($self, chr, /)\n"
105"--\n"
106"\n"
107"Returns the general category assigned to the character chr as string.");
108
109#define UNICODEDATA_UCD_CATEGORY_METHODDEF \
110 {"category", (PyCFunction)unicodedata_UCD_category, METH_O, unicodedata_UCD_category__doc__},
111
112static PyObject *
113unicodedata_UCD_category_impl(PyObject *self, int chr);
114
115static PyObject *
116unicodedata_UCD_category(PyObject *self, PyObject *arg)
117{
118 PyObject *return_value = NULL;
119 int chr;
120
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300121 if (!PyArg_Parse(arg, "C:category", &chr))
Serhiy Storchaka63596412015-04-17 21:18:49 +0300122 goto exit;
123 return_value = unicodedata_UCD_category_impl(self, chr);
124
125exit:
126 return return_value;
127}
128
129PyDoc_STRVAR(unicodedata_UCD_bidirectional__doc__,
130"bidirectional($self, chr, /)\n"
131"--\n"
132"\n"
133"Returns the bidirectional class assigned to the character chr as string.\n"
134"\n"
135"If no such value is defined, an empty string is returned.");
136
137#define UNICODEDATA_UCD_BIDIRECTIONAL_METHODDEF \
138 {"bidirectional", (PyCFunction)unicodedata_UCD_bidirectional, METH_O, unicodedata_UCD_bidirectional__doc__},
139
140static PyObject *
141unicodedata_UCD_bidirectional_impl(PyObject *self, int chr);
142
143static PyObject *
144unicodedata_UCD_bidirectional(PyObject *self, PyObject *arg)
145{
146 PyObject *return_value = NULL;
147 int chr;
148
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300149 if (!PyArg_Parse(arg, "C:bidirectional", &chr))
Serhiy Storchaka63596412015-04-17 21:18:49 +0300150 goto exit;
151 return_value = unicodedata_UCD_bidirectional_impl(self, chr);
152
153exit:
154 return return_value;
155}
156
157PyDoc_STRVAR(unicodedata_UCD_combining__doc__,
158"combining($self, chr, /)\n"
159"--\n"
160"\n"
161"Returns the canonical combining class assigned to the character chr as integer.\n"
162"\n"
163"Returns 0 if no combining class is defined.");
164
165#define UNICODEDATA_UCD_COMBINING_METHODDEF \
166 {"combining", (PyCFunction)unicodedata_UCD_combining, METH_O, unicodedata_UCD_combining__doc__},
167
168static int
169unicodedata_UCD_combining_impl(PyObject *self, int chr);
170
171static PyObject *
172unicodedata_UCD_combining(PyObject *self, PyObject *arg)
173{
174 PyObject *return_value = NULL;
175 int chr;
176 int _return_value;
177
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300178 if (!PyArg_Parse(arg, "C:combining", &chr))
Serhiy Storchaka63596412015-04-17 21:18:49 +0300179 goto exit;
180 _return_value = unicodedata_UCD_combining_impl(self, chr);
181 if ((_return_value == -1) && PyErr_Occurred())
182 goto exit;
183 return_value = PyLong_FromLong((long)_return_value);
184
185exit:
186 return return_value;
187}
188
189PyDoc_STRVAR(unicodedata_UCD_mirrored__doc__,
190"mirrored($self, chr, /)\n"
191"--\n"
192"\n"
193"Returns the mirrored property assigned to the character chr as integer.\n"
194"\n"
195"Returns 1 if the character has been identified as a \"mirrored\"\n"
196"character in bidirectional text, 0 otherwise.");
197
198#define UNICODEDATA_UCD_MIRRORED_METHODDEF \
199 {"mirrored", (PyCFunction)unicodedata_UCD_mirrored, METH_O, unicodedata_UCD_mirrored__doc__},
200
201static int
202unicodedata_UCD_mirrored_impl(PyObject *self, int chr);
203
204static PyObject *
205unicodedata_UCD_mirrored(PyObject *self, PyObject *arg)
206{
207 PyObject *return_value = NULL;
208 int chr;
209 int _return_value;
210
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300211 if (!PyArg_Parse(arg, "C:mirrored", &chr))
Serhiy Storchaka63596412015-04-17 21:18:49 +0300212 goto exit;
213 _return_value = unicodedata_UCD_mirrored_impl(self, chr);
214 if ((_return_value == -1) && PyErr_Occurred())
215 goto exit;
216 return_value = PyLong_FromLong((long)_return_value);
217
218exit:
219 return return_value;
220}
221
222PyDoc_STRVAR(unicodedata_UCD_east_asian_width__doc__,
223"east_asian_width($self, chr, /)\n"
224"--\n"
225"\n"
226"Returns the east asian width assigned to the character chr as string.");
227
228#define UNICODEDATA_UCD_EAST_ASIAN_WIDTH_METHODDEF \
229 {"east_asian_width", (PyCFunction)unicodedata_UCD_east_asian_width, METH_O, unicodedata_UCD_east_asian_width__doc__},
230
231static PyObject *
232unicodedata_UCD_east_asian_width_impl(PyObject *self, int chr);
233
234static PyObject *
235unicodedata_UCD_east_asian_width(PyObject *self, PyObject *arg)
236{
237 PyObject *return_value = NULL;
238 int chr;
239
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300240 if (!PyArg_Parse(arg, "C:east_asian_width", &chr))
Serhiy Storchaka63596412015-04-17 21:18:49 +0300241 goto exit;
242 return_value = unicodedata_UCD_east_asian_width_impl(self, chr);
243
244exit:
245 return return_value;
246}
247
248PyDoc_STRVAR(unicodedata_UCD_decomposition__doc__,
249"decomposition($self, chr, /)\n"
250"--\n"
251"\n"
252"Returns the character decomposition mapping assigned to the character chr as string.\n"
253"\n"
254"An empty string is returned in case no such mapping is defined.");
255
256#define UNICODEDATA_UCD_DECOMPOSITION_METHODDEF \
257 {"decomposition", (PyCFunction)unicodedata_UCD_decomposition, METH_O, unicodedata_UCD_decomposition__doc__},
258
259static PyObject *
260unicodedata_UCD_decomposition_impl(PyObject *self, int chr);
261
262static PyObject *
263unicodedata_UCD_decomposition(PyObject *self, PyObject *arg)
264{
265 PyObject *return_value = NULL;
266 int chr;
267
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300268 if (!PyArg_Parse(arg, "C:decomposition", &chr))
Serhiy Storchaka63596412015-04-17 21:18:49 +0300269 goto exit;
270 return_value = unicodedata_UCD_decomposition_impl(self, chr);
271
272exit:
273 return return_value;
274}
275
276PyDoc_STRVAR(unicodedata_UCD_normalize__doc__,
277"normalize($self, form, unistr, /)\n"
278"--\n"
279"\n"
280"Return the normal form \'form\' for the Unicode string unistr.\n"
281"\n"
282"Valid values for form are \'NFC\', \'NFKC\', \'NFD\', and \'NFKD\'.");
283
284#define UNICODEDATA_UCD_NORMALIZE_METHODDEF \
285 {"normalize", (PyCFunction)unicodedata_UCD_normalize, METH_VARARGS, unicodedata_UCD_normalize__doc__},
286
287static PyObject *
288unicodedata_UCD_normalize_impl(PyObject *self, const char *form,
289 PyObject *input);
290
291static PyObject *
292unicodedata_UCD_normalize(PyObject *self, PyObject *args)
293{
294 PyObject *return_value = NULL;
295 const char *form;
296 PyObject *input;
297
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300298 if (!PyArg_ParseTuple(args, "sO!:normalize",
Serhiy Storchaka63596412015-04-17 21:18:49 +0300299 &form, &PyUnicode_Type, &input))
300 goto exit;
301 return_value = unicodedata_UCD_normalize_impl(self, form, input);
302
303exit:
304 return return_value;
305}
306
307PyDoc_STRVAR(unicodedata_UCD_name__doc__,
308"name($self, chr, default=None, /)\n"
309"--\n"
310"\n"
311"Returns the name assigned to the character chr as a string.\n"
312"\n"
313"If no name is defined, default is returned, or, if not given,\n"
314"ValueError is raised.");
315
316#define UNICODEDATA_UCD_NAME_METHODDEF \
317 {"name", (PyCFunction)unicodedata_UCD_name, METH_VARARGS, unicodedata_UCD_name__doc__},
318
319static PyObject *
320unicodedata_UCD_name_impl(PyObject *self, int chr, PyObject *default_value);
321
322static PyObject *
323unicodedata_UCD_name(PyObject *self, PyObject *args)
324{
325 PyObject *return_value = NULL;
326 int chr;
327 PyObject *default_value = NULL;
328
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300329 if (!PyArg_ParseTuple(args, "C|O:name",
Serhiy Storchaka63596412015-04-17 21:18:49 +0300330 &chr, &default_value))
331 goto exit;
332 return_value = unicodedata_UCD_name_impl(self, chr, default_value);
333
334exit:
335 return return_value;
336}
337
338PyDoc_STRVAR(unicodedata_UCD_lookup__doc__,
339"lookup($self, name, /)\n"
340"--\n"
341"\n"
342"Look up character by name.\n"
343"\n"
344"If a character with the given name is found, return the\n"
345"corresponding character. If not found, KeyError is raised.");
346
347#define UNICODEDATA_UCD_LOOKUP_METHODDEF \
348 {"lookup", (PyCFunction)unicodedata_UCD_lookup, METH_O, unicodedata_UCD_lookup__doc__},
349
350static PyObject *
351unicodedata_UCD_lookup_impl(PyObject *self, const char *name,
352 Py_ssize_clean_t name_length);
353
354static PyObject *
355unicodedata_UCD_lookup(PyObject *self, PyObject *arg)
356{
357 PyObject *return_value = NULL;
358 const char *name;
359 Py_ssize_clean_t name_length;
360
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300361 if (!PyArg_Parse(arg, "s#:lookup", &name, &name_length))
Serhiy Storchaka63596412015-04-17 21:18:49 +0300362 goto exit;
363 return_value = unicodedata_UCD_lookup_impl(self, name, name_length);
364
365exit:
366 return return_value;
367}
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300368/*[clinic end generated code: output=4f8da33c6bc6efc9 input=a9049054013a1b77]*/