Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions core/clingutils/res/TClingUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class AnnotatedRecordDecl {
bool fRequestOnlyTClass;
int fRequestedVersionNumber;
int fRequestedRNTupleSerializationMode;
std::string fRequestedRNTupleSoARecord;
Comment thread
jblomer marked this conversation as resolved.
// clang-format on

public:
Expand All @@ -228,6 +229,7 @@ class AnnotatedRecordDecl {
bool rRequestOnlyTClass,
int rRequestedVersionNumber,
int rRequestedRNTupleSerializationMode,
const std::string &rRequestedRNTupleSoARecord,
const cling::Interpreter &interpret,
const TNormalizedCtxt &normCtxt);

Expand All @@ -240,6 +242,7 @@ class AnnotatedRecordDecl {
bool rRequestOnlyTClass,
int rRequestedVersionNumber,
int rRequestedRNTupleSerializationMode,
const std::string &rRequestedRNTupleSoARecord,
const cling::Interpreter &interpret,
const TNormalizedCtxt &normCtxt);

Expand All @@ -253,6 +256,7 @@ class AnnotatedRecordDecl {
bool rRequestOnlyTClass,
int rRequestedVersionNumber,
int rRequestedRNTupleSerializationMode,
const std::string &rRequestedRNTupleSoARecord,
const cling::Interpreter &interpret,
const TNormalizedCtxt &normCtxt);

Expand All @@ -267,6 +271,7 @@ class AnnotatedRecordDecl {
bool rRequestOnlyTClass,
int rRequestedVersionNumber,
int rRequestedRNTupleSerializationMode,
const std::string &rRequestedRNTupleSoARecord,
const cling::Interpreter &interpret,
const TNormalizedCtxt &normCtxt);
// clang-format on
Expand All @@ -292,6 +297,7 @@ class AnnotatedRecordDecl {
bool RequestOnlyTClass() const { return fRequestOnlyTClass; }
int RequestedVersionNumber() const { return fRequestedVersionNumber; }
int RequestedRNTupleSerializationMode() const { return fRequestedRNTupleSerializationMode; }
const std::string &RequestedRNTupleSoARecord() const { return fRequestedRNTupleSoARecord; }
// clang-format on
int RootFlag() const {
// Return the request (streamerInfo, has_version, etc.) combined in a single
Expand Down
2 changes: 2 additions & 0 deletions core/clingutils/src/RStl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ void ROOT::Internal::RStl::GenerateTClassFor(const clang::QualType &type, const
false,
-1,
0,
"",
interp,
normCtxt));
// clang-format on
Expand Down Expand Up @@ -163,6 +164,7 @@ void ROOT::Internal::RStl::GenerateTClassFor(const char *requestedName, const cl
false,
-1,
0,
"",
interp,
normCtxt));
// clang-format on
Expand Down
24 changes: 20 additions & 4 deletions core/clingutils/src/TClingUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ AnnotatedRecordDecl::AnnotatedRecordDecl(long index,
bool rRequestOnlyTClass,
int rRequestedVersionNumber,
int rRequestedRNTupleSerializationMode,
const std::string &rRequestedRNTupleSoARecord,
const cling::Interpreter &interpreter,
const TNormalizedCtxt &normCtxt)
: fRuleIndex(index),
Expand All @@ -395,7 +396,8 @@ AnnotatedRecordDecl::AnnotatedRecordDecl(long index,
fRequestNoInputOperator(rRequestNoInputOperator),
fRequestOnlyTClass(rRequestOnlyTClass),
fRequestedVersionNumber(rRequestedVersionNumber),
fRequestedRNTupleSerializationMode(rRequestedRNTupleSerializationMode)
fRequestedRNTupleSerializationMode(rRequestedRNTupleSerializationMode),
fRequestedRNTupleSoARecord(rRequestedRNTupleSoARecord)
// clang-format on
{
TMetaUtils::GetNormalizedName(fNormalizedName, decl->getASTContext().getTypeDeclType(decl), interpreter,normCtxt);
Expand All @@ -417,6 +419,7 @@ AnnotatedRecordDecl::AnnotatedRecordDecl(long index,
bool rRequestOnlyTClass,
int rRequestVersionNumber,
int rRequestedRNTupleSerializationMode,
const std::string &rRequestedRNTupleSoARecord,
const cling::Interpreter &interpreter,
const TNormalizedCtxt &normCtxt)
: fRuleIndex(index),
Expand All @@ -427,7 +430,8 @@ AnnotatedRecordDecl::AnnotatedRecordDecl(long index,
fRequestNoInputOperator(rRequestNoInputOperator),
fRequestOnlyTClass(rRequestOnlyTClass),
fRequestedVersionNumber(rRequestVersionNumber),
fRequestedRNTupleSerializationMode(rRequestedRNTupleSerializationMode)
fRequestedRNTupleSerializationMode(rRequestedRNTupleSerializationMode),
fRequestedRNTupleSoARecord(rRequestedRNTupleSoARecord)
// clang-format on
{
// For comparison purposes.
Expand Down Expand Up @@ -456,6 +460,7 @@ AnnotatedRecordDecl::AnnotatedRecordDecl(long index,
bool rRequestOnlyTClass,
int rRequestVersionNumber,
int rRequestedRNTupleSerializationMode,
const std::string &rRequestedRNTupleSoARecord,
const cling::Interpreter &interpreter,
const TNormalizedCtxt &normCtxt)
: fRuleIndex(index),
Expand All @@ -466,7 +471,8 @@ AnnotatedRecordDecl::AnnotatedRecordDecl(long index,
fRequestNoInputOperator(rRequestNoInputOperator),
fRequestOnlyTClass(rRequestOnlyTClass),
fRequestedVersionNumber(rRequestVersionNumber),
fRequestedRNTupleSerializationMode(rRequestedRNTupleSerializationMode)
fRequestedRNTupleSerializationMode(rRequestedRNTupleSerializationMode),
fRequestedRNTupleSoARecord(rRequestedRNTupleSoARecord)
// clang-format on
{
// For comparison purposes.
Expand All @@ -490,6 +496,7 @@ AnnotatedRecordDecl::AnnotatedRecordDecl(long index,
bool rRequestOnlyTClass,
int rRequestVersionNumber,
int rRequestedRNTupleSerializationMode,
const std::string &rRequestedRNTupleSoARecord,
const cling::Interpreter &interpreter,
const TNormalizedCtxt &normCtxt)
: fRuleIndex(index),
Expand All @@ -500,7 +507,8 @@ AnnotatedRecordDecl::AnnotatedRecordDecl(long index,
fRequestNoInputOperator(rRequestNoInputOperator),
fRequestOnlyTClass(rRequestOnlyTClass),
fRequestedVersionNumber(rRequestVersionNumber),
fRequestedRNTupleSerializationMode(rRequestedRNTupleSerializationMode)
fRequestedRNTupleSerializationMode(rRequestedRNTupleSerializationMode),
fRequestedRNTupleSoARecord(rRequestedRNTupleSoARecord)
// clang-format on
{
// const clang::ClassTemplateSpecializationDecl *tmplt_specialization = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl> (decl);
Expand Down Expand Up @@ -2063,6 +2071,14 @@ void ROOT::TMetaUtils::WriteClassInit(std::ostream& finalString,

}

//---------------------------------------------------------------------------
// Register underlying SoA record for RNTuple SoA layouts
/////////////////////////////////////////////////////////////////////////////

if (!cl.RequestedRNTupleSoARecord().empty()) {
finalString << " instance.SetRNTupleSoARecord(\"" << cl.RequestedRNTupleSoARecord() << "\");" << "\n";
}

//---------------------------------------------------------------------------
// Pass the schema evolution rules to TGenericClassInfo
/////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 4 additions & 0 deletions core/dictgen/res/ClassSelectionRule.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class ClassSelectionRule final : public BaseSelectionRule
int fRequestedVersionNumber; // Explicit request for a specific version number (default to no request with -1).
// Explicit request for unsplit (-1) or split (=1), defaults to unset (=0)
int fRequestedRNTupleSerializationMode = 0;
// If not empty, marks the class as an RNTuple SoA layout for the underlying given record class
std::string fRequestedRNTupleSoARecord;
// clang-format on

public:
Expand Down Expand Up @@ -83,6 +85,7 @@ class ClassSelectionRule final : public BaseSelectionRule
void SetRequestPrivate(bool val);
void SetRequestedVersionNumber(int version);
void SetRequestedRNTupleSerializationMode(int serializationMode);
void SetRequestedRNTupleSoARecord(const std::string &recordName);

bool RequestOnlyTClass() const; // True if the user want the TClass intiliazer but *not* the interpreter meta data
bool RequestNoStreamer() const; // Request no Streamer function in the dictionary
Expand All @@ -92,6 +95,7 @@ class ClassSelectionRule final : public BaseSelectionRule
bool RequestPrivate() const;
int RequestedVersionNumber() const;
int RequestedRNTupleSerializationMode() const;
const std::string &RequestedRNTupleSoARecord() const;
};

#endif
Expand Down
10 changes: 10 additions & 0 deletions core/dictgen/src/ClassSelectionRule.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ void ClassSelectionRule::SetRequestedRNTupleSerializationMode(int serializationM
fRequestedRNTupleSerializationMode = serializationMode;
}

void ClassSelectionRule::SetRequestedRNTupleSoARecord(const std::string &recordName)
{
fRequestedRNTupleSoARecord = recordName;
}

bool ClassSelectionRule::RequestOnlyTClass() const
{
return fRequestOnlyTClass;
Expand All @@ -186,3 +191,8 @@ int ClassSelectionRule::RequestedRNTupleSerializationMode() const
{
return fRequestedRNTupleSerializationMode;
}

const std::string &ClassSelectionRule::RequestedRNTupleSoARecord() const
{
return fRequestedRNTupleSoARecord;
}
31 changes: 30 additions & 1 deletion core/dictgen/src/LinkdefReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <iostream>
#include <memory>
#include <string>
#include "LinkdefReader.h"
#include "SelectionRules.h"
#include "RConversionRuleParser.h"
Expand Down Expand Up @@ -57,6 +58,7 @@ struct LinkdefReader::Options {
};
int fVersionNumber;
int fRNTupleSerializationMode; // 0: unset, -1: enforce streamed, 1: enforce native
std::string fRNTupleSoARecord;
};

/*
Expand Down Expand Up @@ -409,6 +411,7 @@ bool LinkdefReader::AddRule(const std::string& ruletype,
if (options->fVersionNumber >= 0) csr.SetRequestedVersionNumber(options->fVersionNumber);
if (options->fRNTupleSerializationMode != 0)
csr.SetRequestedRNTupleSerializationMode(options->fRNTupleSerializationMode);
csr.SetRequestedRNTupleSoARecord(options->fRNTupleSoARecord);
}
if (csr.RequestStreamerInfo() && csr.RequestNoStreamer()) {
std::cerr << "Warning: " << localIdentifier << " option + mutual exclusive with -, + prevails\n";
Expand Down Expand Up @@ -663,7 +666,8 @@ class LinkdefReaderPragmaHandler : public clang::PragmaHandler {
* nomap: (ignored by roocling; prevents entry in ROOT's rootmap file)
* stub: (ignored by rootcling was a directly for CINT code generation)
* version(x): sets the version number of the class to x
* rntuple[un]split: enforce split/unsplit encoding in RNTuple
* rntupleStreamerMode(true|false): enforce/prevent use of the RNTuple streamer field
* rntupleSoARecord(x): marks the class as an RNTuple SoA layout for the underlying record class x
*/

// We assume that the first toke in option or options
Expand Down Expand Up @@ -718,11 +722,36 @@ class LinkdefReaderPragmaHandler : public clang::PragmaHandler {
"(either rntupleStreamerMode(true) or rntupleStreamerMode(false))",
boolval, PP);
} else {
if (!options.fRNTupleSoARecord.empty()) {
Error("Error: rntupleStreamerMode(true) and rntupleSoARecord are mutually exclusive", boolval, PP);
}
options.fRNTupleSerializationMode = -1;
}
} else {
Error("Error: Malformed rntupleStreamerMode option (either 'true' or 'false').", boolval, PP);
}
} else if (tok.getIdentifierInfo()->getName() == "rntupleSoARecord") {
clang::Token start = tok;
PP.Lex(tok);
if (tok.isNot(clang::tok::l_paren)) {
Error("Error: missing left parenthesis after rntupleSoARecord.", start, PP);
return false;
}
PP.Lex(tok);
clang::Token strval = tok;
if (tok.isNot(clang::tok::eod))
PP.Lex(tok);
if (tok.isNot(clang::tok::r_paren)) {
Error("Error: missing right parenthesis after rntupleSoARecord.", start, PP);
return false;
}
if (!strval.getIdentifierInfo() || strval.getIdentifierInfo()->getName().empty()) {
Error("Error: Malformed rntupleSoARecord option.", strval, PP);
}
if (options.fRNTupleSerializationMode == -1) {
Error("Error: rntupleStreamerMode(true) and rntupleSoARecord are mutually exclusive", strval, PP);
}
options.fRNTupleSoARecord = strval.getIdentifierInfo()->getName();
} else if (tok.getIdentifierInfo()->getName() == "stub") {
// This was solely for CINT dictionary, ignore for now.
// options.fUseStubs = 1;
Expand Down
2 changes: 2 additions & 0 deletions core/dictgen/src/Scanner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ int RScanner::AddAnnotatedRecordDecl(const ClassSelectionRule* selected,
selected->RequestOnlyTClass(),
selected->RequestedVersionNumber(),
selected->RequestedRNTupleSerializationMode(),
selected->RequestedRNTupleSoARecord(),
fInterpreter,
fNormCtxt);
} else {
Expand All @@ -574,6 +575,7 @@ int RScanner::AddAnnotatedRecordDecl(const ClassSelectionRule* selected,
selected->RequestOnlyTClass(),
selected->RequestedVersionNumber(),
selected->RequestedRNTupleSerializationMode(),
selected->RequestedRNTupleSoARecord(),
fInterpreter,
fNormCtxt);
}
Expand Down
19 changes: 19 additions & 0 deletions core/dictgen/src/XMLReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,13 @@ bool XMLReader::Parse(const std::string &fileName, SelectionRules& out)
"not both\n",
lineNumCharp, iAttrValue.c_str());
} else {
if (!csr->RequestedRNTupleSoARecord().empty()) {
ROOT::TMetaUtils::Error(
nullptr,
"XML at line %s: class attributes rntupleStreamerMode and rntupleSoARecord "
"are mutually exclusive\n",
lineNumCharp, iAttrValue.c_str());
}
csr->SetRequestedRNTupleSerializationMode(-1);
}
} else {
Expand All @@ -972,6 +979,18 @@ bool XMLReader::Parse(const std::string &fileName, SelectionRules& out)
}
}

// request RNTuple SoA record type name
if (tagKind == kClass && csr && "rntupleSoARecord" == iAttrName) {
if (csr->RequestedRNTupleSerializationMode() == -1) {
ROOT::TMetaUtils::Error(
nullptr,
"XML at line %s: class attributes rntupleStreamerMode and rntupleSoARecord "
"are mutually exclusive\n",
lineNumCharp, iAttrValue.c_str());
}
csr->SetRequestedRNTupleSoARecord(iAttrValue);
}

// request no input operator
if (tagKind == kClass && csr && "noInputOperator" == iAttrName){
if (iAttrValue == "true") {
Expand Down
8 changes: 5 additions & 3 deletions core/dictgen/src/rootcling_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3930,7 +3930,7 @@ int RootClingMain(int argc,

const char *etcDir = gDriverConfig->fTROOT__GetEtcDir();
std::string llvmResourceDir = etcDir ? std::string(etcDir) + "/cling" : "";

if (gBareClingSubcommand) {
std::vector<const char *> clingArgsC;
clingArgsC.push_back(executableFileName);
Expand Down Expand Up @@ -4106,7 +4106,7 @@ int RootClingMain(int argc,
// cling-only arguments
if (etcDir)
clingArgs.push_back(std::string("-I") + llvm::sys::path::convert_to_slash(etcDir));

// We do not want __ROOTCLING__ in the pch!
if (!gOptGeneratePCH) {
clingArgs.push_back("-D__ROOTCLING__");
Expand Down Expand Up @@ -4616,7 +4616,7 @@ int RootClingMain(int argc,
// interpPragmaSource and we still need to process it.

LinkdefReader ldefr(interp, constructorTypes);

if (!ldefr.Parse(selectionRules, interpPragmaSource, clingArgs,
llvmResourceDir.c_str())) {
ROOT::TMetaUtils::Error(nullptr, "Parsing #pragma failed %s\n", linkdefFilename.c_str());
Expand Down Expand Up @@ -5532,6 +5532,7 @@ int GenReflexMain(int argc, char **argv)
" Default value is 'false'\n"
" - rntupleStreamerMode [true/false]: enforce streamed or native writing for RNTuple.\n"
" If unset, RNTuple stores classes in split mode or fails if the class cannot be split.\n"
" - rntupleSoARecord [class name]: marks the class as an RNTuple SoA layout for the underlying record\n"
" - noInputOperator [true/false]: turns off input operator generation if set\n"
" to 'true'. Default value is 'false'\n"
" Example XML:\n"
Expand All @@ -5542,6 +5543,7 @@ int GenReflexMain(int argc, char **argv)
" [id=\"xxxx\"] [noStreamer=\"true/false\"]\n"
" [noInputOperator=\"true/false\"]\n"
" [rntupleStreamerMode=\"true/false\"] />\n"
" [rntupleSoARecord=\"class_name\"] />\n"
" <class name=\"classname\" >\n"
" <field name=\"m_transient\" transient=\"true\"/>\n"
" <field name=\"m_anothertransient\" persistent=\"false\"/>\n"
Expand Down
2 changes: 2 additions & 0 deletions core/meta/inc/TGenericClassInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace ROOT {
TVirtualCollectionProxy *fCollectionProxy;
Int_t fSizeof;
Int_t fPragmaBits;
std::string fRNTupleSoARecord;
Detail::TCollectionProxyInfo *fCollectionProxyInfo;
Detail::TCollectionProxyInfo *fCollectionStreamerInfo;
std::vector<ROOT::Internal::TSchemaHelper> fReadRules;
Expand Down Expand Up @@ -142,6 +143,7 @@ namespace ROOT {
void SetStreamerFunc(ClassStreamerFunc_t);
void SetConvStreamerFunc(ClassConvStreamerFunc_t);
Short_t SetVersion(Short_t version);
void SetRNTupleSoARecord(const std::string &recordName);

// protected:
private:
Expand Down
Loading
Loading