Skip to content

Commit 8c63c1d

Browse files
committed
recognize custom browse method in dict generation
1 parent de7bd32 commit 8c63c1d

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,17 @@ bool ROOT::TMetaUtils::HasDirectoryAutoAdd(const clang::CXXRecordDecl *cl, const
12761276
return CheckPublicFuncWithProto(cl, name, proto, interp, false /*diags*/);
12771277
}
12781278

1279+
////////////////////////////////////////////////////////////////////////////////
1280+
/// Return true if the class has a method Browse(TBrowser*) const
1281+
1282+
bool ROOT::TMetaUtils::HasBrowse(const clang::CXXRecordDecl *cl, const cling::Interpreter &interp)
1283+
{
1284+
const char *proto = "TBrowser*";
1285+
const char *name = "Browse";
1286+
1287+
return CheckPublicFuncWithProto(cl, name, proto, interp, false /*diags*/, true /* objectIsConst */);
1288+
}
1289+
12791290
////////////////////////////////////////////////////////////////////////////////
12801291
/// Return true if the class has a method Merge(TCollection*,TFileMergeInfo*)
12811292

@@ -1806,6 +1817,9 @@ void ROOT::TMetaUtils::WriteClassInit(std::ostream& finalString,
18061817
if (HasCustomConvStreamerMemberFunction(cl, decl, interp, normCtxt)) {
18071818
finalString << " static void conv_streamer_" << mappedname.c_str() << "(TBuffer &buf, void *obj, const TClass*);" << "\n";
18081819
}
1820+
if (HasBrowse(decl, interp)) {
1821+
finalString << " static void browse_" << mappedname.c_str() << "(const void *obj, TBrowser *b);" << "\n";
1822+
}
18091823
if (HasNewMerge(decl, interp) || HasOldMerge(decl, interp)) {
18101824
finalString << " static Long64_t merge_" << mappedname.c_str() << "(void *obj, TCollection *coll,TFileMergeInfo *info);" << "\n";
18111825
}
@@ -1986,6 +2000,9 @@ void ROOT::TMetaUtils::WriteClassInit(std::ostream& finalString,
19862000
// We have a custom member function streamer or an older (not StreamerInfo based) automatic streamer.
19872001
finalString << " instance.SetConvStreamerFunc(&conv_streamer_" << mappedname.c_str() << ");" << "\n";
19882002
}
2003+
if (HasBrowse(decl, interp)) {
2004+
finalString << " instance.SetBrowse(&browse_" << mappedname.c_str() << ");" << "\n";
2005+
}
19892006
if (HasNewMerge(decl, interp) || HasOldMerge(decl, interp)) {
19902007
finalString << " instance.SetMerge(&merge_" << mappedname.c_str() << ");" << "\n";
19912008
}
@@ -2604,6 +2621,13 @@ void ROOT::TMetaUtils::WriteAuxFunctions(std::ostream& finalString,
26042621
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";
26052622
}
26062623

2624+
if (HasBrowse(decl, interp)) {
2625+
finalString << " // Wrapper around the browse function." << "\n"
2626+
<< " static void browse_" << mappedname.c_str() << "(const void *obj, TBrowser *b) {" << "\n"
2627+
<< " return ((const " << classname.c_str() << "*)obj)->Browse(b);" << "\n"
2628+
<< " }" << "\n";
2629+
}
2630+
26072631
if (HasNewMerge(decl, interp)) {
26082632
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";
26092633
} else if (HasOldMerge(decl, interp)) {

0 commit comments

Comments
 (0)