Format code and misc cleanup

This commit is contained in:
Billy Laws 2020-08-09 15:02:38 +01:00 committed by ◱ PixelyIon
parent fcae5d54da
commit ade8a711fb
17 changed files with 60 additions and 46 deletions

View File

@ -39,9 +39,12 @@ add_library(skyline SHARED
${source_DIR}/skyline/audio/resampler.cpp
${source_DIR}/skyline/audio/adpcm_decoder.cpp
${source_DIR}/skyline/gpu.cpp
${source_DIR}/skyline/gpu/macro_interpreter.cpp
${source_DIR}/skyline/gpu/memory_manager.cpp
${source_DIR}/skyline/gpu/gpfifo.cpp
${source_DIR}/skyline/gpu/syncpoint.cpp
${source_DIR}/skyline/gpu/texture.cpp
${source_DIR}/skyline/gpu/engines/maxwell_3d.cpp
${source_DIR}/skyline/os.cpp
${source_DIR}/skyline/loader/loader.cpp
${source_DIR}/skyline/loader/nro.cpp
@ -124,6 +127,7 @@ add_library(skyline SHARED
${source_DIR}/skyline/services/account/IProfile.cpp
${source_DIR}/skyline/services/friends/IServiceCreator.cpp
${source_DIR}/skyline/services/friends/IFriendService.cpp
${source_DIR}/skyline/services/friends/INotificationService.cpp
${source_DIR}/skyline/services/nfp/IUserManager.cpp
${source_DIR}/skyline/services/nfp/IUser.cpp
${source_DIR}/skyline/services/nifm/IStaticService.cpp
@ -131,6 +135,7 @@ add_library(skyline SHARED
${source_DIR}/skyline/services/nifm/IRequest.cpp
${source_DIR}/skyline/services/socket/bsd/IClient.cpp
${source_DIR}/skyline/services/ssl/ISslService.cpp
${source_DIR}/skyline/services/ssl/ISslContext.cpp
${source_DIR}/skyline/services/prepo/IPrepoService.cpp
${source_DIR}/skyline/vfs/os_filesystem.cpp
${source_DIR}/skyline/vfs/partition_filesystem.cpp

View File

@ -15,7 +15,7 @@ namespace skyline::audio {
template<typename Type, size_t Size>
class CircularBuffer {
private:
std::array <Type, Size> array{}; //!< The internal array holding the circular buffer
std::array<Type, Size> array{}; //!< The internal array holding the circular buffer
Type *start{array.begin()}; //!< The start/oldest element of the internal array
Type *end{array.begin()}; //!< The end/newest element of the internal array
bool empty{true}; //!< This boolean is used to differentiate between the buffer being full or empty
@ -145,7 +145,7 @@ namespace skyline::audio {
* @brief This appends data from a vector to the buffer
* @param sampleData A reference to a vector containing the data to be appended
*/
inline void Append(const std::vector <Type> &data) {
inline void Append(const std::vector<Type> &data) {
Append(const_cast<Type *>(data.data()), data.size());
}
};

View File

@ -328,26 +328,26 @@ namespace skyline {
};
enum class CounterType : u8 {
Zero = 0x0,
InputVertices = 0x1,
InputPrimitives = 0x3,
VertexShaderInvocations = 0x5,
GeometryShaderInvocations = 0x7,
GeometryShaderPrimitives = 0x9,
ZcullStats0 = 0xa,
Zero = 0x0,
InputVertices = 0x1,
InputPrimitives = 0x3,
VertexShaderInvocations = 0x5,
GeometryShaderInvocations = 0x7,
GeometryShaderPrimitives = 0x9,
ZcullStats0 = 0xa,
TransformFeedbackPrimitivesWritten = 0xb,
ZcullStats1 = 0xc,
ZcullStats2 = 0xe,
ClipperInputPrimitives = 0xf,
ZcullStats3 = 0x10,
ClipperOutputPrimitives = 0x11,
PrimitivesGenerated = 0x12,
FragmentShaderInvocations = 0x13,
SamplesPassed = 0x15,
TransformFeedbackOffset = 0x1a,
TessControlShaderInvocations = 0x1b,
TessEvaluationShaderInvocations = 0x1d,
TessEvaluationShaderPrimitives = 0x1f
ZcullStats1 = 0xc,
ZcullStats2 = 0xe,
ClipperInputPrimitives = 0xf,
ZcullStats3 = 0x10,
ClipperOutputPrimitives = 0x11,
PrimitivesGenerated = 0x12,
FragmentShaderInvocations = 0x13,
SamplesPassed = 0x15,
TransformFeedbackOffset = 0x1a,
TessControlShaderInvocations = 0x1b,
TessEvaluationShaderInvocations = 0x1d,
TessEvaluationShaderPrimitives = 0x1f
};
enum class StructureSize : u8 {

View File

@ -83,7 +83,7 @@ namespace skyline::gpu {
opcode += opcode->immediate;
return true;
} else {
Opcode* targetOpcode = opcode + opcode->immediate;
Opcode *targetOpcode = opcode + opcode->immediate;
// Step into delay slot
opcode++;

View File

@ -113,7 +113,7 @@ namespace skyline {
*/
template<typename T>
void Read(std::span<T> destination, u64 address) const {
Read(reinterpret_cast<u8*>(destination.data()), address, destination.size_bytes());
Read(reinterpret_cast<u8 *>(destination.data()), address, destination.size_bytes());
}
/**
@ -123,7 +123,7 @@ namespace skyline {
template<typename T>
T Read(u64 address) const {
T obj;
Read(reinterpret_cast<u8*>(&obj), address, sizeof(T));
Read(reinterpret_cast<u8 *>(&obj), address, sizeof(T));
return obj;
}
@ -134,7 +134,7 @@ namespace skyline {
*/
template<typename T>
void Write(std::span<T> source, u64 address) const {
Write(reinterpret_cast<u8*>(source.data()), address, source.size_bytes());
Write(reinterpret_cast<u8 *>(source.data()), address, source.size_bytes());
}
/**
@ -143,7 +143,7 @@ namespace skyline {
*/
template<typename T>
void Write(T source, u64 address) const {
Write(reinterpret_cast<u8*>(&source), address, sizeof(T));
Write(reinterpret_cast<u8 *>(&source), address, sizeof(T));
}
};
}

View File

@ -24,7 +24,7 @@ namespace skyline::loader {
}
}
if (!programNca.has_value() || !controlNca.has_value())
if (!programNca || !controlNca)
throw exception("Incomplete NSP file");
romFs = programNca->romFs;

View File

@ -10,6 +10,6 @@ namespace skyline::service::apm {
}) {}
void IManager::OpenSession(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
manager.RegisterService(std::make_shared<ISession>(state, manager), session, response);
manager.RegisterService(SRVREG(ISession), session, response);
}
}

View File

@ -68,11 +68,11 @@ namespace skyline::service::audio::IAudioRenderer {
state.process->ReadMemory(samples.data(), currentBuffer.address, currentBuffer.size);
break;
case skyline::audio::AudioFormat::ADPCM: {
std::vector<u8> adpcmData(currentBuffer.size);
state.process->ReadMemory(adpcmData.data(), currentBuffer.address, currentBuffer.size);
samples = adpcmDecoder->Decode(adpcmData);
}
std::vector<u8> adpcmData(currentBuffer.size);
state.process->ReadMemory(adpcmData.data(), currentBuffer.address, currentBuffer.size);
samples = adpcmDecoder->Decode(adpcmData);
break;
}
default:
throw exception("Unsupported PCM format used by Voice: {}", format);
}

View File

@ -2,14 +2,20 @@
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
#include "IFriendService.h"
#include "INotificationService.h"
#include "IServiceCreator.h"
namespace skyline::service::friends {
IServiceCreator::IServiceCreator(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::friends_IServiceCreator, "friends:IServiceCreator", {
{0x0, SFUNC(IServiceCreator::CreateFriendService)}
{0x0, SFUNC(IServiceCreator::CreateFriendService)},
{0x1, SFUNC(IServiceCreator::CreateNotificationService)},
}) {}
void IServiceCreator::CreateFriendService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
manager.RegisterService(SRVREG(IFriendService), session, response);
}
void IServiceCreator::CreateNotificationService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
manager.RegisterService(SRVREG(INotificationService), session, response);
}
}

View File

@ -18,5 +18,10 @@ namespace skyline::service::friends {
* @brief This opens an IFriendService that can be used by applications to access user friend info
*/
void CreateFriendService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/**
* @brief This opens an INotificationService that can be used by applications to receive notifications
*/
void CreateNotificationService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
};
}

View File

@ -27,8 +27,8 @@ namespace skyline::service::fssrv {
auto type = backing->GetEntryType(path);
if (type.has_value()) {
response.Push(type.value());
if (type) {
response.Push(*type);
} else {
response.Push<u32>(0);
response.errorCode = constant::status::PathDoesNotExist;

View File

@ -31,8 +31,8 @@ namespace skyline::service::fssrv {
if (attribute.programId == 0)
attribute.programId = state.loader->nacp->nacpContents.saveDataOwnerId;
std::string saveDataPath = [spaceId, &attribute] () {
std::string spaceIdStr = [spaceId] () {
std::string saveDataPath = [spaceId, &attribute]() {
std::string spaceIdStr = [spaceId]() {
switch (spaceId) {
case SaveDataSpaceId::System:
return "/nand/system";
@ -43,7 +43,7 @@ namespace skyline::service::fssrv {
default:
throw exception("Unsupported savedata ID: {}", spaceId);
};
} ();
}();
switch (attribute.type) {
case SaveDataType::System:
@ -58,7 +58,7 @@ namespace skyline::service::fssrv {
default:
throw exception("Unsupported savedata type: {}", attribute.type);
};
} ();
}();
manager.RegisterService(std::make_shared<IFileSystem>(std::make_shared<vfs::OsFileSystem>(state.os->appFilesPath + "/switch" + saveDataPath), state, manager), session, response);
}

View File

@ -10,6 +10,6 @@ namespace skyline::service::lm {
}) {}
void ILogService::OpenLogger(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
manager.RegisterService(std::make_shared<ILogger>(state, manager), session, response);
manager.RegisterService(SRVREG(ILogger), session, response);
}
}

View File

@ -56,7 +56,7 @@ namespace skyline::service::lm {
logMessage << " ";
switch (fieldType) {
switch (fieldType) {
case LogFieldType::Start:
offset += length;
continue;

View File

@ -8,10 +8,9 @@ namespace skyline::service::pctl {
IParentalControlServiceFactory::IParentalControlServiceFactory(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::pctl_IParentalControlServiceFactory, "pctl:IParentalControlServiceFactory", {
{0x0, SFUNC(IParentalControlServiceFactory::CreateService)},
{0x1, SFUNC(IParentalControlServiceFactory::CreateService)}
}) {}
void IParentalControlServiceFactory::CreateService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
manager.RegisterService(std::make_shared<IParentalControlService>(state, manager), session, response);
manager.RegisterService(SRVREG(IParentalControlService), session, response);
}
}

View File

@ -64,7 +64,7 @@ namespace skyline::vfs {
*/
inline bool FileExists(std::string path) {
auto entry = GetEntryType(path);
return entry.has_value() && entry.value() == Directory::EntryType::File;
return entry && *entry == Directory::EntryType::File;
}
/**
@ -74,7 +74,7 @@ namespace skyline::vfs {
*/
inline bool DirectoryExists(std::string path) {
auto entry = GetEntryType(path);
return entry.has_value() && entry.value() == Directory::EntryType::Directory;
return entry && *entry == Directory::EntryType::Directory;
}
/**

View File

@ -59,7 +59,6 @@ namespace skyline::vfs {
return true;
}
std::shared_ptr<Backing> OsFileSystem::OpenFile(std::string path, Backing::Mode mode) {
if (!(mode.read || mode.write))
throw exception("Cannot open a file that is neither readable or writable");