aboutsummaryrefslogtreecommitdiffstats
path: root/tools/snippets_translate/converter.py
Commit message (Collapse)AuthorAgeFilesLines
* snippets_translate: Qualify enumerationsFriedemann Kleint2025-02-041-0/+3
| | | | | | | | | | | Qualify common enumerations. Add a separate file for this which can be re-used in a migration tool. Pick-to: 6.8 Task-number: PYSIDE-1735 Change-Id: Ieb30d68de82a509a92e39c40e5c7014afe3aeeb6 Reviewed-by: Ece Cinucen <[email protected]> Reviewed-by: Shyamnath Premnadh <[email protected]>
* snippets_translate: Fix flake8-warningsFriedemann Kleint2024-10-021-6/+5
| | | | | Change-Id: I91f211639846bb119d696244060f3013c52e59ed Reviewed-by: Shyamnath Premnadh <[email protected]>
* Python-3.10: Allow the new syntax for Python 3.9Christian Tismer2024-06-201-0/+1
| | | | | | | | Add a future statement to all Python source files. Task-number: PYSIDE-2786 Change-Id: Icd6688c7795a9e16fdcaa829686d57792df27690 Reviewed-by: Adrian Herrmann <[email protected]>
* snippets_translate: Prevent the variable initialization code from triggering ↵Friedemann Kleint2023-07-051-2/+7
| | | | | | | | | | | | | | | | for functions The code trying to change a constructor initialization: "Foo foo(2);" into "foo = Foo(2)" also triggered for member function definitions returning pointers "Foo *Foo:foo()" and many function declarations in headers. Restrict this by checking for a semicolon and non-presence of some function qualifiers. Pick-to: 6.5 Task-number: PYSIDE-1106 Change-Id: I224ac3e7321e57f1c5beecdcdb568a273330a664 Reviewed-by: Shyamnath Premnadh <[email protected]>
* snippets_translate: Replace :: in switch/case valuesFriedemann Kleint2023-03-301-1/+1
| | | | | | | | | | Amends f9ed8662794d14b995b53c73ee18693a114e9773 Pick-to: 6.5 Task-number: PYSIDE-1106 Change-Id: I774adaa377cba4bb8745c5ab86c1f52bead2ad86 Reviewed-by: Adrian Herrmann <[email protected]> Reviewed-by: Christian Tismer <[email protected]>
* snippets_translate: Implement rudimentary switch() handlingFriedemann Kleint2023-03-281-0/+27
| | | | | | | Pick-to: 6.5 Task-number: PYSIDE-1106 Change-Id: If19ac5a962aed846e4a127c652a9bae277999807 Reviewed-by: Cristian Maureira-Fredes <[email protected]>
* snippets_translate: Fix syntax errorFriedemann Kleint2023-03-021-1/+1
| | | | | | | | | | Amends 088acf9aec615372b297aab701757318e94b1fb5. Pick-to: 6.4 6.2 Task-number: PYSIDE-1106 Change-Id: I8b56874f5c686d11669b776f7398d0f9643e2bb5 Reviewed-by: Adrian Herrmann <[email protected]> Reviewed-by: Shyamnath Premnadh <[email protected]>
* snippets_translate: Do not append "()" when assigning special valuesFriedemann Kleint2023-02-281-1/+4
| | | | | | | | | | | It used to generate things like "b = False()" for variable assignments. Check the special values. Pick-to: 6.4 6.2 Task-number: PYSIDE-1106 Change-Id: I19cdcd4205369d0d5681151b1f1243d6a9a3f81e Reviewed-by: Adrian Herrmann <[email protected]> Reviewed-by: Christian Tismer <[email protected]>
* snippets_translate: Fix handling of operator new, take 2Friedemann Kleint2022-09-211-3/+2
| | | | | | | | | | Change e48dce39c1450e73f7cdef58cfeba29e1c3b8be3 introduced a bug appending "()" to member initalizer lists "m_member(new X()),". Fix that by using a regexp to loop through the expressions. Pick-to: 6.3 Change-Id: I6ce095749bcab74e92fb6dd630f25fb9fd517cc5 Reviewed-by: Cristian Maureira-Fredes <[email protected]>
* snippets_translate: Handle more qualifiersFriedemann Kleint2022-09-211-9/+7
| | | | | | | | | | Use a set instead of regexps. Pick-to: 6.3 Change-Id: If9c05fffd4f5ebb880d21cd24fafc0be5698ee66 Reviewed-by: Shyamnath Premnadh <[email protected]> Reviewed-by: Adrian Herrmann <[email protected]> Reviewed-by: Cristian Maureira-Fredes <[email protected]>
* snippets_translate: Handle "new" without parenthesesFriedemann Kleint2022-09-161-0/+2
| | | | | | | | Pick-to: 6.3 Change-Id: Ic50c175fab1f362c4c15e12f78e5ec440784e20c Reviewed-by: Adrian Herrmann <[email protected]> Reviewed-by: Shyamnath Premnadh <[email protected]> Reviewed-by: Cristian Maureira-Fredes <[email protected]>
* snippets_translate: Speed up regexp evaluationFriedemann Kleint2022-09-021-35/+66
| | | | | | | | | | Precompile the regular expressions and store the stripped string. Brings down user time from 2.3s to 2s, approximately. Pick-to: 6.3 Change-Id: If929dc0c85cbe3e797bb3ec01eff9c434a8c5527 Reviewed-by: Cristian Maureira-Fredes <[email protected]>
* snippets_translate: Handle connect statementsFriedemann Kleint2022-08-171-1/+5
| | | | | | | | | | Replace pairs of instance/pointer to member functions (PMF) by the Python dot notation and connect statements afterwards. Pick-to: 6.3 6.2 Task-number: PYSIDE-1721 Change-Id: I29f01d47026e3a7ab2407cf8c5b112533d5fb4dc Reviewed-by: Christian Tismer <[email protected]>
* snippet_translate double colon improvementsShyamnath Premnadh2022-06-241-1/+15
| | | | | | | | | | | | | | | | | | - Earlier, double colons were converted to dot operator only when the statement had a QObject class or namespace. For cases with a normal C++ namespace like MyClass::x, it was still translated without modifications to Python. - This patch adds an extra statement at the end of snippet_translate(x) to convert all the remaining scope resolution to dot operator On top of the above changes, it also addresses a FIXME to handle C++ iterator declaration in Python Task-number: PYSIDE-1972 Pick-to: 6.3 Change-Id: I45d12954835aaa569d1a4ef15badb366eaff0fe7 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Cristian Maureira-Fredes <[email protected]>
* Use SPDX license identifiersLucie Gérard2022-05-271-38/+2
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: I065150015bdb84a3096b5b39c061cf0a20ab637d Reviewed-by: Friedemann Kleint <[email protected]> Reviewed-by: Cristian Maureira-Fredes <[email protected]>
* flake8: fix styling issues in tools/Cristián Maureira-Fredes2022-04-021-12/+10
| | | | | | Change-Id: I8cbf5d521900df4f55abf8f68997f8a71437f722 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Friedemann Kleint <[email protected]>
* Purge remaining app.exec_()Friedemann Kleint2021-05-171-1/+1
| | | | | | | | Add a porting note. Pick-to: 6.1 Change-Id: I4ccb1dc2a3a5925e55e94e7f3d23b1fb199afe4a Reviewed-by: Christian Tismer <[email protected]>
* Long live snippets_translate!Cristian Maureira-Fredes2021-03-181-0/+334
This is not a C++ -> Python translator, but a line-by-line conversion tool. This scripts requires two arguments to identify a Qt and PySide directory including the sources. There is a set of file extensions that are currently omitted from the process, and for the ones that will be copied, there will be messages related if the file already exists or if it's new. If you use the '-v' option, you will see the C++ code and the converted Python code, so it's easy to check for issues and missing features. Also, two command line options were added to have a different behavior '--filter' to include a word to filter the full paths of all the snippets found (for example the name of a directory), and '-s/--single' to translate only a specific C++ file to be translated. Including test cases for transformations related to the C++ snippets. Fixes: PYSIDE-691 Pick-to: 6.0 Change-Id: I208e3a9139c7e84fe369a7c2ea93af240d83fa83 Reviewed-by: Christian Tismer <[email protected]>