2021-04-08 22:24:08 +00:00
|
|
|
/*
|
2021-10-04 19:59:10 +00:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2021-04-08 22:24:08 +00:00
|
|
|
*
|
|
|
|
* 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/tipc/tipc_common.hpp>
|
|
|
|
#include <stratosphere/tipc/tipc_out.hpp>
|
|
|
|
#include <stratosphere/tipc/tipc_pointer_and_size.hpp>
|
|
|
|
|
|
|
|
namespace ams::tipc {
|
|
|
|
|
2021-10-12 07:20:21 +00:00
|
|
|
/* TODO: How do InHandles work in tipc? No examples to work off of. */
|
|
|
|
class CopyHandle {
|
|
|
|
private:
|
|
|
|
CopyHandle();
|
|
|
|
};
|
2021-04-08 22:24:08 +00:00
|
|
|
|
2021-10-12 07:20:21 +00:00
|
|
|
class MoveHandle {
|
|
|
|
private:
|
|
|
|
MoveHandle();
|
|
|
|
};
|
2021-04-08 22:24:08 +00:00
|
|
|
|
|
|
|
template<>
|
2021-10-12 07:20:21 +00:00
|
|
|
class Out<CopyHandle> {
|
2021-04-08 22:24:08 +00:00
|
|
|
private:
|
2022-03-06 20:08:20 +00:00
|
|
|
tipc::NativeHandle * const m_ptr;
|
2021-04-08 22:24:08 +00:00
|
|
|
public:
|
2022-03-06 20:08:20 +00:00
|
|
|
ALWAYS_INLINE Out(tipc::NativeHandle *p) : m_ptr(p) { /* ... */ }
|
2021-04-08 22:24:08 +00:00
|
|
|
|
2022-03-06 20:08:20 +00:00
|
|
|
ALWAYS_INLINE void SetValue(tipc::NativeHandle v) const {
|
2021-10-12 07:20:21 +00:00
|
|
|
*m_ptr = v;
|
2021-04-08 22:24:08 +00:00
|
|
|
}
|
|
|
|
|
2022-03-06 20:08:20 +00:00
|
|
|
ALWAYS_INLINE const tipc::NativeHandle &GetValue() const {
|
2021-10-12 07:20:21 +00:00
|
|
|
return *m_ptr;
|
2021-04-08 22:24:08 +00:00
|
|
|
}
|
|
|
|
|
2022-03-06 20:08:20 +00:00
|
|
|
ALWAYS_INLINE tipc::NativeHandle *GetPointer() const {
|
2021-10-12 07:20:21 +00:00
|
|
|
return m_ptr;
|
2021-04-08 22:24:08 +00:00
|
|
|
}
|
|
|
|
|
2021-10-12 07:20:21 +00:00
|
|
|
/* Convenience operators. */
|
2022-03-06 20:08:20 +00:00
|
|
|
ALWAYS_INLINE tipc::NativeHandle &operator*() const {
|
2021-10-12 07:20:21 +00:00
|
|
|
return *m_ptr;
|
2021-04-08 22:24:08 +00:00
|
|
|
}
|
|
|
|
|
2022-03-06 20:08:20 +00:00
|
|
|
ALWAYS_INLINE tipc::NativeHandle *operator->() const {
|
2021-10-12 07:20:21 +00:00
|
|
|
return m_ptr;
|
2021-04-08 22:24:08 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<>
|
2021-10-12 07:20:21 +00:00
|
|
|
class Out<MoveHandle> {
|
2021-04-08 22:24:08 +00:00
|
|
|
private:
|
2022-03-06 20:08:20 +00:00
|
|
|
tipc::NativeHandle * const m_ptr;
|
2021-04-08 22:24:08 +00:00
|
|
|
public:
|
2022-03-06 20:08:20 +00:00
|
|
|
ALWAYS_INLINE Out(tipc::NativeHandle *p) : m_ptr(p) { /* ... */ }
|
2021-04-08 22:24:08 +00:00
|
|
|
|
2022-03-06 20:08:20 +00:00
|
|
|
ALWAYS_INLINE void SetValue(tipc::NativeHandle v) const {
|
2021-10-12 07:20:21 +00:00
|
|
|
*m_ptr = v;
|
2021-04-08 22:24:08 +00:00
|
|
|
}
|
|
|
|
|
2022-03-06 20:08:20 +00:00
|
|
|
ALWAYS_INLINE const tipc::NativeHandle &GetValue() const {
|
2021-10-12 07:20:21 +00:00
|
|
|
return *m_ptr;
|
2021-04-08 22:24:08 +00:00
|
|
|
}
|
|
|
|
|
2022-03-06 20:08:20 +00:00
|
|
|
ALWAYS_INLINE tipc::NativeHandle *GetPointer() const {
|
2021-10-12 07:20:21 +00:00
|
|
|
return m_ptr;
|
2021-04-08 22:24:08 +00:00
|
|
|
}
|
|
|
|
|
2021-10-12 07:20:21 +00:00
|
|
|
/* Convenience operators. */
|
2022-03-06 20:08:20 +00:00
|
|
|
ALWAYS_INLINE tipc::NativeHandle &operator*() const {
|
2021-10-12 07:20:21 +00:00
|
|
|
return *m_ptr;
|
2021-04-08 22:24:08 +00:00
|
|
|
}
|
|
|
|
|
2022-03-06 20:08:20 +00:00
|
|
|
ALWAYS_INLINE tipc::NativeHandle *operator->() const {
|
2021-10-12 07:20:21 +00:00
|
|
|
return m_ptr;
|
2021-04-08 22:24:08 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
using OutMoveHandle = tipc::Out<tipc::MoveHandle>;
|
|
|
|
using OutCopyHandle = tipc::Out<tipc::CopyHandle>;
|
|
|
|
|
|
|
|
}
|