File tree 3 files changed +14
-0
lines changed
src/core/modules/listeners 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)
90
90
{
91
91
return m_vecCallables.HasElement (oCallback);
92
92
}
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
67
67
void Notify (boost::python::tuple args, dict kwargs);
68
68
int GetCount ();
69
69
bool IsRegistered (object oCallback);
70
+ object __getitem__ (unsigned int index);
70
71
71
72
public:
72
73
CUtlVector<object> m_vecCallables;
Original file line number Diff line number Diff line change @@ -106,6 +106,11 @@ void export_listener_managers(scope _listeners)
106
106
&CListenerManager::IsRegistered,
107
107
" Return whether or not the given callback is registered."
108
108
)
109
+
110
+ .def (" __getitem__" ,
111
+ &CListenerManager::__getitem__,
112
+ " Return the callback at the given index."
113
+ )
109
114
;
110
115
111
116
_listeners.attr (" on_client_active_listener_manager" ) = object (ptr (GetOnClientActiveListenerManager ()));
You can’t perform that action at this time.
0 commit comments