lr: Organise types

This commit is contained in:
Adubbz 2019-08-15 20:24:11 +10:00
parent 6f99b0bf2b
commit f044c52e7d
10 changed files with 75 additions and 37 deletions

View file

@ -47,6 +47,7 @@
#include "stratosphere/cfg.hpp"
#include "stratosphere/fatal.hpp"
#include "stratosphere/hid.hpp"
#include "stratosphere/lr.hpp"
#include "stratosphere/ncm.hpp"
#include "stratosphere/pm.hpp"
#include "stratosphere/rnd.hpp"

View file

@ -0,0 +1,20 @@
/*
* Copyright (c) 2018-2019 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <switch.h>
#include "lr/lr_types.hpp"

View file

@ -0,0 +1,49 @@
/*
* Copyright (c) 2019 Adubbz
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::lr {
constexpr size_t MaxPathLen = 0x300;
struct Path {
char path[MaxPathLen];
Path() {
path[0] = '\0';
}
Path(const char* path) {
strncpy(this->path, path, MaxPathLen-1);
this->EnsureNullTerminated();
}
Path& operator=(const Path& other) {
/* N appears to always memcpy paths, so we will too. */
std::memcpy(this->path, other.path, MaxPathLen);
this->EnsureNullTerminated();
return *this;
}
void EnsureNullTerminated() {
path[MaxPathLen-1] = '\0';
}
};
}

View file

@ -17,12 +17,13 @@
#include "../lr_contentlocationresolver.hpp"
#include "../lr_redirectonlylocationresolver.hpp"
#include "lr_manager.hpp"
#include "ncm_bounded_map.hpp"
namespace sts::lr::impl {
namespace {
BoundedMap<ncm::StorageId, std::shared_ptr<ILocationResolver>, 5> g_location_resolvers;
ncm::impl::BoundedMap<ncm::StorageId, std::shared_ptr<ILocationResolver>, 5> g_location_resolvers;
std::shared_ptr<RegisteredLocationResolverInterface> g_registered_location_resolver = nullptr;
std::shared_ptr<AddOnContentLocationResolverInterface> g_add_on_content_location_resolver = nullptr;
HosMutex g_mutex;

View file

@ -18,8 +18,6 @@
#include <switch.h>
#include <stratosphere.hpp>
#include "../lr_types.hpp"
namespace sts::lr::impl {
enum RedirectionFlags {

View file

@ -18,8 +18,6 @@
#include <switch.h>
#include <stratosphere.hpp>
#include "../lr_types.hpp"
namespace sts::lr::impl {
template<typename Key, typename Value, size_t NumEntries>

View file

@ -18,34 +18,8 @@
#include <switch.h>
#include <stratosphere.hpp>
namespace sts::lr {
constexpr size_t MaxPathLen = 0x300;
struct Path {
char path[MaxPathLen];
Path() {
path[0] = '\0';
}
Path(const char* path) {
strncpy(this->path, path, MaxPathLen-1);
this->EnsureNullTerminated();
}
Path& operator=(const Path& other) {
/* N appears to always memcpy paths, so we will too. */
std::memcpy(this->path, other.path, MaxPathLen);
this->EnsureNullTerminated();
return *this;
}
void EnsureNullTerminated() {
path[MaxPathLen-1] = '\0';
}
};
namespace sts::ncm::impl {
template<class Key, class Value, size_t N>
class BoundedMap {
private:
@ -107,4 +81,4 @@ namespace sts::lr {
}
};
}
}

View file

@ -19,7 +19,6 @@
#include <stratosphere.hpp>
#include "impl/lr_registered_data.hpp"
#include "lr_types.hpp"
namespace sts::lr {

View file

@ -20,7 +20,6 @@
#include "impl/lr_redirection.hpp"
#include "impl/lr_registered_data.hpp"
#include "lr_types.hpp"
namespace sts::lr {

View file

@ -18,7 +18,6 @@
#include <switch.h>
#include <stratosphere.hpp>
#include "lr_types.hpp"
#include "ncm_types.hpp"
namespace sts::ncm {