30T
GetFromMacro(
const std::string&
file,
const std::string& funcname,
const std::string&
type,
const std::string& unique)
37 auto firstindex =
file.find_last_of(
"/") + 1;
38 auto lastindex =
file.find_last_of(
".");
40 lastindex <
size ? lastindex - firstindex :
size - firstindex) +
43 auto gfunc =
func.substr(0,
func.find_first_of(
'('));
46 if (!gROOT->GetGlobalFunction(gfunc.c_str())) {
47 if (gROOT->LoadMacro(
file.c_str()) != 0) {
48 LOG(fatal) <<
"Cannot find " <<
file;
51 if (!gROOT->GetGlobalFunction(gfunc.c_str())) {
52 LOG(fatal) <<
"Global function '" << gfunc <<
"' not defined";
58 auto returnedtype = gROOT->GetGlobalFunction(gfunc.c_str())->GetReturnTypeName();
59 if (strcmp(returnedtype,
type.c_str())) {
60 LOG(info) <<
"Global function '" << gfunc <<
"' does not return a '" <<
type <<
"' type ( but " << returnedtype <<
" )";
65 gROOT->ProcessLine(Form(
"%s __%s__ = %s;",
type.c_str(), unique.c_str(),
func.c_str()));
66 auto ptr = (T*)gROOT->GetGlobal(Form(
"__%s__", unique.c_str()))->GetAddress();
78T
JITAndEvalFunction(
const std::string& functiondecl,
const std::string& funcname,
const std::string&
type,
const std::string& unique)
81 auto line = Form(
"%s; %s __%s__ = %s;", functiondecl.c_str(),
type.c_str(), unique.c_str(), funcname.c_str());
82 gROOT->ProcessLine(line);
83 auto ptr = (T*)gROOT->GetGlobal(Form(
"__%s__", unique.c_str()))->GetAddress();