LoadMacro and overloaded functions

Dear Rooters,

when using gROOT.LoadMacro from within a python script to use i.e. functions written in c++, I run into trouble as soon as the macro contains overloaded functions.
Here is a short example:
RootTestMacro.h:

#include <iostream> void PrintAString(std::string myString){ std::cout<<myString<<endl; } void PrintAString(std::string myString1, std::string myString2){ std::cout<<myString1<<" "<<myString2<<endl; }
which is called from
PythonTest.py:

import ROOT ROOT.gROOT.LoadMacro('RootTestMacro.h+') ROOT.PrintAString('Hello World') ROOT.PrintAString('Hello World','once again')
which results as output in:

python PythonTest.py
Hello World
Traceback (most recent call last):
File “PythonTest.py”, line 6, in
ROOT.PrintAString(‘Hello World’,‘once again’)
TypeError: void ::PrintAString(string myString) =>
takes at most 1 arguments (2 given)

With this script only the first appearance of the overloaded function in the macro is accessible. Is there a way to access the overloaded implementations as well?

Regards,
Stefan

Stefan,

ouch, looks like a bug. Workaround is to put the two functions in a namespace.

Cheers,
Wim

Dear Wim,

mmm - as far as I know python itself does not support function overloading. However - functionality provided by ROOT such as class definitions can be accessed properly with python even if they are overloaded. Is there an extra wrapper layer that provides that this is possible? If that’s the case, should the needed code be generated automatically when the LoadMacro() function is used?

Stefan

Stefan,

yes an extra layer, but no, no generation. This code used to work, but something changed in CINT. I haven’t been able yet to track it down as I was working on other things, although I think it is a simple matter of synchronization.

Cheers,
Wim

Hi,

so yes, syncing problem (I don’t know what has changed in CINT, though). Fixed in trunk.

Cheers,
Wim