forked from RosettaCommons/binder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
T30.include.ref.cpp
132 lines (101 loc) · 4.22 KB
/
T30.include.ref.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// File: T30_include_incl_a_include.cpp
#include <T30.include.incl.a.include> // aaaa::A
#include <sstream> // __str__
#include <functional>
#include <pybind11/pybind11.h>
#include <string>
#ifndef BINDER_PYBIND11_TYPE_CASTER
#define BINDER_PYBIND11_TYPE_CASTER
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>)
PYBIND11_DECLARE_HOLDER_TYPE(T, T*)
PYBIND11_MAKE_OPAQUE(std::shared_ptr<void>)
#endif
void bind_T30_include_incl_a_include(std::function< pybind11::module &(std::string const &namespace_) > &M)
{
{ // aaaa::A file:T30.include.incl.a.include line:7
pybind11::class_<aaaa::A, std::shared_ptr<aaaa::A>> cl(M("aaaa"), "A", "");
cl.def( pybind11::init( [](){ return new aaaa::A(); } ) );
}
}
// File: T30_include_incl_b_include.cpp
#include <T30.include.incl.a.include> // aaaa::A
#include <T30.include.incl.b.include> // bbbb::B
#include <sstream> // __str__
#include <functional>
#include <pybind11/pybind11.h>
#include <string>
#ifndef BINDER_PYBIND11_TYPE_CASTER
#define BINDER_PYBIND11_TYPE_CASTER
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>)
PYBIND11_DECLARE_HOLDER_TYPE(T, T*)
PYBIND11_MAKE_OPAQUE(std::shared_ptr<void>)
#endif
void bind_T30_include_incl_b_include(std::function< pybind11::module &(std::string const &namespace_) > &M)
{
{ // bbbb::B file:T30.include.incl.b.include line:8
pybind11::class_<bbbb::B<aaaa::A>, std::shared_ptr<bbbb::B<aaaa::A>>> cl(M("bbbb"), "B_aaaa_A_t", "");
cl.def( pybind11::init( [](){ return new bbbb::B<aaaa::A>(); } ) );
}
}
// File: T30_include.cpp
#include <T30.include.hpp> // foo
#include <T30.include.incl.a.include> // aaaa::A
#include <T30.include.incl.b.include> // bbbb::B
#include <functional>
#include <pybind11/pybind11.h>
#include <string>
#ifndef BINDER_PYBIND11_TYPE_CASTER
#define BINDER_PYBIND11_TYPE_CASTER
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>)
PYBIND11_DECLARE_HOLDER_TYPE(T, T*)
PYBIND11_MAKE_OPAQUE(std::shared_ptr<void>)
#endif
void bind_T30_include(std::function< pybind11::module &(std::string const &namespace_) > &M)
{
// foo(class bbbb::B<class aaaa::A>) file:T30.include.hpp line:19
M("").def("foo", (void (*)(class bbbb::B<class aaaa::A>)) &foo, "C++: foo(class bbbb::B<class aaaa::A>) --> void", pybind11::arg(""));
}
#include <map>
#include <algorithm>
#include <functional>
#include <memory>
#include <stdexcept>
#include <string>
#include <pybind11/pybind11.h>
typedef std::function< pybind11::module & (std::string const &) > ModuleGetter;
void bind_T30_include_incl_a_include(std::function< pybind11::module &(std::string const &namespace_) > &M);
void bind_T30_include_incl_b_include(std::function< pybind11::module &(std::string const &namespace_) > &M);
void bind_T30_include(std::function< pybind11::module &(std::string const &namespace_) > &M);
PYBIND11_MODULE(T30_include, root_module) {
root_module.doc() = "T30_include module";
std::map <std::string, pybind11::module> modules;
ModuleGetter M = [&](std::string const &namespace_) -> pybind11::module & {
auto it = modules.find(namespace_);
if( it == modules.end() ) throw std::runtime_error("Attempt to access pybind11::module for namespace " + namespace_ + " before it was created!!!");
return it->second;
};
modules[""] = root_module;
static std::vector<std::string> const reserved_python_words {"nonlocal", "global", };
auto mangle_namespace_name(
[](std::string const &ns) -> std::string {
if ( std::find(reserved_python_words.begin(), reserved_python_words.end(), ns) == reserved_python_words.end() ) return ns;
else return ns+'_';
}
);
std::vector< std::pair<std::string, std::string> > sub_modules {
{"", "aaaa"},
{"", "bbbb"},
};
for(auto &p : sub_modules ) modules[p.first.size() ? p.first+"::"+p.second : p.second] = modules[p.first].def_submodule( mangle_namespace_name(p.second).c_str(), ("Bindings for " + p.first + "::" + p.second + " namespace").c_str() );
//pybind11::class_<std::shared_ptr<void>>(M(""), "_encapsulated_data_");
bind_T30_include_incl_a_include(M);
bind_T30_include_incl_b_include(M);
bind_T30_include(M);
}
// Source list file: TEST/T30_include.sources
// T30_include.cpp
// T30_include_incl_a_include.cpp
// T30_include_incl_b_include.cpp
// T30_include.cpp
// Modules list file: TEST/T30_include.modules
// aaaa bbbb