mirror of
https://github.com/boostorg/python.git
synced 2026-01-27 07:02:15 +00:00
- New code (more generic) for declaring the smart pointer converters
[SVN r18269]
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
16 Apr 2003
|
||||
Added a more generic (but ugly) code to declare the smart pointer converters.
|
||||
|
||||
07 Apr 2003
|
||||
- Removed the warnings about forward declarations: it was not accurate enough.
|
||||
Another strategy must be thought of.
|
||||
|
||||
@@ -24,6 +24,21 @@ private:
|
||||
|
||||
inline std::auto_ptr<D> NewD() { return std::auto_ptr<D>( new D() ); }
|
||||
|
||||
|
||||
// test an abstract class
|
||||
struct A
|
||||
{
|
||||
virtual int f() = 0;
|
||||
};
|
||||
|
||||
struct B: A
|
||||
{
|
||||
virtual int f(){ return 1; }
|
||||
};
|
||||
|
||||
inline boost::shared_ptr<A> NewA() { return boost::shared_ptr<A>(new B()); }
|
||||
inline int GetA(boost::shared_ptr<A> a) { return a->f(); }
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
C = Class('smart_ptr::C', 'smart_ptr.h')
|
||||
use_shared_ptr(C)
|
||||
|
||||
D = Class('smart_ptr::D', 'smart_ptr.h')
|
||||
use_auto_ptr(D)
|
||||
|
||||
A = Class('smart_ptr::A', 'smart_ptr.h')
|
||||
use_shared_ptr(A)
|
||||
|
||||
Function('smart_ptr::NewC', 'smart_ptr.h')
|
||||
Function('smart_ptr::NewD', 'smart_ptr.h')
|
||||
Function('smart_ptr::NewA', 'smart_ptr.h')
|
||||
Function('smart_ptr::GetA', 'smart_ptr.h')
|
||||
|
||||
@@ -560,8 +560,18 @@ class ClassExporter(Exporter):
|
||||
def ExportSmartPointer(self):
|
||||
smart_ptr = self.info.smart_ptr
|
||||
if smart_ptr:
|
||||
self.Add('template', smart_ptr % self.class_.FullName())
|
||||
|
||||
class_name = self.class_.FullName()
|
||||
smart_ptr = smart_ptr % class_name
|
||||
#self.Add('template', smart_ptr)
|
||||
|
||||
self.Add('scope', '// Temporary code for smart pointers')
|
||||
self.Add('scope', namespaces.python + 'objects::class_value_wrapper< ')
|
||||
self.Add('scope', ' %s, objects::make_ptr_instance< ' % smart_ptr)
|
||||
self.Add('scope', ' %s, objects::pointer_holder< ' % class_name)
|
||||
self.Add('scope', ' %s, %s >' % (smart_ptr, class_name))
|
||||
self.Add('scope', ' >')
|
||||
self.Add('scope', '>();')
|
||||
|
||||
|
||||
def ExportOpaquePointerPolicies(self):
|
||||
# check all methods for 'return_opaque_pointer' policies
|
||||
|
||||
@@ -34,7 +34,7 @@ from policies import *
|
||||
from CppParser import CppParser, CppParserError
|
||||
import time
|
||||
|
||||
__VERSION__ = '0.7.3'
|
||||
__VERSION__ = '0.7.4'
|
||||
|
||||
def RecursiveIncludes(include):
|
||||
'Return a list containg the include dir and all its subdirectories'
|
||||
|
||||
@@ -11,6 +11,8 @@ class BasicExampleTest(unittest.TestCase):
|
||||
c1 = d.Get()
|
||||
c1.value = 6
|
||||
self.assertEqual(c.value, 6)
|
||||
a = NewA()
|
||||
self.assertEqual(GetA(a), 1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user