Wrap all STL includes to support drv:: and eng::
This commit is contained in:
22
luprex/core/wrap/mkstub.py
Executable file
22
luprex/core/wrap/mkstub.py
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
|
||||
base=sys.argv[1]
|
||||
ubase=base.upper()
|
||||
dash=base.replace("_", "-")
|
||||
|
||||
with open(f"wrap-{dash}.hpp", "w") as f:
|
||||
print(f"#ifndef WRAP_{ubase}_HPP", file=f)
|
||||
print(f"#define WRAP_{ubase}_HPP", file=f)
|
||||
print("", file=f)
|
||||
print('#include "two-mallocs.hpp"', file=f)
|
||||
print(f"#include <{base}>", file=f)
|
||||
print("", file=f)
|
||||
print("namespace eng {", file=f)
|
||||
print("} // namespace eng", file=f)
|
||||
print("", file=f)
|
||||
print("namespace drv {", file=f)
|
||||
print("} // namespace drv", file=f)
|
||||
print("", file=f)
|
||||
print(f"#endif // WRAP_{ubase}_HPP", file=f)
|
||||
13
luprex/core/wrap/wrap-algorithm.hpp
Normal file
13
luprex/core/wrap/wrap-algorithm.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef WRAP_ALGORITHM_HPP
|
||||
#define WRAP_ALGORITHM_HPP
|
||||
|
||||
#include "two-mallocs.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
namespace eng {
|
||||
} // namespace eng
|
||||
|
||||
namespace drv {
|
||||
} // namespace drv
|
||||
|
||||
#endif // WRAP_ALGORITHM_HPP
|
||||
17
luprex/core/wrap/wrap-deque.hpp
Normal file
17
luprex/core/wrap/wrap-deque.hpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef WRAP_DEQUE_HPP
|
||||
#define WRAP_DEQUE_HPP
|
||||
|
||||
#include "two-mallocs.hpp"
|
||||
#include <deque>
|
||||
|
||||
namespace eng {
|
||||
template<class T>
|
||||
using deque = std::deque<T, EngAllocator<T>>;
|
||||
} // namespace eng
|
||||
|
||||
namespace drv {
|
||||
template<class T>
|
||||
using deque = std::deque<T, std::allocator<T>>;
|
||||
} // namespace drv
|
||||
|
||||
#endif // WRAP_DEQUE_HPP
|
||||
25
luprex/core/wrap/wrap-map.hpp
Normal file
25
luprex/core/wrap/wrap-map.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef WRAP_MAP_HPP
|
||||
#define WRAP_MAP_HPP
|
||||
|
||||
#include "two-mallocs.hpp"
|
||||
#include <map>
|
||||
|
||||
namespace eng {
|
||||
template<class T>
|
||||
using less = std::less<T>;
|
||||
template<class A, class B>
|
||||
using pair = std::pair<A, B>;
|
||||
template<class K, class V, class C=std::less<K>>
|
||||
using map = std::map<K, V, C, EngAllocator<std::pair<const K, V>>>;
|
||||
} // namespace eng
|
||||
|
||||
namespace drv {
|
||||
template<class T>
|
||||
using less = std::less<T>;
|
||||
template<class A, class B>
|
||||
using pair = std::pair<A, B>;
|
||||
template<class K, class V, class C=std::less<K>>
|
||||
using map = std::map<K, V, C, std::allocator<std::pair<const K, V>>>;
|
||||
} // namespace drv
|
||||
|
||||
#endif // WRAP_MAP_HPP
|
||||
21
luprex/core/wrap/wrap-memory.hpp
Normal file
21
luprex/core/wrap/wrap-memory.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef WRAP_MEMORY_HPP
|
||||
#define WRAP_MEMORY_HPP
|
||||
|
||||
#include "two-mallocs.hpp"
|
||||
#include <memory>
|
||||
|
||||
namespace eng {
|
||||
template<class T, class D=std::default_delete<T>>
|
||||
using unique_ptr = std::unique_ptr<T, D>;
|
||||
template<class T>
|
||||
using shared_ptr = std::shared_ptr<T>;
|
||||
} // namespace eng
|
||||
|
||||
namespace drv {
|
||||
template<class T, class D=std::default_delete<T>>
|
||||
using unique_ptr = std::unique_ptr<T, D>;
|
||||
template<class T>
|
||||
using shared_ptr = std::shared_ptr<T>;
|
||||
} // namespace drv
|
||||
|
||||
#endif // WRAP_MEMORY_HPP
|
||||
15
luprex/core/wrap/wrap-ostream.hpp
Normal file
15
luprex/core/wrap/wrap-ostream.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef WRAP_OSTREAM_HPP
|
||||
#define WRAP_OSTREAM_HPP
|
||||
|
||||
#include "two-mallocs.hpp"
|
||||
#include <ostream>
|
||||
|
||||
namespace eng {
|
||||
using ostream = std::ostream;
|
||||
} // namespace eng
|
||||
|
||||
namespace drv {
|
||||
using ostream = std::ostream;
|
||||
} // namespace drv
|
||||
|
||||
#endif // WRAP_OSTREAM_HPP
|
||||
21
luprex/core/wrap/wrap-set.hpp
Normal file
21
luprex/core/wrap/wrap-set.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef WRAP_SET_HPP
|
||||
#define WRAP_SET_HPP
|
||||
|
||||
#include "two-mallocs.hpp"
|
||||
#include <set>
|
||||
|
||||
namespace eng {
|
||||
template<class T>
|
||||
using less = std::less<T>;
|
||||
template<class K, class C=std::less<K>>
|
||||
using set = std::set<K, C, EngAllocator<K>>;
|
||||
} // namespace eng
|
||||
|
||||
namespace drv {
|
||||
template<class T>
|
||||
using less = std::less<T>;
|
||||
template<class K, class C=std::less<K>>
|
||||
using set = std::set<K, C, std::allocator<K>>;
|
||||
} // namespace drv
|
||||
|
||||
#endif // WRAP_SET_HPP
|
||||
19
luprex/core/wrap/wrap-sstream.hpp
Normal file
19
luprex/core/wrap/wrap-sstream.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef WRAP_SSTREAM_HPP
|
||||
#define WRAP_SSTREAM_HPP
|
||||
|
||||
#include "two-mallocs.hpp"
|
||||
#include <sstream>
|
||||
|
||||
namespace eng {
|
||||
template<class C, class T=std::char_traits<C>>
|
||||
using basic_ostringstream = std::basic_ostringstream<C, T, EngAllocator<C>>;
|
||||
using ostringstream = std::basic_ostringstream<char>;
|
||||
} // namespace eng
|
||||
|
||||
namespace drv {
|
||||
template<class C, class T=std::char_traits<C>>
|
||||
using basic_ostringstream = std::basic_ostringstream<C, T, std::allocator<C>>;
|
||||
using ostringstream = std::basic_ostringstream<char>;
|
||||
} // namespace drv
|
||||
|
||||
#endif // WRAP_SSTREAM_HPP
|
||||
19
luprex/core/wrap/wrap-string-view.hpp
Normal file
19
luprex/core/wrap/wrap-string-view.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef WRAP_STRING_VIEW_HPP
|
||||
#define WRAP_STRING_VIEW_HPP
|
||||
|
||||
#include "two-mallocs.hpp"
|
||||
#include <string_view>
|
||||
|
||||
namespace eng {
|
||||
template<class C, class T=std::char_traits<C>>
|
||||
using basic_string_view = std::basic_string_view<C, T>;
|
||||
using string_view = basic_string_view<char>;
|
||||
} // namespace eng
|
||||
|
||||
namespace drv {
|
||||
template<class C, class T=std::char_traits<C>>
|
||||
using basic_string_view = std::basic_string_view<C, T>;
|
||||
using string_view = basic_string_view<char>;
|
||||
} // namespace drv
|
||||
|
||||
#endif // WRAP_STRING_VIEW_HPP
|
||||
19
luprex/core/wrap/wrap-string.hpp
Normal file
19
luprex/core/wrap/wrap-string.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef WRAP_STRING_HPP
|
||||
#define WRAP_STRING_HPP
|
||||
|
||||
#include "two-mallocs.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace eng {
|
||||
template<class C, class T=std::char_traits<C>>
|
||||
using basic_string = std::basic_string<C, T, EngAllocator<C>>;
|
||||
using string = basic_string<char>;
|
||||
} // namespace eng
|
||||
|
||||
namespace drv {
|
||||
template<class C, class T=std::char_traits<C>>
|
||||
using basic_string = std::basic_string<C, T, std::allocator<C>>;
|
||||
using string = basic_string<char>;
|
||||
} // namespace drv
|
||||
|
||||
#endif // WRAP_STRING_HPP
|
||||
29
luprex/core/wrap/wrap-unordered-map.hpp
Normal file
29
luprex/core/wrap/wrap-unordered-map.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef WRAP_UNORDERED_MAP_HPP
|
||||
#define WRAP_UNORDERED_MAP_HPP
|
||||
|
||||
#include "two-mallocs.hpp"
|
||||
#include <unordered_map>
|
||||
|
||||
namespace eng {
|
||||
template<class T>
|
||||
using hash = std::hash<T>;
|
||||
template<class T>
|
||||
using equal_to = std::equal_to<T>;
|
||||
template<class A, class B>
|
||||
using pair = std::pair<A, B>;
|
||||
template<class K, class V, class H=std::hash<K>, class E=std::equal_to<K>>
|
||||
using unordered_map = std::unordered_map<K, V, H, E, EngAllocator<std::pair<const K, V>>>;
|
||||
} // namespace eng
|
||||
|
||||
namespace drv {
|
||||
template<class T>
|
||||
using hash = std::hash<T>;
|
||||
template<class T>
|
||||
using equal_to = std::equal_to<T>;
|
||||
template<class A, class B>
|
||||
using pair = std::pair<A, B>;
|
||||
template<class K, class V, class H=std::hash<K>, class E=std::equal_to<K>>
|
||||
using unordered_map = std::unordered_map<K, V, H, E, std::allocator<std::pair<const K, V>>>;
|
||||
} // namespace drv
|
||||
|
||||
#endif // WRAP_UNORDERED_MAP_HPP
|
||||
25
luprex/core/wrap/wrap-unordered-set.hpp
Normal file
25
luprex/core/wrap/wrap-unordered-set.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef WRAP_UNORDERED_SET_HPP
|
||||
#define WRAP_UNORDERED_SET_HPP
|
||||
|
||||
#include "two-mallocs.hpp"
|
||||
#include <unordered_set>
|
||||
|
||||
namespace eng {
|
||||
template<class T>
|
||||
using hash = std::hash<T>;
|
||||
template<class T>
|
||||
using equal_to = std::equal_to<T>;
|
||||
template<class K, class H=std::hash<K>, class E=std::equal_to<K>>
|
||||
using unordered_set = std::unordered_set<K, H, E, EngAllocator<K>>;
|
||||
} // namespace eng
|
||||
|
||||
namespace drv {
|
||||
template<class T>
|
||||
using hash = std::hash<T>;
|
||||
template<class T>
|
||||
using equal_to = std::equal_to<T>;
|
||||
template<class K, class H=std::hash<K>, class E=std::equal_to<K>>
|
||||
using unordered_set = std::unordered_set<K, H, E, std::allocator<K>>;
|
||||
} // namespace drv
|
||||
|
||||
#endif // WRAP_UNORDERED_SET_HPP
|
||||
17
luprex/core/wrap/wrap-utility.hpp
Normal file
17
luprex/core/wrap/wrap-utility.hpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef WRAP_UTILITY_HPP
|
||||
#define WRAP_UTILITY_HPP
|
||||
|
||||
#include "two-mallocs.hpp"
|
||||
#include <utility>
|
||||
|
||||
namespace eng {
|
||||
template<class A, class B>
|
||||
using pair = std::pair<A, B>;
|
||||
} // namespace eng
|
||||
|
||||
namespace drv {
|
||||
template<class A, class B>
|
||||
using pair = std::pair<A, B>;
|
||||
} // namespace drv
|
||||
|
||||
#endif // WRAP_UTILITY_HPP
|
||||
17
luprex/core/wrap/wrap-vector.hpp
Normal file
17
luprex/core/wrap/wrap-vector.hpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef WRAP_VECTOR_HPP
|
||||
#define WRAP_VECTOR_HPP
|
||||
|
||||
#include "two-mallocs.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace eng {
|
||||
template<class T>
|
||||
using vector = std::vector<T, EngAllocator<T>>;
|
||||
} // namespace eng
|
||||
|
||||
namespace drv {
|
||||
template<class T>
|
||||
using vector = std::vector<T, EngAllocator<T>>;
|
||||
} // namespace drv
|
||||
|
||||
#endif // WRAP_VECTOR_HPP
|
||||
Reference in New Issue
Block a user