<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2873" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=548341910-09052006><FONT face=Arial color=#0000ff size=2>Hello
there,</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial color=#0000ff size=2>due
the continous discussion about smart pointers I want to make an approach how an
implementation might look like. The main point is that we do not want to have a
smart pointer object at all in Python because it is not necessary - Python
always uses smart pointer in some POV.</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial color=#0000ff size=2>Of
course this would require some <FONT color=#ff00ff>new</FONT> language features.
Okay, generelly we have a class with two functions. One returning a smart
pointer reference and the other simply a pointer:</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" size=2>%Import
MySmartPointer.sip</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" size=2>class
Test</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>{</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>public:</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New">
<FONT size=2>MyClass* GetSmartPointer() <FONT
color=#ff00ff>/SmartPointerReturned=MySmartPointer/</FONT>;</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New">
<FONT size=2>MyClass* GetNoSmartPointer();</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>};</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial color=#0000ff size=2>The
same for function parameters:</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" size=2>%Import
MySmartPointer.sip</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" size=2>class
Test2</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>{</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>public:</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New">
<FONT size=2>void SetSmartPointer (MyClass* <FONT
color=#ff00ff>/SmartPointer=MySmartPointer/</FONT>);</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New">
<FONT size=2>void SetNoSmartPointer (MyClass*);</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>};</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial color=#0000ff size=2>
<DIV><SPAN class=548341910-09052006><FONT face=Arial color=#0000ff size=2>And
variables:</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial color=#000000
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" color=#000000
size=2>%Import MySmartPointer.sip</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" color=#000000
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" color=#000000
size=2>class Test3</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" color=#000000
size=2>{</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" color=#000000
size=2>public:</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"><FONT
color=#000000> <FONT size=2>MyClass* smartPtr <FONT
color=#ff00ff>/SmartPointer=MySmartPointer/</FONT>;</FONT></FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" color=#000000
size=2>};</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial color=#000000
size=2></FONT></SPAN> </DIV>It might be usefull to be able to specify a
default for modules (may be overwritten at any time):</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" size=2>%Import
MySmartPointer.sip</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" color=#ff00ff
size=2>%DefaultSmartPointer MySmartPointer</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" size=2>class
Test</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>{</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>public:</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New">
<FONT size=2>MyClass* GetSmartPointer() <FONT
color=#ff00ff>/SmartPointerReturned/</FONT>;</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New">
<FONT size=2>MyClass* GetNoSmartPointer();</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>};</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" size=2>class
Test2</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>{</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>public:</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New">
<FONT size=2>void SetSmartPointer (MyClass* <FONT
color=#ff00ff>/SmartPointer/</FONT>);</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New">
<FONT size=2>void SetNoSmartPointer (MyClass*);</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>};</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" size=2>class
Test3</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>{</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>public:</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2> MyClass* smartPtr <FONT
color=#ff00ff>/SmartPointer/</FONT>;</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>};</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial color=#0000ff
size=2>Finally it is required to define a smart pointer:</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" size=2><FONT
color=#ff00ff>%SmartPointer</FONT> MySmartPointer</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>{</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" size=2><FONT
color=#ff00ff>%CreateRefCode</FONT> // optional; this is the
default</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2> /* arguments:</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT
face="Courier New"> <FONT
size=2>MySmartPointer* sipCppPtr</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT
face="Courier New"> <FONT size=2>type
= /in this case/ MyClass</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT
face="Courier New"> <FONT
size=2>MyClass* sipInnerPtr</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2> */</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT
face="Courier New"> <FONT size=2>sipCppPtr = new
MySmartCppPointer<type> (sipInnerPtr);</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>%End</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" size=2><FONT
color=#ff00ff>%GetInnerRefCode</FONT> // optional; this is the
default</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New">
<FONT size=2>/* arguments:</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT
face="Courier New"> <FONT
size=2>MySmartPointer& sipCppRef</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT
face="Courier New"> <FONT
size=2>MyClass* sipInnerPtr</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New">
<FONT size=2>*/</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New">
<FONT size=2>sipInnerPtr = &*sipCppRef;</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>%End</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" size=2><FONT
color=#ff00ff>%IncRefCode</FONT> //
required</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New">
<FONT size=2>/* arguments:</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT
face="Courier New"> <FONT
size=2>MySmartPointer& sipCppRef</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New">
<FONT size=2>*/</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New">
<FONT size=2>sipCppRef->AddRef();</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>%End</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New" size=2><FONT
color=#ff00ff>%DecRefCode</FONT> //
required</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New">
<DIV><SPAN class=548341910-09052006><FONT face="Courier New">
<FONT size=2>/* arguments:</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT
face="Courier New"> <FONT
size=2>MySmartPointer& sipCppRef</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New">
<FONT size=2>*/</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV><FONT size=2></FONT><FONT
size=2></FONT> <FONT
size=2>sipCppRef->Release();</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>%End</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face="Courier New"
size=2>};</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial color=#0000ff size=2>What
do you think of it? cu Felix</FONT></SPAN></DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=548341910-09052006><FONT face=Arial
size=2></FONT></SPAN> </DIV></SPAN></DIV></SPAN></DIV></BODY></HTML>