2018-01-13 13:22:39 -08:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2017-10-14 19:50:04 -07:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-03-17 19:39:29 -07:00
|
|
|
#include <chrono>
|
2018-01-22 10:46:36 -08:00
|
|
|
#include <memory>
|
2018-11-06 23:01:33 -08:00
|
|
|
#include <queue>
|
2021-01-31 01:38:57 -08:00
|
|
|
|
2017-10-14 19:50:04 -07:00
|
|
|
#include "core/hle/service/service.h"
|
|
|
|
|
2019-07-10 21:53:55 -07:00
|
|
|
namespace Kernel {
|
|
|
|
class KernelCore;
|
2021-01-31 01:38:57 -08:00
|
|
|
class KEvent;
|
2020-01-26 10:18:13 -08:00
|
|
|
class TransferMemory;
|
|
|
|
} // namespace Kernel
|
2019-07-10 21:53:55 -07:00
|
|
|
|
|
|
|
namespace Service::NVFlinger {
|
2018-01-22 10:46:36 -08:00
|
|
|
class NVFlinger;
|
|
|
|
}
|
|
|
|
|
2019-07-10 21:53:55 -07:00
|
|
|
namespace Service::AM {
|
2017-10-14 19:50:04 -07:00
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
enum SystemLanguage {
|
|
|
|
Japanese = 0,
|
2018-05-25 19:31:54 -07:00
|
|
|
English = 1, // en-US
|
|
|
|
French = 2,
|
|
|
|
German = 3,
|
|
|
|
Italian = 4,
|
|
|
|
Spanish = 5,
|
|
|
|
Chinese = 6,
|
|
|
|
Korean = 7,
|
|
|
|
Dutch = 8,
|
|
|
|
Portuguese = 9,
|
|
|
|
Russian = 10,
|
|
|
|
Taiwanese = 11,
|
|
|
|
BritishEnglish = 12, // en-GB
|
|
|
|
CanadianFrench = 13,
|
|
|
|
LatinAmericanSpanish = 14, // es-419
|
|
|
|
// 4.0.0+
|
|
|
|
SimplifiedChinese = 15,
|
|
|
|
TraditionalChinese = 16,
|
2018-02-02 13:03:40 -08:00
|
|
|
};
|
|
|
|
|
2018-11-06 23:01:33 -08:00
|
|
|
class AppletMessageQueue {
|
|
|
|
public:
|
|
|
|
enum class AppletMessage : u32 {
|
|
|
|
NoMessage = 0,
|
2019-07-06 10:09:27 -07:00
|
|
|
ExitRequested = 4,
|
2018-11-06 23:01:33 -08:00
|
|
|
FocusStateChanged = 15,
|
|
|
|
OperationModeChanged = 30,
|
|
|
|
PerformanceModeChanged = 31,
|
|
|
|
};
|
|
|
|
|
2019-07-10 21:53:55 -07:00
|
|
|
explicit AppletMessageQueue(Kernel::KernelCore& kernel);
|
2018-11-06 23:01:33 -08:00
|
|
|
~AppletMessageQueue();
|
|
|
|
|
2021-01-29 22:48:06 -08:00
|
|
|
const std::shared_ptr<Kernel::KReadableEvent>& GetMessageReceiveEvent() const;
|
|
|
|
const std::shared_ptr<Kernel::KReadableEvent>& GetOperationModeChangedEvent() const;
|
2018-11-06 23:01:33 -08:00
|
|
|
void PushMessage(AppletMessage msg);
|
|
|
|
AppletMessage PopMessage();
|
|
|
|
std::size_t GetMessageCount() const;
|
|
|
|
void OperationModeChanged();
|
2019-07-06 10:09:27 -07:00
|
|
|
void RequestExit();
|
2018-11-06 23:01:33 -08:00
|
|
|
|
|
|
|
private:
|
2018-11-07 01:12:27 -08:00
|
|
|
std::queue<AppletMessage> messages;
|
2021-01-31 01:38:57 -08:00
|
|
|
std::shared_ptr<Kernel::KEvent> on_new_message;
|
|
|
|
std::shared_ptr<Kernel::KEvent> on_operation_mode_changed;
|
2018-11-06 23:01:33 -08:00
|
|
|
};
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
class IWindowController final : public ServiceFramework<IWindowController> {
|
|
|
|
public:
|
2019-07-10 21:53:55 -07:00
|
|
|
explicit IWindowController(Core::System& system_);
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
~IWindowController() override;
|
2018-02-02 13:03:40 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
void GetAppletResourceUserId(Kernel::HLERequestContext& ctx);
|
|
|
|
void AcquireForegroundRights(Kernel::HLERequestContext& ctx);
|
|
|
|
};
|
|
|
|
|
|
|
|
class IAudioController final : public ServiceFramework<IAudioController> {
|
|
|
|
public:
|
2020-11-26 12:19:08 -08:00
|
|
|
explicit IAudioController(Core::System& system_);
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
~IAudioController() override;
|
2018-02-22 06:28:15 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
void SetExpectedMasterVolume(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx);
|
2019-03-17 19:39:29 -07:00
|
|
|
void ChangeMainAppletMasterVolume(Kernel::HLERequestContext& ctx);
|
2019-03-17 18:09:25 -07:00
|
|
|
void SetTransparentAudioRate(Kernel::HLERequestContext& ctx);
|
2018-02-22 06:28:15 -08:00
|
|
|
|
2019-03-17 17:47:03 -07:00
|
|
|
static constexpr float min_allowed_volume = 0.0f;
|
|
|
|
static constexpr float max_allowed_volume = 1.0f;
|
|
|
|
|
|
|
|
float main_applet_volume{0.25f};
|
|
|
|
float library_applet_volume{max_allowed_volume};
|
2019-03-17 18:09:25 -07:00
|
|
|
float transparent_volume_rate{min_allowed_volume};
|
2019-03-17 19:39:29 -07:00
|
|
|
|
|
|
|
// Volume transition fade time in nanoseconds.
|
|
|
|
// e.g. If the main applet volume was 0% and was changed to 50%
|
|
|
|
// with a fade of 50ns, then over the course of 50ns,
|
|
|
|
// the volume will gradually fade up to 50%
|
|
|
|
std::chrono::nanoseconds fade_time_ns{0};
|
2018-02-02 13:03:40 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
class IDisplayController final : public ServiceFramework<IDisplayController> {
|
|
|
|
public:
|
2020-11-26 12:19:08 -08:00
|
|
|
explicit IDisplayController(Core::System& system_);
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
~IDisplayController() override;
|
2018-02-02 13:03:40 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
class IDebugFunctions final : public ServiceFramework<IDebugFunctions> {
|
|
|
|
public:
|
2020-11-26 12:19:08 -08:00
|
|
|
explicit IDebugFunctions(Core::System& system_);
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
~IDebugFunctions() override;
|
2018-02-02 13:03:40 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
class ISelfController final : public ServiceFramework<ISelfController> {
|
|
|
|
public:
|
2020-11-24 14:31:58 -08:00
|
|
|
explicit ISelfController(Core::System& system_, NVFlinger::NVFlinger& nvflinger_);
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
~ISelfController() override;
|
2018-02-02 13:03:40 -08:00
|
|
|
|
|
|
|
private:
|
2019-07-06 10:41:38 -07:00
|
|
|
void Exit(Kernel::HLERequestContext& ctx);
|
2018-02-02 13:03:40 -08:00
|
|
|
void LockExit(Kernel::HLERequestContext& ctx);
|
|
|
|
void UnlockExit(Kernel::HLERequestContext& ctx);
|
2019-03-26 12:12:09 -07:00
|
|
|
void EnterFatalSection(Kernel::HLERequestContext& ctx);
|
|
|
|
void LeaveFatalSection(Kernel::HLERequestContext& ctx);
|
2018-02-07 04:11:17 -08:00
|
|
|
void GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx);
|
2019-03-26 11:54:03 -07:00
|
|
|
void SetScreenShotPermission(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetOperationModeChangedNotification(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetPerformanceModeChangedNotification(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetFocusHandlingMode(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetRestartMessageEnabled(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& ctx);
|
2020-06-26 17:32:26 -07:00
|
|
|
void SetAlbumImageOrientation(Kernel::HLERequestContext& ctx);
|
2018-02-02 13:03:40 -08:00
|
|
|
void CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx);
|
2020-07-05 03:26:07 -07:00
|
|
|
void CreateManagedDisplaySeparableLayer(Kernel::HLERequestContext& ctx);
|
2018-05-07 08:27:30 -07:00
|
|
|
void SetHandlesRequestToDisplay(Kernel::HLERequestContext& ctx);
|
2018-08-16 21:23:08 -07:00
|
|
|
void SetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx);
|
2019-07-11 10:02:29 -07:00
|
|
|
void SetAutoSleepDisabled(Kernel::HLERequestContext& ctx);
|
2019-07-11 10:32:20 -07:00
|
|
|
void IsAutoSleepDisabled(Kernel::HLERequestContext& ctx);
|
2019-07-06 12:13:34 -07:00
|
|
|
void GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx);
|
2019-06-16 02:06:33 -07:00
|
|
|
void GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequestContext& ctx);
|
2021-03-30 09:58:27 -07:00
|
|
|
void SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestContext& ctx);
|
2018-02-02 13:03:40 -08:00
|
|
|
|
2020-07-31 07:44:14 -07:00
|
|
|
enum class ScreenshotPermission : u32 {
|
|
|
|
Inherit = 0,
|
|
|
|
Enable = 1,
|
|
|
|
Disable = 2,
|
|
|
|
};
|
|
|
|
|
2020-11-24 14:31:58 -08:00
|
|
|
NVFlinger::NVFlinger& nvflinger;
|
2021-01-31 01:38:57 -08:00
|
|
|
std::shared_ptr<Kernel::KEvent> launchable_event;
|
|
|
|
std::shared_ptr<Kernel::KEvent> accumulated_suspended_tick_changed_event;
|
2019-06-16 02:06:33 -07:00
|
|
|
|
2018-08-16 21:23:08 -07:00
|
|
|
u32 idle_time_detection_extension = 0;
|
2019-03-26 12:12:09 -07:00
|
|
|
u64 num_fatal_sections_entered = 0;
|
2019-07-11 10:02:29 -07:00
|
|
|
bool is_auto_sleep_disabled = false;
|
2020-07-31 07:44:14 -07:00
|
|
|
ScreenshotPermission screenshot_permission = ScreenshotPermission::Inherit;
|
2018-02-02 13:03:40 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
class ICommonStateGetter final : public ServiceFramework<ICommonStateGetter> {
|
|
|
|
public:
|
2020-11-26 12:19:08 -08:00
|
|
|
explicit ICommonStateGetter(Core::System& system_,
|
|
|
|
std::shared_ptr<AppletMessageQueue> msg_queue_);
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
~ICommonStateGetter() override;
|
2018-02-02 13:03:40 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
enum class FocusState : u8 {
|
|
|
|
InFocus = 1,
|
|
|
|
NotInFocus = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class OperationMode : u8 {
|
|
|
|
Handheld = 0,
|
|
|
|
Docked = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
void GetEventHandle(Kernel::HLERequestContext& ctx);
|
|
|
|
void ReceiveMessage(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetCurrentFocusState(Kernel::HLERequestContext& ctx);
|
2018-08-16 14:20:54 -07:00
|
|
|
void GetDefaultDisplayResolutionChangeEvent(Kernel::HLERequestContext& ctx);
|
2018-02-02 13:03:40 -08:00
|
|
|
void GetOperationMode(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetPerformanceMode(Kernel::HLERequestContext& ctx);
|
2018-08-23 15:31:45 -07:00
|
|
|
void GetBootMode(Kernel::HLERequestContext& ctx);
|
2020-03-26 07:31:45 -07:00
|
|
|
void IsVrModeEnabled(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetVrModeEnabled(Kernel::HLERequestContext& ctx);
|
2020-02-27 08:49:23 -08:00
|
|
|
void SetLcdBacklighOffEnabled(Kernel::HLERequestContext& ctx);
|
2021-01-24 05:34:01 -08:00
|
|
|
void BeginVrModeEx(Kernel::HLERequestContext& ctx);
|
2020-03-26 07:31:45 -07:00
|
|
|
void EndVrModeEx(Kernel::HLERequestContext& ctx);
|
2018-09-18 08:10:16 -07:00
|
|
|
void GetDefaultDisplayResolution(Kernel::HLERequestContext& ctx);
|
2019-06-28 19:46:51 -07:00
|
|
|
void SetCpuBoostMode(Kernel::HLERequestContext& ctx);
|
2018-02-02 13:03:40 -08:00
|
|
|
|
2018-11-06 23:01:33 -08:00
|
|
|
std::shared_ptr<AppletMessageQueue> msg_queue;
|
2020-04-29 04:48:58 -07:00
|
|
|
bool vr_mode_state{};
|
2018-02-02 13:03:40 -08:00
|
|
|
};
|
|
|
|
|
2020-01-26 10:18:13 -08:00
|
|
|
class IStorageImpl {
|
|
|
|
public:
|
|
|
|
virtual ~IStorageImpl();
|
|
|
|
virtual std::vector<u8>& GetData() = 0;
|
|
|
|
virtual const std::vector<u8>& GetData() const = 0;
|
|
|
|
virtual std::size_t GetSize() const = 0;
|
|
|
|
};
|
|
|
|
|
2018-11-09 17:04:07 -08:00
|
|
|
class IStorage final : public ServiceFramework<IStorage> {
|
|
|
|
public:
|
2020-11-26 12:19:08 -08:00
|
|
|
explicit IStorage(Core::System& system_, std::vector<u8>&& buffer);
|
2018-11-11 13:39:25 -08:00
|
|
|
~IStorage() override;
|
2018-11-09 17:04:07 -08:00
|
|
|
|
2020-01-26 10:18:13 -08:00
|
|
|
std::vector<u8>& GetData() {
|
|
|
|
return impl->GetData();
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::vector<u8>& GetData() const {
|
|
|
|
return impl->GetData();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::size_t GetSize() const {
|
|
|
|
return impl->GetSize();
|
|
|
|
}
|
2018-11-09 17:04:07 -08:00
|
|
|
|
|
|
|
private:
|
2020-01-26 10:18:13 -08:00
|
|
|
void Register();
|
2018-11-09 17:04:07 -08:00
|
|
|
void Open(Kernel::HLERequestContext& ctx);
|
|
|
|
|
2020-01-26 10:18:13 -08:00
|
|
|
std::shared_ptr<IStorageImpl> impl;
|
2018-11-09 17:04:07 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
class IStorageAccessor final : public ServiceFramework<IStorageAccessor> {
|
|
|
|
public:
|
2020-11-26 12:19:08 -08:00
|
|
|
explicit IStorageAccessor(Core::System& system_, IStorage& backing_);
|
2018-11-11 13:39:25 -08:00
|
|
|
~IStorageAccessor() override;
|
2018-11-09 17:04:07 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
void GetSize(Kernel::HLERequestContext& ctx);
|
|
|
|
void Write(Kernel::HLERequestContext& ctx);
|
|
|
|
void Read(Kernel::HLERequestContext& ctx);
|
2018-11-11 13:39:25 -08:00
|
|
|
|
|
|
|
IStorage& backing;
|
2018-11-09 17:04:07 -08:00
|
|
|
};
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
class ILibraryAppletCreator final : public ServiceFramework<ILibraryAppletCreator> {
|
|
|
|
public:
|
2019-07-10 21:53:55 -07:00
|
|
|
explicit ILibraryAppletCreator(Core::System& system_);
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
~ILibraryAppletCreator() override;
|
2018-02-07 04:11:17 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
void CreateLibraryApplet(Kernel::HLERequestContext& ctx);
|
2018-06-03 11:19:24 -07:00
|
|
|
void CreateStorage(Kernel::HLERequestContext& ctx);
|
2018-11-09 17:01:20 -08:00
|
|
|
void CreateTransferMemoryStorage(Kernel::HLERequestContext& ctx);
|
2018-02-02 13:03:40 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
class IApplicationFunctions final : public ServiceFramework<IApplicationFunctions> {
|
|
|
|
public:
|
2019-07-10 21:53:55 -07:00
|
|
|
explicit IApplicationFunctions(Core::System& system_);
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
~IApplicationFunctions() override;
|
2018-02-02 13:03:40 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
void PopLaunchParameter(Kernel::HLERequestContext& ctx);
|
2018-05-07 08:27:30 -07:00
|
|
|
void CreateApplicationAndRequestToStartForQuest(Kernel::HLERequestContext& ctx);
|
2018-02-05 17:58:11 -08:00
|
|
|
void EnsureSaveData(Kernel::HLERequestContext& ctx);
|
2018-02-02 13:03:40 -08:00
|
|
|
void SetTerminateResult(Kernel::HLERequestContext& ctx);
|
2018-05-25 21:21:03 -07:00
|
|
|
void GetDisplayVersion(Kernel::HLERequestContext& ctx);
|
2018-02-02 13:03:40 -08:00
|
|
|
void GetDesiredLanguage(Kernel::HLERequestContext& ctx);
|
2021-01-31 00:11:03 -08:00
|
|
|
void IsGamePlayRecordingSupported(Kernel::HLERequestContext& ctx);
|
2018-02-02 13:03:40 -08:00
|
|
|
void InitializeGamePlayRecording(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetGamePlayRecordingState(Kernel::HLERequestContext& ctx);
|
|
|
|
void NotifyRunning(Kernel::HLERequestContext& ctx);
|
2018-06-05 15:44:01 -07:00
|
|
|
void GetPseudoDeviceId(Kernel::HLERequestContext& ctx);
|
2018-12-10 19:17:45 -08:00
|
|
|
void ExtendSaveData(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetSaveDataSize(Kernel::HLERequestContext& ctx);
|
2018-10-19 06:01:10 -07:00
|
|
|
void BeginBlockingHomeButtonShortAndLongPressed(Kernel::HLERequestContext& ctx);
|
|
|
|
void EndBlockingHomeButtonShortAndLongPressed(Kernel::HLERequestContext& ctx);
|
|
|
|
void BeginBlockingHomeButton(Kernel::HLERequestContext& ctx);
|
|
|
|
void EndBlockingHomeButton(Kernel::HLERequestContext& ctx);
|
2018-11-17 06:05:55 -08:00
|
|
|
void EnableApplicationCrashReport(Kernel::HLERequestContext& ctx);
|
2019-11-02 17:26:13 -07:00
|
|
|
void InitializeApplicationCopyrightFrameBuffer(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetApplicationCopyrightImage(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetApplicationCopyrightVisibility(Kernel::HLERequestContext& ctx);
|
2019-11-14 12:59:50 -08:00
|
|
|
void QueryApplicationPlayStatistics(Kernel::HLERequestContext& ctx);
|
2019-11-11 07:21:45 -08:00
|
|
|
void QueryApplicationPlayStatisticsByUid(Kernel::HLERequestContext& ctx);
|
2020-11-24 15:17:43 -08:00
|
|
|
void ExecuteProgram(Kernel::HLERequestContext& ctx);
|
|
|
|
void ClearUserChannel(Kernel::HLERequestContext& ctx);
|
|
|
|
void UnpopToUserChannel(Kernel::HLERequestContext& ctx);
|
2020-09-17 17:45:51 -07:00
|
|
|
void GetPreviousProgramIndex(Kernel::HLERequestContext& ctx);
|
2019-11-14 12:59:50 -08:00
|
|
|
void GetGpuErrorDetectedSystemEvent(Kernel::HLERequestContext& ctx);
|
2020-04-30 05:37:26 -07:00
|
|
|
void GetFriendInvitationStorageChannelEvent(Kernel::HLERequestContext& ctx);
|
2021-01-30 18:43:55 -08:00
|
|
|
void TryPopFromFriendInvitationStorageChannel(Kernel::HLERequestContext& ctx);
|
2021-02-02 07:47:09 -08:00
|
|
|
void GetHealthWarningDisappearedSystemEvent(Kernel::HLERequestContext& ctx);
|
2019-09-04 08:43:04 -07:00
|
|
|
|
2019-05-01 19:40:51 -07:00
|
|
|
bool launch_popped_application_specific = false;
|
|
|
|
bool launch_popped_account_preselect = false;
|
2020-09-17 17:45:51 -07:00
|
|
|
s32 previous_program_index{-1};
|
2021-01-31 01:38:57 -08:00
|
|
|
std::shared_ptr<Kernel::KEvent> gpu_error_detected_event;
|
|
|
|
std::shared_ptr<Kernel::KEvent> friend_invitation_storage_channel_event;
|
|
|
|
std::shared_ptr<Kernel::KEvent> health_warning_disappeared_system_event;
|
2018-02-02 13:03:40 -08:00
|
|
|
};
|
|
|
|
|
2018-05-07 08:27:30 -07:00
|
|
|
class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> {
|
|
|
|
public:
|
2020-11-26 12:19:08 -08:00
|
|
|
explicit IHomeMenuFunctions(Core::System& system_);
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
~IHomeMenuFunctions() override;
|
2018-05-07 08:27:30 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
void RequestToGetForeground(Kernel::HLERequestContext& ctx);
|
2020-04-30 18:20:43 -07:00
|
|
|
void GetPopFromGeneralChannelEvent(Kernel::HLERequestContext& ctx);
|
|
|
|
|
2021-01-31 01:38:57 -08:00
|
|
|
std::shared_ptr<Kernel::KEvent> pop_from_general_channel_event;
|
2018-05-07 08:27:30 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class IGlobalStateController final : public ServiceFramework<IGlobalStateController> {
|
|
|
|
public:
|
2020-11-26 12:19:08 -08:00
|
|
|
explicit IGlobalStateController(Core::System& system_);
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
~IGlobalStateController() override;
|
2018-05-07 08:27:30 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class IApplicationCreator final : public ServiceFramework<IApplicationCreator> {
|
|
|
|
public:
|
2020-11-26 12:19:08 -08:00
|
|
|
explicit IApplicationCreator(Core::System& system_);
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
~IApplicationCreator() override;
|
2018-05-07 08:27:30 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class IProcessWindingController final : public ServiceFramework<IProcessWindingController> {
|
|
|
|
public:
|
2020-11-26 12:19:08 -08:00
|
|
|
explicit IProcessWindingController(Core::System& system_);
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
~IProcessWindingController() override;
|
2018-05-07 08:27:30 -07:00
|
|
|
};
|
|
|
|
|
2017-10-14 19:50:04 -07:00
|
|
|
/// Registers all AM services with the specified service manager.
|
2020-11-24 14:31:58 -08:00
|
|
|
void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger,
|
|
|
|
Core::System& system);
|
2017-10-14 19:50:04 -07:00
|
|
|
|
2019-07-10 21:53:55 -07:00
|
|
|
} // namespace Service::AM
|