@@ -171,9 +171,12 @@ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(set_ptr_overload, SetPtr, 1, 2)
171171BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(set_string_ptr_overload, SetStringPtr, 1 , 2 )
172172BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(set_string_array_overload, SetStringArray, 1 , 2 )
173173
174+
175+ BOOST_PYTHON_FUNCTION_OVERLOADS(alloc_overload, Alloc, 1 , 2 )
176+
174177void export_memtools()
175178{
176- class_<CPointer>(" Pointer" , init< optional<unsigned long > >())
179+ class_<CPointer, boost::noncopyable >(" Pointer" , init< optional<unsigned long , bool > >())
177180 // get/set_<type> methods
178181 EXPOSE_GET_SET_TYPE (bool , bool )
179182 EXPOSE_GET_SET_TYPE (char , char )
@@ -332,15 +335,21 @@ void export_memtools()
332335 .def_readwrite (" address" ,
333336 &CPointer::m_ulAddr
334337 )
338+
339+ .def_readwrite (" auto_dealloc" ,
340+ &CPointer::m_bAutoDealloc
341+ )
335342 ;
336343
337344 def (" alloc" ,
338345 Alloc,
339- " Allocates a memory block." ,
340- args (" size" )
346+ alloc_overload (
347+ " Allocates a memory block." ,
348+ args (" size" , " auto_dealloc" )
349+ )[manage_new_object_policy ()]
341350 );
342351
343- class_<CFunction, bases<CPointer> >(" Function" , init<unsigned long , Convention_t, tuple, ReturnType_t>())
352+ class_<CFunction, bases<CPointer>, boost::noncopyable >(" Function" , init<unsigned long , Convention_t, tuple, ReturnType_t>())
344353 .def (" __call__" ,
345354 raw_method (&CFunction::Call),
346355 " Calls the function dynamically."
@@ -469,7 +478,7 @@ void export_dynamichooks()
469478
470479 // Properties
471480 .add_property (" esp" ,
472- &CStackData::GetESP,
481+ make_function ( &CStackData::GetESP, manage_new_object_policy ()) ,
473482 " Stack pointer register."
474483 )
475484 ;
@@ -480,7 +489,7 @@ void export_dynamichooks()
480489// -----------------------------------------------------------------------------
481490void export_callbacks ()
482491{
483- class_< CCallback, bases< CFunction > >(" Callback" , init< object, Convention_t, tuple, ReturnType_t >())
492+ class_< CCallback, bases< CFunction >, boost::noncopyable >(" Callback" , init< object, Convention_t, tuple, ReturnType_t >())
484493 .def_readwrite (" callback" ,
485494 &CCallback::m_oCallback,
486495 " The Python function that gets called by the C++ callback"
@@ -490,14 +499,15 @@ void export_callbacks()
490499
491500
492501// -----------------------------------------------------------------------------
493- // Exposes wrap/get_address /TYPE_SIZES functionality
502+ // Exposes wrap/get_pointer /TYPE_SIZES functionality
494503// -----------------------------------------------------------------------------
495504// Use this macro to add the ability to get the address of an object
496- #define GET_ADDRESS (type ) \
497- def (" get_address " , \
498- &GetAddress <type>, \
505+ #define GET_POINTER (type ) \
506+ def (" get_pointer " , \
507+ &GetPointer <type>, \
499508 " Returns the memory address of the given object." , \
500- args (" object" ) \
509+ args (" object" ), \
510+ manage_new_object_policy() \
501511 );
502512
503513// Use this macro to add the ability to get the size of an object
@@ -515,7 +525,7 @@ void export_callbacks()
515525
516526// Use this macro to call the three macros all at once
517527#define ADD_ALL (type ) \
518- GET_ADDRESS (type) \
528+ GET_POINTER (type) \
519529 WRAP_POINTER(type) \
520530 ADD_SIZE(type)
521531
0 commit comments