File tree Expand file tree Collapse file tree 3 files changed +14
-0
lines changed
src/core/modules/listeners Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -90,3 +90,11 @@ bool CListenerManager::IsRegistered(object oCallback)
9090{
9191 return m_vecCallables.HasElement (oCallback);
9292}
93+
94+ object CListenerManager::__getitem__ (unsigned int index)
95+ {
96+ if (index >= (unsigned int ) m_vecCallables.Count ())
97+ BOOST_RAISE_EXCEPTION (PyExc_IndexError, " Index out of range." )
98+
99+ return m_vecCallables[index];
100+ }
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ class CListenerManager
6767 void Notify (boost::python::tuple args, dict kwargs);
6868 int GetCount ();
6969 bool IsRegistered (object oCallback);
70+ object __getitem__ (unsigned int index);
7071
7172public:
7273 CUtlVector<object> m_vecCallables;
Original file line number Diff line number Diff line change @@ -106,6 +106,11 @@ void export_listener_managers(scope _listeners)
106106 &CListenerManager::IsRegistered,
107107 " Return whether or not the given callback is registered."
108108 )
109+
110+ .def (" __getitem__" ,
111+ &CListenerManager::__getitem__,
112+ " Return the callback at the given index."
113+ )
109114 ;
110115
111116 _listeners.attr (" on_client_active_listener_manager" ) = object (ptr (GetOnClientActiveListenerManager ()));
You can’t perform that action at this time.
0 commit comments