diff --git a/TODO b/TODO index bc62720d6..b9f4fe46b 100644 --- a/TODO +++ b/TODO @@ -61,7 +61,7 @@ Just need to figure out backing_mem (a u8*) ✔ Wait object @done(19-08-13 16:46) ☐ Service @started(19-12-23 12:49) - ☐ AC @started(19-12-23 12:48) + ✔ AC @started(19-12-23 12:48) @done(19-12-24 22:38) @lasted(1d9h50m3s) ☐ ACT ☐ AM ☐ APT diff --git a/src/common/construct.h b/src/common/construct.h index 28f4cc349..6ef9af1ef 100644 --- a/src/common/construct.h +++ b/src/common/construct.h @@ -1,9 +1,5 @@ #include -#define BOOST_SERIALIZATION_FRIENDS \ - friend class boost::serialization::access; \ - friend class construct_access; - class construct_access { public: template diff --git a/src/core/hle/service/ac/ac.cpp b/src/core/hle/service/ac/ac.cpp index acae47fd5..356df5a63 100644 --- a/src/core/hle/service/ac/ac.cpp +++ b/src/core/hle/service/ac/ac.cpp @@ -17,8 +17,6 @@ #include "core/hle/service/ac/ac_u.h" #include "core/memory.h" -SERIALIZE_EXPORT_IMPL(Service::AC::Module::Interface) - namespace Service::AC { void Module::Interface::CreateDefaultConfig(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x1, 0, 0); @@ -182,4 +180,16 @@ void InstallInterfaces(Core::System& system) { std::make_shared(ac)->InstallAsService(service_manager); } +template +void Module::serialize(Archive& ar, const unsigned int) +{ + ar & ac_connected; + ar & close_event; + ar & connect_event; + ar & disconnect_event; + // default_config is never written to +} + } // namespace Service::AC + +SERIALIZE_IMPL(Service::AC::Module) diff --git a/src/core/hle/service/ac/ac.h b/src/core/hle/service/ac/ac.h index 12e304f59..b7a079b33 100644 --- a/src/core/hle/service/ac/ac.h +++ b/src/core/hle/service/ac/ac.h @@ -8,7 +8,6 @@ #include #include #include -#include "common/construct.h" #include "core/hle/service/service.h" namespace Core { @@ -19,6 +18,8 @@ namespace Kernel { class Event; } +BOOST_SERIALIZATION_ASSUME_ABSTRACT(Service::AC::Module::Interface) + namespace Service::AC { class Module final { public: @@ -142,34 +143,6 @@ public: protected: std::shared_ptr ac; - - private: - template - void save_construct(Archive& ar, const unsigned int file_version) const - { - ar << ac; - ar << GetServiceName(); - ar << GetMaxSessions(); - } - - template - static void load_construct(Archive& ar, Interface* t, const unsigned int file_version) - { - std::shared_ptr ac; - std::string name; - u32 max_sessions; - ar >> ac; - ar >> name; - ar >> max_sessions; - ::new(t)Interface(ac, name.c_str(), max_sessions); - } - - template - void serialize(Archive& ar, const unsigned int file_version) - { - ar & boost::serialization::base_object(*this); - } - BOOST_SERIALIZATION_FRIENDS }; protected: @@ -187,20 +160,10 @@ protected: private: template - void serialize(Archive& ar, const unsigned int file_version) - { - ar & ac_connected; - ar & close_event; - ar & connect_event; - ar & disconnect_event; - // default_config is never written to - } + void serialize(Archive& ar, const unsigned int file_version); friend class boost::serialization::access; }; void InstallInterfaces(Core::System& system); } // namespace Service::AC - -BOOST_SERIALIZATION_CONSTRUCT(Service::AC::Module::Interface) -BOOST_CLASS_EXPORT_KEY(Service::AC::Module::Interface) diff --git a/src/core/hle/service/ac/ac_i.cpp b/src/core/hle/service/ac/ac_i.cpp index 0dde7bf90..e4cc4c1f1 100644 --- a/src/core/hle/service/ac/ac_i.cpp +++ b/src/core/hle/service/ac/ac_i.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include "core/hle/service/ac/ac_i.h" +#include "common/archives.h" namespace Service::AC { @@ -33,3 +34,5 @@ AC_I::AC_I(std::shared_ptr ac) : Module::Interface(std::move(ac), "ac:i" } } // namespace Service::AC + +SERIALIZE_EXPORT_IMPL(Service::AC::AC_I) diff --git a/src/core/hle/service/ac/ac_i.h b/src/core/hle/service/ac/ac_i.h index bca91aabe..d7ab22b25 100644 --- a/src/core/hle/service/ac/ac_i.h +++ b/src/core/hle/service/ac/ac_i.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include "core/hle/service/ac/ac.h" namespace Service::AC { @@ -12,6 +13,12 @@ namespace Service::AC { class AC_I final : public Module::Interface { public: explicit AC_I(std::shared_ptr ac); + +private: + SERVICE_SERIALIZATION(AC_I, ac) }; } // namespace Service::AC + +BOOST_CLASS_EXPORT_KEY(Service::AC::AC_I) +BOOST_SERIALIZATION_CONSTRUCT(Service::AC::AC_I) diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index f05c15f23..d124b0070 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -10,7 +10,9 @@ #include #include #include +#include #include "common/common_types.h" +#include "common/construct.h" #include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/object.h" #include "core/hle/service/sm/sm.h" @@ -194,3 +196,26 @@ struct ServiceModuleInfo { extern const std::array service_module_map; } // namespace Service + +#define SERVICE_SERIALIZATION(T, MFIELD) \ + template \ + void save_construct(Archive& ar, const unsigned int file_version) const \ + { \ + ar << MFIELD; \ + } \ + \ + template \ + static void load_construct(Archive& ar, T* t, const unsigned int file_version) \ + { \ + std::shared_ptr MFIELD; \ + ar >> MFIELD; \ + ::new(t)T(MFIELD); \ + } \ + \ + template \ + void serialize(Archive& ar, const unsigned int) \ + { \ + ar & boost::serialization::base_object(*this); \ + } \ + friend class boost::serialization::access; \ + friend class construct_access;