blob: c3a5910b49007535663f0c4bed3378c0e01725d1 [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 \
Victor Stinner259f0e42017-01-17 01:35:17 +010016 {"decimal", (PyCFunction)unicodedata_UCD_decimal, METH_FASTCALL, unicodedata_UCD_decimal__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030017
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 *
Victor Stinner259f0e42017-01-17 01:35:17 +010023unicodedata_UCD_decimal(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
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
Victor Stinner259f0e42017-01-17 01:35:17 +010029 if (!_PyArg_ParseStack(args, nargs, "C|O:decimal",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030030 &chr, &default_value)) {
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030031 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030032 }
Victor Stinner259f0e42017-01-17 01:35:17 +010033
34 if (!_PyArg_NoStackKeywords("decimal", kwnames)) {
35 goto exit;
36 }
Serhiy Storchaka63596412015-04-17 21:18:49 +030037 return_value = unicodedata_UCD_decimal_impl(self, chr, default_value);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030038
39exit:
40 return return_value;
41}
Serhiy Storchaka63596412015-04-17 21:18:49 +030042
43PyDoc_STRVAR(unicodedata_UCD_digit__doc__,
44"digit($self, chr, default=None, /)\n"
45"--\n"
46"\n"
47"Converts a Unicode character into its equivalent digit value.\n"
48"\n"
49"Returns the digit value assigned to the character chr as integer.\n"
50"If no such value is defined, default is returned, or, if not given,\n"
51"ValueError is raised.");
52
53#define UNICODEDATA_UCD_DIGIT_METHODDEF \
Victor Stinner259f0e42017-01-17 01:35:17 +010054 {"digit", (PyCFunction)unicodedata_UCD_digit, METH_FASTCALL, unicodedata_UCD_digit__doc__},
Serhiy Storchaka63596412015-04-17 21:18:49 +030055
56static PyObject *
57unicodedata_UCD_digit_impl(PyObject *self, int chr, PyObject *default_value);
58
59static PyObject *
Victor Stinner259f0e42017-01-17 01:35:17 +010060unicodedata_UCD_digit(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
Serhiy Storchaka63596412015-04-17 21:18:49 +030061{
62 PyObject *return_value = NULL;
63 int chr;
64 PyObject *default_value = NULL;
65
Victor Stinner259f0e42017-01-17 01:35:17 +010066 if (!_PyArg_ParseStack(args, nargs, "C|O:digit",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030067 &chr, &default_value)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +030068 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030069 }
Victor Stinner259f0e42017-01-17 01:35:17 +010070
71 if (!_PyArg_NoStackKeywords("digit", kwnames)) {
72 goto exit;
73 }
Serhiy Storchaka63596412015-04-17 21:18:49 +030074 return_value = unicodedata_UCD_digit_impl(self, chr, default_value);
75
76exit:
77 return return_value;
78}
79
80PyDoc_STRVAR(unicodedata_UCD_numeric__doc__,
81"numeric($self, chr, default=None, /)\n"
82"--\n"
83"\n"
84"Converts a Unicode character into its equivalent numeric value.\n"
85"\n"
86"Returns the numeric value assigned to the character chr as float.\n"
87"If no such value is defined, default is returned, or, if not given,\n"
88"ValueError is raised.");
89
90#define UNICODEDATA_UCD_NUMERIC_METHODDEF \
Victor Stinner259f0e42017-01-17 01:35:17 +010091 {"numeric", (PyCFunction)unicodedata_UCD_numeric, METH_FASTCALL, unicodedata_UCD_numeric__doc__},
Serhiy Storchaka63596412015-04-17 21:18:49 +030092
93static PyObject *
94unicodedata_UCD_numeric_impl(PyObject *self, int chr,
95 PyObject *default_value);
96
97static PyObject *
Victor Stinner259f0e42017-01-17 01:35:17 +010098unicodedata_UCD_numeric(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
Serhiy Storchaka63596412015-04-17 21:18:49 +030099{
100 PyObject *return_value = NULL;
101 int chr;
102 PyObject *default_value = NULL;
103
Victor Stinner259f0e42017-01-17 01:35:17 +0100104 if (!_PyArg_ParseStack(args, nargs, "C|O:numeric",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300105 &chr, &default_value)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300106 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300107 }
Victor Stinner259f0e42017-01-17 01:35:17 +0100108
109 if (!_PyArg_NoStackKeywords("numeric", kwnames)) {
110 goto exit;
111 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300112 return_value = unicodedata_UCD_numeric_impl(self, chr, default_value);
113
114exit:
115 return return_value;
116}
117
118PyDoc_STRVAR(unicodedata_UCD_category__doc__,
119"category($self, chr, /)\n"
120"--\n"
121"\n"
122"Returns the general category assigned to the character chr as string.");
123
124#define UNICODEDATA_UCD_CATEGORY_METHODDEF \
125 {"category", (PyCFunction)unicodedata_UCD_category, METH_O, unicodedata_UCD_category__doc__},
126
127static PyObject *
128unicodedata_UCD_category_impl(PyObject *self, int chr);
129
130static PyObject *
131unicodedata_UCD_category(PyObject *self, PyObject *arg)
132{
133 PyObject *return_value = NULL;
134 int chr;
135
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300136 if (!PyArg_Parse(arg, "C:category", &chr)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300137 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300138 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300139 return_value = unicodedata_UCD_category_impl(self, chr);
140
141exit:
142 return return_value;
143}
144
145PyDoc_STRVAR(unicodedata_UCD_bidirectional__doc__,
146"bidirectional($self, chr, /)\n"
147"--\n"
148"\n"
149"Returns the bidirectional class assigned to the character chr as string.\n"
150"\n"
151"If no such value is defined, an empty string is returned.");
152
153#define UNICODEDATA_UCD_BIDIRECTIONAL_METHODDEF \
154 {"bidirectional", (PyCFunction)unicodedata_UCD_bidirectional, METH_O, unicodedata_UCD_bidirectional__doc__},
155
156static PyObject *
157unicodedata_UCD_bidirectional_impl(PyObject *self, int chr);
158
159static PyObject *
160unicodedata_UCD_bidirectional(PyObject *self, PyObject *arg)
161{
162 PyObject *return_value = NULL;
163 int chr;
164
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300165 if (!PyArg_Parse(arg, "C:bidirectional", &chr)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300166 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300167 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300168 return_value = unicodedata_UCD_bidirectional_impl(self, chr);
169
170exit:
171 return return_value;
172}
173
174PyDoc_STRVAR(unicodedata_UCD_combining__doc__,
175"combining($self, chr, /)\n"
176"--\n"
177"\n"
178"Returns the canonical combining class assigned to the character chr as integer.\n"
179"\n"
180"Returns 0 if no combining class is defined.");
181
182#define UNICODEDATA_UCD_COMBINING_METHODDEF \
183 {"combining", (PyCFunction)unicodedata_UCD_combining, METH_O, unicodedata_UCD_combining__doc__},
184
185static int
186unicodedata_UCD_combining_impl(PyObject *self, int chr);
187
188static PyObject *
189unicodedata_UCD_combining(PyObject *self, PyObject *arg)
190{
191 PyObject *return_value = NULL;
192 int chr;
193 int _return_value;
194
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300195 if (!PyArg_Parse(arg, "C:combining", &chr)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300196 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300197 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300198 _return_value = unicodedata_UCD_combining_impl(self, chr);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300199 if ((_return_value == -1) && PyErr_Occurred()) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300200 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300201 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300202 return_value = PyLong_FromLong((long)_return_value);
203
204exit:
205 return return_value;
206}
207
208PyDoc_STRVAR(unicodedata_UCD_mirrored__doc__,
209"mirrored($self, chr, /)\n"
210"--\n"
211"\n"
212"Returns the mirrored property assigned to the character chr as integer.\n"
213"\n"
214"Returns 1 if the character has been identified as a \"mirrored\"\n"
215"character in bidirectional text, 0 otherwise.");
216
217#define UNICODEDATA_UCD_MIRRORED_METHODDEF \
218 {"mirrored", (PyCFunction)unicodedata_UCD_mirrored, METH_O, unicodedata_UCD_mirrored__doc__},
219
220static int
221unicodedata_UCD_mirrored_impl(PyObject *self, int chr);
222
223static PyObject *
224unicodedata_UCD_mirrored(PyObject *self, PyObject *arg)
225{
226 PyObject *return_value = NULL;
227 int chr;
228 int _return_value;
229
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300230 if (!PyArg_Parse(arg, "C:mirrored", &chr)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300231 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300232 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300233 _return_value = unicodedata_UCD_mirrored_impl(self, chr);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300234 if ((_return_value == -1) && PyErr_Occurred()) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300235 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300236 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300237 return_value = PyLong_FromLong((long)_return_value);
238
239exit:
240 return return_value;
241}
242
243PyDoc_STRVAR(unicodedata_UCD_east_asian_width__doc__,
244"east_asian_width($self, chr, /)\n"
245"--\n"
246"\n"
247"Returns the east asian width assigned to the character chr as string.");
248
249#define UNICODEDATA_UCD_EAST_ASIAN_WIDTH_METHODDEF \
250 {"east_asian_width", (PyCFunction)unicodedata_UCD_east_asian_width, METH_O, unicodedata_UCD_east_asian_width__doc__},
251
252static PyObject *
253unicodedata_UCD_east_asian_width_impl(PyObject *self, int chr);
254
255static PyObject *
256unicodedata_UCD_east_asian_width(PyObject *self, PyObject *arg)
257{
258 PyObject *return_value = NULL;
259 int chr;
260
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300261 if (!PyArg_Parse(arg, "C:east_asian_width", &chr)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300262 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300263 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300264 return_value = unicodedata_UCD_east_asian_width_impl(self, chr);
265
266exit:
267 return return_value;
268}
269
270PyDoc_STRVAR(unicodedata_UCD_decomposition__doc__,
271"decomposition($self, chr, /)\n"
272"--\n"
273"\n"
274"Returns the character decomposition mapping assigned to the character chr as string.\n"
275"\n"
276"An empty string is returned in case no such mapping is defined.");
277
278#define UNICODEDATA_UCD_DECOMPOSITION_METHODDEF \
279 {"decomposition", (PyCFunction)unicodedata_UCD_decomposition, METH_O, unicodedata_UCD_decomposition__doc__},
280
281static PyObject *
282unicodedata_UCD_decomposition_impl(PyObject *self, int chr);
283
284static PyObject *
285unicodedata_UCD_decomposition(PyObject *self, PyObject *arg)
286{
287 PyObject *return_value = NULL;
288 int chr;
289
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300290 if (!PyArg_Parse(arg, "C:decomposition", &chr)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300291 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300292 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300293 return_value = unicodedata_UCD_decomposition_impl(self, chr);
294
295exit:
296 return return_value;
297}
298
299PyDoc_STRVAR(unicodedata_UCD_normalize__doc__,
300"normalize($self, form, unistr, /)\n"
301"--\n"
302"\n"
303"Return the normal form \'form\' for the Unicode string unistr.\n"
304"\n"
305"Valid values for form are \'NFC\', \'NFKC\', \'NFD\', and \'NFKD\'.");
306
307#define UNICODEDATA_UCD_NORMALIZE_METHODDEF \
Victor Stinner259f0e42017-01-17 01:35:17 +0100308 {"normalize", (PyCFunction)unicodedata_UCD_normalize, METH_FASTCALL, unicodedata_UCD_normalize__doc__},
Serhiy Storchaka63596412015-04-17 21:18:49 +0300309
310static PyObject *
311unicodedata_UCD_normalize_impl(PyObject *self, const char *form,
312 PyObject *input);
313
314static PyObject *
Victor Stinner259f0e42017-01-17 01:35:17 +0100315unicodedata_UCD_normalize(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
Serhiy Storchaka63596412015-04-17 21:18:49 +0300316{
317 PyObject *return_value = NULL;
318 const char *form;
319 PyObject *input;
320
Victor Stinner259f0e42017-01-17 01:35:17 +0100321 if (!_PyArg_ParseStack(args, nargs, "sU:normalize",
Serhiy Storchakaf8d7d412016-10-23 15:12:25 +0300322 &form, &input)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300323 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300324 }
Victor Stinner259f0e42017-01-17 01:35:17 +0100325
326 if (!_PyArg_NoStackKeywords("normalize", kwnames)) {
327 goto exit;
328 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300329 return_value = unicodedata_UCD_normalize_impl(self, form, input);
330
331exit:
332 return return_value;
333}
334
335PyDoc_STRVAR(unicodedata_UCD_name__doc__,
336"name($self, chr, default=None, /)\n"
337"--\n"
338"\n"
339"Returns the name assigned to the character chr as a string.\n"
340"\n"
341"If no name is defined, default is returned, or, if not given,\n"
342"ValueError is raised.");
343
344#define UNICODEDATA_UCD_NAME_METHODDEF \
Victor Stinner259f0e42017-01-17 01:35:17 +0100345 {"name", (PyCFunction)unicodedata_UCD_name, METH_FASTCALL, unicodedata_UCD_name__doc__},
Serhiy Storchaka63596412015-04-17 21:18:49 +0300346
347static PyObject *
348unicodedata_UCD_name_impl(PyObject *self, int chr, PyObject *default_value);
349
350static PyObject *
Victor Stinner259f0e42017-01-17 01:35:17 +0100351unicodedata_UCD_name(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
Serhiy Storchaka63596412015-04-17 21:18:49 +0300352{
353 PyObject *return_value = NULL;
354 int chr;
355 PyObject *default_value = NULL;
356
Victor Stinner259f0e42017-01-17 01:35:17 +0100357 if (!_PyArg_ParseStack(args, nargs, "C|O:name",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300358 &chr, &default_value)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300359 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300360 }
Victor Stinner259f0e42017-01-17 01:35:17 +0100361
362 if (!_PyArg_NoStackKeywords("name", kwnames)) {
363 goto exit;
364 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300365 return_value = unicodedata_UCD_name_impl(self, chr, default_value);
366
367exit:
368 return return_value;
369}
370
371PyDoc_STRVAR(unicodedata_UCD_lookup__doc__,
372"lookup($self, name, /)\n"
373"--\n"
374"\n"
375"Look up character by name.\n"
376"\n"
377"If a character with the given name is found, return the\n"
378"corresponding character. If not found, KeyError is raised.");
379
380#define UNICODEDATA_UCD_LOOKUP_METHODDEF \
381 {"lookup", (PyCFunction)unicodedata_UCD_lookup, METH_O, unicodedata_UCD_lookup__doc__},
382
383static PyObject *
384unicodedata_UCD_lookup_impl(PyObject *self, const char *name,
385 Py_ssize_clean_t name_length);
386
387static PyObject *
388unicodedata_UCD_lookup(PyObject *self, PyObject *arg)
389{
390 PyObject *return_value = NULL;
391 const char *name;
392 Py_ssize_clean_t name_length;
393
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300394 if (!PyArg_Parse(arg, "s#:lookup", &name, &name_length)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300395 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300396 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300397 return_value = unicodedata_UCD_lookup_impl(self, name, name_length);
398
399exit:
400 return return_value;
401}
Victor Stinner259f0e42017-01-17 01:35:17 +0100402/*[clinic end generated code: output=fcb86aaa3fa40876 input=a9049054013a1b77]*/