Skip to content

Commit c8e5231

Browse files
committed
recognize custom browse method in dict generation
1 parent 068b0ff commit c8e5231

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

core/clingutils/res/TClingUtils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ bool HasDirectoryAutoAdd(clang::CXXRecordDecl const*, const cling::Interpreter&)
423423
//______________________________________________________________________________
424424
bool HasIOConstructor(clang::CXXRecordDecl const*, std::string&, const RConstructorTypes&, const cling::Interpreter&);
425425

426+
//______________________________________________________________________________
427+
bool HasBrowse(clang::CXXRecordDecl const*, const cling::Interpreter&);
428+
426429
//______________________________________________________________________________
427430
bool HasNewMerge(clang::CXXRecordDecl const*, const cling::Interpreter&);
428431

core/clingutils/src/TClingUtils.cxx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,17 @@ bool ROOT::TMetaUtils::HasDirectoryAutoAdd(const clang::CXXRecordDecl *cl, const
12811281
return CheckPublicFuncWithProto(cl,name,proto,interp, false /*diags*/);
12821282
}
12831283

1284+
////////////////////////////////////////////////////////////////////////////////
1285+
/// Return true if the class has a method Browse(TBrowser*) const
1286+
1287+
bool ROOT::TMetaUtils::HasBrowse(const clang::CXXRecordDecl *cl, const cling::Interpreter &interp)
1288+
{
1289+
const char *proto = "TBrowser*";
1290+
const char *name = "Browse";
1291+
1292+
return CheckPublicFuncWithProto(cl,name,proto,interp, false /*diags*/, true /* objectIsConst */);
1293+
}
1294+
12841295
////////////////////////////////////////////////////////////////////////////////
12851296
/// Return true if the class has a method Merge(TCollection*,TFileMergeInfo*)
12861297

@@ -1811,6 +1822,9 @@ void ROOT::TMetaUtils::WriteClassInit(std::ostream& finalString,
18111822
if (HasCustomConvStreamerMemberFunction(cl, decl, interp, normCtxt)) {
18121823
finalString << " static void conv_streamer_" << mappedname.c_str() << "(TBuffer &buf, void *obj, const TClass*);" << "\n";
18131824
}
1825+
if (HasBrowse(decl, interp)) {
1826+
finalString << " static void browse_" << mappedname.c_str() << "(const void *obj, TBrowser *b);" << "\n";
1827+
}
18141828
if (HasNewMerge(decl, interp) || HasOldMerge(decl, interp)) {
18151829
finalString << " static Long64_t merge_" << mappedname.c_str() << "(void *obj, TCollection *coll,TFileMergeInfo *info);" << "\n";
18161830
}
@@ -1991,6 +2005,9 @@ void ROOT::TMetaUtils::WriteClassInit(std::ostream& finalString,
19912005
// We have a custom member function streamer or an older (not StreamerInfo based) automatic streamer.
19922006
finalString << " instance.SetConvStreamerFunc(&conv_streamer_" << mappedname.c_str() << ");" << "\n";
19932007
}
2008+
if (HasBrowse(decl, interp)) {
2009+
finalString << " instance.SetBrowse(&browse_" << mappedname.c_str() << ");" << "\n";
2010+
}
19942011
if (HasNewMerge(decl, interp) || HasOldMerge(decl, interp)) {
19952012
finalString << " instance.SetMerge(&merge_" << mappedname.c_str() << ");" << "\n";
19962013
}
@@ -2609,6 +2626,12 @@ void ROOT::TMetaUtils::WriteAuxFunctions(std::ostream& finalString,
26092626
finalString << " // Wrapper around a custom streamer member function." << "\n" << " static void conv_streamer_" << mappedname.c_str() << "(TBuffer &buf, void *obj, const TClass *onfile_class) {" << "\n" << " ((" << classname.c_str() << "*)obj)->" << classname.c_str() << "::Streamer(buf,onfile_class);" << "\n" << " }" << "\n";
26102627
}
26112628

2629+
if (HasBrowse(decl, interp)) {
2630+
finalString << " // Wrapper around the browse function." << "\n"
2631+
<< " static void browse_" << mappedname.c_str() << "(const void *obj, TBrowser *b) {" << "\n"
2632+
<< " return ((const " << classname.c_str() << "*)obj)->Browse(b);" << "\n" << " }" << "\n";
2633+
}
2634+
26122635
if (HasNewMerge(decl, interp)) {
26132636
finalString << " // Wrapper around the merge function." << "\n" << " static Long64_t merge_" << mappedname.c_str() << "(void *obj,TCollection *coll,TFileMergeInfo *info) {" << "\n" << " return ((" << classname.c_str() << "*)obj)->Merge(coll,info);" << "\n" << " }" << "\n";
26142637
} else if (HasOldMerge(decl, interp)) {

0 commit comments

Comments
 (0)