Revision: 1016
http://svn.sourceforge.net/pygccxml/?rev=1016&view=rev
Author: roman_yakovenko
Date: 2007-04-23 10:15:08 -0700 (Mon, 23 Apr 2007)
Log Message:
-----------
moving smart_ptr_t class to a namespace
Modified Paths:
--------------
pyplusplus_dev/docs/troubleshooting_guide/smart_ptrs/bindings.cpp
pyplusplus_dev/docs/troubleshooting_guide/smart_ptrs/classes.hpp
pyplusplus_dev/docs/troubleshooting_guide/smart_ptrs/sconstruct
pyplusplus_dev/docs/troubleshooting_guide/smart_ptrs/smart_ptr.h
pyplusplus_dev/docs/troubleshooting_guide/smart_ptrs/smart_ptrs.zip
Modified: pyplusplus_dev/docs/troubleshooting_guide/smart_ptrs/bindings.cpp
===================================================================
--- pyplusplus_dev/docs/troubleshooting_guide/smart_ptrs/bindings.cpp 2007-04-22 18:45:10 UTC (rev 1015)
+++ pyplusplus_dev/docs/troubleshooting_guide/smart_ptrs/bindings.cpp 2007-04-23 17:15:08 UTC (rev 1016)
@@ -3,22 +3,20 @@
namespace bp = boost::python;
-//namespace boost{
+namespace smart_pointers{
// "get_pointer" function returns pointer to the object managed by smart pointer
// class instance
template<class T>
- inline T * get_pointer(smart_ptr_t<T> const& p){
+ inline T * get_pointer(smart_pointers::smart_ptr_t<T> const& p){
return p.get();
}
inline derived_t * get_pointer(derived_ptr_t const& p){
return p.get();
}
-//}
+}
-//using boost::get_pointer;
-
namespace boost{ namespace python{
using boost::get_pointer;
@@ -29,7 +27,7 @@
// http://boost.org/libs/python/doc/v2/pointee.html
template <class T>
- struct pointee< smart_ptr_t<T> >{
+ struct pointee< smart_pointers::smart_ptr_t<T> >{
typedef T type;
};
@@ -85,37 +83,49 @@
};
BOOST_PYTHON_MODULE( custom_sptr ){
- bp::class_< base_wrapper_t, boost::noncopyable, smart_ptr_t< base_wrapper_t > >( "base_i" )
- // ---------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ bp::class_< base_wrapper_t
+ , boost::noncopyable
+ , smart_pointers::smart_ptr_t< base_wrapper_t > >( "base_i" )
+ // -----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// HeldType of the abstract class, which is managed by custom smart pointer
- // should be smart_ptr_t< base_wrapper_t >.
+ // should be smart_pointers::smart_ptr_t< base_wrapper_t >.
.def( "get_value", bp::pure_virtual( &base_i::get_value ) );
// Register implicit conversion between smart pointers. Boost.Python library
// can not discover relationship between classes. You have to tell about the
// relationship to it. This will allow Boost.Python to treat right, the
- // functions, which expect to get as argument smart_ptr_t< base_i > class
- // instance, when smart_ptr_t< derived from base_i > class instance is passed.
+ // functions, which expect to get as argument smart_pointers::smart_ptr_t< base_i > class
+ // instance, when smart_pointers::smart_ptr_t< derived from base_i > class instance is passed.
//
// For more information about implicitly_convertible see the documentation:
// http://boost.org/libs/python/doc/v2/implicit.html .
- bp::implicitly_convertible< smart_ptr_t< base_wrapper_t >, smart_ptr_t< base_i > >();
+ bp::implicitly_convertible<
+ smart_pointers::smart_ptr_t< base_wrapper_t >
+ , smart_pointers::smart_ptr_t< base_i > >();
// The register_ptr_to_python functionality is explaned very well in the
// documentation:
// http://boost.org/libs/python/doc/v2/register_ptr_to_python.html .
- bp::register_ptr_to_python< smart_ptr_t< base_i > >();
+ bp::register_ptr_to_python< smart_pointers::smart_ptr_t< base_i > >();
- bp::class_< derived_wrapper_t, bp::bases< base_i >, smart_ptr_t<derived_wrapper_t> >( "derived_t" )
- // -------------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ bp::class_< derived_wrapper_t
+ , bp::bases< base_i >
+ , smart_pointers::smart_ptr_t<derived_wrapper_t> >( "derived_t" )
+ // -----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Pay attention on the class HeldType. It will allow us to create new classes
// in Python, which derive from the derived_t class.
.def( "get_value", &derived_t::get_value, &derived_wrapper_t::default_get_value );
// Now register all existing conversion:
- bp::implicitly_convertible< smart_ptr_t< derived_wrapper_t >, smart_ptr_t< derived_t > >();
- bp::implicitly_convertible< smart_ptr_t< derived_t >, smart_ptr_t< base_i > >();
- bp::implicitly_convertible< derived_ptr_t, smart_ptr_t< derived_t > >();
+ bp::implicitly_convertible<
+ smart_pointers::smart_ptr_t< derived_wrapper_t >
+ , smart_pointers::smart_ptr_t< derived_t > >();
+ bp::implicitly_convertible<
+ smart_pointers::smart_ptr_t< derived_t >
+ , smart_pointers::smart_ptr_t< base_i > >();
+ bp::implicitly_convertible<
+ derived_ptr_t
+ , smart_pointers::smart_ptr_t< derived_t > >();
bp::register_ptr_to_python< derived_ptr_t >();
bp::def( "const_ref_get_value", &::const_ref_get_value );
@@ -125,7 +135,7 @@
bp::def( "create_base", &::create_base );
- bp::class_< numeric_t, smart_ptr_t< numeric_t > >( "numeric_t" )
+ bp::class_< numeric_t, smart_pointers::smart_ptr_t< numeric_t > >( "numeric_t" )
.def_readwrite( "value", &numeric_t::value );
bp::def( "create_numeric", &::create_numeric );
@@ -136,13 +146,13 @@
bp::class_< shared_data::buffer_t >( "buffer_t" )
.def_readwrite( "size", &shared_data::buffer_t::size );
- bp::register_ptr_to_python< smart_ptr_t< shared_data::buffer_t > >();
+ bp::register_ptr_to_python< smart_pointers::smart_ptr_t< shared_data::buffer_t > >();
bp::class_< shared_data::buffer_holder_t >( "buffer_holder_t" )
.def( "get_data", &shared_data::buffer_holder_t::get_data )
.def_readwrite( "data_naive", &shared_data::buffer_holder_t::data )
// If you will try to access "data_naive" you will get
- // TypeError: No Python class registered for C++ class smart_ptr_t<shared_data::buffer_t>
+ // TypeError: No Python class registered for C++ class smart_pointers::smart_ptr_t<shared_data::buffer_t>
// Next lines of code contain work around
.add_property( "data"
, bp::make_getter( &shared_data::buffer_holder_t::data
Modified: pyplusplus_dev/docs/troubleshooting_guide/smart_ptrs/classes.hpp
===================================================================
--- pyplusplus_dev/docs/troubleshooting_guide/smart_ptrs/classes.hpp 2007-04-22 18:45:10 UTC (rev 1015)
+++ pyplusplus_dev/docs/troubleshooting_guide/smart_ptrs/classes.hpp 2007-04-23 17:15:08 UTC (rev 1016)
@@ -17,21 +17,21 @@
// Some smart pointer classes does not have reach interface as boost ones.
// In order to provide same level of convenience, users are forced to create
// classes, which derive from smart pointer class.
-struct derived_ptr_t : public smart_ptr_t< derived_t >{
+struct derived_ptr_t : public smart_pointers::smart_ptr_t< derived_t >{
derived_ptr_t()
- : smart_ptr_t< derived_t >()
+ : smart_pointers::smart_ptr_t< derived_t >()
{}
explicit derived_ptr_t(derived_t* rep)
- : smart_ptr_t<derived_t>(rep)
+ : smart_pointers::smart_ptr_t<derived_t>(rep)
{}
derived_ptr_t(const derived_ptr_t& r)
- : smart_ptr_t<derived_t>(r) {}
+ : smart_pointers::smart_ptr_t<derived_t>(r) {}
- derived_ptr_t( const smart_ptr_t< base_i >& r)
- : smart_ptr_t<derived_t>()
+ derived_ptr_t( const smart_pointers::smart_ptr_t< base_i >& r)
+ : smart_pointers::smart_ptr_t<derived_t>()
{
m_managed = static_cast<derived_t*>(r.get());
m_use_count = r.use_count_ptr();
@@ -41,7 +41,7 @@
}
}
- derived_ptr_t& operator=(const smart_ptr_t< base_i >& r)
+ derived_ptr_t& operator=(const smart_pointers::smart_ptr_t< base_i >& r)
{
if (m_managed == static_cast<derived_t*>(r.get()))
return *this;
@@ -63,8 +63,8 @@
return derived_ptr_t( new derived_t() );
}
-smart_ptr_t< base_i > create_base(){
- return smart_ptr_t< base_i >( new derived_t() );
+smart_pointers::smart_ptr_t< base_i > create_base(){
+ return smart_pointers::smart_ptr_t< base_i >( new derived_t() );
}
@@ -72,25 +72,25 @@
// the argument is the instance of a derived class.
//
// This is the explanation David Abrahams gave:
-// Naturally; there is no instance of smart_ptr_t<base_i> anywhere in the
+// Naturally; there is no instance of smart_pointers::smart_ptr_t<base_i> anywhere in the
// Python object for the reference to bind to. The rules are the same as in C++:
//
-// int f(smart_ptr_t<base>& x);
-// smart_ptr_t<derived> y;
+// int f(smart_pointers::smart_ptr_t<base>& x);
+// smart_pointers::smart_ptr_t<derived> y;
// int z = f(y); // fails to compile
inline int
-ref_get_value( smart_ptr_t< base_i >& a ){
+ref_get_value( smart_pointers::smart_ptr_t< base_i >& a ){
return a->get_value();
}
inline int
-val_get_value( smart_ptr_t< base_i > a ){
+val_get_value( smart_pointers::smart_ptr_t< base_i > a ){
return a->get_value();
}
inline int
-const_ref_get_value( const smart_ptr_t< base_i >& a ){
+const_ref_get_value( const smart_pointers::smart_ptr_t< base_i >& a ){
return a->get_value();
}
@@ -103,13 +103,13 @@
int value;
};
-smart_ptr_t< numeric_t > create_numeric( int value ){
- smart_ptr_t< numeric_t > num( new numeric_t() );
+smart_pointers::smart_ptr_t< numeric_t > create_numeric( int value ){
+ smart_pointers::smart_ptr_t< numeric_t > num( new numeric_t() );
num->value = value;
return num;
}
-int get_numeric_value( smart_ptr_t< numeric_t > n ){
+int get_numeric_value( smart_pointers::smart_ptr_t< numeric_t > n ){
if( n.get() ){
return n->value;
}
@@ -138,9 +138,9 @@
: data( new buffer_t() )
{}
- smart_ptr_t< buffer_t > get_data(){ return data; }
+ smart_pointers::smart_ptr_t< buffer_t > get_data(){ return data; }
- smart_ptr_t< buffer_t > data;
+ smart_pointers::smart_ptr_t< buffer_t > data;
};
}
Modified: pyplusplus_dev/docs/troubleshooting_guide/smart_ptrs/sconstruct
===================================================================
--- pyplusplus_dev/docs/troubleshooting_guide/smart_ptrs/sconstruct 2007-04-22 18:45:10 UTC (rev 1015)
+++ pyplusplus_dev/docs/troubleshooting_guide/smart_ptrs/sconstruct 2007-04-23 17:15:08 UTC (rev 1016)
@@ -2,7 +2,7 @@
SharedLibrary( target=r'custom_sptr'
, source=[ r'bindings.cpp' ]
, LIBS=[ r"boost_python" ]
- , LIBPATH=[ r"/home/roman/boost_cvs/bin",r"" ]
+ , LIBPATH=[ r"/home/roman/boost_cvs/libs/python/build/bin-stage",r"" ]
, CPPPATH=[ r"/home/roman/boost_cvs"
, r"/usr/include/python2.4" ]
, SHLIBPREFIX=''
Modified: pyplusplus_dev/docs/troubleshooting_guide/smart_ptrs/smart_ptr.h
===================================================================
--- pyplusplus_dev/docs/troubleshooting_guide/smart_ptrs/smart_ptr.h 2007-04-22 18:45:10 UTC (rev 1015)
+++ pyplusplus_dev/docs/troubleshooting_guide/smart_ptrs/smart_ptr.h 2007-04-23 17:15:08 UTC (rev 1016)
@@ -3,10 +3,11 @@
#include <assert.h>
-
//The smart_ptr_t class has been created based on Ogre::SharedPtr class
//http://www.ogre3d.org/docs/api/html/OgreSharedPtr_8h-source.html
+namespace smart_pointers{
+
template<class T>
class smart_ptr_t {
protected:
@@ -128,6 +129,7 @@
}
};
+} //smart_pointers
#endif //smart_ptr_t_19_09_2006
Modified: pyplusplus_dev/docs/troubleshooting_guide/smart_ptrs/smart_ptrs.zip
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|