[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Really struggling on how to write a constructor corresponding to std::shared_ptr. need some help on 
From:       Suman Chatterjee <sum_chat () hotmail ! com>
Date:       2021-05-18 6:22:18
Message-ID: PU4P216MB10565ACE52BA01E9090E8889E52C9 () PU4P216MB1056 ! KORP216 ! PROD ! OUTLOOK ! COM
[Download RAW message or body]

Hi,
 I am struggling to write the sip file for a header file which contains a constructor \
with a std::shared_ptr


Attachment(std::shared_ptr<QRTImpl::AttachmentImpl> impl, QObject* parent);





This is what I tried :

 Attachment(SIP_PYCALLABLE m_impl,QObject* parent = \
0)[(std::shared_ptr<QRTImpl::AttachmentImpl>,QObject*)];  %MethodCode

    // Make sure the callable doesn't get garbage collected, this is needed because \
refcount for a1 is 0  // and the creation function pointer is passed to the metadata \
and it needs to be kept in memory.  Py_INCREF( a0 );

    Py_BEGIN_ALLOW_THREADS

    auto m_impl = [a0]() -> QRTImpl::AttachmentImpl *
    {
      QRTImpl::AttachmentImpl  *result = nullptr;
      SIP_BLOCK_THREADS
      PyObject *s = sipCallMethod( NULL, a0, NULL );
      int state;
      int sipIsError = 0;
      result = reinterpret_cast<QRT_Impl::AttachmentImpl* >( sipForceConvertToType( \
s, sipTypeQRTImpl_AttachmentImpl, NULL, SIP_NOT_NONE, &state, &sipIsError ) );  \
SIP_UNBLOCK_THREADS  return result;
    };


  sipCpp = new sipA_B_Attachment(m_impl,a1)

    Py_END_ALLOW_THREADS

    %End


But I get the error


note: candidate constructor not viable: no known conversion from '(lambda at \
/Users/sum10122/pythonBindingsEnv/sip/sip/.../Data_Attachment.sip:50:19)' to \
'std::shared_ptr<QRTImpl::AttachmentImpl>' for 1st argument


I will really appreciate if someone can help me on this


Thank You,

Suman


[Attachment #3 (text/html)]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} \
</style> </head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> Hi,&nbsp;</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> &nbsp;I am struggling to write the sip file for a header file which \
contains a constructor with a std::shared_ptr</div> <div style="font-family: Calibri, \
Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"> <br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> <br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> <span style="margin:0px;caret-color:rgb(0, 0, \
0)">Attachment(std::shared_ptr&lt;QRTImpl::AttachmentImpl&gt; impl, QObject* \
parent);</span> <div style="margin:0px;caret-color:rgb(0, 0, 0)"><br>
</div>
<div style="margin:0px;caret-color:rgb(0, 0, 0)"><br>
</div>
<div style="margin:0px;caret-color:rgb(0, 0, 0)"><br>
</div>
<div style="margin:0px;caret-color:rgb(0, 0, 0)"><br>
</div>
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> This is what I tried :</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> <br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> &nbsp;Attachment(SIP_PYCALLABLE m_impl,QObject* parent = \
0)[(std::shared_ptr&lt;QRTImpl::AttachmentImpl&gt;,QObject*)]; <div>&nbsp; &nbsp; \
&nbsp;%MethodCode </div> <div><br>
</div>
<div>&nbsp; &nbsp; // Make sure the callable doesn't get garbage collected, this is \
needed because refcount for a1 is 0 </div>
<div>&nbsp; &nbsp; // and the creation function pointer is passed to the metadata and \
it needs to be kept in memory. </div>
<div>&nbsp; &nbsp; Py_INCREF( a0 ); </div>
<div><br>
</div>
<div>&nbsp; &nbsp; Py_BEGIN_ALLOW_THREADS </div>
<div><br>
</div>
<div>&nbsp; &nbsp; auto m_impl = [a0]() -&gt; QRTImpl::AttachmentImpl * </div>
<div>&nbsp; &nbsp; { </div>
<div>&nbsp; &nbsp; &nbsp; QRTImpl::AttachmentImpl &nbsp;*result = nullptr; </div>
<div>&nbsp; &nbsp; &nbsp; SIP_BLOCK_THREADS </div>
<div>&nbsp; &nbsp; &nbsp; PyObject *s = sipCallMethod( NULL, a0, NULL ); </div>
<div>&nbsp; &nbsp; &nbsp; int state; </div>
<div>&nbsp; &nbsp; &nbsp; int sipIsError = 0; </div>
<div>&nbsp; &nbsp; &nbsp; result = reinterpret_cast&lt;<span style="background: \
var(--white);">QRT_Impl::AttachmentImpl* &gt;( sipForceConvertToType( s, \
sipTypeQRTImpl_AttachmentImpl, NULL, SIP_NOT_NONE, &amp;state, &amp;sipIsError ) \
);</span></div> <div>&nbsp; &nbsp; &nbsp; SIP_UNBLOCK_THREADS </div>
<div>&nbsp; &nbsp; &nbsp; return result; </div>
<div>&nbsp; &nbsp; }; </div>
<div><br>
</div>
<div><br>
</div>
<div>&nbsp; sipCpp = new sipA_B_Attachment(m_impl,a1)</div>
<div><br>
</div>
<div>&nbsp; &nbsp; Py_END_ALLOW_THREADS </div>
<div><br>
</div>
&nbsp; &nbsp; %End <br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> <br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> <br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> But I get the error</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> <br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> <p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px \
Menlo;color:#000000"><span style="font-variant-ligatures:no-common-ligatures">note: \
candidate constructor not viable: no known conversion from '(lambda at \
/Users/sum10122/pythonBindingsEnv/sip/sip/.../Data_Attachment.sip:50:19)'  to \
'std::shared_ptr&lt;QRTImpl::AttachmentImpl&gt;' for 1st argument</span></p> <p \
style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo;color:#000000"><span \
style="font-variant-ligatures:no-common-ligatures"><br> </span></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo;color:#000000">I will \
really appreciate if someone can help me on this</p> <p style="margin:0.0px 0.0px \
0.0px 0.0px;font:11.0px Menlo;color:#000000"><br> </p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo;color:#000000">Thank \
You,</p> <p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px \
Menlo;color:#000000">Suman</p> <br>
</div>
</body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic