MCPcopy Create free account
hub / github.com/carbonengine/trinity / RebuildDeviceResourcesInPython

Method RebuildDeviceResourcesInPython

trinity/TriDevice.cpp:597–651  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

595}
596
597void TriDevice::RebuildDeviceResourcesInPython()
598{
599 //Call the OnCreate handler on python objects. This allows them to recreate stuff that they
600 //had to release because device became invalid.
601#if BLUE_WITH_PYTHON
602 if( m_pyResourceSet )
603 {
604 auto gil = PyGILState_Ensure();
605 ON_BLOCK_EXIT( [&gil] { PyGILState_Release( gil ); } );
606
607#if PY_MAJOR_VERSION == 2
608 BluePySeq keys = BluePy( PyObject_CallMethod( m_pyResourceSet, const_cast<char*>( "keys" ), 0 ) );
609 if( !keys )
610 {
611 CCP_LOGERR( "TriDev: Python callback failed in \"RebuildDeviceResourcesInPython\"" );
612 PyOS->PyError();
613 }
614 Py_ssize_t n = keys.Size();
615 for( Py_ssize_t i = 0; i < n; i++ )
616 {
617 BluePy item( keys.Get( i ) );
618 BluePy result( PyOS->CallMethodWithTrap( item, "OnCreate", "OnCreate", "(N)", PyOS->WrapBlueObject( GetRawRoot() ) ) );
619 if( !result )
620 {
621 PyOS->PyError();
622 }
623 }
624#else
625 BluePy keys( PyObject_CallMethod( m_pyResourceSet, "keys", 0 ) );
626
627 if( !keys )
628 {
629 CCP_LOGERR( "keys() method failed on resource set in \"RebuildDeviceResourcesInPython\"." );
630 PyOS->PyError();
631 return;
632 }
633 if( !PyIter_Check( keys.o ) )
634 {
635 CCP_LOGERR( "Could not iterate through resource set keys in \"RebuildDeviceResourcesInPython\"." );
636 return;
637 }
638
639 while( PyObject* next = PyIter_Next( keys ) )
640 {
641 BluePy item( next );
642 BluePy result( PyOS->CallMethodWithTrap( item, "OnCreate", "OnCreate", "(N)", PyOS->WrapBlueObject( GetRawRoot() ) ) );
643 if( !result )
644 {
645 PyOS->PyError();
646 }
647 }
648#endif
649 }
650#endif
651}
652
653
654float TriDevice::AspectRatio()

Callers

nothing calls this directly

Calls 2

SizeMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected