mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-27 21:24:11 -04:00
sf: Change interface definition methodology (#1074)
* sf: Begin experimenting with new interface declaration format * sf: convert fs interfaces to new format * sf: finish conversion of libstrat to new definitions * sf: convert loader to new format * sf: convert spl to new format * sf: update ncm for new format * sf: convert pm to new format * sf: convert ro/sm to new format * sf: update fatal for new format * sf: support building dmnt under new scheme * sf: update ams.mitm for new format * sf: correct invocation def for pointer holder * fs: correct 10.x+ user bindings for Get*SpaceSize
This commit is contained in:
parent
94eb2195d3
commit
9fde97cfdd
190 changed files with 3220 additions and 3172 deletions
|
@ -25,38 +25,44 @@ namespace ams::sf {
|
|||
virtual ~IServiceObject() { /* ... */ }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
concept IsServiceObject = std::derived_from<T, IServiceObject>;
|
||||
|
||||
class IMitmServiceObject : public IServiceObject {
|
||||
public:
|
||||
virtual ~IMitmServiceObject() { /* ... */ }
|
||||
};
|
||||
|
||||
class MitmServiceImplBase {
|
||||
protected:
|
||||
std::shared_ptr<::Service> forward_service;
|
||||
sm::MitmProcessInfo client_info;
|
||||
public:
|
||||
IMitmServiceObject(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &c) : forward_service(std::move(s)), client_info(c) { /* ... */ }
|
||||
|
||||
virtual ~IMitmServiceObject() { /* ... */ }
|
||||
|
||||
static bool ShouldMitm(os::ProcessId process_id, ncm::ProgramId program_id);
|
||||
MitmServiceImplBase(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &c) : forward_service(std::move(s)), client_info(c) { /* ... */ }
|
||||
};
|
||||
|
||||
/* Utility. */
|
||||
#define SF_MITM_SERVICE_OBJECT_CTOR(cls) cls(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &c) : ::ams::sf::IMitmServiceObject(std::forward<std::shared_ptr<::Service>>(s), c)
|
||||
|
||||
template<typename T>
|
||||
struct ServiceObjectTraits {
|
||||
static_assert(std::is_base_of<ams::sf::IServiceObject, T>::value, "ServiceObjectTraits requires ServiceObject");
|
||||
concept IsMitmServiceObject = IsServiceObject<T> && std::derived_from<T, IMitmServiceObject>;
|
||||
|
||||
static constexpr bool IsMitmServiceObject = std::is_base_of<IMitmServiceObject, T>::value;
|
||||
|
||||
struct SharedPointerHelper {
|
||||
|
||||
static constexpr void EmptyDelete(T *) { /* Empty deleter, for fake shared pointer. */ }
|
||||
|
||||
static constexpr std::shared_ptr<T> GetEmptyDeleteSharedPointer(T *srv_obj) {
|
||||
return std::shared_ptr<T>(srv_obj, EmptyDelete);
|
||||
}
|
||||
|
||||
};
|
||||
template<typename T>
|
||||
concept IsMitmServiceImpl = requires (std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &c) {
|
||||
{ T(std::forward<std::shared_ptr<::Service>>(s), c) };
|
||||
{ T::ShouldMitm(c) } -> std::same_as<bool>;
|
||||
};
|
||||
|
||||
template<typename Interface, typename Impl, typename... Arguments> requires std::constructible_from<Impl, Arguments...>
|
||||
constexpr ALWAYS_INLINE std::shared_ptr<typename Interface::ImplHolder<Impl>> MakeShared(Arguments &&... args) {
|
||||
return std::make_shared<typename Interface::ImplHolder<Impl>>(std::forward<Arguments>(args)...);
|
||||
}
|
||||
|
||||
template<typename Interface, typename Impl>
|
||||
constexpr ALWAYS_INLINE std::shared_ptr<typename Interface::ImplPointer<Impl>> GetSharedPointerTo(Impl *impl) {
|
||||
return std::make_shared<typename Interface::ImplPointer<Impl>>(impl);
|
||||
}
|
||||
|
||||
template<typename Interface, typename Impl>
|
||||
constexpr ALWAYS_INLINE std::shared_ptr<typename Interface::ImplPointer<Impl>> GetSharedPointerTo(Impl &impl) {
|
||||
return GetSharedPointerTo<Interface, Impl>(std::addressof(impl));
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue