/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
usecrate::interfaces::{nsIComponentManager, nsIComponentRegistrar, nsIServiceManager}; usecrate::{GetterAddrefs, RefPtr, XpCom}; use std::ffi::CStr;
/// Get a reference to the global `nsIComponentManager`. /// /// Can return `None` during shutdown. #[inline] pubfn component_manager() -> Option<RefPtr<nsIComponentManager>> { unsafe { RefPtr::from_raw(Gecko_GetComponentManager()) }
}
/// Get a reference to the global `nsIServiceManager`. /// /// Can return `None` during shutdown. #[inline] pubfn service_manager() -> Option<RefPtr<nsIServiceManager>> { unsafe { RefPtr::from_raw(Gecko_GetServiceManager()) }
}
/// Get a reference to the global `nsIComponentRegistrar` /// /// Can return `None` during shutdown. #[inline] pubfn component_registrar() -> Option<RefPtr<nsIComponentRegistrar>> { unsafe { RefPtr::from_raw(Gecko_GetComponentRegistrar()) }
}
/// Helper for calling `nsIComponentManager::CreateInstanceByContractID` on the /// global `nsIComponentRegistrar`. /// /// This method is similar to `do_CreateInstance` in C++. #[inline] pubfn create_instance<T: XpCom>(id: &CStr) -> Option<RefPtr<T>> { unsafe { letmut ga = GetterAddrefs::<T>::new(); if component_manager()?
.CreateInstanceByContractID(id.as_ptr(), &T::IID, ga.void_ptr())
.succeeded()
{
ga.refptr()
} else {
None
}
}
}
/// Helper for calling `nsIServiceManager::GetServiceByContractID` on the global /// `nsIServiceManager`. /// /// This method is similar to `do_GetService` in C++. #[inline] pubfn get_service<T: XpCom>(id: &CStr) -> Option<RefPtr<T>> { unsafe { letmut ga = GetterAddrefs::<T>::new(); if service_manager()?
.GetServiceByContractID(id.as_ptr(), &T::IID, ga.void_ptr())
.succeeded()
{
ga.refptr()
} else {
None
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.