aboutsummaryrefslogtreecommitdiffstats
path: root/tools/snippets_translate/tests
Commit message (Collapse)AuthorAgeFilesLines
* snippets_translate: Replace C++ ++/-- operators by +=/-=Friedemann Kleint2024-10-021-2/+2
| | | | | | | Generate "var += 1" instead of "var = var + 1". Change-Id: Ia9b3b3e4135156ebac8b7d5b1f47c735e2be1458 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* snippets_translate: Fix flake8-warningsFriedemann Kleint2024-10-021-7/+8
| | | | | Change-Id: I91f211639846bb119d696244060f3013c52e59ed Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* Python-3.10: Allow the new syntax for Python 3.9Christian Tismer2024-06-202-0/+2
| | | | | | | | Add a future statement to all Python source files. Task-number: PYSIDE-2786 Change-Id: Icd6688c7795a9e16fdcaa829686d57792df27690 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
* snippets_translate: Prevent the variable initialization code from triggering ↵Friedemann Kleint2023-07-051-2/+6
| | | | | | | | | | | | | | | | 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 <Shyamnath.Premnadh@qt.io>
* snippets_translate: Fix repetitive snippet ID linesFriedemann Kleint2023-04-271-12/+22
| | | | | | | | | | | | | | | | | | | | When writing consecutive snippets like // [1] line1 // [1] [2] line2 // [2] the line "// [1] [2]" would appear twice as end marker of snippet 1 and start marker of snippet 2, causing QtXmlToSphinx to extract an empty snippet for [2]. Fix by reconstructing the ID lines to use one ID per line. Task-number: PYSIDE-1106 Pick-to: 6.5 Change-Id: I0d7c0b30ff6bcc51c7d9ea6c9bfc844316a41c67 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* snippets_translate: Replace :: in switch/case valuesFriedemann Kleint2023-03-301-2/+2
| | | | | | | | | | Amends f9ed8662794d14b995b53c73ee18693a114e9773 Pick-to: 6.5 Task-number: PYSIDE-1106 Change-Id: I774adaa377cba4bb8745c5ab86c1f52bead2ad86 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* snippets_translate: Implement rudimentary switch() handlingFriedemann Kleint2023-03-281-0/+34
| | | | | | | Pick-to: 6.5 Task-number: PYSIDE-1106 Change-Id: If19ac5a962aed846e4a127c652a9bae277999807 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* snippets_translate: Improve connect handlingFriedemann Kleint2023-03-281-0/+15
| | | | | | | | | | Extend the matching to recognize connects for member variables (m_ui.button), remove smart pointer accessor. Pick-to: 6.5 Task-number: PYSIDE-1106 Change-Id: Ib68df3d9d31a8de64059832c4c60ad4b20bf78e1 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* snippets_translate: Do not append "()" when assigning special valuesFriedemann Kleint2023-02-281-0/+2
| | | | | | | | | | | 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 <adrian.herrmann@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* snippets_translate: Fix new string literalsFriedemann Kleint2023-02-281-1/+1
| | | | | | | | | | | | Use a regexp to change u"s"_s to "s". Amends 4315cfb44eaa8abd57c685390c6b9d3aff09ba0f. Pick-to: 6.4 6.2 Task-number: PYSIDE-2151 Task-number: PYSIDE-1106 Change-Id: Id8a2cdee5966dfc4c5fbff9df6e7b9eeb7c0e436 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* snippets_translate: Improve handling of string literalsFriedemann Kleint2022-12-141-0/+5
| | | | | | | | | | | Add QStringLiteral and others and handle multiple occurrences per line better by making the patterns more discriminative. Pick-to: 6.4 6.2 Task-number: PYSIDE-2151 Task-number: PYSIDE-1106 Change-Id: I37589dfafe27d69480db665363d5900d163014da Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* snippets_translate: Remove qAsConst(), std::as_const() from for loopsFriedemann Kleint2022-10-131-1/+1
| | | | | | | Pick-to: 6.2 Change-Id: If31883998a08073ecf4ca7bfb91ee000cc2f630f Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* snippets_translate: Fix handling of operator new, take 2Friedemann Kleint2022-09-211-0/+4
| | | | | | | | | | 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 <cristian.maureira-fredes@qt.io>
* snippets_translate: Handle "new" without parenthesesFriedemann Kleint2022-09-161-1/+1
| | | | | | | | Pick-to: 6.3 Change-Id: Ic50c175fab1f362c4c15e12f78e5ec440784e20c Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* snippets_translate: Use super() for base class initializationFriedemann Kleint2022-09-121-6/+6
| | | | | | | Pick-to: 6.3 Change-Id: Ie7642f45d59839a52a650abd47383e30e508b8d3 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* snippets_translate: Refactor handling of castsFriedemann Kleint2022-09-021-0/+4
| | | | | | | | | Use one non-greedy regexp instead of several ones. Pick-to: 6.3 Change-Id: I192476b5f184d22227fdd0e26ec9408098114b0e Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
* snippets_translate: Handle connect statementsFriedemann Kleint2022-08-171-2/+2
| | | | | | | | | | 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 <tismer@stackless.com>
* snippets_translate: Do convert return statements to functionsFriedemann Kleint2022-08-161-0/+1
| | | | | | | | Pick-to: 6.3 6.2 Task-number: PYSIDE-2030 Change-Id: Icd6f3a639449d737933d4420fbeb891224999b59 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* snippets_translate: Fix indented conditionsFriedemann Kleint2022-08-151-0/+1
| | | | | | | | | | Adapt the regexes accordingly. Pick-to: 6.3 6.2 Fixes: PYSIDE-2030 Change-Id: I6515b2ca0fe23c753feadeb491173b72889abba5 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* snippets_translate: Fix the testsFriedemann Kleint2022-08-151-32/+55
| | | | | | | | | | | | Change c4a266e38fe5bdce707ad6b123fa88bb4f10dff3 broke the test by changing the function values and signature. Pick-to: 6.3 6.2 Task-number: PYSIDE-1984 Task-number: PYSIDE-2030 Change-Id: I88412f3f4398aa7fd0748d9ad3b7ba2a75cf9ff0 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* snippet translate: fix get_snippetsJaime Resano2022-06-292-9/+95
| | | | | | | | | | - Fixed the get_snippets function which did not work properly when more than one snippet id was on the same line. - Tests were added Pick-to: 6.2 6.3 Change-Id: Idffbb0aee258522d7855e2ad0e2b8df61a1872c8 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* snippet_translate double colon improvementsShyamnath Premnadh2022-06-241-2/+8
| | | | | | | | | | | | | | | | | | - 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 <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-272-76/+4
| | | | | | | | | | | 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 <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Documentation: Loosen snippet patternFriedemann Kleint2021-12-081-0/+53
| | | | | | | | | Some examples(queuedcustomtype, codeeditor) use '//![snippet]'. Change-Id: If13fd12f8eff8a41a3b8e4f74a7bf3a03c8b39b3 Pick-to: 6.2 Task-number: PYSIDE-1721 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Long live snippets_translate!Cristian Maureira-Fredes2021-03-181-0/+439
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 <tismer@stackless.com>