<div dir="ltr"><div>Hi,<br>I am at the basic level in using sip wrapper in python. I have written a small library in c++ and wrapping it in sip for execution in Python.<br>Copy pasting my entire files for better understanding. Also pasting
the output from the terminal, the behaviour i am getting is completely unexpected, can you
please look into it...<br><br>
</div><div><b>word.h:</b><br><span style="color:rgb(255,0,0)"><br><span style="color:rgb(102,102,102)">class Word<br>{<br><br>public:<br> int integer;<br> const char *name;<br> Word();<br> void set_name(const char *a);<br>
void reset_name();<br> const char *get_name();<br>};</span></span><span style="color:rgb(102,102,102)"><br></span><br></div><div><b>word.cpp:</b><br><span style="color:rgb(102,102,102)"><br>#include <iostream><br>
#include "word.h"<br><br>using namespace std;<br><br>Word::Word(){<br> name = "PyQt";<div class="im"><br>}<br><br>void Word::set_name(const char *a){<br></div> cout << "parameter passed to set_name is " << a << endl;<br>
cout << "name before set_name is " << name << endl;<br> name = a;<br> cout << "name after set_name is " << name << endl;<br>}<br><br>void Word::reset_name(){<br>
cout << "name before reset_name is " << name << endl;<br> const char *x = "Epics";<br> name = x;<br> cout << "name after reset_name is " << name << endl;<br>
}<br><br>const char *Word::get_name(){<br> cout << "name before get_name is " << name << endl;<br> return name;<br>}</span><br><br></div><div><b>word.sip:</b><br><span style="color:rgb(102,102,102)"><br>
%Module word <br><br>class Word<br>{<br><br>%TypeHeaderCode<br>#include <word.h><br>%End<br><br>public:<br> int integer;<br> const char *name;<br> Word();<br> void set_name(const char *a);<br> void reset_name();<br>
const char *get_name();<br>};</span><br><br></div><div><b>Output in Python (Terminal):</b><br><span style="color:rgb(255,0,0)"><br><span style="color:rgb(102,102,102)"><div class="im">>>> import word<br>>>> w = word.Word()<br>
</div>
>>> w.get_name()<br>name before get_name is PyQt<br>'PyQt'<br>>>> w.set_name("Amey")<br>parameter passed to set_name is Amey<br>name before set_name is PyQt<br>name after set_name is Amey<br>
>>> w.get_name()<br><span style="background-color:rgb(255,255,0)">name before get_name is </span><br>''<br>>>> w.reset_name()<br><span style="background-color:rgb(255,255,0)">name before reset_name is <stdin></span><br>
name after reset_name is Epics<br>>>> w.get_name()<br>name before get_name is Epics<br>'Epics'</span></span><br><br></div><div>PROBLEMS:<br></div><div>1. It won't print the output when i call<span style="color:rgb(102,102,102)"> get_name()</span> after calling <span style="color:rgb(102,102,102)">set_name()</span>.<br>
2. As
you can see in the output, I am editing nothing between the highlighted
lines, still the output shows <span style="color:rgb(102,102,102)">nothing</span> in one while <span style="color:rgb(102,102,102)"><stdin></span> in
other. <br><br>Please tell me what's wrong.<br>
<br></div><div>Looking forward for your reply,<br><br></div><div>Sincere Regards,<br></div>Amey Patil</div>