mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-02 23:59:49 -04:00
ams: support building unit test programs on windows/linux/macos
This commit is contained in:
parent
9a38be201a
commit
64a97576d0
756 changed files with 33359 additions and 9372 deletions
|
@ -14,67 +14,52 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include "lr_remote_location_resolver_impl.hpp"
|
||||
#include "lr_remote_registered_location_resolver_impl.hpp"
|
||||
#include "lr_location_resolver_manager_factory.hpp"
|
||||
|
||||
namespace ams::lr {
|
||||
|
||||
namespace {
|
||||
|
||||
bool g_initialized;
|
||||
constinit sf::SharedPointer<ILocationResolverManager> g_location_resolver_manager;
|
||||
|
||||
/* TODO: This belongs inside lr_location_resolver_manager_factory */
|
||||
struct LocationResolverManagerAllocatorTag;
|
||||
using LocationResolverManagerAllocator = sf::ExpHeapStaticAllocator<1_KB, LocationResolverManagerAllocatorTag>;
|
||||
|
||||
using LocationResolverManagerFactory = sf::ObjectFactory<typename LocationResolverManagerAllocator::Policy>;
|
||||
|
||||
class StaticAllocatorInitializer {
|
||||
public:
|
||||
StaticAllocatorInitializer() {
|
||||
LocationResolverManagerAllocator::Initialize(lmem::CreateOption_None);
|
||||
}
|
||||
} g_static_allocator_initializer;
|
||||
}
|
||||
|
||||
void Initialize() {
|
||||
AMS_ASSERT(!g_initialized);
|
||||
R_ABORT_UNLESS(lrInitialize());
|
||||
g_initialized = true;
|
||||
AMS_ASSERT(g_location_resolver_manager == nullptr);
|
||||
g_location_resolver_manager = GetLocationResolverManagerService();
|
||||
}
|
||||
|
||||
void Finalize() {
|
||||
AMS_ASSERT(g_initialized);
|
||||
lrExit();
|
||||
g_initialized = false;
|
||||
AMS_ASSERT(g_location_resolver_manager != nullptr);
|
||||
g_location_resolver_manager = nullptr;
|
||||
}
|
||||
|
||||
|
||||
Result OpenLocationResolver(LocationResolver *out, ncm::StorageId storage_id) {
|
||||
LrLocationResolver lr;
|
||||
R_TRY(lrOpenLocationResolver(static_cast<NcmStorageId>(storage_id), std::addressof(lr)));
|
||||
sf::SharedPointer<lr::ILocationResolver> lr;
|
||||
R_TRY(g_location_resolver_manager->OpenLocationResolver(std::addressof(lr), storage_id));
|
||||
|
||||
*out = LocationResolver(LocationResolverManagerFactory::CreateSharedEmplaced<ILocationResolver, RemoteLocationResolverImpl>(lr));
|
||||
return ResultSuccess();
|
||||
*out = LocationResolver(std::move(lr));
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result OpenRegisteredLocationResolver(RegisteredLocationResolver *out) {
|
||||
LrRegisteredLocationResolver lr;
|
||||
R_TRY(lrOpenRegisteredLocationResolver(std::addressof(lr)));
|
||||
sf::SharedPointer<lr::IRegisteredLocationResolver> lr;
|
||||
R_TRY(g_location_resolver_manager->OpenRegisteredLocationResolver(std::addressof(lr)));
|
||||
|
||||
*out = RegisteredLocationResolver(LocationResolverManagerFactory::CreateSharedEmplaced<IRegisteredLocationResolver, RemoteRegisteredLocationResolverImpl>(lr));
|
||||
return ResultSuccess();
|
||||
*out = RegisteredLocationResolver(std::move(lr));
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result OpenAddOnContentLocationResolver(AddOnContentLocationResolver *out) {
|
||||
/* TODO: libnx binding */
|
||||
AMS_UNUSED(out);
|
||||
AMS_ABORT();
|
||||
sf::SharedPointer<lr::IAddOnContentLocationResolver> lr;
|
||||
R_TRY(g_location_resolver_manager->OpenAddOnContentLocationResolver(std::addressof(lr)));
|
||||
|
||||
*out = AddOnContentLocationResolver(std::move(lr));
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result RefreshLocationResolver(ncm::StorageId storage_id) {
|
||||
/* TODO: libnx binding */
|
||||
AMS_UNUSED(storage_id);
|
||||
AMS_ABORT();
|
||||
R_RETURN(g_location_resolver_manager->RefreshLocationResolver(storage_id));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 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/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include <stratosphere/lr/lr_location_resolver_manager_impl.hpp>
|
||||
#include "lr_remote_location_resolver_manager_impl.hpp"
|
||||
|
||||
namespace ams::lr {
|
||||
|
||||
namespace {
|
||||
|
||||
class StaticAllocatorInitializer {
|
||||
public:
|
||||
StaticAllocatorInitializer() {
|
||||
LocationResolverManagerAllocator::Initialize(lmem::CreateOption_None);
|
||||
}
|
||||
} g_static_allocator_initializer;
|
||||
|
||||
}
|
||||
|
||||
sf::SharedPointer<ILocationResolverManager> GetLocationResolverManagerService() {
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
return LocationResolverManagerFactory::CreateSharedEmplaced<ILocationResolverManager, RemoteLocationResolverManagerImpl>();
|
||||
#else
|
||||
return LocationResolverManagerFactory::CreateSharedEmplaced<ILocationResolverManager, LocationResolverManagerImpl>();
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 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 <stratosphere.hpp>
|
||||
|
||||
namespace ams::lr {
|
||||
|
||||
struct LocationResolverManagerAllocatorTag;
|
||||
using LocationResolverManagerAllocator = sf::ExpHeapStaticAllocator<1_KB, LocationResolverManagerAllocatorTag>;
|
||||
|
||||
using LocationResolverManagerFactory = sf::ObjectFactory<typename LocationResolverManagerAllocator::Policy>;
|
||||
|
||||
sf::SharedPointer<ILocationResolverManager> GetLocationResolverManagerService();
|
||||
|
||||
}
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
namespace ams::lr {
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
class RemoteLocationResolverImpl {
|
||||
private:
|
||||
::LrLocationResolver m_srv;
|
||||
|
@ -155,5 +156,6 @@ namespace ams::lr {
|
|||
}
|
||||
};
|
||||
static_assert(lr::IsILocationResolver<RemoteLocationResolverImpl>);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (c) 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 <stratosphere.hpp>
|
||||
#include "lr_location_resolver_manager_factory.hpp"
|
||||
#include "lr_remote_location_resolver_impl.hpp"
|
||||
#include "lr_remote_registered_location_resolver_impl.hpp"
|
||||
|
||||
namespace ams::lr {
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
class RemoteLocationResolverManagerImpl {
|
||||
public:
|
||||
RemoteLocationResolverManagerImpl() { R_ABORT_UNLESS(::lrInitialize()); }
|
||||
|
||||
~RemoteLocationResolverManagerImpl() { ::lrExit(); }
|
||||
public:
|
||||
/* Actual commands. */
|
||||
Result OpenLocationResolver(sf::Out<sf::SharedPointer<ILocationResolver>> out, ncm::StorageId storage_id) {
|
||||
LrLocationResolver lr;
|
||||
R_TRY(::lrOpenLocationResolver(static_cast<::NcmStorageId>(storage_id), std::addressof(lr)));
|
||||
|
||||
*out = LocationResolverManagerFactory::CreateSharedEmplaced<ILocationResolver, RemoteLocationResolverImpl>(lr);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result OpenRegisteredLocationResolver(sf::Out<sf::SharedPointer<IRegisteredLocationResolver>> out) {
|
||||
LrRegisteredLocationResolver lr;
|
||||
R_TRY(::lrOpenRegisteredLocationResolver(std::addressof(lr)));
|
||||
|
||||
*out = LocationResolverManagerFactory::CreateSharedEmplaced<IRegisteredLocationResolver, RemoteRegisteredLocationResolverImpl>(lr);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result RefreshLocationResolver(ncm::StorageId storage_id) {
|
||||
AMS_UNUSED(storage_id);
|
||||
AMS_ABORT("TODO: libnx binding");
|
||||
}
|
||||
|
||||
Result OpenAddOnContentLocationResolver(sf::Out<sf::SharedPointer<IAddOnContentLocationResolver>> out) {
|
||||
AMS_UNUSED(out);
|
||||
AMS_ABORT("TODO: libnx binding");
|
||||
}
|
||||
};
|
||||
static_assert(lr::IsILocationResolverManager<RemoteLocationResolverManagerImpl>);
|
||||
#endif
|
||||
|
||||
}
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
namespace ams::lr {
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
class RemoteRegisteredLocationResolverImpl {
|
||||
private:
|
||||
::LrRegisteredLocationResolver m_srv;
|
||||
|
@ -110,5 +111,6 @@ namespace ams::lr {
|
|||
}
|
||||
};
|
||||
static_assert(lr::IsIRegisteredLocationResolver<RemoteRegisteredLocationResolverImpl>);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue