diff --git a/source/Command.cpp b/source/Command.cpp index 6366f751..fef1fc0b 100644 --- a/source/Command.cpp +++ b/source/Command.cpp @@ -1024,6 +1024,7 @@ void Register(HSQUIRRELVM vm) .SquirrelFunc(_SC("_typename"), &Manager::Typename) .Func(_SC("_tostring"), &Manager::ToString) // Member Properties + .Prop(_SC("Count"), &Manager::GetCount) .Prop(_SC("IsContext"), &Manager::IsContext) .Prop(_SC("OnFail"), &Manager::GetOnFail) .Prop(_SC("OnFail"), &Manager::GetOnFail) @@ -1067,6 +1068,7 @@ void Register(HSQUIRRELVM vm) .Func(_SC("_tostring"), &Listener::ToString) // Member Properties .Prop(_SC("Attached"), &Listener::Attached) + .Prop(_SC("Manager"), &Listener::GetManager) .Prop(_SC("Name"), &Listener::GetName, &Listener::SetName) .Prop(_SC("Spec"), &Listener::GetSpec, &Listener::SetSpec) .Prop(_SC("Specifier"), &Listener::GetSpec, &Listener::SetSpec) diff --git a/source/Command.hpp b/source/Command.hpp index dc1140a5..5a521ee1 100644 --- a/source/Command.hpp +++ b/source/Command.hpp @@ -805,6 +805,14 @@ public: return GetValid()->FindByName(name); } + /* -------------------------------------------------------------------------------------------- + * Retrieve the number of managed command listeners. + */ + SQInteger GetCount() const + { + return ConvTo< SQInteger >::From(GetValid()->m_Commands.size()); + } + /* -------------------------------------------------------------------------------------------- * See whether an execution context is currently active. */ @@ -1172,6 +1180,24 @@ public: return (!m_Controller.Expired() && m_Controller.Lock()->Attached(this)); } + /* -------------------------------------------------------------------------------------------- + * Retrieve the manager associated with this command listener instance. + */ + Object GetManager() const + { + // Are we even associated with a controller? + if (!m_Controller) + { + return NullObject(); // Default to null + } + // Obtain the initial stack size + const StackGuard sg; + // Push the instance on the stack + ClassType< Manager >::PushInstance(DefaultVM::Get(), m_Controller.Lock()->m_Manager); + // Grab the instance from the stack + return Var< Object >(DefaultVM::Get(), -1).value; + } + /* -------------------------------------------------------------------------------------------- * Retrieve the name that triggers this command listener instance. */