Inspecting macro arguments

Hi,

I would like to write a piece of code that inspects the arguments a macro expects. Something such as:

const char* macrofile = "usermacro.C";
const char* macro = "usermacro";

gROOT->LoadMacro(macrofile);
std::vector<std::string> argument, type;
inspectmacro(macro, argument, type);

and the vectors “argument” and “type” would then be filled with the arguments expected by “usermacro” in this example.

Is there a simple way to write that with ROOT? (calling CINT?)

Thanks

Pierre-François

Hi,

you can use TFunction* f = (TFunction*) gROOT->GetListOfGlobalFunctions()->FindObject(macro); TList* args = f->GetListOfMethodArgs(); TIter iArg(args); TMethodArg ma = 0; while ((ma = (TMethodArg*) iArg())) ma->ExtractAnyInfoYouWant() See the doc for TMethodArg at root.cern.ch/root/html/TMethodArg on how to determine types etc.

Cheers, Axel.

Thanks Axel,

It’s working! This is very useful!

Pierre-François