blob: d481ccbe643fb8aa1651d4267683be3a6b31626e [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 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 }
Serhiy Storchaka63596412015-04-17 21:18:49 +030033 return_value = unicodedata_UCD_decimal_impl(self, chr, default_value);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030034
35exit:
36 return return_value;
37}
Serhiy Storchaka63596412015-04-17 21:18:49 +030038
39PyDoc_STRVAR(unicodedata_UCD_digit__doc__,
40"digit($self, chr, default=None, /)\n"
41"--\n"
42"\n"
43"Converts a Unicode character into its equivalent digit value.\n"
44"\n"
45"Returns the digit value assigned to the character chr as integer.\n"
46"If no such value is defined, default is returned, or, if not given,\n"
47"ValueError is raised.");
48
49#define UNICODEDATA_UCD_DIGIT_METHODDEF \
50 {"digit", (PyCFunction)unicodedata_UCD_digit, METH_VARARGS, unicodedata_UCD_digit__doc__},
51
52static PyObject *
53unicodedata_UCD_digit_impl(PyObject *self, int chr, PyObject *default_value);
54
55static PyObject *
56unicodedata_UCD_digit(PyObject *self, PyObject *args)
57{
58 PyObject *return_value = NULL;
59 int chr;
60 PyObject *default_value = NULL;
61
Serhiy Storchaka247789c2015-04-24 00:40:51 +030062 if (!PyArg_ParseTuple(args, "C|O:digit",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030063 &chr, &default_value)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +030064 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030065 }
Serhiy Storchaka63596412015-04-17 21:18:49 +030066 return_value = unicodedata_UCD_digit_impl(self, chr, default_value);
67
68exit:
69 return return_value;
70}
71
72PyDoc_STRVAR(unicodedata_UCD_numeric__doc__,
73"numeric($self, chr, default=None, /)\n"
74"--\n"
75"\n"
76"Converts a Unicode character into its equivalent numeric value.\n"
77"\n"
78"Returns the numeric value assigned to the character chr as float.\n"
79"If no such value is defined, default is returned, or, if not given,\n"
80"ValueError is raised.");
81
82#define UNICODEDATA_UCD_NUMERIC_METHODDEF \
83 {"numeric", (PyCFunction)unicodedata_UCD_numeric, METH_VARARGS, unicodedata_UCD_numeric__doc__},
84
85static PyObject *
86unicodedata_UCD_numeric_impl(PyObject *self, int chr,
87 PyObject *default_value);
88
89static PyObject *
90unicodedata_UCD_numeric(PyObject *self, PyObject *args)
91{
92 PyObject *return_value = NULL;
93 int chr;
94 PyObject *default_value = NULL;
95
Serhiy Storchaka247789c2015-04-24 00:40:51 +030096 if (!PyArg_ParseTuple(args, "C|O:numeric",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030097 &chr, &default_value)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +030098 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030099 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300100 return_value = unicodedata_UCD_numeric_impl(self, chr, default_value);
101
102exit:
103 return return_value;
104}
105
106PyDoc_STRVAR(unicodedata_UCD_category__doc__,
107"category($self, chr, /)\n"
108"--\n"
109"\n"
110"Returns the general category assigned to the character chr as string.");
111
112#define UNICODEDATA_UCD_CATEGORY_METHODDEF \
113 {"category", (PyCFunction)unicodedata_UCD_category, METH_O, unicodedata_UCD_category__doc__},
114
115static PyObject *
116unicodedata_UCD_category_impl(PyObject *self, int chr);
117
118static PyObject *
119unicodedata_UCD_category(PyObject *self, PyObject *arg)
120{
121 PyObject *return_value = NULL;
122 int chr;
123
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300124 if (!PyArg_Parse(arg, "C:category", &chr)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300125 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300126 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300127 return_value = unicodedata_UCD_category_impl(self, chr);
128
129exit:
130 return return_value;
131}
132
133PyDoc_STRVAR(unicodedata_UCD_bidirectional__doc__,
134"bidirectional($self, chr, /)\n"
135"--\n"
136"\n"
137"Returns the bidirectional class assigned to the character chr as string.\n"
138"\n"
139"If no such value is defined, an empty string is returned.");
140
141#define UNICODEDATA_UCD_BIDIRECTIONAL_METHODDEF \
142 {"bidirectional", (PyCFunction)unicodedata_UCD_bidirectional, METH_O, unicodedata_UCD_bidirectional__doc__},
143
144static PyObject *
145unicodedata_UCD_bidirectional_impl(PyObject *self, int chr);
146
147static PyObject *
148unicodedata_UCD_bidirectional(PyObject *self, PyObject *arg)
149{
150 PyObject *return_value = NULL;
151 int chr;
152
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300153 if (!PyArg_Parse(arg, "C:bidirectional", &chr)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300154 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300155 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300156 return_value = unicodedata_UCD_bidirectional_impl(self, chr);
157
158exit:
159 return return_value;
160}
161
162PyDoc_STRVAR(unicodedata_UCD_combining__doc__,
163"combining($self, chr, /)\n"
164"--\n"
165"\n"
166"Returns the canonical combining class assigned to the character chr as integer.\n"
167"\n"
168"Returns 0 if no combining class is defined.");
169
170#define UNICODEDATA_UCD_COMBINING_METHODDEF \
171 {"combining", (PyCFunction)unicodedata_UCD_combining, METH_O, unicodedata_UCD_combining__doc__},
172
173static int
174unicodedata_UCD_combining_impl(PyObject *self, int chr);
175
176static PyObject *
177unicodedata_UCD_combining(PyObject *self, PyObject *arg)
178{
179 PyObject *return_value = NULL;
180 int chr;
181 int _return_value;
182
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300183 if (!PyArg_Parse(arg, "C:combining", &chr)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300184 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300185 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300186 _return_value = unicodedata_UCD_combining_impl(self, chr);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300187 if ((_return_value == -1) && PyErr_Occurred()) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300188 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300189 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300190 return_value = PyLong_FromLong((long)_return_value);
191
192exit:
193 return return_value;
194}
195
196PyDoc_STRVAR(unicodedata_UCD_mirrored__doc__,
197"mirrored($self, chr, /)\n"
198"--\n"
199"\n"
200"Returns the mirrored property assigned to the character chr as integer.\n"
201"\n"
202"Returns 1 if the character has been identified as a \"mirrored\"\n"
203"character in bidirectional text, 0 otherwise.");
204
205#define UNICODEDATA_UCD_MIRRORED_METHODDEF \
206 {"mirrored", (PyCFunction)unicodedata_UCD_mirrored, METH_O, unicodedata_UCD_mirrored__doc__},
207
208static int
209unicodedata_UCD_mirrored_impl(PyObject *self, int chr);
210
211static PyObject *
212unicodedata_UCD_mirrored(PyObject *self, PyObject *arg)
213{
214 PyObject *return_value = NULL;
215 int chr;
216 int _return_value;
217
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300218 if (!PyArg_Parse(arg, "C:mirrored", &chr)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300219 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300220 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300221 _return_value = unicodedata_UCD_mirrored_impl(self, chr);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300222 if ((_return_value == -1) && PyErr_Occurred()) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300223 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300224 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300225 return_value = PyLong_FromLong((long)_return_value);
226
227exit:
228 return return_value;
229}
230
231PyDoc_STRVAR(unicodedata_UCD_east_asian_width__doc__,
232"east_asian_width($self, chr, /)\n"
233"--\n"
234"\n"
235"Returns the east asian width assigned to the character chr as string.");
236
237#define UNICODEDATA_UCD_EAST_ASIAN_WIDTH_METHODDEF \
238 {"east_asian_width", (PyCFunction)unicodedata_UCD_east_asian_width, METH_O, unicodedata_UCD_east_asian_width__doc__},
239
240static PyObject *
241unicodedata_UCD_east_asian_width_impl(PyObject *self, int chr);
242
243static PyObject *
244unicodedata_UCD_east_asian_width(PyObject *self, PyObject *arg)
245{
246 PyObject *return_value = NULL;
247 int chr;
248
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300249 if (!PyArg_Parse(arg, "C:east_asian_width", &chr)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300250 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300251 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300252 return_value = unicodedata_UCD_east_asian_width_impl(self, chr);
253
254exit:
255 return return_value;
256}
257
258PyDoc_STRVAR(unicodedata_UCD_decomposition__doc__,
259"decomposition($self, chr, /)\n"
260"--\n"
261"\n"
262"Returns the character decomposition mapping assigned to the character chr as string.\n"
263"\n"
264"An empty string is returned in case no such mapping is defined.");
265
266#define UNICODEDATA_UCD_DECOMPOSITION_METHODDEF \
267 {"decomposition", (PyCFunction)unicodedata_UCD_decomposition, METH_O, unicodedata_UCD_decomposition__doc__},
268
269static PyObject *
270unicodedata_UCD_decomposition_impl(PyObject *self, int chr);
271
272static PyObject *
273unicodedata_UCD_decomposition(PyObject *self, PyObject *arg)
274{
275 PyObject *return_value = NULL;
276 int chr;
277
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300278 if (!PyArg_Parse(arg, "C:decomposition", &chr)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300279 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300280 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300281 return_value = unicodedata_UCD_decomposition_impl(self, chr);
282
283exit:
284 return return_value;
285}
286
287PyDoc_STRVAR(unicodedata_UCD_normalize__doc__,
288"normalize($self, form, unistr, /)\n"
289"--\n"
290"\n"
291"Return the normal form \'form\' for the Unicode string unistr.\n"
292"\n"
293"Valid values for form are \'NFC\', \'NFKC\', \'NFD\', and \'NFKD\'.");
294
295#define UNICODEDATA_UCD_NORMALIZE_METHODDEF \
296 {"normalize", (PyCFunction)unicodedata_UCD_normalize, METH_VARARGS, unicodedata_UCD_normalize__doc__},
297
298static PyObject *
299unicodedata_UCD_normalize_impl(PyObject *self, const char *form,
300 PyObject *input);
301
302static PyObject *
303unicodedata_UCD_normalize(PyObject *self, PyObject *args)
304{
305 PyObject *return_value = NULL;
306 const char *form;
307 PyObject *input;
308
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300309 if (!PyArg_ParseTuple(args, "sO!:normalize",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300310 &form, &PyUnicode_Type, &input)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300311 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300312 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300313 return_value = unicodedata_UCD_normalize_impl(self, form, input);
314
315exit:
316 return return_value;
317}
318
319PyDoc_STRVAR(unicodedata_UCD_name__doc__,
320"name($self, chr, default=None, /)\n"
321"--\n"
322"\n"
323"Returns the name assigned to the character chr as a string.\n"
324"\n"
325"If no name is defined, default is returned, or, if not given,\n"
326"ValueError is raised.");
327
328#define UNICODEDATA_UCD_NAME_METHODDEF \
329 {"name", (PyCFunction)unicodedata_UCD_name, METH_VARARGS, unicodedata_UCD_name__doc__},
330
331static PyObject *
332unicodedata_UCD_name_impl(PyObject *self, int chr, PyObject *default_value);
333
334static PyObject *
335unicodedata_UCD_name(PyObject *self, PyObject *args)
336{
337 PyObject *return_value = NULL;
338 int chr;
339 PyObject *default_value = NULL;
340
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300341 if (!PyArg_ParseTuple(args, "C|O:name",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300342 &chr, &default_value)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300343 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300344 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300345 return_value = unicodedata_UCD_name_impl(self, chr, default_value);
346
347exit:
348 return return_value;
349}
350
351PyDoc_STRVAR(unicodedata_UCD_lookup__doc__,
352"lookup($self, name, /)\n"
353"--\n"
354"\n"
355"Look up character by name.\n"
356"\n"
357"If a character with the given name is found, return the\n"
358"corresponding character. If not found, KeyError is raised.");
359
360#define UNICODEDATA_UCD_LOOKUP_METHODDEF \
361 {"lookup", (PyCFunction)unicodedata_UCD_lookup, METH_O, unicodedata_UCD_lookup__doc__},
362
363static PyObject *
364unicodedata_UCD_lookup_impl(PyObject *self, const char *name,
365 Py_ssize_clean_t name_length);
366
367static PyObject *
368unicodedata_UCD_lookup(PyObject *self, PyObject *arg)
369{
370 PyObject *return_value = NULL;
371 const char *name;
372 Py_ssize_clean_t name_length;
373
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300374 if (!PyArg_Parse(arg, "s#:lookup", &name, &name_length)) {
Serhiy Storchaka63596412015-04-17 21:18:49 +0300375 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300376 }
Serhiy Storchaka63596412015-04-17 21:18:49 +0300377 return_value = unicodedata_UCD_lookup_impl(self, name, name_length);
378
379exit:
380 return return_value;
381}
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300382/*[clinic end generated code: output=5313ce129da87b2f input=a9049054013a1b77]*/