Commit Graph

88 Commits

Author SHA1 Message Date
fearlessTobi
63c2e32e20 Port #4182 from Citra: "Prefix all size_t with std::" 2018-09-15 15:21:06 +02:00
Lioncash
6ac955a0b4 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 23:55:31 -04:00
Lioncash
0cbcd6ec9a kernel: Eliminate kernel global state
As means to pave the way for getting rid of global state within core,
This eliminates kernel global state by removing all globals. Instead
this introduces a KernelCore class which acts as a kernel instance. This
instance lives in the System class, which keeps its lifetime contained
to the lifetime of the System class.

This also forces the kernel types to actually interact with the main
kernel instance itself instead of having transient kernel state placed
all over several translation units, keeping everything together. It also
has a nice consequence of making dependencies much more explicit.

This also makes our initialization a tad bit more correct. Previously we
were creating a kernel process before the actual kernel was initialized,
which doesn't really make much sense.

The KernelCore class itself follows the PImpl idiom, which allows
keeping all the implementation details sealed away from everything else,
which forces the use of the exposed API and allows us to avoid any
unnecessary inclusions within the main kernel header.
2018-08-28 22:31:51 -04:00
David
5049ca5d8c Added GetBootMode (#1107)
* Added GetBootMode

Used by homebrew

* Added enum for GetBootMode
2018-08-23 18:31:45 -04:00
Lioncash
8dd9cb98ce am: Utilize std::array within PopLaunchParameter()
Gets rid of the potential for C array-to-pointer decay, and also makes
pointer arithmetic to get the end of the copy range unnecessary. We can
just use std::array's begin() and end() member functions.
2018-08-21 11:03:14 -04:00
greggameplayer
2003771789 Implement SetIdleTimeDetectionExtension & GetIdleTimeDetectionExtension (#1059)
* Used by Mario Tennis Aces
2018-08-17 00:23:08 -04:00
greggameplayer
cef35e7c9c
correct coding style 2018-08-16 23:46:06 +02:00
greggameplayer
928e78dced Implement GetDefaultDisplayResolutionChangeEvent
Require by Toki Tori and Toki Tori 2+
2018-08-16 23:25:54 +02:00
bunnei
b7fb9f2071 am: Stub SetScreenShotImageOrientation.
- Used by Super Mario Odyssey.
2018-08-08 00:41:35 -04:00
David
c1d54f4aea Added ability to change username & language code in the settings ui. Added IProfile::Get and SET::GetLanguageCode for libnx tests (#851) 2018-08-03 11:02:55 -04:00
Lioncash
7da8f15461 service/am: Add missing am services
Adds the basic skeleton for missing am services idle:sys, omm, and spsm
based off the information provided by Switch Brew.
2018-07-31 08:02:20 -04:00
Lioncash
c061c2bf3c hle/service: Make constructors explicit where applicable
Prevents implicit construction and makes these lingering non-explicit
constructors consistent with the rest of the other classes in services.
2018-07-19 12:25:02 -04:00
Zach Hilman
29aff8d5ab Virtual Filesystem 2: Electric Boogaloo (#676)
* Virtual Filesystem

* Fix delete bug and documentate

* Review fixes + other stuff

* Fix puyo regression
2018-07-18 18:07:11 -07:00
Zach Hilman
69bfe075b5 General Filesystem and Save Data Fixes (#670) 2018-07-17 12:42:15 -07:00
bunnei
913896cbd9 Revert "Virtual Filesystem (#597)"
This reverts commit 77c684c114.
2018-07-07 20:24:51 -07:00
Zach Hilman
77c684c114 Virtual Filesystem (#597)
* Add VfsFile and VfsDirectory classes

* Finish abstract Vfs classes

* Implement RealVfsFile (computer fs backend)

* Finish RealVfsFile and RealVfsDirectory

* Finished OffsetVfsFile

* More changes

* Fix import paths

* Major refactor

* Remove double const

* Use experimental/filesystem or filesystem depending on compiler

* Port partition_filesystem

* More changes

* More Overhaul

* FSP_SRV fixes

* Fixes and testing

* Try to get filesystem to compile

* Filesystem on linux

* Remove std::filesystem and document/test

* Compile fixes

* Missing include

* Bug fixes

* Fixes

* Rename v_file and v_dir

* clang-format fix

* Rename NGLOG_* to LOG_*

* Most review changes

* Fix TODO

* Guess 'main' to be Directory by filename
2018-07-06 10:51:32 -04:00
James Rowe
638956aa81 Rename logging macro back to LOG_* 2018-07-02 21:45:47 -04:00
bunnei
2abe5e39fc am: Stub out IApplicationFunctions::GetPseudoDeviceId. 2018-06-05 23:54:02 -04:00
bunnei
afdd2f4cad am: Implement ILibraryAppletAccessor::PopOutData. 2018-06-03 23:44:23 -04:00
bunnei
df4336a85e am: ISelfController:LaunchableEvent should be sticky. 2018-06-03 23:44:22 -04:00
bunnei
51d8a2c322 am: Stub out ILibraryAppletAccessor Start and GetResult methods. 2018-06-03 23:44:22 -04:00
bunnei
876b805e50 am: Implement ILibraryAppletAccessor::PushInData. 2018-06-03 22:10:06 -04:00
bunnei
2dcb98226b am: Implement IStorageAccessor::Write. 2018-06-03 22:10:06 -04:00
bunnei
9fedfbe141 am: Cleanup IStorageAccessor::Read. 2018-06-03 22:10:06 -04:00
bunnei
d73c22bf4d am: Implement ILibraryAppletCreator::CreateStorage. 2018-06-03 22:10:05 -04:00
bunnei
0d681f7a7a am: Stub IApplicationFunctions GetDisplayVersion. 2018-05-26 00:21:59 -04:00
greggameplayer
b16e5c6a81 Add & correct miscellaneous things (#470)
* add some InfoType

* correct OpenApplicationProxy cmd number

* add IDisplayController functions

* fix clang-format

* add more system languages
2018-05-25 22:31:54 -04:00
Hexagon12
5e9c547952 Stubs for QLaunch (#428)
* Stubs for QLaunch

* Wiped unrelated stuff

* Addressed comment

* Dropped GetPopFromGeneralChannelEvent
2018-05-07 11:27:30 -04:00
Lioncash
7c9644646f
general: Make formatting of logged hex values more straightforward
This makes the formatting expectations more obvious (e.g. any zero padding specified
is padding that's entirely dedicated to the value being printed, not any pretty-printing
that also gets tacked on).
2018-05-02 09:49:36 -04:00
bunnei
334e859ab1 am: Fix GetDesiredLanguage implementation. 2018-04-29 11:07:07 -04:00
Lioncash
5483c08b44
am: Move logging macros over to new fmt-compatible ones 2018-04-24 10:14:11 -04:00
Lioncash
ccca5e7c28 service: Use nested namespace specifiers where applicable
Tidies up namespace declarations
2018-04-19 22:20:28 -04:00
Hexagon12
cc89b7bfcb Various fixes and clang 2018-04-11 14:48:56 +03:00
Hexagon12
434cffa37d
Updated AppletOE with more service names. 2018-04-10 18:41:17 +03:00
Hexagon12
0cc2e7d81d
Updated AppletAE with more service names. 2018-04-10 18:39:46 +03:00
Hexagon12
84d39530cf
Updated AM with more service names. 2018-04-10 18:36:00 +03:00
bunnei
5ecf152c8e config: Rename is_docked to use_docked_mode to be consistent with other config bools. 2018-03-26 23:02:36 -04:00
bunnei
12b05c719e config: Add setting for whether the system is docked or not. 2018-03-26 23:02:35 -04:00
Subv
0eefe6e4d1 FS: Make EnsureSaveData create the savedata folder when called for the first time. 2018-03-04 14:30:07 -05:00
mailwl
e4f94ee30b Stub more functions 2018-02-22 17:28:15 +03:00
mailwl
910198a29a Stub am::SetScreenShotPermission, and bsd::StartMonitoring functions 2018-02-22 13:04:23 +03:00
Subv
5ab285f1f9 AM: Corrected the response in EnsureSaveData.
The values are still unknown and the function is still considered a stub.
Puyo Puyo Tetris now tries to call fsp-srv:MountSaveData.
2018-02-18 18:09:52 -05:00
bunnei
516a95721c service: Remove remaining uses of BufferDescriptor*. 2018-02-13 23:54:13 -05:00
mailwl
335096e19a Service: stub some functions in am, audio, time, vi services 2018-02-07 15:11:17 +03:00
bunnei
c83f69841f IApplicationFunctions: Stub out EnsureSaveData. 2018-02-05 20:58:11 -05:00
bunnei
65cfe09b62 logger: Add AM service logging category. 2018-02-04 16:58:12 -05:00
mailwl
1a8f5bfb8e Service/am: Add AppletAE service (#153)
* Add AppletAE, step 1: move common interfaces to am.h

* Add AppletAE, step 2
2018-02-02 13:03:40 -08:00
bunnei
1b1d399e5f hle: Rename RequestBuilder to ResponseBuilder. 2018-01-24 22:24:10 -05:00
bunnei
f9dae99006 service: Fix all incorrect IPC response headers. 2018-01-24 22:21:33 -05:00
Subv
10c67bf395 AppletOE: Stubbed CreateManagedDisplayLayer to create a new layer in the Default display.
This function is used by libnx to obtain a new layer.
2018-01-22 13:50:22 -05:00