mirror of
https://github.com/matrix-construct/construct
synced 2024-10-03 06:08:52 +02:00
ircd::mods: Better support for std::shared_ptr import between modules.
This commit is contained in:
parent
760e47247e
commit
15d9b638f6
1 changed files with 35 additions and 8 deletions
|
@ -80,12 +80,11 @@ class sym_ptr
|
||||||
bool operator!() const { return expired(); }
|
bool operator!() const { return expired(); }
|
||||||
|
|
||||||
template<class T> const T *get() const;
|
template<class T> const T *get() const;
|
||||||
template<class T> T *get();
|
|
||||||
|
|
||||||
template<class T> const T *operator->() const;
|
template<class T> const T *operator->() const;
|
||||||
template<class T> T *operator->();
|
|
||||||
|
|
||||||
template<class T> const T &operator*() const;
|
template<class T> const T &operator*() const;
|
||||||
|
|
||||||
|
template<class T> T *get();
|
||||||
|
template<class T> T *operator->();
|
||||||
template<class T> T &operator*();
|
template<class T> T &operator*();
|
||||||
|
|
||||||
sym_ptr(const std::string &modname, const std::string &symname);
|
sym_ptr(const std::string &modname, const std::string &symname);
|
||||||
|
@ -97,17 +96,32 @@ struct import
|
||||||
:sym_ptr
|
:sym_ptr
|
||||||
{
|
{
|
||||||
const T *operator->() const { return sym_ptr::operator-><T>(); }
|
const T *operator->() const { return sym_ptr::operator-><T>(); }
|
||||||
T *operator->() { return sym_ptr::operator-><T>(); }
|
|
||||||
|
|
||||||
const T &operator*() const { return sym_ptr::operator*<T>(); }
|
const T &operator*() const { return sym_ptr::operator*<T>(); }
|
||||||
T &operator*() { return sym_ptr::operator*<T>(); }
|
|
||||||
|
|
||||||
operator const T &() const { return sym_ptr::operator*<T>(); }
|
operator const T &() const { return sym_ptr::operator*<T>(); }
|
||||||
|
|
||||||
|
T *operator->() { return sym_ptr::operator-><T>(); }
|
||||||
|
T &operator*() { return sym_ptr::operator*<T>(); }
|
||||||
operator T &() { return sym_ptr::operator*<T>(); }
|
operator T &() { return sym_ptr::operator*<T>(); }
|
||||||
|
|
||||||
using sym_ptr::sym_ptr;
|
using sym_ptr::sym_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct import_shared
|
||||||
|
:import<std::shared_ptr<T>>
|
||||||
|
,std::shared_ptr<T>
|
||||||
|
{
|
||||||
|
using std::shared_ptr<T>::get;
|
||||||
|
using std::shared_ptr<T>::operator bool;
|
||||||
|
using std::shared_ptr<T>::operator->;
|
||||||
|
using std::shared_ptr<T>::operator*;
|
||||||
|
|
||||||
|
operator const T &() const { return std::shared_ptr<T>::operator*(); }
|
||||||
|
operator T &() { return std::shared_ptr<T>::operator*(); }
|
||||||
|
|
||||||
|
import_shared(const std::string &modname, const std::string &symname);
|
||||||
|
};
|
||||||
|
|
||||||
std::vector<std::string> symbols(const std::string &fullpath, const std::string §ion);
|
std::vector<std::string> symbols(const std::string &fullpath, const std::string §ion);
|
||||||
std::vector<std::string> symbols(const std::string &fullpath);
|
std::vector<std::string> symbols(const std::string &fullpath);
|
||||||
std::vector<std::string> sections(const std::string &fullpath);
|
std::vector<std::string> sections(const std::string &fullpath);
|
||||||
|
@ -133,9 +147,22 @@ namespace ircd {
|
||||||
|
|
||||||
using mods::module; // Bring struct module into main ircd::
|
using mods::module; // Bring struct module into main ircd::
|
||||||
using mods::import;
|
using mods::import;
|
||||||
|
using mods::import_shared;
|
||||||
|
|
||||||
} // namespace ircd
|
} // namespace ircd
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
ircd::mods::import_shared<T>::import_shared(const std::string &modname,
|
||||||
|
const std::string &symname)
|
||||||
|
:import<std::shared_ptr<T>>
|
||||||
|
{
|
||||||
|
modname, symname
|
||||||
|
}
|
||||||
|
,std::shared_ptr<T>
|
||||||
|
{
|
||||||
|
import<std::shared_ptr<T>>::operator*()
|
||||||
|
}{}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T &
|
T &
|
||||||
ircd::mods::sym_ptr::operator*()
|
ircd::mods::sym_ptr::operator*()
|
||||||
|
|
Loading…
Reference in a new issue