aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2022-09-22 03:01:04 +0000
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2022-09-22 03:01:04 +0000
commit09189296271176e32507100f32e9ee1b155b61f7 (patch)
treee67fef1c9c12a34cc6ad8102821e9b9b293918ff
parent61eaceb8d132ca8baf442eef12edc3dd708814e1 (diff)
parent6bc801c6a51915a7f1d4d0cefe64034121d0beab (diff)
Merge branch 6.3 into wip/6.3_pypy
-rw-r--r--build_scripts/platforms/linux.py3
-rw-r--r--build_scripts/platforms/macos.py3
-rw-r--r--sources/pyside6/doc/CMakeLists.txt2
-rw-r--r--sources/shiboken6/doc/scripts/patch_qhp.py16
-rw-r--r--tools/snippets_translate/converter.py21
-rw-r--r--tools/snippets_translate/handlers.py18
-rw-r--r--tools/snippets_translate/tests/test_converter.py4
7 files changed, 52 insertions, 15 deletions
diff --git a/build_scripts/platforms/linux.py b/build_scripts/platforms/linux.py
index 229d4397d..b0c025bc8 100644
--- a/build_scripts/platforms/linux.py
+++ b/build_scripts/platforms/linux.py
@@ -40,6 +40,7 @@
import os
from ..config import config
+from ..options import OPTION
from ..utils import (copy_icu_libs, copydir, copyfile, find_files_using_glob,
linux_patch_executable)
from ..versions import PYSIDE
@@ -95,7 +96,7 @@ def prepare_standalone_package_linux(self, _vars):
self.update_rpath_for_linux_qt_libraries(destination_lib_dir.format(**_vars))
# Patching designer to use the Qt libraries provided in the wheel
- if config.is_internal_pyside_build():
+ if config.is_internal_pyside_build() and not OPTION['NO_QT_TOOLS']:
assistant_path = "{st_build_dir}/{st_package_name}/assistant".format(**_vars)
linux_patch_executable(self._patchelf_path, assistant_path)
designer_path = "{st_build_dir}/{st_package_name}/designer".format(**_vars)
diff --git a/build_scripts/platforms/macos.py b/build_scripts/platforms/macos.py
index 69c2a436c..07a565f35 100644
--- a/build_scripts/platforms/macos.py
+++ b/build_scripts/platforms/macos.py
@@ -41,6 +41,7 @@ import fnmatch
import os
from ..config import config
+from ..options import OPTION
from ..utils import (copydir, copyfile, macos_add_rpath,
macos_fix_rpaths_for_library)
from ..versions import PYSIDE
@@ -90,7 +91,7 @@ def prepare_standalone_package_macos(self, _vars):
return True
# Patching designer to use the Qt libraries provided in the wheel
- if config.is_internal_pyside_build():
+ if config.is_internal_pyside_build() and not OPTION['NO_QT_TOOLS']:
_macos_patch_executable('assistant', _vars)
_macos_patch_executable('designer', _vars)
_macos_patch_executable('linguist', _vars)
diff --git a/sources/pyside6/doc/CMakeLists.txt b/sources/pyside6/doc/CMakeLists.txt
index 93c4b995a..c8f21b23a 100644
--- a/sources/pyside6/doc/CMakeLists.txt
+++ b/sources/pyside6/doc/CMakeLists.txt
@@ -215,7 +215,7 @@ else()
set(PATCH_QHP_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/../../shiboken6/doc/scripts/patch_qhp.py")
file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/html/PySide.qhp QHP_FILE)
add_custom_command(TARGET apidoc POST_BUILD
- COMMAND ${python_executable} ${PATCH_QHP_SCRIPT} -v pyside6 ${QHP_FILE}
+ COMMAND ${python_executable} ${PATCH_QHP_SCRIPT} -p -v pyside6 ${QHP_FILE}
COMMAND "${qhelpgenerator_binary}" ${QHP_FILE}
COMMENT "Generating QCH from a QHP file..."
VERBATIM
diff --git a/sources/shiboken6/doc/scripts/patch_qhp.py b/sources/shiboken6/doc/scripts/patch_qhp.py
index 9c7c875ae..586c8d1fe 100644
--- a/sources/shiboken6/doc/scripts/patch_qhp.py
+++ b/sources/shiboken6/doc/scripts/patch_qhp.py
@@ -50,9 +50,13 @@ registering the documentation in Qt Assistant."""
VIRTUAL_FOLDER_PATTERN = re.compile("(^.*virtualFolder.)doc(.*$)")
+# Strip "PySide6.QtModule." from index entries
+INDEX_CLASS_PATTERN = re.compile(r'^(\s*<keyword name=")PySide6\.[^.]+\.(.*\(class in .*)$')
+INDEX_METHOD_PATTERN = re.compile(r'^(\s+<keyword name=".* \()PySide6\.[^.]+\.(.*>)$')
virtual_folder = ""
+strip_pyside_module = False
def process_line(line):
@@ -61,6 +65,15 @@ def process_line(line):
if match:
print(f"{match.group(1)}{virtual_folder}{match.group(2)}")
return
+ if strip_pyside_module:
+ match = INDEX_METHOD_PATTERN.match(line)
+ if match:
+ print(f"{match.group(1)}{match.group(2)}")
+ return
+ match = INDEX_CLASS_PATTERN.match(line)
+ if match:
+ print(f"{match.group(1)}{match.group(2)}")
+ return
sys.stdout.write(line)
@@ -69,9 +82,12 @@ if __name__ == '__main__':
formatter_class=RawTextHelpFormatter)
arg_parser.add_argument('-v', '--vfolder', type=str,
help='String to be injected into the Qhp file.')
+ arg_parser.add_argument("--pyside", "-p", action="store_true",
+ help="Strip the PySide module path off the index entries.")
arg_parser.add_argument("file", type=str, help='Qhp filename.')
options = arg_parser.parse_args()
virtual_folder = options.vfolder
+ strip_pyside_module = options.pyside
try:
with fileinput.input(options.file, inplace=True,
diff --git a/tools/snippets_translate/converter.py b/tools/snippets_translate/converter.py
index a0650b3af..98de860b2 100644
--- a/tools/snippets_translate/converter.py
+++ b/tools/snippets_translate/converter.py
@@ -46,6 +46,7 @@ from handlers import (handle_array_declarations, handle_casts, handle_class,
handle_inc_dec, handle_include, handle_keywords,
handle_methods_return_type, handle_negate,
handle_type_var_declaration, handle_useless_qt_classes,
+ handle_new,
handle_void_functions, handle_qt_connects)
from parse_utils import dstrip, get_indent, remove_ref
@@ -61,8 +62,6 @@ ELSE_REPLACEMENT_PATTERN = re.compile(r"}? *else *{?")
CLASS_PATTERN = re.compile(r"^ *class ")
STRUCT_PATTERN = re.compile(r"^ *struct ")
DELETE_PATTERN = re.compile(r"^ *delete ")
-PUBLIC_PATTERN = re.compile(r"^public:$")
-PRIVATE_PATTERN = re.compile(r"^private:$")
VAR1_PATTERN = re.compile(r"^[a-zA-Z0-9]+(<.*?>)? [\w\*\&]+(\(.*?\))? ?(?!.*=|:).*$")
VAR2_PATTERN = re.compile(r"^[a-zA-Z0-9]+(<.*?>)? [\w]+::[\w\*\&]+\(.*\)$")
VAR3_PATTERN = re.compile(r"^[a-zA-Z0-9]+(<.*?>)? [\w\*]+ *= *[\w\.\"\']*(\(.*?\))?")
@@ -75,6 +74,10 @@ ITERATOR_PATTERN = re.compile(r"(std::)?[\w]+<[\w]+>::(const_)?iterator")
SCOPE_PATTERN = re.compile(r"[\w]+::")
+QUALIFIERS = {"public:", "protected:", "private:", "public slots:",
+ "protected slots:", "private slots:", "signals:"}
+
+
def snippet_translate(x):
## Cases which are not C++
@@ -127,9 +130,7 @@ def snippet_translate(x):
# This contains an extra whitespace because of some variables
# that include the string 'new'
if "new " in x:
- x = x.replace("new ", "")
- if not x.endswith(")"): # "new Foo" -> "new Foo()"
- x += "()"
+ x = handle_new(x)
# Handle 'const'
# Some variables/functions have the word 'const' so we explicitly
@@ -251,13 +252,9 @@ def snippet_translate(x):
if DELETE_PATTERN.search(x):
return x.replace("delete", "del")
- # 'public:'
- if PUBLIC_PATTERN.search(xs):
- return x.replace("public:", "# public")
-
- # 'private:'
- if PRIVATE_PATTERN.search(xs):
- return x.replace("private:", "# private")
+ # 'public:', etc
+ if xs in QUALIFIERS:
+ return f"# {x}".replace(":", "")
# For expressions like: `Type var`
# which does not contain a `= something` on the right side
diff --git a/tools/snippets_translate/handlers.py b/tools/snippets_translate/handlers.py
index 642db24cb..8a074a040 100644
--- a/tools/snippets_translate/handlers.py
+++ b/tools/snippets_translate/handlers.py
@@ -75,6 +75,7 @@ COUT_ENDL_PATTERN = re.compile(r"cout *<<(.*)<< *.*endl")
COUT1_PATTERN = re.compile(r" *<< *")
COUT2_PATTERN = re.compile(r".*cout *<<")
COUT_ENDL2_PATTERN = re.compile(r"<< +endl")
+NEW_PATTERN = re.compile(r"new +([a-zA-Z][a-zA-Z0-9_]*)")
def handle_condition(x, name):
@@ -548,6 +549,23 @@ def handle_useless_qt_classes(x):
return x
+def handle_new(x):
+ """Parse operator new() and add parentheses were needed:
+ func(new Foo, new Bar(x))" -> "func(Foo(), Bar(x))"""
+ result = ""
+ last_pos = 0
+ for match in NEW_PATTERN.finditer(x):
+ end = match.end(0)
+ parentheses_needed = end >= len(x) or x[end] != "("
+ type_name = match.group(1)
+ result += x[last_pos:match.start(0)] + type_name
+ if parentheses_needed:
+ result += "()"
+ last_pos = end
+ result += x[last_pos:]
+ return result
+
+
# The code below handles pairs of instance/pointer to member functions (PMF)
# which appear in Qt in connect statements like:
# "connect(fontButton, &QAbstractButton::clicked, this, &Dialog::setFont)".
diff --git a/tools/snippets_translate/tests/test_converter.py b/tools/snippets_translate/tests/test_converter.py
index 28436e846..813c07ac5 100644
--- a/tools/snippets_translate/tests/test_converter.py
+++ b/tools/snippets_translate/tests/test_converter.py
@@ -101,6 +101,10 @@ def test_else():
def test_new():
assert st("a = new Something(...);") == "a = Something(...)"
assert st("a = new Something") == "a = Something()"
+ assert st("foo(new X, new Y(b), new Z)") == "foo(X(), Y(b), Z())"
+ # Class member initialization list
+ assert st("m_mem(new Something(p)),") == "m_mem(Something(p)),"
+ assert st("m_mem(new Something),") == "m_mem(Something()),"
def test_semicolon():