From 596ecbee9c7d094477d197258515b95e6e27f36f Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Wed, 20 Nov 2024 14:59:14 +1000 Subject: [PATCH] [sip] Implement MappedType for unique_ptr to Python conversion --- python/PyQt6/core/conversions.sip | 18 ++++++++++++++++++ python/core/conversions.sip | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/python/PyQt6/core/conversions.sip b/python/PyQt6/core/conversions.sip index 2053f181eee..e16de1eb600 100644 --- a/python/PyQt6/core/conversions.sip +++ b/python/PyQt6/core/conversions.sip @@ -1242,6 +1242,24 @@ which are not wrapped by PyQt: %End }; +template +%MappedType std::unique_ptr< TYPE > /NoRelease,AllowNone,TypeHint="Optional[TYPE]",TypeHintValue="TYPE"/ +{ +%TypeHeaderCode +#include +%End + +%ConvertFromTypeCode + const sipTypeDef *sip_type = sipFindType("TYPE*"); + return sipConvertFromNewType(sipCpp->release(), sip_type, NULL); +%End + +%ConvertToTypeCode + // only one way for now... + return 0; +%End +}; + template %MappedType QVector< QVector > { diff --git a/python/core/conversions.sip b/python/core/conversions.sip index 0570b253649..68bbea27737 100644 --- a/python/core/conversions.sip +++ b/python/core/conversions.sip @@ -1241,6 +1241,25 @@ which are not wrapped by PyQt: %End }; +template +%MappedType std::unique_ptr< TYPE > /NoRelease,AllowNone,TypeHint="Optional[TYPE]",TypeHintValue="TYPE"/ +{ +%TypeHeaderCode +#include +%End + +%ConvertFromTypeCode + const sipTypeDef *sip_type = sipFindType("TYPE*"); + return sipConvertFromNewType(sipCpp->release(), sip_type, NULL); +%End + +%ConvertToTypeCode + // only one way for now... + return 0; +%End +}; + + template %MappedType QVector< QVector > {