19 #include <TClassTable.h>
20 #include <TDataMember.h>
21 #include <TInterpreter.h>
32 bool cn_has_scope = class_name.find(
"::") != std::string::npos;
33 std::string cn_with_scope_prefix = std::string(
"::") + class_name;
36 std::vector<TClass*> tclasses;
37 while ((current = TClassTable::At(idx++)) !=
nullptr) {
38 std::string scurrent(current);
39 if (scurrent.find(
"::") == std::string::npos) {
41 if (std::string(current).compare(class_name) == 0) {
42 tclasses.push_back(TClassTable::GetDict(current)());
46 if (
EndsWith(scurrent, class_name)) {
47 tclasses.push_back(TClassTable::GetDict(current)());
50 if (
EndsWith(scurrent, cn_with_scope_prefix)) {
51 tclasses.push_back(TClassTable::GetDict(current)());
61 const std::string& data_member) {
62 std::vector<TDataMember*> ret_val;
64 bool dm_has_scope = data_member.find(
"::") != std::string::npos;
65 std::string class_name =
"";
66 std::string dm_only_name = data_member;
68 auto idx = data_member.find_last_of(
"::");
69 class_name = data_member.substr(0, idx - 1);
70 dm_only_name = data_member.substr(idx + 1, data_member.size());
73 std::stack<TClass*> tc_stack;
74 tc_stack.push(tclass);
76 while (tc_stack.size() != 0) {
77 auto* current_tc = tc_stack.top();
79 for (
const auto&& base : *current_tc->GetListOfBases()) {
80 auto get_dict_functor = TClassTable::GetDict(base->GetName());
81 if (get_dict_functor !=
nullptr) {
82 tc_stack.push(get_dict_functor());
86 for (
int i = 0; i < current_tc->GetListOfDataMembers()->GetSize(); ++i) {
88 static_cast<TDataMember*
>(current_tc->GetListOfDataMembers()->At(i));
90 if (dm_only_name.compare(dm->GetName()) == 0 &&
91 EndsWith(std::string(current_tc->GetName()), class_name)) {
92 ret_val.push_back(dm);
95 if (data_member.compare(dm->GetName()) == 0) {
96 ret_val.push_back(dm);
107 TClass* tclass,
const std::vector<std::string>& dm_names,
108 const std::string& functor_name,
109 const std::function<std::string(
110 const std::string&,
const std::vector<TDataMember*>&)>& code_generator)
111 : functor_name_(
Concat(functor_name, counter_++)),
112 code_generator_(code_generator) {
114 for (
auto& dm : dm_names) {
116 if (candidates.size() == 1) {
118 }
else if (candidates.size() == 0) {
119 Log::Fatal(
"JitForEachDataMemberFunctor::JitForEachDataMemberFunctor",
120 "Could not find data member ", dm);
122 Log::Fatal(
"JitForEachDataMemberFunctor::JitForEachDataMemberFunctor",
123 "Data member name (", dm,
") is ambiguous");
138 return reinterpret_cast<void*
>(gInterpreter->Calc(cmd.c_str()));
152 bool ExistsInIncludePath(
const std::string& header) {
154 std::string inc_dir_flags = gInterpreter->GetIncludePath();
157 Split(inc_dir_flags.substr(3, inc_dir_flags.length() - 4),
"\" -I\"");
159 std::string slash_header =
Concat(
"/", header);
160 for (
auto& dir : include_dirs) {
161 std::filesystem::path hpath = dir;
162 hpath += slash_header;
163 if (std::filesystem::exists(hpath)) {
170 std::string GetIncludePaths() {
171 std::string inc_dir_flags = gInterpreter->GetIncludePath();
173 Split(inc_dir_flags.substr(3, inc_dir_flags.length() - 4),
"\" -I\"");
174 std::stringstream sstr;
175 for (
auto& dir : dirs) {
176 sstr << dir << std::endl;
186 std::filesystem::path hpath = header;
187 if (hpath.is_absolute()) {
188 if (std::filesystem::exists(hpath)) {
189 gInterpreter->Declare(
Concat(
"#include \"", header,
"\"").c_str());
192 Concat(
"Header file ", header,
" does not exist."));
195 if (ExistsInIncludePath(header)) {
196 gInterpreter->Declare(
Concat(
"#include \"", header,
"\"").c_str());
199 Concat(
"Header file ", header,
200 " does not exist in any of the following include "