Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
36a7534
[TCling] Use string,vector instead of std.
Axel-Naumann Jul 22, 2022
9670fe8
[test] Remove legacy using namespace std/stdext.
Axel-Naumann May 9, 2023
38a0341
[proof] Remove unnecessary `using namespace std` in header.
Axel-Naumann May 9, 2023
1395866
[foundation] Add doc to some TClassEdit functions (NFC).
Axel-Naumann May 9, 2023
7c7a1d5
[dictgen] Make gOptNoGlobalUsingStd the default and only way.
Axel-Naumann May 9, 2023
6a2a6a7
[dictgen] Remove unused var; add using decls for std types.
Axel-Naumann May 10, 2023
d9edba9
[core] In generated dict code, always prefix std classes with "std":
Axel-Naumann May 10, 2023
859bfeb
[mathcore] Do not generate a dict for vector<double> iters:
Axel-Naumann May 10, 2023
f1065cb
[foundation] TClassEdit::InsertStd: add PRNG types to std type list.
Axel-Naumann May 11, 2023
c6ec900
Do not generate dicts for iterators:
Axel-Naumann May 11, 2023
542e382
[foundation] Fix spelling of std types; add missing ones, rm auto_ptr.
Axel-Naumann May 11, 2023
cdc2a31
[io] Diagnose missing stdlib I/O support:
Axel-Naumann May 15, 2023
4503bd0
[geo] Do not generate dictionaries for thread::id:
Axel-Naumann May 15, 2023
52e9f32
[fumili] no dict for TFumiliMinimizer: not persistent and not a TObje…
Axel-Naumann May 15, 2023
430660e
[clingutils] Fwd decls must use "std::" where needed:
Axel-Naumann May 15, 2023
a316141
[dictgen] Inject using decls for common stdlib names in ACLiC dicts:
Axel-Naumann May 16, 2023
32f08fa
[core] Do not InspectMembers() for stdlib types:
Axel-Naumann May 16, 2023
353faaa
[core] Centralize using decls injected into cling, add more.
Axel-Naumann May 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[core] In generated dict code, always prefix std classes with "std":
This is backward compatible and avoids having to inject a "using namespace std".
  • Loading branch information
Axel-Naumann committed May 15, 2023
commit d9edba9e35c961e9362def2655c2991d9465540a
26 changes: 11 additions & 15 deletions core/clingutils/src/TClingUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1715,13 +1715,11 @@ void ROOT::TMetaUtils::WriteClassInit(std::ostream& finalString,
std::string csymbol = classname;
std::string args;

if ( ! TClassEdit::IsStdClass( classname.c_str() ) ) {
csymbol = TClassEdit::InsertStd(csymbol.c_str());

// Prefix the full class name with '::' except for the STL
// containers and std::string. This is to request the
// real class instead of the class in the namespace ROOT::Shadow
csymbol.insert(0,"::");
}
// Prefix the full class name with '::', to refert to the
// real class instead of the class in the namespace ROOT::Shadow
csymbol.insert(0,"::");

int stl = TClassEdit::IsSTLCont(classname);
bool bset = TClassEdit::IsSTLBitset(classname.c_str());
Expand Down Expand Up @@ -1988,7 +1986,8 @@ void ROOT::TMetaUtils::WriteClassInit(std::ostream& finalString,
// FIXME Workaround: for the moment we do not generate coll proxies with unique ptrs since
// they imply copies and therefore do not compile.
auto classNameForIO = TClassEdit::GetNameForIO(classname);
finalString << " instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::" << methodTCP << "< " << classNameForIO.c_str() << " >()));" << "\n";
classNameForIO = TClassEdit::InsertStd(classNameForIO.c_str());
finalString << " instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::" << methodTCP << "< " << classNameForIO << " >()));" << "\n";

needCollectionProxy = true;
}
Expand Down Expand Up @@ -2378,15 +2377,12 @@ void ROOT::TMetaUtils::WriteAuxFunctions(std::ostream& finalString,
// operator delete
// operator delete[]

ROOT::TMetaUtils::GetCppName(mappedname,classname.c_str());

if ( ! TClassEdit::IsStdClass( classname.c_str() ) ) {
classname = TClassEdit::InsertStd(classname.c_str());

// Prefix the full class name with '::' except for the STL
// containers and std::string. This is to request the
// real class instead of the class in the namespace ROOT::Shadow
classname.insert(0,"::");
}
// Prefix the full class name with '::' except for the STL
// containers and std::string. This is to request the
// real class instead of the class in the namespace ROOT::Shadow
classname.insert(0,"::");

finalString << "namespace ROOT {" << "\n";

Expand Down
48 changes: 31 additions & 17 deletions core/dictgen/src/rootcling_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,7 @@ int STLContainerStreamer(const clang::FieldDecl &m,
if (!tmplt_specialization) return 0;

string stlType(ROOT::TMetaUtils::ShortTypeName(mTypename.c_str()));
stlType = TClassEdit::InsertStd(stlType.c_str());
string stlName;
stlName = ROOT::TMetaUtils::ShortTypeName(m.getName().str().c_str());

Expand Down Expand Up @@ -1171,6 +1172,8 @@ void WriteClassFunctions(const clang::CXXRecordDecl *cl, std::ostream &dictStrea
enclSpaceNesting = ROOT::TMetaUtils::WriteNamespaceHeader(dictStream, cl);
}

clsname = TClassEdit::InsertStd(clsname.c_str());

if (autoLoad)
dictStream << "#include \"TInterpreter.h\"\n";

Expand All @@ -1189,16 +1192,22 @@ void WriteClassFunctions(const clang::CXXRecordDecl *cl, std::ostream &dictStrea
dictStream << "//_______________________________________"
<< "_______________________________________" << std::endl;
if (add_template_keyword) dictStream << "template <> ";
dictStream << "const char *" << clsname << "::ImplFileName()" << std::endl << "{" << std::endl
<< " return ::ROOT::GenerateInitInstanceLocal((const ::" << fullname
<< "*)nullptr)->GetImplFileName();" << std::endl << "}" << std::endl << std::endl
dictStream << "const char *" << clsname << "::ImplFileName()" << std::endl
<< "{" << std::endl
<< " return ::ROOT::GenerateInitInstanceLocal((const ::" << clsname << "*)nullptr)->GetImplFileName();"
<< std::endl
<< "}" << std::endl
<< std::endl

<< "//_______________________________________"
<< "_______________________________________" << std::endl;
if (add_template_keyword) dictStream << "template <> ";
dictStream << "int " << clsname << "::ImplFileLine()" << std::endl << "{" << std::endl
<< " return ::ROOT::GenerateInitInstanceLocal((const ::" << fullname
<< "*)nullptr)->GetImplFileLine();" << std::endl << "}" << std::endl << std::endl
dictStream << "int " << clsname << "::ImplFileLine()" << std::endl
<< "{" << std::endl
<< " return ::ROOT::GenerateInitInstanceLocal((const ::" << clsname << "*)nullptr)->GetImplFileLine();"
<< std::endl
<< "}" << std::endl
<< std::endl

<< "//_______________________________________"
<< "_______________________________________" << std::endl;
Expand All @@ -1208,20 +1217,21 @@ void WriteClassFunctions(const clang::CXXRecordDecl *cl, std::ostream &dictStrea
// Trigger autoloading if dictionary is split
if (autoLoad)
dictStream << " gInterpreter->AutoLoad(\"" << fullname << "\");\n";
dictStream << " fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::" << fullname
<< "*)nullptr)->GetClass();" << std::endl
<< " return fgIsA;\n"
<< "}" << std::endl << std::endl
dictStream << " fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::" << clsname << "*)nullptr)->GetClass();"
<< std::endl
<< " return fgIsA;\n"
<< "}" << std::endl
<< std::endl

<< "//_______________________________________"
<< "_______________________________________" << std::endl;
<< "//_______________________________________"
<< "_______________________________________" << std::endl;
if (add_template_keyword) dictStream << "template <> ";
dictStream << "TClass *" << clsname << "::Class()" << std::endl << "{" << std::endl;
if (autoLoad) {
dictStream << " Dictionary();\n";
} else {
dictStream << " if (!fgIsA.load()) { R__LOCKGUARD(gInterpreterMutex); fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::";
dictStream << fullname << "*)nullptr)->GetClass(); }" << std::endl;
dictStream << clsname << "*)nullptr)->GetClass(); }" << std::endl;
}
dictStream << " return fgIsA;" << std::endl
<< "}" << std::endl << std::endl;
Expand Down Expand Up @@ -1386,6 +1396,7 @@ void WriteStreamer(const ROOT::TMetaUtils::AnnotatedRecordDecl &cl,
if (ROOT::TMetaUtils::GetNameWithinNamespace(fullname, clsname, nsname, clxx)) {
enclSpaceNesting = ROOT::TMetaUtils::WriteNamespaceHeader(dictStream, cl);
}
clsname = TClassEdit::InsertStd(clsname.c_str());

dictStream << "//_______________________________________"
<< "_______________________________________" << std::endl;
Expand Down Expand Up @@ -1788,19 +1799,22 @@ void WriteAutoStreamer(const ROOT::TMetaUtils::AnnotatedRecordDecl &cl,
if (ROOT::TMetaUtils::GetNameWithinNamespace(fullname, clsname, nsname, clxx)) {
enclSpaceNesting = ROOT::TMetaUtils::WriteNamespaceHeader(dictStream, cl);
}
clsname = TClassEdit::InsertStd(clsname.c_str());

dictStream << "//_______________________________________"
<< "_______________________________________" << std::endl;
if (add_template_keyword) dictStream << "template <> ";
dictStream << "void " << clsname << "::Streamer(TBuffer &R__b)" << std::endl
<< "{" << std::endl
<< " // Stream an object of class " << fullname << "." << std::endl << std::endl
<< " // Stream an object of class " << fullname << "." << std::endl
<< std::endl
<< " if (R__b.IsReading()) {" << std::endl
<< " R__b.ReadClassBuffer(" << fullname << "::Class(),this);" << std::endl
<< " R__b.ReadClassBuffer(" << clsname << "::Class(),this);" << std::endl
<< " } else {" << std::endl
<< " R__b.WriteClassBuffer(" << fullname << "::Class(),this);" << std::endl
<< " R__b.WriteClassBuffer(" << clsname << "::Class(),this);" << std::endl
<< " }" << std::endl
<< "}" << std::endl << std::endl;
<< "}" << std::endl
<< std::endl;

while (enclSpaceNesting) {
dictStream << "} // namespace " << nsname << std::endl;
Expand Down
15 changes: 9 additions & 6 deletions core/foundation/src/RConversionRuleParser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -475,10 +475,11 @@ namespace ROOT

static void WriteAutoVariables( const std::list<std::string>& target,
const SourceTypeList_t& source,
MembersTypeMap_t& members,
std::string& className, std::string& mappedName,
const MembersTypeMap_t& members,
std::string className, const std::string& mappedName,
std::ostream& output )
{
className = TClassEdit::InsertStd(className.c_str());
if (!source.empty()) {
Bool_t start = true;
SourceTypeList_t::const_iterator it;
Expand Down Expand Up @@ -616,18 +617,20 @@ namespace ROOT

std::list<std::string>::const_iterator it;
for( it = target.begin(); it != target.end(); ++it ) {
Internal::TSchemaType memData = members[*it];
const Internal::TSchemaType &memData = members.find(*it)->second;
output << " static Long_t offset_" << *it << " = ";
output << "cls->GetDataMemberOffset(\"" << *it << "\");";
output << std::endl;
std::string memDataType = TClassEdit::InsertStd(memData.fType.c_str());
if (memData.fDimensions.size()) {
output << " typedef " << memData.fType << " " << *it << "_t" << memData.fDimensions << ";" << std::endl;
output << " typedef " << memDataType << " " << *it << "_t" << memData.fDimensions << ";"
<< std::endl;
output << " " << *it << "_t& " << *it << " = ";
output << "*(" << *it << "_t *)(target+offset_" << *it;
output << ");" << std::endl;
} else {
output << " " << memData.fType << "& " << *it << " = ";
output << "*(" << memData.fType << "*)(target+offset_" << *it;
output << " " << memDataType << "& " << *it << " = ";
output << "*(" << memDataType << "*)(target+offset_" << *it;
output << ");" << std::endl;
}
}
Expand Down