From 5b5ada108ccaca39b9bd02d2ea8c7799fa749e56 Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Fri, 12 Sep 2014 14:05:34 +0200 Subject: [PATCH] Use new fwd decl mechanism and raw string literals. --- core/utils/src/rootcling.cxx | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/core/utils/src/rootcling.cxx b/core/utils/src/rootcling.cxx index 9c22bfc..7bb531a 100644 --- a/core/utils/src/rootcling.cxx +++ b/core/utils/src/rootcling.cxx @@ -3414,17 +3414,14 @@ std::string GenerateFwdDeclString(const RScanner &scan, using namespace ROOT::TMetaUtils::AST2SourceTools; - const char *emptyString = "\"\""; - std::string fwdDeclString; std::string buffer; std::unordered_set fwdDecls; // Classes - +/* for (auto const & annRcd : scan.fSelectedClasses) { const auto rcdDeclPtr = annRcd.GetRecordDecl(); -// newFwdDeclString += Decl2FwdDecl(*rcdDeclPtr,interp); int retCode = FwdDeclFromRcdDecl(*rcdDeclPtr, interp, buffer); if (-1 == retCode) { @@ -3436,9 +3433,23 @@ std::string GenerateFwdDeclString(const RScanner &scan, if (retCode == 0 && fwdDecls.insert(buffer).second) fwdDeclString += "\"" + buffer + "\"\n"; } +*/ + // Build the input for a transaction containing all of the selected declarations + // Cling will produce the fwd declaration payload. - // Typedefs + std::vector selectedDecls(scan.fSelectedClasses.size()); + + // Pick only RecordDecls + std::transform (scan.fSelectedClasses.begin(), + scan.fSelectedClasses.end(), + selectedDecls.begin(), + [](const ROOT::TMetaUtils::AnnotatedRecordDecl& rcd){return rcd.GetRecordDecl();}); + + fwdDeclString += "R\"DICTFWDDCLS(\n"; + fwdDeclString += Decls2FwdDecls(selectedDecls,interp); + fwdDeclString += ")DICTFWDDCLS\""; + // Typedefs for (auto const & tdNameDeclPtr : scan.fSelectedTypedefs) { buffer = ""; int retCode = FwdDeclFromTypeDefNameDecl(*tdNameDeclPtr, @@ -3446,8 +3457,7 @@ std::string GenerateFwdDeclString(const RScanner &scan, buffer, &fwdDecls); if (retCode == 0 && fwdDecls.insert(buffer).second) { - fwdDeclString += "\"" + buffer + "\"\n"; - + fwdDeclString += "R\"FWDDECL(" + buffer + ")FWDDECL\"\n"; } } @@ -3465,14 +3475,7 @@ std::string GenerateFwdDeclString(const RScanner &scan, // fwdDeclString+="\""+buffer+"\"\n"; // } - if (fwdDeclString.empty()) fwdDeclString = emptyString; - -// std::cout << "\n======================" << std::endl -// << "OLD: " << fwdDeclString -// << "\n======================" << std::endl -// << "NEW: " << newFwdDeclString -// << "\n======================" << std::endl; - + if (fwdDeclString.empty()) fwdDeclString = R"("")"; return fwdDeclString; } -- 1.8.2