[pygccxml-development] [FT] not exception safe generated code
Brought to you by:
mbaas,
roman_yakovenko
|
From: Roman Y. <rom...@gm...> - 2006-09-14 18:54:27
|
Hi Matthias. I did quick review to part of the code and this is what I found:
mem_fun_v_transformed_wrapper_t.create_virtual_body method:
PyGILState_STATE gstate;
gstate = PyGILState_Ensure();
$DECLARATIONS
PyGILState_Release(gstate);
Obviously the code you generate here is not exception safe. I think
you should use
RIIA principle.
class gil_lock_t{
public:
gil_lock_t( bool lock=true )
: m_locked( lock )
{
if( m_locked )
m_gstate = PyGILState_Ensure();
}
~gil_lock_t(){
if( m_locked )
PyGILState_Release(m_gstate);
}
void lock(){
if( !m_locked )
m_gstate = PyGILState_Ensure();
}
void unlock(){
if( m_locked )
PyGILState_Release(m_gstate);
}
private:
bool m_locked;
PyGILState_STATE m_gstate;
};
With this class you can change the code in create_virtual_body method.
Py++ has all functionality needed to add this code Take a look on
code_repository package.
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|