2018-01-13 21:22:39 +00:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2017-10-15 02:50:04 +00:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-03-18 02:39:29 +00:00
|
|
|
#include <chrono>
|
2018-01-22 18:46:36 +00:00
|
|
|
#include <memory>
|
2018-11-07 07:01:33 +00:00
|
|
|
#include <queue>
|
2018-11-27 14:18:29 +00:00
|
|
|
#include "core/hle/kernel/writable_event.h"
|
2017-10-15 02:50:04 +00:00
|
|
|
#include "core/hle/service/service.h"
|
|
|
|
|
2019-07-11 04:53:55 +00:00
|
|
|
namespace Kernel {
|
|
|
|
class KernelCore;
|
2020-01-26 18:18:13 +00:00
|
|
|
class TransferMemory;
|
|
|
|
} // namespace Kernel
|
2019-07-11 04:53:55 +00:00
|
|
|
|
|
|
|
namespace Service::NVFlinger {
|
2018-01-22 18:46:36 +00:00
|
|
|
class NVFlinger;
|
|
|
|
}
|
|
|
|
|
2019-07-11 04:53:55 +00:00
|
|
|
namespace Service::AM {
|
2017-10-15 02:50:04 +00:00
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
enum SystemLanguage {
|
|
|
|
Japanese = 0,
|
2018-05-26 02:31:54 +00: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 21:03:40 +00:00
|
|
|
};
|
|
|
|
|
2018-11-07 07:01:33 +00:00
|
|
|
class AppletMessageQueue {
|
|
|
|
public:
|
|
|
|
enum class AppletMessage : u32 {
|
|
|
|
NoMessage = 0,
|
2019-07-06 17:09:27 +00:00
|
|
|
ExitRequested = 4,
|
2018-11-07 07:01:33 +00:00
|
|
|
FocusStateChanged = 15,
|
|
|
|
OperationModeChanged = 30,
|
|
|
|
PerformanceModeChanged = 31,
|
|
|
|
};
|
|
|
|
|
2019-07-11 04:53:55 +00:00
|
|
|
explicit AppletMessageQueue(Kernel::KernelCore& kernel);
|
2018-11-07 07:01:33 +00:00
|
|
|
~AppletMessageQueue();
|
|
|
|
|
2021-01-02 14:00:05 +00:00
|
|
|
const std::shared_ptr<Kernel::ReadableEvent>& GetMessageReceiveEvent() const;
|
2019-11-25 01:15:51 +00:00
|
|
|
const std::shared_ptr<Kernel::ReadableEvent>& GetOperationModeChangedEvent() const;
|
2018-11-07 07:01:33 +00:00
|
|
|
void PushMessage(AppletMessage msg);
|
|
|
|
AppletMessage PopMessage();
|
|
|
|
std::size_t GetMessageCount() const;
|
|
|
|
void OperationModeChanged();
|
2019-07-06 17:09:27 +00:00
|
|
|
void RequestExit();
|
2018-11-07 07:01:33 +00:00
|
|
|
|
|
|
|
private:
|
2018-11-07 09:12:27 +00:00
|
|
|
std::queue<AppletMessage> messages;
|
2018-11-27 14:18:29 +00:00
|
|
|
Kernel::EventPair on_new_message;
|
|
|
|
Kernel::EventPair on_operation_mode_changed;
|
2018-11-07 07:01:33 +00:00
|
|
|
};
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
class IWindowController final : public ServiceFramework<IWindowController> {
|
|
|
|
public:
|
2019-07-11 04:53:55 +00: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-11 01:20:52 +00:00
|
|
|
~IWindowController() override;
|
2018-02-02 21:03:40 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void GetAppletResourceUserId(Kernel::HLERequestContext& ctx);
|
|
|
|
void AcquireForegroundRights(Kernel::HLERequestContext& ctx);
|
|
|
|
};
|
|
|
|
|
|
|
|
class IAudioController final : public ServiceFramework<IAudioController> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00: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-11 01:20:52 +00:00
|
|
|
~IAudioController() override;
|
2018-02-22 14:28:15 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void SetExpectedMasterVolume(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx);
|
2019-03-18 02:39:29 +00:00
|
|
|
void ChangeMainAppletMasterVolume(Kernel::HLERequestContext& ctx);
|
2019-03-18 01:09:25 +00:00
|
|
|
void SetTransparentAudioRate(Kernel::HLERequestContext& ctx);
|
2018-02-22 14:28:15 +00:00
|
|
|
|
2019-03-18 00:47:03 +00: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-18 01:09:25 +00:00
|
|
|
float transparent_volume_rate{min_allowed_volume};
|
2019-03-18 02:39:29 +00: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 21:03:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class IDisplayController final : public ServiceFramework<IDisplayController> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00: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-11 01:20:52 +00:00
|
|
|
~IDisplayController() override;
|
2018-02-02 21:03:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class IDebugFunctions final : public ServiceFramework<IDebugFunctions> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00: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-11 01:20:52 +00:00
|
|
|
~IDebugFunctions() override;
|
2018-02-02 21:03:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class ISelfController final : public ServiceFramework<ISelfController> {
|
|
|
|
public:
|
2020-11-24 22:31:58 +00: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-11 01:20:52 +00:00
|
|
|
~ISelfController() override;
|
2018-02-02 21:03:40 +00:00
|
|
|
|
|
|
|
private:
|
2019-07-06 17:41:38 +00:00
|
|
|
void Exit(Kernel::HLERequestContext& ctx);
|
2018-02-02 21:03:40 +00:00
|
|
|
void LockExit(Kernel::HLERequestContext& ctx);
|
|
|
|
void UnlockExit(Kernel::HLERequestContext& ctx);
|
2019-03-26 19:12:09 +00:00
|
|
|
void EnterFatalSection(Kernel::HLERequestContext& ctx);
|
|
|
|
void LeaveFatalSection(Kernel::HLERequestContext& ctx);
|
2018-02-07 12:11:17 +00:00
|
|
|
void GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx);
|
2019-03-26 18:54:03 +00: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-27 00:32:26 +00:00
|
|
|
void SetAlbumImageOrientation(Kernel::HLERequestContext& ctx);
|
2018-02-02 21:03:40 +00:00
|
|
|
void CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx);
|
2020-07-05 10:26:07 +00:00
|
|
|
void CreateManagedDisplaySeparableLayer(Kernel::HLERequestContext& ctx);
|
2018-05-07 15:27:30 +00:00
|
|
|
void SetHandlesRequestToDisplay(Kernel::HLERequestContext& ctx);
|
2018-08-17 04:23:08 +00:00
|
|
|
void SetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx);
|
2019-07-11 17:02:29 +00:00
|
|
|
void SetAutoSleepDisabled(Kernel::HLERequestContext& ctx);
|
2019-07-11 17:32:20 +00:00
|
|
|
void IsAutoSleepDisabled(Kernel::HLERequestContext& ctx);
|
2019-07-06 19:13:34 +00:00
|
|
|
void GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx);
|
2019-06-16 09:06:33 +00:00
|
|
|
void GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequestContext& ctx);
|
2018-02-02 21:03:40 +00:00
|
|
|
|
2020-07-31 14:44:14 +00:00
|
|
|
enum class ScreenshotPermission : u32 {
|
|
|
|
Inherit = 0,
|
|
|
|
Enable = 1,
|
|
|
|
Disable = 2,
|
|
|
|
};
|
|
|
|
|
2020-11-24 22:31:58 +00:00
|
|
|
NVFlinger::NVFlinger& nvflinger;
|
2018-11-27 14:18:29 +00:00
|
|
|
Kernel::EventPair launchable_event;
|
2019-06-16 09:06:33 +00:00
|
|
|
Kernel::EventPair accumulated_suspended_tick_changed_event;
|
|
|
|
|
2018-08-17 04:23:08 +00:00
|
|
|
u32 idle_time_detection_extension = 0;
|
2019-03-26 19:12:09 +00:00
|
|
|
u64 num_fatal_sections_entered = 0;
|
2019-07-11 17:02:29 +00:00
|
|
|
bool is_auto_sleep_disabled = false;
|
2020-07-31 14:44:14 +00:00
|
|
|
ScreenshotPermission screenshot_permission = ScreenshotPermission::Inherit;
|
2018-02-02 21:03:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class ICommonStateGetter final : public ServiceFramework<ICommonStateGetter> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00: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-11 01:20:52 +00:00
|
|
|
~ICommonStateGetter() override;
|
2018-02-02 21:03:40 +00: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 21:20:54 +00:00
|
|
|
void GetDefaultDisplayResolutionChangeEvent(Kernel::HLERequestContext& ctx);
|
2018-02-02 21:03:40 +00:00
|
|
|
void GetOperationMode(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetPerformanceMode(Kernel::HLERequestContext& ctx);
|
2018-08-23 22:31:45 +00:00
|
|
|
void GetBootMode(Kernel::HLERequestContext& ctx);
|
2020-03-26 14:31:45 +00:00
|
|
|
void IsVrModeEnabled(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetVrModeEnabled(Kernel::HLERequestContext& ctx);
|
2020-02-27 16:49:23 +00:00
|
|
|
void SetLcdBacklighOffEnabled(Kernel::HLERequestContext& ctx);
|
2021-01-24 13:34:01 +00:00
|
|
|
void BeginVrModeEx(Kernel::HLERequestContext& ctx);
|
2020-03-26 14:31:45 +00:00
|
|
|
void EndVrModeEx(Kernel::HLERequestContext& ctx);
|
2018-09-18 15:10:16 +00:00
|
|
|
void GetDefaultDisplayResolution(Kernel::HLERequestContext& ctx);
|
2019-06-29 02:46:51 +00:00
|
|
|
void SetCpuBoostMode(Kernel::HLERequestContext& ctx);
|
2018-02-02 21:03:40 +00:00
|
|
|
|
2018-11-07 07:01:33 +00:00
|
|
|
std::shared_ptr<AppletMessageQueue> msg_queue;
|
2020-04-29 11:48:58 +00:00
|
|
|
bool vr_mode_state{};
|
2018-02-02 21:03:40 +00:00
|
|
|
};
|
|
|
|
|
2020-01-26 18:18:13 +00: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-10 01:04:07 +00:00
|
|
|
class IStorage final : public ServiceFramework<IStorage> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00:00
|
|
|
explicit IStorage(Core::System& system_, std::vector<u8>&& buffer);
|
2018-11-11 21:39:25 +00:00
|
|
|
~IStorage() override;
|
2018-11-10 01:04:07 +00:00
|
|
|
|
2020-01-26 18:18:13 +00: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-10 01:04:07 +00:00
|
|
|
|
|
|
|
private:
|
2020-01-26 18:18:13 +00:00
|
|
|
void Register();
|
2018-11-10 01:04:07 +00:00
|
|
|
void Open(Kernel::HLERequestContext& ctx);
|
|
|
|
|
2020-01-26 18:18:13 +00:00
|
|
|
std::shared_ptr<IStorageImpl> impl;
|
2018-11-10 01:04:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class IStorageAccessor final : public ServiceFramework<IStorageAccessor> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00:00
|
|
|
explicit IStorageAccessor(Core::System& system_, IStorage& backing_);
|
2018-11-11 21:39:25 +00:00
|
|
|
~IStorageAccessor() override;
|
2018-11-10 01:04:07 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void GetSize(Kernel::HLERequestContext& ctx);
|
|
|
|
void Write(Kernel::HLERequestContext& ctx);
|
|
|
|
void Read(Kernel::HLERequestContext& ctx);
|
2018-11-11 21:39:25 +00:00
|
|
|
|
|
|
|
IStorage& backing;
|
2018-11-10 01:04:07 +00:00
|
|
|
};
|
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
class ILibraryAppletCreator final : public ServiceFramework<ILibraryAppletCreator> {
|
|
|
|
public:
|
2019-07-11 04:53:55 +00: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-11 01:20:52 +00:00
|
|
|
~ILibraryAppletCreator() override;
|
2018-02-07 12:11:17 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void CreateLibraryApplet(Kernel::HLERequestContext& ctx);
|
2018-06-03 18:19:24 +00:00
|
|
|
void CreateStorage(Kernel::HLERequestContext& ctx);
|
2018-11-10 01:01:20 +00:00
|
|
|
void CreateTransferMemoryStorage(Kernel::HLERequestContext& ctx);
|
2018-02-02 21:03:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class IApplicationFunctions final : public ServiceFramework<IApplicationFunctions> {
|
|
|
|
public:
|
2019-07-11 04:53:55 +00: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-11 01:20:52 +00:00
|
|
|
~IApplicationFunctions() override;
|
2018-02-02 21:03:40 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void PopLaunchParameter(Kernel::HLERequestContext& ctx);
|
2018-05-07 15:27:30 +00:00
|
|
|
void CreateApplicationAndRequestToStartForQuest(Kernel::HLERequestContext& ctx);
|
2018-02-06 01:58:11 +00:00
|
|
|
void EnsureSaveData(Kernel::HLERequestContext& ctx);
|
2018-02-02 21:03:40 +00:00
|
|
|
void SetTerminateResult(Kernel::HLERequestContext& ctx);
|
2018-05-26 04:21:03 +00:00
|
|
|
void GetDisplayVersion(Kernel::HLERequestContext& ctx);
|
2018-02-02 21:03:40 +00:00
|
|
|
void GetDesiredLanguage(Kernel::HLERequestContext& ctx);
|
2021-01-31 08:11:03 +00:00
|
|
|
void IsGamePlayRecordingSupported(Kernel::HLERequestContext& ctx);
|
2018-02-02 21:03:40 +00:00
|
|
|
void InitializeGamePlayRecording(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetGamePlayRecordingState(Kernel::HLERequestContext& ctx);
|
|
|
|
void NotifyRunning(Kernel::HLERequestContext& ctx);
|
2018-06-05 22:44:01 +00:00
|
|
|
void GetPseudoDeviceId(Kernel::HLERequestContext& ctx);
|
2018-12-11 03:17:45 +00:00
|
|
|
void ExtendSaveData(Kernel::HLERequestContext& ctx);
|
|
|
|
void GetSaveDataSize(Kernel::HLERequestContext& ctx);
|
2018-10-19 13:01:10 +00:00
|
|
|
void BeginBlockingHomeButtonShortAndLongPressed(Kernel::HLERequestContext& ctx);
|
|
|
|
void EndBlockingHomeButtonShortAndLongPressed(Kernel::HLERequestContext& ctx);
|
|
|
|
void BeginBlockingHomeButton(Kernel::HLERequestContext& ctx);
|
|
|
|
void EndBlockingHomeButton(Kernel::HLERequestContext& ctx);
|
2018-11-17 14:05:55 +00:00
|
|
|
void EnableApplicationCrashReport(Kernel::HLERequestContext& ctx);
|
2019-11-03 00:26:13 +00:00
|
|
|
void InitializeApplicationCopyrightFrameBuffer(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetApplicationCopyrightImage(Kernel::HLERequestContext& ctx);
|
|
|
|
void SetApplicationCopyrightVisibility(Kernel::HLERequestContext& ctx);
|
2019-11-14 20:59:50 +00:00
|
|
|
void QueryApplicationPlayStatistics(Kernel::HLERequestContext& ctx);
|
2019-11-11 15:21:45 +00:00
|
|
|
void QueryApplicationPlayStatisticsByUid(Kernel::HLERequestContext& ctx);
|
2020-11-24 23:17:43 +00:00
|
|
|
void ExecuteProgram(Kernel::HLERequestContext& ctx);
|
|
|
|
void ClearUserChannel(Kernel::HLERequestContext& ctx);
|
|
|
|
void UnpopToUserChannel(Kernel::HLERequestContext& ctx);
|
2020-09-18 00:45:51 +00:00
|
|
|
void GetPreviousProgramIndex(Kernel::HLERequestContext& ctx);
|
2019-11-14 20:59:50 +00:00
|
|
|
void GetGpuErrorDetectedSystemEvent(Kernel::HLERequestContext& ctx);
|
2020-04-30 12:37:26 +00:00
|
|
|
void GetFriendInvitationStorageChannelEvent(Kernel::HLERequestContext& ctx);
|
2021-01-31 02:43:55 +00:00
|
|
|
void TryPopFromFriendInvitationStorageChannel(Kernel::HLERequestContext& ctx);
|
2019-09-04 15:43:04 +00:00
|
|
|
|
2019-05-02 02:40:51 +00:00
|
|
|
bool launch_popped_application_specific = false;
|
|
|
|
bool launch_popped_account_preselect = false;
|
2020-09-18 00:45:51 +00:00
|
|
|
s32 previous_program_index{-1};
|
2019-09-04 15:43:04 +00:00
|
|
|
Kernel::EventPair gpu_error_detected_event;
|
2020-04-30 12:37:26 +00:00
|
|
|
Kernel::EventPair friend_invitation_storage_channel_event;
|
2018-02-02 21:03:40 +00:00
|
|
|
};
|
|
|
|
|
2018-05-07 15:27:30 +00:00
|
|
|
class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00: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-11 01:20:52 +00:00
|
|
|
~IHomeMenuFunctions() override;
|
2018-05-07 15:27:30 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void RequestToGetForeground(Kernel::HLERequestContext& ctx);
|
2020-05-01 01:20:43 +00:00
|
|
|
void GetPopFromGeneralChannelEvent(Kernel::HLERequestContext& ctx);
|
|
|
|
|
|
|
|
Kernel::EventPair pop_from_general_channel_event;
|
2018-05-07 15:27:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class IGlobalStateController final : public ServiceFramework<IGlobalStateController> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00: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-11 01:20:52 +00:00
|
|
|
~IGlobalStateController() override;
|
2018-05-07 15:27:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class IApplicationCreator final : public ServiceFramework<IApplicationCreator> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00: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-11 01:20:52 +00:00
|
|
|
~IApplicationCreator() override;
|
2018-05-07 15:27:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class IProcessWindingController final : public ServiceFramework<IProcessWindingController> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00: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-11 01:20:52 +00:00
|
|
|
~IProcessWindingController() override;
|
2018-05-07 15:27:30 +00:00
|
|
|
};
|
|
|
|
|
2017-10-15 02:50:04 +00:00
|
|
|
/// Registers all AM services with the specified service manager.
|
2020-11-24 22:31:58 +00:00
|
|
|
void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger,
|
|
|
|
Core::System& system);
|
2017-10-15 02:50:04 +00:00
|
|
|
|
2019-07-11 04:53:55 +00:00
|
|
|
} // namespace Service::AM
|