summaryrefslogtreecommitdiffstats
path: root/Tools/clinic
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/clinic')
-rwxr-xr-xTools/clinic/clinic.py38
1 files changed, 24 insertions, 14 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 5dcaa93..64b9bf7 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -1252,10 +1252,11 @@ class BlockParser:
match = self.start_re.match(line.lstrip())
return match.group(1) if match else None
- def _line(self):
+ def _line(self, lookahead=False):
self.line_number += 1
line = self.input.pop()
- self.language.parse_line(line)
+ if not lookahead:
+ self.language.parse_line(line)
return line
def parse_verbatim_block(self):
@@ -1311,7 +1312,7 @@ class BlockParser:
output_add, output_output = text_accumulator()
arguments = None
while self.input:
- line = self._line()
+ line = self._line(lookahead=True)
match = checksum_re.match(line.lstrip())
arguments = match.group(1) if match else None
if arguments:
@@ -1832,6 +1833,7 @@ __iadd__
__iand__
__ifloordiv__
__ilshift__
+__imatmul__
__imod__
__imul__
__index__
@@ -1848,6 +1850,7 @@ __le__
__len__
__lshift__
__lt__
+__matmul__
__mod__
__mul__
__neg__
@@ -1862,6 +1865,7 @@ __rdivmod__
__repr__
__rfloordiv__
__rlshift__
+__rmatmul__
__rmod__
__rmul__
__ror__
@@ -2424,11 +2428,13 @@ class int_converter(CConverter):
format_unit = 'i'
c_ignored_default = "0"
- def converter_init(self, *, types='int'):
+ def converter_init(self, *, types='int', type=None):
if types == 'str':
self.format_unit = 'C'
elif types != 'int':
fail("int_converter: illegal 'types' argument")
+ if type != None:
+ self.type = type
class unsigned_int_converter(CConverter):
type = 'unsigned int'
@@ -2531,9 +2537,9 @@ class str_converter(CConverter):
length=False, nullable=False, zeroes=False):
types = set(types.strip().split())
- bytes_type = set(("bytes",))
- str_type = set(("str",))
- all_3_type = set(("bytearray",)) | bytes_type | str_type
+ bytes_type = {"bytes"}
+ str_type = {"str"}
+ all_3_type = {"bytearray"} | bytes_type | str_type
is_bytes = types == bytes_type
is_str = types == str_type
is_all_3 = types == all_3_type
@@ -2629,12 +2635,12 @@ class Py_buffer_converter(CConverter):
fail("The only legal default value for Py_buffer is None.")
self.c_default = self.c_ignored_default
types = set(types.strip().split())
- bytes_type = set(('bytes',))
- bytearray_type = set(('bytearray',))
- buffer_type = set(('buffer',))
- rwbuffer_type = set(('rwbuffer',))
- robuffer_type = set(('robuffer',))
- str_type = set(('str',))
+ bytes_type = {'bytes'}
+ bytearray_type = {'bytearray'}
+ buffer_type = {'buffer'}
+ rwbuffer_type = {'rwbuffer'}
+ robuffer_type = {'robuffer'}
+ str_type = {'str'}
bytes_bytearray_buffer_type = bytes_type | bytearray_type | buffer_type
format_unit = None
@@ -2863,10 +2869,11 @@ class long_return_converter(CReturnConverter):
type = 'long'
conversion_fn = 'PyLong_FromLong'
cast = ''
+ unsigned_cast = ''
def render(self, function, data):
self.declare(data)
- self.err_occurred_if("_return_value == -1", data)
+ self.err_occurred_if("_return_value == {}-1".format(self.unsigned_cast), data)
data.return_conversion.append(
''.join(('return_value = ', self.conversion_fn, '(', self.cast, '_return_value);\n')))
@@ -2887,10 +2894,12 @@ class init_return_converter(long_return_converter):
class unsigned_long_return_converter(long_return_converter):
type = 'unsigned long'
conversion_fn = 'PyLong_FromUnsignedLong'
+ unsigned_cast = '(unsigned long)'
class unsigned_int_return_converter(unsigned_long_return_converter):
type = 'unsigned int'
cast = '(unsigned long)'
+ unsigned_cast = '(unsigned int)'
class Py_ssize_t_return_converter(long_return_converter):
type = 'Py_ssize_t'
@@ -2899,6 +2908,7 @@ class Py_ssize_t_return_converter(long_return_converter):
class size_t_return_converter(long_return_converter):
type = 'size_t'
conversion_fn = 'PyLong_FromSize_t'
+ unsigned_cast = '(size_t)'
class double_return_converter(CReturnConverter):