{"action":"created","comment":{"url":"https://api.github.com/repos/cms-sw/cmssw/pulls/comments/23768313","id":23768313,"diff_hunk":"@@ -0,0 +1,141 @@\n+#include \"CommonTools/Utils/interface/ExpressionEvaluator.h\"\n+#include \"FWCore/Version/interface/GetReleaseVersion.h\"\n+#include \"FWCore/Utilities/interface/GetEnvironmentVariable.h\"\n+#include \"FWCore/Utilities/interface/Exception.h\"\n+#include \"FWCore/MessageLogger/interface/MessageLogger.h\"\n+\n+#include \"popenCPP.h\"\n+\n+#include <fstream>\n+#include <regex>\n+#include <dlfcn.h>\n+\n+\n+#ifdef VI_DEBUG\n+#include <iostream>\n+#define COUT std::cout;\n+#else\n+#define COUT LogDebug(\"ExpressionEvaluator\")\n+#endif\n+\n+using namespace\treco::exprEvalDetails;\n+\n+\n+namespace {\n+  std::string generateName() {\n+    auto n1 = execSysCommand(\"uuidgen | sed 's/-//g'\");\n+    n1.pop_back();\n+    return n1;\n+  }\n+\n+ void remove(std::string const & name) {\n+  std::string sfile = \"/tmp/\"+name+\".cc\";\n+  std::string ofile = \"/tmp/\"+name+\".so\";\n+\n+  std::string rm=\"rm -f \"; rm+=sfile+' '+ofile;\n+\n+  system(rm.c_str());\n+\n+ }\n+\n+}\n+\n+namespace reco{\n+\n+ExpressionEvaluator::ExpressionEvaluator(const char * pkg, const char * iname, std::string const & iexpr) :\n+  m_name(\"VI_\"+generateName())\n+{\n+\n+\n+  std::string pch = pkg; pch += \"/src/precompile.h\";\n+  std::string quote(\"\\\"\");\n+\n+  \n+  std::string sfile = \"/tmp/\"+m_name+\".cc\";\n+  std::string ofile = \"/tmp/\"+m_name+\".so\";\n+\n+  auto arch = edm::getEnvironmentVariable(\"SCRAM_ARCH\");\n+  auto baseDir = edm::getEnvironmentVariable(\"CMSSW_BASE\");\n+  auto relDir = edm::getEnvironmentVariable(\"CMSSW_RELEASE_BASE\");\n+\n+\n+  std::string incDir = \"/include/\" + arch + \"/\";\n+  std::string cxxf;\n+  {\n+    // look in local dir\n+    std::string file = baseDir + incDir + pch + \".cxxflags\";\n+    std::ifstream ss(file.c_str());\n+    COUT << \"local file: \" << file << std::endl;\n+    if (ss) {\n+      std::getline(ss,cxxf);\n+      incDir = baseDir + incDir;\n+    } else {\n+       // look in release area \n+       std::string file = relDir + incDir + pch + \".cxxflags\";\n+       COUT << \"file in release area: \" << file << std::endl;\n+       std::ifstream ss(file.c_str());\n+       if (!ss) throw  cms::Exception(\"ExpressionEvaluator\", pch + \" file not found neither in \" + baseDir + \" nor in \" + relDir);\n+       std::getline(ss,cxxf);\n+       incDir = relDir + incDir;\n+    }\n+\n+    { std::regex rq(\"-I[^ ]+\"); cxxf = std::regex_replace(cxxf,rq,std::string(\"\")); }\n+    { std::regex rq(\"=\\\"\"); cxxf = std::regex_replace(cxxf,rq,std::string(\"='\\\"\")); }\n+    { std::regex rq(\"\\\" \"); cxxf = std::regex_replace(cxxf,rq,std::string(\"\\\"' \")); }\n+    COUT << '|' << cxxf << \"|\\n\" << std::endl;\n+\n+  }\n+\n+  std::string cpp = \"c++ -H -Wall -shared -Winvalid-pch \"; cpp+=cxxf;\n+  cpp += \" -I\" + incDir; \n+  cpp += \" -o \" + ofile + ' ' + sfile+\" 2>&1\\n\";\n+\n+  COUT << cpp << std::endl;\n+\n+\n+  //  prepare the file to compile\n+  std::string factory = \"factory\" + m_name;\n+\n+  std::string source = std::string(\"#include \")+quote+ pch +quote+\"\\n\";\n+  source+=\"struct \"+m_name+\" final : public \"+iname + \"{\\n\";\n+  source+=iexpr;\n+  source+=\"\\n};\\n\";\n+\n+\n+  source += \"extern \" + quote+'C'+quote+' ' + std::string(iname) + \"* \"+factory+\"() {\\n\";\n+  source += \"static \"+m_name+\" local;\\n\";","path":"CommonTools/Utils/src/ExpressionEvaluator.cc","position":106,"original_position":106,"commit_id":"a849aa813d8fbafde4c208e17c4c51dc4f02bb3e","original_commit_id":"a849aa813d8fbafde4c208e17c4c51dc4f02bb3e","user":{"login":"VinInn","id":4143702,"avatar_url":"https://avatars.githubusercontent.com/u/4143702?v=3","gravatar_id":"","url":"https://api.github.com/users/VinInn","html_url":"https://github.com/VinInn","followers_url":"https://api.github.com/users/VinInn/followers","following_url":"https://api.github.com/users/VinInn/following{/other_user}","gists_url":"https://api.github.com/users/VinInn/gists{/gist_id}","starred_url":"https://api.github.com/users/VinInn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VinInn/subscriptions","organizations_url":"https://api.github.com/users/VinInn/orgs","repos_url":"https://api.github.com/users/VinInn/repos","events_url":"https://api.github.com/users/VinInn/events{/privacy}","received_events_url":"https://api.github.com/users/VinInn/received_events","type":"User","site_admin":false},"body":"add const...","created_at":"2015-01-29T13:54:31Z","updated_at":"2015-01-29T13:54:31Z","html_url":"https://github.com/cms-sw/cmssw/pull/7363#discussion_r23768313","pull_request_url":"https://api.github.com/repos/cms-sw/cmssw/pulls/7363","_links":{"self":{"href":"https://api.github.com/repos/cms-sw/cmssw/pulls/comments/23768313"},"html":{"href":"https://github.com/cms-sw/cmssw/pull/7363#discussion_r23768313"},"pull_request":{"href":"https://api.github.com/repos/cms-sw/cmssw/pulls/7363"}}},"pull_request":{"url":"https://api.github.com/repos/cms-sw/cmssw/pulls/7363","id":28014776,"html_url":"https://github.com/cms-sw/cmssw/pull/7363","diff_url":"https://github.com/cms-sw/cmssw/pull/7363.diff","patch_url":"https://github.com/cms-sw/cmssw/pull/7363.patch","issue_url":"https://api.github.com/repos/cms-sw/cmssw/issues/7363","number":7363,"state":"open","locked":false,"title":"Expression evaluator","user":{"login":"VinInn","id":4143702,"avatar_url":"https://avatars.githubusercontent.com/u/4143702?v=3","gravatar_id":"","url":"https://api.github.com/users/VinInn","html_url":"https://github.com/VinInn","followers_url":"https://api.github.com/users/VinInn/followers","following_url":"https://api.github.com/users/VinInn/following{/other_user}","gists_url":"https://api.github.com/users/VinInn/gists{/gist_id}","starred_url":"https://api.github.com/users/VinInn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VinInn/subscriptions","organizations_url":"https://api.github.com/users/VinInn/orgs","repos_url":"https://api.github.com/users/VinInn/repos","events_url":"https://api.github.com/users/VinInn/events{/privacy}","received_events_url":"https://api.github.com/users/VinInn/received_events","type":"User","site_admin":false},"body":"A new Expression Evaluator based on the standard C++ compiler\r\nto replace the current one that is implemented using on a home-made parser (based on boost::spirit) and access objects using ROOT-reflection\r\n\r\nmotivations, doc, examples in \r\nhttp://innocent.home.cern.ch/innocent/ExprEval.pdf\r\nto be presented at next reco/phys-tool meeting","created_at":"2015-01-26T09:43:31Z","updated_at":"2015-01-29T13:54:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"25e5e3af82870b6e951e6fa67e0d2e057adbb82a","assignee":null,"milestone":{"url":"https://api.github.com/repos/cms-sw/cmssw/milestones/50","labels_url":"https://api.github.com/repos/cms-sw/cmssw/milestones/50/labels","id":875803,"number":50,"title":"Next CMSSW_7_4_X","description":"","creator":{"login":"nclopezo","id":1944922,"avatar_url":"https://avatars.githubusercontent.com/u/1944922?v=3","gravatar_id":"","url":"https://api.github.com/users/nclopezo","html_url":"https://github.com/nclopezo","followers_url":"https://api.github.com/users/nclopezo/followers","following_url":"https://api.github.com/users/nclopezo/following{/other_user}","gists_url":"https://api.github.com/users/nclopezo/gists{/gist_id}","starred_url":"https://api.github.com/users/nclopezo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nclopezo/subscriptions","organizations_url":"https://api.github.com/users/nclopezo/orgs","repos_url":"https://api.github.com/users/nclopezo/repos","events_url":"https://api.github.com/users/nclopezo/events{/privacy}","received_events_url":"https://api.github.com/users/nclopezo/received_events","type":"User","site_admin":false},"open_issues":55,"closed_issues":452,"state":"open","created_at":"2014-11-21T15:23:58Z","updated_at":"2015-01-29T12:47:03Z","due_on":"2015-01-26T08:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/cms-sw/cmssw/pulls/7363/commits","review_comments_url":"https://api.github.com/repos/cms-sw/cmssw/pulls/7363/comments","review_comment_url":"https://api.github.com/repos/cms-sw/cmssw/pulls/comments/{number}","comments_url":"https://api.github.com/repos/cms-sw/cmssw/issues/7363/comments","statuses_url":"https://api.github.com/repos/cms-sw/cmssw/statuses/a849aa813d8fbafde4c208e17c4c51dc4f02bb3e","head":{"label":"VinInn:ExpressionEvaluator","ref":"ExpressionEvaluator","sha":"a849aa813d8fbafde4c208e17c4c51dc4f02bb3e","user":{"login":"VinInn","id":4143702,"avatar_url":"https://avatars.githubusercontent.com/u/4143702?v=3","gravatar_id":"","url":"https://api.github.com/users/VinInn","html_url":"https://github.com/VinInn","followers_url":"https://api.github.com/users/VinInn/followers","following_url":"https://api.github.com/users/VinInn/following{/other_user}","gists_url":"https://api.github.com/users/VinInn/gists{/gist_id}","starred_url":"https://api.github.com/users/VinInn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VinInn/subscriptions","organizations_url":"https://api.github.com/users/VinInn/orgs","repos_url":"https://api.github.com/users/VinInn/repos","events_url":"https://api.github.com/users/VinInn/events{/privacy}","received_events_url":"https://api.github.com/users/VinInn/received_events","type":"User","site_admin":false},"repo":{"id":11128341,"name":"cmssw","full_name":"VinInn/cmssw","owner":{"login":"VinInn","id":4143702,"avatar_url":"https://avatars.githubusercontent.com/u/4143702?v=3","gravatar_id":"","url":"https://api.github.com/users/VinInn","html_url":"https://github.com/VinInn","followers_url":"https://api.github.com/users/VinInn/followers","following_url":"https://api.github.com/users/VinInn/following{/other_user}","gists_url":"https://api.github.com/users/VinInn/gists{/gist_id}","starred_url":"https://api.github.com/users/VinInn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VinInn/subscriptions","organizations_url":"https://api.github.com/users/VinInn/orgs","repos_url":"https://api.github.com/users/VinInn/repos","events_url":"https://api.github.com/users/VinInn/events{/privacy}","received_events_url":"https://api.github.com/users/VinInn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/VinInn/cmssw","description":"CMS Offline Software","fork":true,"url":"https://api.github.com/repos/VinInn/cmssw","forks_url":"https://api.github.com/repos/VinInn/cmssw/forks","keys_url":"https://api.github.com/repos/VinInn/cmssw/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VinInn/cmssw/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VinInn/cmssw/teams","hooks_url":"https://api.github.com/repos/VinInn/cmssw/hooks","issue_events_url":"https://api.github.com/repos/VinInn/cmssw/issues/events{/number}","events_url":"https://api.github.com/repos/VinInn/cmssw/events","assignees_url":"https://api.github.com/repos/VinInn/cmssw/assignees{/user}","branches_url":"https://api.github.com/repos/VinInn/cmssw/branches{/branch}","tags_url":"https://api.github.com/repos/VinInn/cmssw/tags","blobs_url":"https://api.github.com/repos/VinInn/cmssw/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VinInn/cmssw/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VinInn/cmssw/git/refs{/sha}","trees_url":"https://api.github.com/repos/VinInn/cmssw/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VinInn/cmssw/statuses/{sha}","languages_url":"https://api.github.com/repos/VinInn/cmssw/languages","stargazers_url":"https://api.github.com/repos/VinInn/cmssw/stargazers","contributors_url":"https://api.github.com/repos/VinInn/cmssw/contributors","subscribers_url":"https://api.github.com/repos/VinInn/cmssw/subscribers","subscription_url":"https://api.github.com/repos/VinInn/cmssw/subscription","commits_url":"https://api.github.com/repos/VinInn/cmssw/commits{/sha}","git_commits_url":"https://api.github.com/repos/VinInn/cmssw/git/commits{/sha}","comments_url":"https://api.github.com/repos/VinInn/cmssw/comments{/number}","issue_comment_url":"https://api.github.com/repos/VinInn/cmssw/issues/comments/{number}","contents_url":"https://api.github.com/repos/VinInn/cmssw/contents/{+path}","compare_url":"https://api.github.com/repos/VinInn/cmssw/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VinInn/cmssw/merges","archive_url":"https://api.github.com/repos/VinInn/cmssw/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VinInn/cmssw/downloads","issues_url":"https://api.github.com/repos/VinInn/cmssw/issues{/number}","pulls_url":"https://api.github.com/repos/VinInn/cmssw/pulls{/number}","milestones_url":"https://api.github.com/repos/VinInn/cmssw/milestones{/number}","notifications_url":"https://api.github.com/repos/VinInn/cmssw/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VinInn/cmssw/labels{/name}","releases_url":"https://api.github.com/repos/VinInn/cmssw/releases{/id}","created_at":"2013-07-02T15:43:52Z","updated_at":"2014-06-25T05:11:32Z","pushed_at":"2015-01-29T11:12:09Z","git_url":"git://github.com/VinInn/cmssw.git","ssh_url":"git@github.com:VinInn/cmssw.git","clone_url":"https://github.com/VinInn/cmssw.git","svn_url":"https://github.com/VinInn/cmssw","homepage":"cms-sw.github.io/cmssw","size":564594,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"CMSSW_7_0_X"}},"base":{"label":"cms-sw:CMSSW_7_4_X","ref":"CMSSW_7_4_X","sha":"4d4fe5729e0f021ad2792cdf6224bf530508532c","user":{"login":"cms-sw","id":3863500,"avatar_url":"https://avatars.githubusercontent.com/u/3863500?v=3","gravatar_id":"","url":"https://api.github.com/users/cms-sw","html_url":"https://github.com/cms-sw","followers_url":"https://api.github.com/users/cms-sw/followers","following_url":"https://api.github.com/users/cms-sw/following{/other_user}","gists_url":"https://api.github.com/users/cms-sw/gists{/gist_id}","starred_url":"https://api.github.com/users/cms-sw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cms-sw/subscriptions","organizations_url":"https://api.github.com/users/cms-sw/orgs","repos_url":"https://api.github.com/users/cms-sw/repos","events_url":"https://api.github.com/users/cms-sw/events{/privacy}","received_events_url":"https://api.github.com/users/cms-sw/received_events","type":"Organization","site_admin":false},"repo":{"id":10969551,"name":"cmssw","full_name":"cms-sw/cmssw","owner":{"login":"cms-sw","id":3863500,"avatar_url":"https://avatars.githubusercontent.com/u/3863500?v=3","gravatar_id":"","url":"https://api.github.com/users/cms-sw","html_url":"https://github.com/cms-sw","followers_url":"https://api.github.com/users/cms-sw/followers","following_url":"https://api.github.com/users/cms-sw/following{/other_user}","gists_url":"https://api.github.com/users/cms-sw/gists{/gist_id}","starred_url":"https://api.github.com/users/cms-sw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cms-sw/subscriptions","organizations_url":"https://api.github.com/users/cms-sw/orgs","repos_url":"https://api.github.com/users/cms-sw/repos","events_url":"https://api.github.com/users/cms-sw/events{/privacy}","received_events_url":"https://api.github.com/users/cms-sw/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cms-sw/cmssw","description":"CMS Offline Software","fork":false,"url":"https://api.github.com/repos/cms-sw/cmssw","forks_url":"https://api.github.com/repos/cms-sw/cmssw/forks","keys_url":"https://api.github.com/repos/cms-sw/cmssw/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cms-sw/cmssw/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cms-sw/cmssw/teams","hooks_url":"https://api.github.com/repos/cms-sw/cmssw/hooks","issue_events_url":"https://api.github.com/repos/cms-sw/cmssw/issues/events{/number}","events_url":"https://api.github.com/repos/cms-sw/cmssw/events","assignees_url":"https://api.github.com/repos/cms-sw/cmssw/assignees{/user}","branches_url":"https://api.github.com/repos/cms-sw/cmssw/branches{/branch}","tags_url":"https://api.github.com/repos/cms-sw/cmssw/tags","blobs_url":"https://api.github.com/repos/cms-sw/cmssw/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cms-sw/cmssw/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cms-sw/cmssw/git/refs{/sha}","trees_url":"https://api.github.com/repos/cms-sw/cmssw/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cms-sw/cmssw/statuses/{sha}","languages_url":"https://api.github.com/repos/cms-sw/cmssw/languages","stargazers_url":"https://api.github.com/repos/cms-sw/cmssw/stargazers","contributors_url":"https://api.github.com/repos/cms-sw/cmssw/contributors","subscribers_url":"https://api.github.com/repos/cms-sw/cmssw/subscribers","subscription_url":"https://api.github.com/repos/cms-sw/cmssw/subscription","commits_url":"https://api.github.com/repos/cms-sw/cmssw/commits{/sha}","git_commits_url":"https://api.github.com/repos/cms-sw/cmssw/git/commits{/sha}","comments_url":"https://api.github.com/repos/cms-sw/cmssw/comments{/number}","issue_comment_url":"https://api.github.com/repos/cms-sw/cmssw/issues/comments/{number}","contents_url":"https://api.github.com/repos/cms-sw/cmssw/contents/{+path}","compare_url":"https://api.github.com/repos/cms-sw/cmssw/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cms-sw/cmssw/merges","archive_url":"https://api.github.com/repos/cms-sw/cmssw/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cms-sw/cmssw/downloads","issues_url":"https://api.github.com/repos/cms-sw/cmssw/issues{/number}","pulls_url":"https://api.github.com/repos/cms-sw/cmssw/pulls{/number}","milestones_url":"https://api.github.com/repos/cms-sw/cmssw/milestones{/number}","notifications_url":"https://api.github.com/repos/cms-sw/cmssw/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cms-sw/cmssw/labels{/name}","releases_url":"https://api.github.com/repos/cms-sw/cmssw/releases{/id}","created_at":"2013-06-26T14:09:07Z","updated_at":"2015-01-29T12:47:04Z","pushed_at":"2015-01-29T13:09:19Z","git_url":"git://github.com/cms-sw/cmssw.git","ssh_url":"git@github.com:cms-sw/cmssw.git","clone_url":"https://github.com/cms-sw/cmssw.git","svn_url":"https://github.com/cms-sw/cmssw","homepage":"http://cms-sw.github.io/","size":787189,"stargazers_count":201,"watchers_count":201,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1233,"mirror_url":null,"open_issues_count":133,"forks":1233,"open_issues":133,"watchers":201,"default_branch":"CMSSW_7_4_X"}},"_links":{"self":{"href":"https://api.github.com/repos/cms-sw/cmssw/pulls/7363"},"html":{"href":"https://github.com/cms-sw/cmssw/pull/7363"},"issue":{"href":"https://api.github.com/repos/cms-sw/cmssw/issues/7363"},"comments":{"href":"https://api.github.com/repos/cms-sw/cmssw/issues/7363/comments"},"review_comments":{"href":"https://api.github.com/repos/cms-sw/cmssw/pulls/7363/comments"},"review_comment":{"href":"https://api.github.com/repos/cms-sw/cmssw/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/cms-sw/cmssw/pulls/7363/commits"},"statuses":{"href":"https://api.github.com/repos/cms-sw/cmssw/statuses/a849aa813d8fbafde4c208e17c4c51dc4f02bb3e"}}}}