Skip to content

Commit

Permalink
[NFC] clang-format white space
Browse files Browse the repository at this point in the history
  • Loading branch information
pcanal committed Jan 19, 2025
1 parent 4a60b1a commit 34a8b14
Show file tree
Hide file tree
Showing 18 changed files with 176 additions and 203 deletions.
6 changes: 2 additions & 4 deletions core/clingutils/res/TClingUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,13 +568,11 @@ void WriteClassInit(std::ostream& finalString,
bool& needCollectionProxy);

//______________________________________________________________________________
void WriteStandaloneReadRules(std::ostream &finalString, bool rawrules,
std::vector<std::string> &standaloneTargets,
void WriteStandaloneReadRules(std::ostream &finalString, bool rawrules, std::vector<std::string> &standaloneTargets,
const cling::Interpreter &interp);

//______________________________________________________________________________
void WriteRulesRegistration(std::ostream &finalString,
const std::string &dictName,
void WriteRulesRegistration(std::ostream &finalString, const std::string &dictName,
const std::vector<std::string> &standaloneTargets);

//______________________________________________________________________________
Expand Down
51 changes: 26 additions & 25 deletions core/clingutils/src/TClingUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,7 @@ void ROOT::TMetaUtils::WriteClassInit(std::ostream& finalString,
int i = 0;
finalString << "\n // Schema evolution read functions\n";
std::list<ROOT::SchemaRuleMap_t>::iterator rIt = rulesIt1->second.fRules.begin();
while( rIt != rulesIt1->second.fRules.end() ) {
while (rIt != rulesIt1->second.fRules.end()) {

//--------------------------------------------------------------------
// Check if the rules refer to valid data members
Expand Down Expand Up @@ -1858,7 +1858,7 @@ void ROOT::TMetaUtils::WriteClassInit(std::ostream& finalString,
int i = 0;
finalString << "\n // Schema evolution read raw functions\n";
std::list<ROOT::SchemaRuleMap_t>::iterator rIt = rulesIt2->second.fRules.begin();
while( rIt != rulesIt2->second.fRules.end() ) {
while (rIt != rulesIt2->second.fRules.end()) {

//--------------------------------------------------------------------
// Check if the rules refer to valid data members
Expand Down Expand Up @@ -2052,14 +2052,14 @@ void ROOT::TMetaUtils::WriteClassInit(std::ostream& finalString,

if( rulesIt1 != ROOT::gReadRules.end() ) {
finalString << "\n" << " // the io read rules" << "\n" << " std::vector<::ROOT::Internal::TSchemaHelper> readrules(" << rulesIt1->second.size() << ");" << "\n";
ROOT::WriteSchemaList( rulesIt1->second.fRules, "readrules", finalString );
ROOT::WriteSchemaList(rulesIt1->second.fRules, "readrules", finalString);
finalString << " instance.SetReadRules( readrules );" << "\n";
rulesIt1->second.fGenerated = true;
}

if( rulesIt2 != ROOT::gReadRawRules.end() ) {
finalString << "\n" << " // the io read raw rules" << "\n" << " std::vector<::ROOT::Internal::TSchemaHelper> readrawrules(" << rulesIt2->second.size() << ");" << "\n";
ROOT::WriteSchemaList( rulesIt2->second.fRules, "readrawrules", finalString );
ROOT::WriteSchemaList(rulesIt2->second.fRules, "readrawrules", finalString);
finalString << " instance.SetReadRawRules( readrawrules );" << "\n";
rulesIt2->second.fGenerated = true;
}
Expand Down Expand Up @@ -2193,19 +2193,17 @@ void ROOT::TMetaUtils::WriteClassInit(std::ostream& finalString,

void ROOT::TMetaUtils::WriteStandaloneReadRules(std::ostream &finalString, bool rawrules,
std::vector<std::string> &standaloneTargets,
const cling::Interpreter& interp)
const cling::Interpreter &interp)
{
for (auto &rulesIt1 : rawrules? ROOT::gReadRawRules : ROOT::gReadRules) {
for (auto &rulesIt1 : rawrules ? ROOT::gReadRawRules : ROOT::gReadRules) {
if (!rulesIt1.second.fGenerated) {
const clang::Type *typeptr = nullptr;
const clang::CXXRecordDecl *target
= ROOT::TMetaUtils::ScopeSearch(rulesIt1.first.c_str(), interp,
true /*diag*/, &typeptr);

const clang::CXXRecordDecl *target =
ROOT::TMetaUtils::ScopeSearch(rulesIt1.first.c_str(), interp, true /*diag*/, &typeptr);

if (!target && !rulesIt1.second.fTargetDecl) {
ROOT::TMetaUtils::Warning(nullptr, "%d Rule(s) for target class %s was not used!\n", rulesIt1.second.size(),
rulesIt1.first.c_str());
rulesIt1.first.c_str());
continue;
}

Expand Down Expand Up @@ -2256,8 +2254,7 @@ void ROOT::TMetaUtils::WriteStandaloneReadRules(std::ostream &finalString, bool
}
}

void ROOT::TMetaUtils::WriteRulesRegistration(std::ostream &finalString,
const std::string &dictName,
void ROOT::TMetaUtils::WriteRulesRegistration(std::ostream &finalString, const std::string &dictName,
const std::vector<std::string> &standaloneTargets)
{
std::string functionname("RecordReadRules_");
Expand All @@ -2267,35 +2264,39 @@ void ROOT::TMetaUtils::WriteRulesRegistration(std::ostream &finalString,
finalString << " // Registration Schema evolution read functions\n";
finalString << " int " << functionname << "() {" << "\n";
if (!standaloneTargets.empty())
finalString << "\n" << " ::ROOT::Internal::TSchemaHelper* rule;" << "\n";
for (const auto &target : standaloneTargets)
{
finalString << "\n"
<< " ::ROOT::Internal::TSchemaHelper* rule;" << "\n";
for (const auto &target : standaloneTargets) {
std::string name;
TClassEdit::GetNormalizedName(name, target);

ROOT::SchemaRuleClassMap_t::iterator rulesIt1 = ROOT::gReadRules.find( target.c_str() );
ROOT::SchemaRuleClassMap_t::iterator rulesIt1 = ROOT::gReadRules.find(target.c_str());
finalString << " {\n";
if (rulesIt1 != ROOT::gReadRules.end()) {
finalString << " // the io read rules for " << target << "\n";
finalString << " std::vector<::ROOT::Internal::TSchemaHelper> readrules(" << rulesIt1->second.size() << ");" << "\n";
ROOT::WriteSchemaList( rulesIt1->second.fRules, "readrules", finalString );
finalString << " TClass::RegisterReadRules(TSchemaRule::kReadRule, \"" << name << "\", std::move(readrules));\n";
finalString << " std::vector<::ROOT::Internal::TSchemaHelper> readrules(" << rulesIt1->second.size()
<< ");" << "\n";
ROOT::WriteSchemaList(rulesIt1->second.fRules, "readrules", finalString);
finalString << " TClass::RegisterReadRules(TSchemaRule::kReadRule, \"" << name
<< "\", std::move(readrules));\n";
rulesIt1->second.fGenerated = true;
}
ROOT::SchemaRuleClassMap_t::iterator rulesIt2 = ROOT::gReadRawRules.find( target.c_str() );
ROOT::SchemaRuleClassMap_t::iterator rulesIt2 = ROOT::gReadRawRules.find(target.c_str());
if (rulesIt2 != ROOT::gReadRawRules.end()) {
finalString << "\n // the io read raw rules for " << target << "\n";
finalString << " std::vector<::ROOT::Internal::TSchemaHelper> readrawrules(" << rulesIt2->second.size() << ");" << "\n";
ROOT::WriteSchemaList( rulesIt2->second.fRules, "readrawrules", finalString );
finalString << " TClass::RegisterReadRules(TSchemaRule::kReadRawRule, \"" << name << "\", std::move(readrawrules));\n";
finalString << " std::vector<::ROOT::Internal::TSchemaHelper> readrawrules(" << rulesIt2->second.size()
<< ");" << "\n";
ROOT::WriteSchemaList(rulesIt2->second.fRules, "readrawrules", finalString);
finalString << " TClass::RegisterReadRules(TSchemaRule::kReadRawRule, \"" << name
<< "\", std::move(readrawrules));\n";
rulesIt2->second.fGenerated = true;
}
finalString << " }\n";
}
finalString << " return 0;\n";
finalString << " }\n";
finalString << " static int _R__UNIQUE_DICT_(ReadRules_" << dictName << ") = " << functionname << "();";
finalString<< "R__UseDummy(_R__UNIQUE_DICT_(ReadRules_" << dictName << "));" << "\n";
finalString << "R__UseDummy(_R__UNIQUE_DICT_(ReadRules_" << dictName << "));" << "\n";
finalString << "} // namespace ROOT" << "\n";
}

Expand Down
23 changes: 5 additions & 18 deletions core/dictgen/src/rootcling_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2649,15 +2649,9 @@ int FinalizeStreamerInfoWriting(cling::Interpreter &interp, bool writeEmptyRootP

////////////////////////////////////////////////////////////////////////////////

int GenerateFullDict(std::ostream &dictStream,
std::string dictName,
cling::Interpreter &interp,
RScanner &scan,
const ROOT::TMetaUtils::RConstructorTypes &ctorTypes,
bool isSplit,
bool isGenreflex,
bool isSelXML,
bool writeEmptyRootPCM)
int GenerateFullDict(std::ostream &dictStream, std::string dictName, cling::Interpreter &interp, RScanner &scan,
const ROOT::TMetaUtils::RConstructorTypes &ctorTypes, bool isSplit, bool isGenreflex,
bool isSelXML, bool writeEmptyRootPCM)
{
ROOT::TMetaUtils::TNormalizedCtxt normCtxt(interp.getLookupHelper());

Expand Down Expand Up @@ -4967,15 +4961,8 @@ int RootClingMain(int argc,
rootclingRetCode += FinalizeStreamerInfoWriting(interp);
}
} else {
rootclingRetCode += GenerateFullDict(*splitDictStream,
modGen.GetDictionaryName(),
interp,
scan,
constructorTypes,
gOptSplit,
isGenreflex,
isSelXML,
gOptWriteEmptyRootPCM);
rootclingRetCode += GenerateFullDict(*splitDictStream, modGen.GetDictionaryName(), interp, scan, constructorTypes,
gOptSplit, isGenreflex, isSelXML, gOptWriteEmptyRootPCM);
}

if (rootclingRetCode != 0) {
Expand Down
2 changes: 1 addition & 1 deletion core/foundation/res/RConversionRuleParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "DllImport.h"

namespace clang {
class CXXRecordDecl;
class CXXRecordDecl;
}

namespace ROOT
Expand Down
8 changes: 4 additions & 4 deletions core/foundation/src/RConversionRuleParser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ namespace ROOT
//////////////////////////////////////////////////////////////////////////

for( it = gReadRules.begin(); it != gReadRules.end(); ++it ) {
for( rule = it->second.fRules.begin(); rule != it->second.fRules.end(); ++rule ) {
for (rule = it->second.fRules.begin(); rule != it->second.fRules.end(); ++rule) {
attr = rule->find( "include" );
if( attr == rule->end() ) continue;
TSchemaRuleProcessor::SplitList( attr->second, tmp );
Expand All @@ -877,7 +877,7 @@ namespace ROOT
//////////////////////////////////////////////////////////////////////////

for( it = gReadRawRules.begin(); it != gReadRawRules.end(); ++it ) {
for( rule = it->second.fRules.begin(); rule != it->second.fRules.end(); ++rule ) {
for (rule = it->second.fRules.begin(); rule != it->second.fRules.end(); ++rule) {
attr = rule->find( "include" );
if( attr == rule->end() ) continue;
TSchemaRuleProcessor::SplitList( attr->second, tmp );
Expand Down Expand Up @@ -926,7 +926,7 @@ namespace ROOT
gReadRules[normalizedTargetName].fRules = lst;
}
else
it->second.fRules.push_back( rule );
it->second.fRules.push_back(rule);
}

/////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -961,7 +961,7 @@ namespace ROOT
gReadRawRules[normalizedTargetName].fRules = lst;
}
else
it->second.fRules.push_back( rule );
it->second.fRules.push_back(rule);
}


Expand Down
3 changes: 2 additions & 1 deletion core/meta/inc/TClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,8 @@ friend class TStreamerInfo;
Long_t Property() const override;
Int_t ReadBuffer(TBuffer &b, void *pointer, Int_t version, UInt_t start, UInt_t count);
Int_t ReadBuffer(TBuffer &b, void *pointer);
static void RegisterReadRules(ROOT::TSchemaRule::RuleType_t, const char *classname, std::vector<::ROOT::Internal::TSchemaHelper> &&rules);
static void RegisterReadRules(ROOT::TSchemaRule::RuleType_t, const char *classname,
std::vector<::ROOT::Internal::TSchemaHelper> &&rules);
void RegisterStreamerInfo(TVirtualStreamerInfo *info);
void RemoveStreamerInfo(Int_t slot);
void ReplaceWith(TClass *newcl) const;
Expand Down
13 changes: 5 additions & 8 deletions core/meta/inc/TSchemaRule.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class TVirtualObject;
class TObjArray;
namespace ROOT {
namespace Internal {
struct TSchemaHelper;
}
struct TSchemaHelper;
}
} // namespace ROOT

namespace ROOT {

Expand Down Expand Up @@ -47,17 +47,14 @@ namespace ROOT {

Int_t GetPointerLevel() const { return fPointerLevel; }

const char* GetUnderlyingTypeName() const
{
return fTitle;
}
const char *GetUnderlyingTypeName() const { return fTitle; }

// The source can be declared with:
// "%s %s%s;", GetTypeForDeclaration().Data(), GetName(), GetDimensions);
TString GetTypeForDeclaration()
{
TString type = fTitle;
for(Int_t s = 0; s < fPointerLevel; ++s)
for (Int_t s = 0; s < fPointerLevel; ++s)
type.Append('*');
return type;
}
Expand All @@ -81,7 +78,7 @@ namespace ROOT {
typedef void (*ReadRawFuncPtr_t)( char*, TBuffer&);

TSchemaRule();
TSchemaRule(RuleType_t type, const char *targetClass, const ROOT::Internal::TSchemaHelper& helper);
TSchemaRule(RuleType_t type, const char *targetClass, const ROOT::Internal::TSchemaHelper &helper);
virtual ~TSchemaRule();

TSchemaRule( const TSchemaRule& rhs );
Expand Down
40 changes: 22 additions & 18 deletions core/meta/src/TClass.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1719,17 +1719,19 @@ void TClass::Init(const char *name, Version_t cversion,
// std::pairs have implicit conversions
GetSchemaRules(kTRUE);
}
for(auto ruletype : {ROOT::TSchemaRule::kReadRule, ROOT::TSchemaRule::kReadRawRule}) {
for (auto ruletype : {ROOT::TSchemaRule::kReadRule, ROOT::TSchemaRule::kReadRawRule}) {
auto &registry = GetReadRulesRegistry(ruletype);
auto rulesiter = registry.find(GetName());
if (rulesiter != registry.end()) {
auto rset = GetSchemaRules( kTRUE );
for(const auto &helper : rulesiter->second) {
auto rset = GetSchemaRules(kTRUE);
for (const auto &helper : rulesiter->second) {
auto rule = new ROOT::TSchemaRule(ruletype, GetName(), helper);
TString errmsg;
if( !rset->AddRule( rule, ROOT::Detail::TSchemaRuleSet::kCheckAll, &errmsg ) ) {
Warning( "Init", "The rule for class: \"%s\": version, \"%s\" and data members: \"%s\" has been skipped because %s.",
GetName(), helper.fVersion.c_str(), helper.fTarget.c_str(), errmsg.Data() );
if (!rset->AddRule(rule, ROOT::Detail::TSchemaRuleSet::kCheckAll, &errmsg)) {
Warning(
"Init",
"The rule for class: \"%s\": version, \"%s\" and data members: \"%s\" has been skipped because %s.",
GetName(), helper.fVersion.c_str(), helper.fTarget.c_str(), errmsg.Data());
delete rule;
}
}
Expand Down Expand Up @@ -3624,16 +3626,16 @@ TRealData* TClass::GetRealData(const char* name) const
// Try ignoring the array dimensions.
std::string::size_type firstBracket = givenName.find_first_of("[");
std::string nameNoDim(givenName.substr(0, firstBracket));
TObjLink* lnk = fRealData->FirstLink();
TObjLink *lnk = fRealData->FirstLink();
while (lnk) {
TObject* obj = lnk->GetObject();
TObject *obj = lnk->GetObject();
std::string objName(obj->GetName());
std::string::size_type pos = objName.find_first_of("[");
if (pos != std::string::npos) {
objName.erase(pos);
}
if (objName == nameNoDim) {
return static_cast<TRealData*>(obj);
return static_cast<TRealData *>(obj);
}
lnk = lnk->Next();
}
Expand Down Expand Up @@ -6918,10 +6920,10 @@ void TClass::StreamerTObject(const TClass* pThis, void *object, TBuffer &b, cons
////////////////////////////////////////////////////////////////////////////////
/// Case of TObjects when fIsOffsetStreamerSet is known to have been set.

void TClass::StreamerTObjectInitialized(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class)
void TClass::StreamerTObjectInitialized(const TClass *pThis, void *object, TBuffer &b, const TClass *onfile_class)
{
if (R__likely(onfile_class == nullptr || pThis == onfile_class)) {
TObject *tobj = (TObject*)((Longptr_t)object + pThis->fOffsetStreamer);
TObject *tobj = (TObject *)((Longptr_t)object + pThis->fOffsetStreamer);
tobj->Streamer(b);
} else {
// This is the case where we are reading an object of a derived class
Expand Down Expand Up @@ -7409,20 +7411,22 @@ TVirtualStreamerInfo *TClass::FindConversionStreamerInfo( const TClass* cl, UInt
/// Rules will end up here if they are created in a dictionary file that does not
/// contain the dictionary for the target class.

void TClass::RegisterReadRules(ROOT::TSchemaRule::RuleType_t type,
const char *classname, std::vector<::ROOT::Internal::TSchemaHelper> &&rules)
void TClass::RegisterReadRules(ROOT::TSchemaRule::RuleType_t type, const char *classname,
std::vector<::ROOT::Internal::TSchemaHelper> &&rules)
{
R__WRITE_LOCKGUARD(ROOT::gCoreMutex);

auto cl = TClass::GetClass(classname, false, false);
if (cl) {
auto rset = cl->GetSchemaRules( kTRUE );
for(const auto &it : rules) {
auto rset = cl->GetSchemaRules(kTRUE);
for (const auto &it : rules) {
auto rule = new ROOT::TSchemaRule(type, cl->GetName(), it);
TString errmsg;
if( !rset->AddRule( rule, ROOT::Detail::TSchemaRuleSet::kCheckAll, &errmsg ) ) {
::Warning( "TGenericClassInfo", "The rule for class: \"%s\": version, \"%s\" and data members: \"%s\" has been skipped because %s.",
cl->GetName(), it.fVersion.c_str(), it.fTarget.c_str(), errmsg.Data() );
if (!rset->AddRule(rule, ROOT::Detail::TSchemaRuleSet::kCheckAll, &errmsg)) {
::Warning(
"TGenericClassInfo",
"The rule for class: \"%s\": version, \"%s\" and data members: \"%s\" has been skipped because %s.",
cl->GetName(), it.fVersion.c_str(), it.fTarget.c_str(), errmsg.Data());
delete rule;
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/meta/src/TGenericClassInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ namespace Internal {
rule = new TSchemaRule(ProcessReadRules ? TSchemaRule::kReadRule : TSchemaRule::kReadRawRule,
fClass->GetName(), *it);

if( !rset->AddRule( rule, TSchemaRuleSet::kCheckAll, &errmsg ) ) {
if (!rset->AddRule(rule, TSchemaRuleSet::kCheckAll, &errmsg)) {
::Warning( "TGenericClassInfo", "The rule for class: \"%s\": version, \"%s\" and data members: \"%s\" has been skipped because %s.",
GetClassName(), it->fVersion.c_str(), it->fTarget.c_str(), errmsg.Data() );
delete rule;
Expand Down
Loading

0 comments on commit 34a8b14

Please sign in to comment.