mirror of
https://github.com/matrix-construct/construct
synced 2024-06-01 01:28:54 +02:00
Eliminate friend-injection.
This commit is contained in:
parent
440cada550
commit
4f721f48e5
|
@ -469,10 +469,6 @@ dnl CXXFLAGS+=" -fcheck-pointer-bounds"
|
|||
CXXFLAGS+=" -fchkp-instrument-marked-only"
|
||||
CXXFLAGS+=" -fstack-protector-explicit"
|
||||
|
||||
dnl -ffriend-injection allows us to deduplicate declarations of friend
|
||||
dnl functions in both the friend class and the enclosing namespace
|
||||
CXXFLAGS+=" -ffriend-injection"
|
||||
|
||||
dnl -fvisibility-inlines-hidden - for optimization; note the address of inline
|
||||
dnl functions won't be the same between translation units
|
||||
CXXFLAGS+=" -fvisibility-inlines-hidden"
|
||||
|
|
|
@ -26,6 +26,11 @@ namespace ircd::allocator
|
|||
template<class T = char, size_t = 512> struct fixed;
|
||||
template<class T> struct node;
|
||||
|
||||
profile &operator+=(profile &, const profile &);
|
||||
profile &operator-=(profile &, const profile &);
|
||||
profile operator+(const profile &, const profile &);
|
||||
profile operator-(const profile &, const profile &);
|
||||
|
||||
bool trim(const size_t &pad = 0); // malloc_trim(3)
|
||||
string_view info(const mutable_buffer &);
|
||||
};
|
||||
|
@ -51,11 +56,6 @@ struct ircd::allocator::profile
|
|||
size_t alloc_bytes {0};
|
||||
size_t free_bytes {0};
|
||||
|
||||
friend profile &operator+=(profile &, const profile &);
|
||||
friend profile &operator-=(profile &, const profile &);
|
||||
friend profile operator+(const profile &, const profile &);
|
||||
friend profile operator-(const profile &, const profile &);
|
||||
|
||||
/// Explicitly enabled by define at compile time only. Note: replaces
|
||||
/// global `new` and `delete` when enabled.
|
||||
static thread_local profile this_thread;
|
||||
|
|
|
@ -15,6 +15,9 @@ namespace ircd
|
|||
{
|
||||
struct client;
|
||||
|
||||
const ipport &remote(const client &);
|
||||
const ipport &local(const client &);
|
||||
|
||||
//TODO: want to upgrade
|
||||
char *read(client &, char *&start, char *const &stop);
|
||||
parse::read_closure read_closure(client &);
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace ircd::ctx
|
|||
struct context;
|
||||
|
||||
extern const size_t DEFAULT_STACK_SIZE;
|
||||
|
||||
void swap(context &a, context &b) noexcept;
|
||||
}
|
||||
|
||||
/// Principal interface for a context.
|
||||
|
|
|
@ -20,6 +20,17 @@ namespace ircd::ctx
|
|||
|
||||
IRCD_EXCEPTION(future_error, future_already_retrieved)
|
||||
IRCD_OVERLOAD(use_future)
|
||||
|
||||
template<class T> const shared_state<T> &state(const future<T> &);
|
||||
template<class T> shared_state<T> &state(future<T> &);
|
||||
|
||||
template<class T,
|
||||
class time_point>
|
||||
bool wait_until(const future<T> &, const time_point &, std::nothrow_t);
|
||||
|
||||
template<class T,
|
||||
class time_point>
|
||||
void wait_until(const future<T> &, const time_point &);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
@ -92,12 +103,6 @@ struct ircd::ctx::future<void>
|
|||
|
||||
namespace ircd::ctx
|
||||
{
|
||||
template<class T> const shared_state<T> &state(const future<T> &);
|
||||
template<class T> shared_state<T> &state(future<T> &);
|
||||
|
||||
template<class T,
|
||||
class time_point>
|
||||
bool wait_until(const future<T> &, const time_point &, std::nothrow_t);
|
||||
}
|
||||
|
||||
template<class... T>
|
||||
|
|
|
@ -184,6 +184,14 @@ struct ircd::db::column::delta
|
|||
{}
|
||||
};
|
||||
|
||||
namespace ircd::db
|
||||
{
|
||||
bool operator==(const column::const_iterator_base &, const column::const_iterator_base &);
|
||||
bool operator!=(const column::const_iterator_base &, const column::const_iterator_base &);
|
||||
bool operator<(const column::const_iterator_base &, const column::const_iterator_base &);
|
||||
bool operator>(const column::const_iterator_base &, const column::const_iterator_base &);
|
||||
}
|
||||
|
||||
/// Iteration over all keys down a column. Default construction is an invalid
|
||||
/// iterator, which could be compared against in the style of STL algorithms.
|
||||
/// Otherwise, construct an iterator by having it returned from the appropriate
|
||||
|
|
|
@ -26,6 +26,9 @@ namespace ircd::db
|
|||
|
||||
bool dropped(const database::column &);
|
||||
void drop(database::column &); // Request to erase column from db
|
||||
|
||||
std::shared_ptr<const database::column> shared_from(const database::column &);
|
||||
std::shared_ptr<database::column> shared_from(database::column &);
|
||||
}
|
||||
|
||||
struct ircd::db::database::column final
|
||||
|
@ -58,7 +61,4 @@ struct ircd::db::database::column final
|
|||
column &operator=(column &&) = delete;
|
||||
column &operator=(const column &) = delete;
|
||||
~column() noexcept;
|
||||
|
||||
friend std::shared_ptr<const column> shared_from(const column &);
|
||||
friend std::shared_ptr<column> shared_from(column &);
|
||||
};
|
||||
|
|
|
@ -17,6 +17,12 @@ namespace rocksdb
|
|||
struct Snapshot;
|
||||
}
|
||||
|
||||
namespace ircd::db
|
||||
{
|
||||
uint64_t sequence(const database::snapshot &); // Sequence of a snapshot
|
||||
uint64_t sequence(const rocksdb::Snapshot *const &);
|
||||
}
|
||||
|
||||
/// Database snapshot object. Maintaining this object will maintain a
|
||||
/// consistent state of access to the database at the sequence number
|
||||
/// from when it's acquired.
|
||||
|
@ -33,7 +39,4 @@ struct ircd::db::database::snapshot
|
|||
explicit snapshot(database &);
|
||||
snapshot() = default;
|
||||
~snapshot() noexcept;
|
||||
|
||||
friend uint64_t sequence(const snapshot &); // Sequence of a snapshot
|
||||
friend uint64_t sequence(const rocksdb::Snapshot *const &);
|
||||
};
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace ircd::json
|
|||
string_view stringify(mutable_buffer &buf, const string_view *const &begin, const string_view *const &end);
|
||||
string_view stringify(mutable_buffer &buf, const std::string *const &begin, const std::string *const &end);
|
||||
string_view stringify(mutable_buffer &, const array &);
|
||||
std::ostream &operator<<(std::ostream &, const array &);
|
||||
}
|
||||
|
||||
/// Lightweight interface to a JSON array string.
|
||||
|
@ -70,9 +71,18 @@ struct ircd::json::array
|
|||
|
||||
template<class it> static size_t serialized(const it &b, const it &e);
|
||||
template<class it> static string_view stringify(mutable_buffer &, const it &b, const it &e);
|
||||
friend std::ostream &operator<<(std::ostream &, const array &);
|
||||
};
|
||||
|
||||
namespace ircd::json
|
||||
{
|
||||
bool operator==(const array::const_iterator &, const array::const_iterator &);
|
||||
bool operator!=(const array::const_iterator &, const array::const_iterator &);
|
||||
bool operator<=(const array::const_iterator &, const array::const_iterator &);
|
||||
bool operator>=(const array::const_iterator &, const array::const_iterator &);
|
||||
bool operator<(const array::const_iterator &, const array::const_iterator &);
|
||||
bool operator>(const array::const_iterator &, const array::const_iterator &);
|
||||
}
|
||||
|
||||
struct ircd::json::array::const_iterator
|
||||
{
|
||||
using value_type = const string_view;
|
||||
|
|
|
@ -15,6 +15,10 @@ namespace ircd::json
|
|||
{
|
||||
struct iov;
|
||||
|
||||
size_t serialized(const iov &);
|
||||
string_view stringify(mutable_buffer &, const iov &);
|
||||
std::ostream &operator<<(std::ostream &, const iov &);
|
||||
|
||||
template<class node, size_t SIZE, class T> iov make_iov(node (&)[SIZE], T&& t);
|
||||
template<class node, class T> iov make_iov(node *const &, const size_t &, T&& t);
|
||||
}
|
||||
|
@ -62,10 +66,6 @@ struct ircd::json::iov
|
|||
value &at(const string_view &key);
|
||||
|
||||
iov() = default;
|
||||
|
||||
friend string_view stringify(mutable_buffer &, const iov &);
|
||||
friend std::ostream &operator<<(std::ostream &, const iov &);
|
||||
friend size_t serialized(const iov &);
|
||||
};
|
||||
|
||||
/// Unconditionally append a member to the object vector
|
||||
|
|
|
@ -17,11 +17,24 @@ namespace ircd::json
|
|||
|
||||
using values = std::initializer_list<value>;
|
||||
|
||||
enum type type(const value &a);
|
||||
bool defined(const value &);
|
||||
|
||||
size_t serialized(const bool &);
|
||||
size_t serialized(const value &);
|
||||
size_t serialized(const value *const &begin, const value *const &end);
|
||||
size_t serialized(const values &);
|
||||
|
||||
string_view stringify(mutable_buffer &, const value &);
|
||||
string_view stringify(mutable_buffer &, const value *const &begin, const value *const &end);
|
||||
std::ostream &operator<<(std::ostream &, const value &);
|
||||
|
||||
bool operator==(const value &a, const value &b);
|
||||
bool operator!=(const value &a, const value &b);
|
||||
bool operator<=(const value &a, const value &b);
|
||||
bool operator>=(const value &a, const value &b);
|
||||
bool operator<(const value &a, const value &b);
|
||||
bool operator>(const value &a, const value &b);
|
||||
}
|
||||
|
||||
/// A primitive of the ircd::json system representing a value at runtime.
|
||||
|
@ -118,19 +131,6 @@ struct ircd::json::value
|
|||
value &operator=(value &&) noexcept;
|
||||
value &operator=(const value &);
|
||||
~value() noexcept;
|
||||
|
||||
friend bool operator==(const value &a, const value &b);
|
||||
friend bool operator!=(const value &a, const value &b);
|
||||
friend bool operator<=(const value &a, const value &b);
|
||||
friend bool operator>=(const value &a, const value &b);
|
||||
friend bool operator<(const value &a, const value &b);
|
||||
friend bool operator>(const value &a, const value &b);
|
||||
|
||||
friend enum type type(const value &a);
|
||||
friend bool defined(const value &);
|
||||
friend size_t serialized(const value &);
|
||||
friend string_view stringify(mutable_buffer &, const value &);
|
||||
friend std::ostream &operator<<(std::ostream &, const value &);
|
||||
};
|
||||
|
||||
static_assert(sizeof(ircd::json::value) == 16, "");
|
||||
|
|
|
@ -52,6 +52,16 @@ struct ircd::json::vector
|
|||
using string_view::string_view;
|
||||
};
|
||||
|
||||
namespace ircd::json
|
||||
{
|
||||
bool operator==(const vector::const_iterator &, const vector::const_iterator &);
|
||||
bool operator!=(const vector::const_iterator &, const vector::const_iterator &);
|
||||
bool operator<=(const vector::const_iterator &, const vector::const_iterator &);
|
||||
bool operator>=(const vector::const_iterator &, const vector::const_iterator &);
|
||||
bool operator<(const vector::const_iterator &, const vector::const_iterator &);
|
||||
bool operator>(const vector::const_iterator &, const vector::const_iterator &);
|
||||
}
|
||||
|
||||
struct ircd::json::vector::const_iterator
|
||||
{
|
||||
using value_type = const object;
|
||||
|
@ -89,85 +99,3 @@ struct ircd::json::vector::const_iterator
|
|||
friend bool operator<(const const_iterator &, const const_iterator &);
|
||||
friend bool operator>(const const_iterator &, const const_iterator &);
|
||||
};
|
||||
|
||||
inline ircd::json::vector::value_type
|
||||
ircd::json::vector::operator[](const size_t &i)
|
||||
const
|
||||
{
|
||||
const auto it(find(i));
|
||||
return it != end()? *it : object{};
|
||||
}
|
||||
|
||||
inline ircd::json::vector::value_type
|
||||
ircd::json::vector::at(const size_t &i)
|
||||
const
|
||||
{
|
||||
const auto it(find(i));
|
||||
if(it == end())
|
||||
throw not_found
|
||||
{
|
||||
"indice %zu", i
|
||||
};
|
||||
|
||||
return *it;
|
||||
}
|
||||
|
||||
inline ircd::json::vector::const_iterator
|
||||
ircd::json::vector::find(size_t i)
|
||||
const
|
||||
{
|
||||
auto it(begin());
|
||||
for(; it != end() && i; ++it, i--);
|
||||
return it;
|
||||
}
|
||||
|
||||
__attribute__((warning("Taking string_view::size() not the count() of vector elements")))
|
||||
inline size_t
|
||||
ircd::json::vector::size()
|
||||
const
|
||||
{
|
||||
return count();
|
||||
}
|
||||
|
||||
inline size_t
|
||||
ircd::json::vector::count()
|
||||
const
|
||||
{
|
||||
return std::distance(begin(), end());
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::json::operator==(const vector::const_iterator &a, const vector::const_iterator &b)
|
||||
{
|
||||
return a.start == b.start;
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::json::operator!=(const vector::const_iterator &a, const vector::const_iterator &b)
|
||||
{
|
||||
return a.start != b.start;
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::json::operator<=(const vector::const_iterator &a, const vector::const_iterator &b)
|
||||
{
|
||||
return a.start <= b.start;
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::json::operator>=(const vector::const_iterator &a, const vector::const_iterator &b)
|
||||
{
|
||||
return a.start >= b.start;
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::json::operator<(const vector::const_iterator &a, const vector::const_iterator &b)
|
||||
{
|
||||
return a.start < b.start;
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::json::operator>(const vector::const_iterator &a, const vector::const_iterator &b)
|
||||
{
|
||||
return a.start > b.start;
|
||||
}
|
||||
|
|
|
@ -42,10 +42,14 @@ struct ircd::m::event::conforms
|
|||
conforms(const event &, const uint64_t &skip);
|
||||
|
||||
static code reflect(const string_view &);
|
||||
friend string_view reflect(const code &);
|
||||
friend std::ostream &operator<<(std::ostream &, const conforms &);
|
||||
};
|
||||
|
||||
namespace ircd::m
|
||||
{
|
||||
string_view reflect(const event::conforms::code &);
|
||||
std::ostream &operator<<(std::ostream &, const event::conforms &);
|
||||
}
|
||||
|
||||
/// Report codes corresponding to the checks conducted by event::conforms.
|
||||
/// Developers: If you add a code here you must also add a string reflection
|
||||
/// in the definition file.
|
||||
|
|
|
@ -16,6 +16,12 @@
|
|||
// is part of the <ircd/asio.h> stack which can be included in your
|
||||
// definition file if you need low level access to this acceptor API.
|
||||
|
||||
namespace ircd::net
|
||||
{
|
||||
std::ostream &operator<<(std::ostream &s, const struct listener::acceptor &);
|
||||
std::ostream &operator<<(std::ostream &s, const struct listener_udp::acceptor &);
|
||||
}
|
||||
|
||||
struct ircd::net::listener::acceptor
|
||||
:std::enable_shared_from_this<struct ircd::net::listener::acceptor>
|
||||
{
|
||||
|
@ -63,8 +69,6 @@ struct ircd::net::listener::acceptor
|
|||
listener::proffer);
|
||||
|
||||
~acceptor() noexcept;
|
||||
|
||||
friend std::ostream &operator<<(std::ostream &s, const acceptor &);
|
||||
};
|
||||
|
||||
struct ircd::net::listener_udp::acceptor
|
||||
|
@ -92,6 +96,4 @@ struct ircd::net::listener_udp::acceptor
|
|||
const json::object &opts);
|
||||
|
||||
~acceptor() noexcept;
|
||||
|
||||
friend std::ostream &operator<<(std::ostream &s, const acceptor &);
|
||||
};
|
||||
|
|
|
@ -29,6 +29,8 @@ namespace ircd::net
|
|||
|
||||
string_view canonize(const mutable_buffer &out, const hostport &, const uint16_t &port = canon_port);
|
||||
std::string canonize(const hostport &, const uint16_t &port = canon_port);
|
||||
|
||||
std::ostream &operator<<(std::ostream &, const hostport &);
|
||||
}
|
||||
|
||||
namespace ircd
|
||||
|
@ -62,8 +64,6 @@ struct ircd::net::hostport
|
|||
hostport(const string_view &host, const uint16_t &port);
|
||||
hostport(const string_view &amalgam);
|
||||
hostport() = default;
|
||||
|
||||
friend std::ostream &operator<<(std::ostream &, const hostport &);
|
||||
};
|
||||
|
||||
/// Creates a host:service pair from a hostname and a service name string.
|
||||
|
|
|
@ -16,6 +16,9 @@ namespace ircd::net
|
|||
struct listener;
|
||||
struct listener_udp;
|
||||
|
||||
std::ostream &operator<<(std::ostream &s, const listener &);
|
||||
std::ostream &operator<<(std::ostream &s, const listener_udp &);
|
||||
|
||||
extern conf::item<bool> listen;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace ircd::net
|
|||
struct open_opts;
|
||||
using open_callback = std::function<void (std::exception_ptr)>;
|
||||
|
||||
string_view common_name(const open_opts &);
|
||||
|
||||
// Open existing socket with callback.
|
||||
void open(socket &, const open_opts &, open_callback);
|
||||
|
||||
|
|
|
@ -165,6 +165,18 @@ struct ircd::rfc1035::record
|
|||
virtual ~record() noexcept;
|
||||
};
|
||||
|
||||
namespace ircd::rfc1035
|
||||
{
|
||||
bool operator==(const record::A &, const record::A &);
|
||||
bool operator!=(const record::A &, const record::A &);
|
||||
bool operator==(const record::AAAA &, const record::AAAA &);
|
||||
bool operator!=(const record::AAAA &, const record::AAAA &);
|
||||
bool operator==(const record::CNAME &, const record::CNAME &);
|
||||
bool operator!=(const record::CNAME &, const record::CNAME &);
|
||||
bool operator==(const record::SRV &, const record::SRV &);
|
||||
bool operator!=(const record::SRV &, const record::SRV &);
|
||||
}
|
||||
|
||||
/// Downcast an abstract record reference to the specific record structure.
|
||||
template<class T>
|
||||
const T &
|
||||
|
@ -187,9 +199,6 @@ struct ircd::rfc1035::record::A
|
|||
|
||||
A(const answer &);
|
||||
A();
|
||||
|
||||
friend bool operator==(const A &, const A &);
|
||||
friend bool operator!=(const A &, const A &);
|
||||
};
|
||||
|
||||
/// IPv6 address record.
|
||||
|
@ -201,9 +210,6 @@ struct ircd::rfc1035::record::AAAA
|
|||
|
||||
AAAA(const answer &);
|
||||
AAAA();
|
||||
|
||||
friend bool operator==(const AAAA &, const AAAA &);
|
||||
friend bool operator!=(const AAAA &, const AAAA &);
|
||||
};
|
||||
|
||||
/// Canonical name aliasing record
|
||||
|
@ -215,9 +221,6 @@ struct ircd::rfc1035::record::CNAME
|
|||
|
||||
CNAME(const answer &);
|
||||
CNAME();
|
||||
|
||||
friend bool operator==(const CNAME &, const CNAME &);
|
||||
friend bool operator!=(const CNAME &, const CNAME &);
|
||||
};
|
||||
|
||||
/// Service record.
|
||||
|
@ -233,7 +236,4 @@ struct ircd::rfc1035::record::SRV
|
|||
|
||||
SRV(const answer &);
|
||||
SRV();
|
||||
|
||||
friend bool operator==(const SRV &, const SRV &);
|
||||
friend bool operator!=(const SRV &, const SRV &);
|
||||
};
|
||||
|
|
|
@ -941,7 +941,7 @@ ircd::fmt::generate_string(char *&out,
|
|||
}
|
||||
else if(type == typeid(const char *))
|
||||
{
|
||||
const char *const &str{*static_cast<const char *const *const>(ptr)};
|
||||
const char *const &str{*static_cast<const char *const *>(ptr)};
|
||||
return karma::generate(out, gen, string_view{str});
|
||||
}
|
||||
|
||||
|
|
87
ircd/json.cc
87
ircd/json.cc
|
@ -1689,6 +1689,93 @@ const
|
|||
// json/vector.h
|
||||
//
|
||||
|
||||
ircd::json::vector::value_type
|
||||
ircd::json::vector::operator[](const size_t &i)
|
||||
const
|
||||
{
|
||||
const auto it(find(i));
|
||||
return it != end()? *it : object{};
|
||||
}
|
||||
|
||||
ircd::json::vector::value_type
|
||||
ircd::json::vector::at(const size_t &i)
|
||||
const
|
||||
{
|
||||
const auto it(find(i));
|
||||
if(it == end())
|
||||
throw not_found
|
||||
{
|
||||
"indice %zu", i
|
||||
};
|
||||
|
||||
return *it;
|
||||
}
|
||||
|
||||
ircd::json::vector::const_iterator
|
||||
ircd::json::vector::find(size_t i)
|
||||
const
|
||||
{
|
||||
auto it(begin());
|
||||
for(; it != end() && i; ++it, i--);
|
||||
return it;
|
||||
}
|
||||
|
||||
__attribute__((warning("Taking string_view::size() not the count() of vector elements")))
|
||||
size_t
|
||||
ircd::json::vector::size()
|
||||
const
|
||||
{
|
||||
return count();
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::json::vector::count()
|
||||
const
|
||||
{
|
||||
return std::distance(begin(), end());
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// vector::const_iterator
|
||||
//
|
||||
|
||||
bool
|
||||
ircd::json::operator==(const vector::const_iterator &a, const vector::const_iterator &b)
|
||||
{
|
||||
return a.start == b.start;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::json::operator!=(const vector::const_iterator &a, const vector::const_iterator &b)
|
||||
{
|
||||
return a.start != b.start;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::json::operator<=(const vector::const_iterator &a, const vector::const_iterator &b)
|
||||
{
|
||||
return a.start <= b.start;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::json::operator>=(const vector::const_iterator &a, const vector::const_iterator &b)
|
||||
{
|
||||
return a.start >= b.start;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::json::operator<(const vector::const_iterator &a, const vector::const_iterator &b)
|
||||
{
|
||||
return a.start < b.start;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::json::operator>(const vector::const_iterator &a, const vector::const_iterator &b)
|
||||
{
|
||||
return a.start > b.start;
|
||||
}
|
||||
|
||||
ircd::json::vector::const_iterator &
|
||||
ircd::json::vector::const_iterator::operator++()
|
||||
try
|
||||
|
|
|
@ -2416,7 +2416,7 @@ catch(const boost::system::system_error &e)
|
|||
if(fini)
|
||||
break;
|
||||
|
||||
//[[fallthrough]];
|
||||
[[fallthrough]];
|
||||
}
|
||||
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue