| 145 | } |
| 146 | |
| 147 | void Tr2ActionPython::InstantiateObject() |
| 148 | { |
| 149 | m_vtable = {}; |
| 150 | m_instance = {}; |
| 151 | |
| 152 | if( m_module.empty() || m_className.empty() ) |
| 153 | { |
| 154 | return; |
| 155 | } |
| 156 | |
| 157 | auto gil = PyGILState_Ensure(); |
| 158 | ON_BLOCK_EXIT( [&gil] { PyGILState_Release( gil ); } ); |
| 159 | |
| 160 | m_instance = CreateInstance( m_module.c_str(), m_className.c_str() ); |
| 161 | |
| 162 | auto ExtractMethod = [&]( const char* methodName, BlueScriptCallback& callback ) { |
| 163 | BluePy method( PyObject_GetAttrString( m_instance, methodName ) ); |
| 164 | if( method && PyCallable_Check( method ) ) |
| 165 | { |
| 166 | BlueExtractArgument( method, callback, 0 ); |
| 167 | } |
| 168 | else |
| 169 | { |
| 170 | PyErr_Clear(); |
| 171 | } |
| 172 | }; |
| 173 | |
| 174 | ExtractMethod( "OnLink", m_vtable.onLink ); |
| 175 | ExtractMethod( "OnUnlink", m_vtable.onUnlink ); |
| 176 | ExtractMethod( "OnStart", m_vtable.onStart ); |
| 177 | ExtractMethod( "OnStop", m_vtable.onStop ); |
| 178 | ExtractMethod( "OnUpdate", m_vtable.onUpdate ); |
| 179 | ExtractMethod( "OnLoad", m_vtable.onLoad ); |
| 180 | ExtractMethod( "OnSave", m_vtable.onSave ); |
| 181 | } |
| 182 | |
| 183 | void Tr2ActionPython::GetWriteBufferAndSize( const char* memberName, uint8_t** buffer, size_t* bufferSize ) |
| 184 | { |
nothing calls this directly
no test coverage detected