diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-06-21 08:19:54 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-06-21 11:06:37 +0200 |
| commit | dedfebbc438ed2f5f6869092ee10e68f9ffd8a36 (patch) | |
| tree | 148a8f39a33bc1298071bd45f43d46f1a1c109dc /tools/qtpy2cpp_lib/formatter.py | |
| parent | bc17293f08a0fa1524b4b1a6cbc49fd1a59967fc (diff) | |
qtpy2cpp: Further improvements
- Fix indentation of context manager scopes
- Fix indentation of augmented assignments
- Handle range based for over variable
- Remove FIXME comment for function types
- Write base name in header comment for testability
Pick-to: 6.3
Task-number: PYSIDE-1945
Change-Id: Ib30af672e56434c30d98f8dce2cb73ef0a1512a8
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'tools/qtpy2cpp_lib/formatter.py')
| -rw-r--r-- | tools/qtpy2cpp_lib/formatter.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/tools/qtpy2cpp_lib/formatter.py b/tools/qtpy2cpp_lib/formatter.py index 98ba3f095..9a38e803d 100644 --- a/tools/qtpy2cpp_lib/formatter.py +++ b/tools/qtpy2cpp_lib/formatter.py @@ -86,6 +86,9 @@ def format_for_loop(f_node): elif isinstance(f_node.iter, ast.List): # Range based for over list result += ': ' + format_literal_list(f_node.iter) + elif isinstance(f_node.iter, ast.Name): + # Range based for over variable + result += ': ' + f_node.iter.id result += ') {' return result @@ -248,20 +251,15 @@ class CppFormatter(Indenter): """Print a function definition with arguments""" self._output_file.write('\n') arguments = format_function_def_arguments(f_node) - warn = True if f_node.name == '__init__' and class_context: # Constructor name = class_context - warn = len(arguments) > 0 elif f_node.name == '__del__' and class_context: # Destructor name = '~' + class_context - warn = False else: return_type = "void" if f_node.returns and isinstance(f_node.returns, ast.Name): return_type = _fix_function_argument_type(f_node.returns.id, True) name = return_type + " " + f_node.name self.indent_string(f'{name}({arguments})') - if warn: - self._output_file.write(' /* FIXME: types */') self._output_file.write('\n') self.indent_line('{') |
