aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-02-25 11:25:42 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-02-25 11:25:42 +0100
commitb97ccab8c268d260f704e11b33d64fa31f74e258 (patch)
tree99faf72f67df4b78b13872b5c95a8f952e7b15ef
parent7a7952fc2e0809ef7f12a726376cec457897c364 (diff)
parentf324cced79a004d6ecb698a01189500384d0f966 (diff)
Merge remote-tracking branch 'origin/5.12' into dev
-rw-r--r--build_scripts/config.py4
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp2
-rw-r--r--sources/shiboken2/libshiboken/signature.cpp7
-rw-r--r--sources/shiboken2/shibokenmodule/support/signature/loader.py34
-rw-r--r--sources/shiboken2/tests/libsmart/smart.cpp16
-rw-r--r--sources/shiboken2/tests/libsmart/smart.h10
-rw-r--r--sources/shiboken2/tests/smartbinding/CMakeLists.txt2
-rw-r--r--sources/shiboken2/tests/smartbinding/smart_pointer_test.py13
-rw-r--r--sources/shiboken2/tests/smartbinding/typesystem_smart.xml4
9 files changed, 71 insertions, 21 deletions
diff --git a/build_scripts/config.py b/build_scripts/config.py
index 0b1547660..cad4e2f57 100644
--- a/build_scripts/config.py
+++ b/build_scripts/config.py
@@ -198,7 +198,7 @@ class Config(object):
elif self.internal_build_type == self.shiboken_generator_option_name:
setup_kwargs['name'] = self.shiboken_generator_st_name
setup_kwargs['description'] = "Python / C++ bindings generator"
- setup_kwargs['install_requires'] = [self.shiboken_module_st_name]
+ setup_kwargs['install_requires'] = ["{}=={}".format(self.shiboken_module_st_name, package_version)]
setup_kwargs['entry_points'] = {
'console_scripts': [
'shiboken2 = {}.scripts.shiboken_tool:main'.format(self.package_name()),
@@ -208,7 +208,7 @@ class Config(object):
elif self.internal_build_type == self.pyside_option_name:
setup_kwargs['name'] = self.pyside_st_name
setup_kwargs['description'] = "Python bindings for the Qt cross-platform application and UI framework"
- setup_kwargs['install_requires'] = [self.shiboken_module_st_name]
+ setup_kwargs['install_requires'] = ["{}=={}".format(self.shiboken_module_st_name, package_version)]
setup_kwargs['entry_points'] = {
'console_scripts': [
'pyside2-uic = {}.scripts.uic:main'.format(self.package_name()),
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 7fea87c1b..3ce07cf93 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -515,7 +515,7 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext)
// Replace the return type of the raw pointer getter method with the actual
// return type.
QString innerTypeName =
- classContext.preciseType()->getSmartPointerInnerType()->name();
+ classContext.preciseType()->getSmartPointerInnerType()->cppSignature();
QString pointerToInnerTypeName = innerTypeName + QLatin1Char('*');
// @TODO: This possibly leaks, but there are a bunch of other places where this
// is done, so this will be fixed in bulk with all the other cases, because the
diff --git a/sources/shiboken2/libshiboken/signature.cpp b/sources/shiboken2/libshiboken/signature.cpp
index da9c56c62..d6c26ac79 100644
--- a/sources/shiboken2/libshiboken/signature.cpp
+++ b/sources/shiboken2/libshiboken/signature.cpp
@@ -445,8 +445,11 @@ static const char PySide_PythonCode[] =
with open(__file__) as _f:
exec(compile(_f.read(), __file__, 'exec'))
except Exception as e:
- print('Exception:', e)
- traceback.print_exc(file=sys.stdout)
+ try:
+ from shiboken2.support.signature import loader
+ except:
+ print('Exception:', e)
+ traceback.print_exc(file=sys.stdout)
globals().update(locals())
)~";
diff --git a/sources/shiboken2/shibokenmodule/support/signature/loader.py b/sources/shiboken2/shibokenmodule/support/signature/loader.py
index 40ad95bdd..458759845 100644
--- a/sources/shiboken2/shibokenmodule/support/signature/loader.py
+++ b/sources/shiboken2/shibokenmodule/support/signature/loader.py
@@ -134,6 +134,21 @@ def formatannotation(annotation, base_module=None):
def _typevar__repr__(self):
return "typing." + self.__name__
+# Note also that during the tests we have a different encoding that would
+# break the Python license decorated files without an encoding line.
+
+# name used in signature.cpp
+def create_signature(props, key):
+ return layout.create_signature(props, key)
+
+# name used in signature.cpp
+def seterror_argument(args, func_name):
+ return errorhandler.seterror_argument(args, func_name)
+
+# name used in signature.cpp
+def make_helptext(func):
+ return errorhandler.make_helptext(func)
+
with ensure_import_support():
# We store all needed modules in signature_loader.
# This way, they are always accessible.
@@ -197,21 +212,10 @@ with ensure_import_support():
from support.signature.lib import enum_sig
put_into_loader_package(enum_sig)
from support.signature.parser import pyside_type_init
+ put_into_loader_package(pyside_type_init)
+ put_into_loader_package(create_signature)
+ put_into_loader_package(seterror_argument)
+ put_into_loader_package(make_helptext)
-# Note also that during the tests we have a different encoding that would
-# break the Python license decorated files without an encoding line.
-
-# name used in signature.cpp
-def create_signature(props, key):
- return layout.create_signature(props, key)
-
-# name used in signature.cpp
-def seterror_argument(args, func_name):
- return errorhandler.seterror_argument(args, func_name)
-
-# name used in signature.cpp
-def make_helptext(func):
- return errorhandler.make_helptext(func)
-
# end of file
diff --git a/sources/shiboken2/tests/libsmart/smart.cpp b/sources/shiboken2/tests/libsmart/smart.cpp
index dbe8efa66..4132c2fc8 100644
--- a/sources/shiboken2/tests/libsmart/smart.cpp
+++ b/sources/shiboken2/tests/libsmart/smart.cpp
@@ -68,6 +68,12 @@ SharedPtr<Integer> Obj::giveSharedPtrToInteger()
return o;
}
+SharedPtr<Smart::Integer2> Obj::giveSharedPtrToInteger2()
+{
+ SharedPtr<Smart::Integer2> o(new Smart::Integer2);
+ return o;
+}
+
int Obj::takeSharedPtrToObj(SharedPtr<Obj> pObj)
{
pObj->printObj();
@@ -172,3 +178,13 @@ void Registry::setShouldPrint(bool flag)
{
m_printStuff = flag;
}
+
+Smart::Integer2::Integer2()
+ : Integer ()
+{
+}
+
+Smart::Integer2::Integer2(const Smart::Integer2 &other)
+ : Integer (other)
+{
+}
diff --git a/sources/shiboken2/tests/libsmart/smart.h b/sources/shiboken2/tests/libsmart/smart.h
index ea64b4439..502187a11 100644
--- a/sources/shiboken2/tests/libsmart/smart.h
+++ b/sources/shiboken2/tests/libsmart/smart.h
@@ -189,6 +189,15 @@ public:
int m_int;
};
+namespace Smart {
+class LIB_SMART_API Integer2 : public Integer {
+public:
+ Integer2();
+ Integer2(const Integer2 &other);
+};
+}
+
+
// Couldn't name it Object because it caused some namespace clashes.
class LIB_SMART_API Obj {
public:
@@ -199,6 +208,7 @@ public:
Integer takeInteger(Integer val);
SharedPtr<Obj> giveSharedPtrToObj();
SharedPtr<Integer> giveSharedPtrToInteger();
+ SharedPtr<Smart::Integer2> giveSharedPtrToInteger2();
int takeSharedPtrToObj(SharedPtr<Obj> pObj);
int takeSharedPtrToInteger(SharedPtr<Integer> pInt);
diff --git a/sources/shiboken2/tests/smartbinding/CMakeLists.txt b/sources/shiboken2/tests/smartbinding/CMakeLists.txt
index 0fb7de825..ed6bcef0a 100644
--- a/sources/shiboken2/tests/smartbinding/CMakeLists.txt
+++ b/sources/shiboken2/tests/smartbinding/CMakeLists.txt
@@ -11,6 +11,8 @@ ${CMAKE_CURRENT_BINARY_DIR}/smart/integer_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/smart/sharedptr_obj_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/smart/sharedptr_integer_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/smart/registry_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/smart/smart_integer2_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/smart/sharedptr_integer2_wrapper.cpp
)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/smart-binding.txt.in"
diff --git a/sources/shiboken2/tests/smartbinding/smart_pointer_test.py b/sources/shiboken2/tests/smartbinding/smart_pointer_test.py
index 730b4a0da..62bfc0500 100644
--- a/sources/shiboken2/tests/smartbinding/smart_pointer_test.py
+++ b/sources/shiboken2/tests/smartbinding/smart_pointer_test.py
@@ -143,5 +143,18 @@ class SmartPointerTests(unittest.TestCase):
self.assertEqual(objCount(), 0)
self.assertEqual(integerCount(), 0)
+ def testSmartPointersWithNamespace(self):
+ # Create the main object
+ o = Obj()
+ self.assertEqual(objCount(), 1)
+
+ # Create a shared pointer to an Integer together with an Integer.
+ ptrToInteger = o.giveSharedPtrToInteger2()
+ self.assertEqual(objCount(), 1)
+ self.assertEqual(integerCount(), 2)
+
+ integer = ptrToInteger.data()
+ self.assertTrue(integer)
+
if __name__ == '__main__':
unittest.main()
diff --git a/sources/shiboken2/tests/smartbinding/typesystem_smart.xml b/sources/shiboken2/tests/smartbinding/typesystem_smart.xml
index a2654730d..b2deb18cb 100644
--- a/sources/shiboken2/tests/smartbinding/typesystem_smart.xml
+++ b/sources/shiboken2/tests/smartbinding/typesystem_smart.xml
@@ -17,7 +17,9 @@
<object-type name="Obj" />
<value-type name="Integer" />
-
+ <namespace-type name="Smart" generate="no">
+ <value-type name="Integer2" />
+ </namespace-type>
<!-- Just used to silence the warnings that shiboken doens't know what to do with this type -->
<custom-type name="RefData" />
</typesystem>