diff options
Diffstat (limited to 'Tools/clinic/clinic.py')
-rwxr-xr-x | Tools/clinic/clinic.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index 65bad51..ee663e8 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: @@ -2425,11 +2426,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' @@ -2864,10 +2867,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'))) @@ -2888,10 +2892,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' @@ -2900,6 +2906,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): |