aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-09-05 15:42:11 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-09-06 09:54:34 +0200
commit7da5e8f0da921788d1159ebe4d4759b5c4736e5c (patch)
treeda64d1975a5bb172def6af3517a9f2fd67b05f93
parent1fabac91e548fdb537dce25b3b9a58235275804c (diff)
shiboken6: Replace options related to nb_zero by nb_bool
nb_zero is Python 2 terminology. Rename the related functions and use new options. [ChangeLog][shiboken6] The command line options --use-operator-bool-as-nb_nonzero and --use-isnull-as-nb_nonzero have been replaced by --use-operator-bool-as-nb-bool and --use-isnull-as-nb-bool, respectivily to match Python 3 terminology. The old options continue to work. Change-Id: I1201f4b15e021c8df96740149c20fa1478c12ae1 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
-rw-r--r--examples/samplebinding/CMakeLists.txt2
-rw-r--r--examples/scriptableapplication/CMakeLists.txt2
-rw-r--r--sources/pyside6/cmake/PySideSetup.cmake2
-rw-r--r--sources/shiboken6/doc/shibokengenerator.rst12
-rw-r--r--sources/shiboken6/doc/typesystem_specialfunctions.rst4
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp4
-rw-r--r--sources/shiboken6/generator/shiboken/shibokengenerator.cpp29
-rw-r--r--sources/shiboken6/generator/shiboken/shibokengenerator.h8
8 files changed, 37 insertions, 26 deletions
diff --git a/examples/samplebinding/CMakeLists.txt b/examples/samplebinding/CMakeLists.txt
index e7d23db7d..4807904c1 100644
--- a/examples/samplebinding/CMakeLists.txt
+++ b/examples/samplebinding/CMakeLists.txt
@@ -135,7 +135,7 @@ target_compile_definitions(${sample_library} PRIVATE BINDINGS_BUILD)
# Set up the options to pass to shiboken.
set(shiboken_options --generator-set=shiboken --enable-parent-ctor-heuristic
- --enable-return-value-heuristic --use-isnull-as-nb_nonzero
+ --enable-return-value-heuristic --use-isnull-as-nb-bool
--avoid-protected-hack
-I${CMAKE_SOURCE_DIR}
-T${CMAKE_SOURCE_DIR}
diff --git a/examples/scriptableapplication/CMakeLists.txt b/examples/scriptableapplication/CMakeLists.txt
index 31174628c..fbfa00b98 100644
--- a/examples/scriptableapplication/CMakeLists.txt
+++ b/examples/scriptableapplication/CMakeLists.txt
@@ -101,7 +101,7 @@ set(WRAPPED_HEADER ${CMAKE_SOURCE_DIR}/wrappedclasses.h)
set(TYPESYSTEM_FILE ${CMAKE_SOURCE_DIR}/scriptableapplication.xml)
set(SHIBOKEN_OPTIONS --generator-set=shiboken --enable-parent-ctor-heuristic
- --enable-pyside-extensions --enable-return-value-heuristic --use-isnull-as-nb_nonzero
+ --enable-pyside-extensions --enable-return-value-heuristic --use-isnull-as-nb-bool
--avoid-protected-hack
${INCLUDES}
-I${CMAKE_SOURCE_DIR}
diff --git a/sources/pyside6/cmake/PySideSetup.cmake b/sources/pyside6/cmake/PySideSetup.cmake
index 4bd3d2831..d6f20bd11 100644
--- a/sources/pyside6/cmake/PySideSetup.cmake
+++ b/sources/pyside6/cmake/PySideSetup.cmake
@@ -222,7 +222,7 @@ set(GENERATOR_EXTRA_FLAGS --generator-set=shiboken
--enable-parent-ctor-heuristic
--enable-pyside-extensions
--enable-return-value-heuristic
- --use-isnull-as-nb_nonzero)
+ --use-isnull-as-nb-bool)
use_protected_as_public_hack()
# Build with Address sanitizer enabled if requested. This may break things, so use at your own risk.
diff --git a/sources/shiboken6/doc/shibokengenerator.rst b/sources/shiboken6/doc/shibokengenerator.rst
index 9a56cb967..09a812eea 100644
--- a/sources/shiboken6/doc/shibokengenerator.rst
+++ b/sources/shiboken6/doc/shibokengenerator.rst
@@ -112,21 +112,25 @@ Options
``--avoid-protected-hack``
Avoid the use of the '#define protected public' hack.
-.. _use-isnull-as-nb-nonzero:
+.. _use-isnull-as-nb-bool:
-``--use-isnull-as-nb_nonzero``
+``--use-isnull-as-nb-bool``
If a class has an isNull() const method, it will be used to
compute the value of boolean casts (see :ref:`bool-cast`).
+ The legacy option ``--use-isnull-as-nb_nonzero`` has the
+ same effect, but should not be used any more.
``--lean-headers``
Forward declare classes in module headers instead of including their class
headers where possible.
-.. _use-operator-bool-as-nb-nonzero:
+.. _use-operator-bool-as-nb-bool:
-``--use-operator-bool-as-nb_nonzero``
+``--use-operator-bool-as-nb-bool``
If a class has an operator bool, it will be used to compute
the value of boolean casts (see :ref:`bool-cast`).
+ The legacy option ``--use-operator-bool-as-nb_nonzero`` has the
+ same effect, but should not be used any more.
.. _no-implicit-conversions:
diff --git a/sources/shiboken6/doc/typesystem_specialfunctions.rst b/sources/shiboken6/doc/typesystem_specialfunctions.rst
index ed6137792..78a6ff489 100644
--- a/sources/shiboken6/doc/typesystem_specialfunctions.rst
+++ b/sources/shiboken6/doc/typesystem_specialfunctions.rst
@@ -47,8 +47,8 @@ in boolean expressions. In C++, this is commonly implemented as
In Python, the function ``__bool__`` is used for this. shiboken can generate
this functions depending on the command line options
-:ref:`--use-operator-bool-as-nb_nonzero <use-operator-bool-as-nb-nonzero>`
-and :ref:`--use-isnull-as-nb_nonzero <use-isnull-as-nb-nonzero>`,
+:ref:`--use-operator-bool-as-nb-bool <use-operator-bool-as-nb-bool>`
+and :ref:`--use-isnull-as-nb-bool <use-isnull-as-nb-bool>`,
which can be overridden by specifying the boolean attributes
**isNull** or **operator-bool** on the :ref:`value-type` or :ref:`object-type`
elements in typesystem XML.
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index 7866a702a..7ff4961f5 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -222,7 +222,7 @@ CppGenerator::BoolCastFunctionOptional
}
auto mode = te->operatorBoolMode();
- if (useOperatorBoolAsNbNonZero()
+ if (useOperatorBoolAsNbBool()
? mode != TypeSystem::BoolCast::Disabled : mode == TypeSystem::BoolCast::Enabled) {
const auto func = metaClass->findOperatorBool();
if (func)
@@ -230,7 +230,7 @@ CppGenerator::BoolCastFunctionOptional
}
mode = te->isNullMode();
- if (useIsNullAsNbNonZero()
+ if (useIsNullAsNbBool()
? mode != TypeSystem::BoolCast::Disabled : mode == TypeSystem::BoolCast::Enabled) {
const auto func = metaClass->findQtIsNullMethod();
if (func)
diff --git a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp
index 62602381c..17c882f0d 100644
--- a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp
@@ -52,8 +52,11 @@ using namespace Qt::StringLiterals;
static const char PARENT_CTOR_HEURISTIC[] = "enable-parent-ctor-heuristic";
static const char RETURN_VALUE_HEURISTIC[] = "enable-return-value-heuristic";
static const char DISABLE_VERBOSE_ERROR_MESSAGES[] = "disable-verbose-error-messages";
+static const char USE_ISNULL_AS_NB_BOOL[] = "use-isnull-as-nb-bool";
+// FIXME PYSIDE 7: Remove USE_ISNULL_AS_NB_NONZERO/USE_OPERATOR_BOOL_AS_NB_NONZERO
static const char USE_ISNULL_AS_NB_NONZERO[] = "use-isnull-as-nb_nonzero";
-static const char USE_OPERATOR_BOOL_AS_NB_NONZERO[] = "use-operator-bool-as-nb_nonzero";
+static const char USE_OPERATOR_BOOL_AS_NB_BOOL[] = "use-operator-bool-as-nb-bool";
+static const char USE_OPERATOR_BOOL_AS_NB_NONZERO[] = "use-operator-bool-as-nb-nonzero";
static const char WRAPPER_DIAGNOSTICS[] = "wrapper-diagnostics";
static const char NO_IMPLICIT_CONVERSIONS[] = "no-implicit-conversions";
static const char LEAN_HEADERS[] = "lean-headers";
@@ -2224,12 +2227,12 @@ Generator::OptionDescriptions ShibokenGenerator::options() const
{QLatin1StringView(RETURN_VALUE_HEURISTIC),
u"Enable heuristics to detect parent relationship on return values\n"
"(USE WITH CAUTION!)"_s},
- {QLatin1StringView(USE_ISNULL_AS_NB_NONZERO),
+ {QLatin1StringView(USE_ISNULL_AS_NB_BOOL),
u"If a class have an isNull() const method, it will be used to compute\n"
"the value of boolean casts"_s},
{QLatin1StringView(LEAN_HEADERS),
u"Forward declare classes in module headers"_s},
- {QLatin1StringView(USE_OPERATOR_BOOL_AS_NB_NONZERO),
+ {QLatin1StringView(USE_OPERATOR_BOOL_AS_NB_BOOL),
u"If a class has an operator bool, it will be used to compute\n"
"the value of boolean casts"_s},
{QLatin1StringView(NO_IMPLICIT_CONVERSIONS),
@@ -2250,12 +2253,16 @@ bool ShibokenGenerator::handleOption(const QString &key, const QString &value)
return (m_userReturnValueHeuristic = true);
if (key == QLatin1StringView(DISABLE_VERBOSE_ERROR_MESSAGES))
return (m_verboseErrorMessagesDisabled = true);
- if (key == QLatin1StringView(USE_ISNULL_AS_NB_NONZERO))
- return (m_useIsNullAsNbNonZero = true);
+ if (key == QLatin1StringView(USE_ISNULL_AS_NB_BOOL)
+ || key == QLatin1StringView(USE_ISNULL_AS_NB_NONZERO)) {
+ return (m_useIsNullAsNbBool = true);
+ }
if (key == QLatin1StringView(LEAN_HEADERS))
return (m_leanHeaders= true);
- if (key == QLatin1StringView(USE_OPERATOR_BOOL_AS_NB_NONZERO))
- return (m_useOperatorBoolAsNbNonZero = true);
+ if (key == QLatin1StringView(USE_OPERATOR_BOOL_AS_NB_BOOL)
+ || key == QLatin1StringView(USE_OPERATOR_BOOL_AS_NB_NONZERO)) {
+ return (m_useOperatorBoolAsNbBool = true);
+ }
if (key == QLatin1StringView(NO_IMPLICIT_CONVERSIONS)) {
m_generateImplicitConversions = false;
return true;
@@ -2280,9 +2287,9 @@ bool ShibokenGenerator::useReturnValueHeuristic() const
return m_userReturnValueHeuristic;
}
-bool ShibokenGenerator::useIsNullAsNbNonZero() const
+bool ShibokenGenerator::useIsNullAsNbBool() const
{
- return m_useIsNullAsNbNonZero;
+ return m_useIsNullAsNbBool;
}
bool ShibokenGenerator::leanHeaders() const
@@ -2290,9 +2297,9 @@ bool ShibokenGenerator::leanHeaders() const
return m_leanHeaders;
}
-bool ShibokenGenerator::useOperatorBoolAsNbNonZero() const
+bool ShibokenGenerator::useOperatorBoolAsNbBool() const
{
- return m_useOperatorBoolAsNbNonZero;
+ return m_useOperatorBoolAsNbBool;
}
bool ShibokenGenerator::generateImplicitConversions() const
diff --git a/sources/shiboken6/generator/shiboken/shibokengenerator.h b/sources/shiboken6/generator/shiboken/shibokengenerator.h
index 492fb1910..146d16244 100644
--- a/sources/shiboken6/generator/shiboken/shibokengenerator.h
+++ b/sources/shiboken6/generator/shiboken/shibokengenerator.h
@@ -290,11 +290,11 @@ protected:
/// Returns true if the user enabled the so called "return value heuristic".
bool useReturnValueHeuristic() const;
/// Returns true if the generator should use the result of isNull()const to compute boolean casts.
- bool useIsNullAsNbNonZero() const;
+ bool useIsNullAsNbBool() const;
/// Whether to generate lean module headers
bool leanHeaders() const;
/// Returns true if the generator should use operator bool to compute boolean casts.
- bool useOperatorBoolAsNbNonZero() const;
+ bool useOperatorBoolAsNbBool() const;
/// Generate implicit conversions of function arguments
bool generateImplicitConversions() const;
static QString cppApiVariableName(const QString &moduleName = QString());
@@ -457,10 +457,10 @@ private:
bool m_useCtorHeuristic = false;
bool m_userReturnValueHeuristic = false;
bool m_verboseErrorMessagesDisabled = false;
- bool m_useIsNullAsNbNonZero = false;
+ bool m_useIsNullAsNbBool = false;
// FIXME PYSIDE 7 Flip m_leanHeaders default or remove?
bool m_leanHeaders = false;
- bool m_useOperatorBoolAsNbNonZero = false;
+ bool m_useOperatorBoolAsNbBool = false;
// FIXME PYSIDE 7 Flip generateImplicitConversions default or remove?
bool m_generateImplicitConversions = true;
bool m_wrapperDiagnostics = false;