RE: [ROOT] TClass::GetMethod

From: Philippe Canal (pcanal@fnal.gov)
Date: Wed Jan 16 2002 - 21:55:05 MET


Hi Matthew,

I fixed this problem and the CVS repository will be updated shortly.
Thanks for your report.

Cheers,
Philippe.

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Matthew Palmer
Sent: Tuesday, January 15, 2002 8:13 AM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] TClass::GetMethod


There appears to be a problem with TClass::GetMethod when used with
interpreted classes.
It does not return the methods correctly.  (says they can't be found).  This
example code shows the problem:

include <iostream.h>

class Test {
public:
 Test() {}
 double RunMe();
};

double RunMe() {
 return 5.0;
}

void MethodTest() {
TClass* c = gROOT->GetClass("Test");
 void* im = gInterpreter->GetInterfaceMethod(c, "RunMe", "");
 TList* l = c->GetListOfMethods();
 TMethod* m2 = (TMethod*)l->FindObject("RunMe");
 void* im2 = m2->InterfaceMethod();

 cout << m2 << "\t" << m2.GetName() << endl;
 cout << im << "\t" << im2 << endl;

 TMethod* m1 = c->GetMethod("RunMe", "");  //Fails because im2 is null when
it shouldn't be
}

The two pointers to InterfaceMethods should be the same, but the second
method for getting it doesn't work even  tho the TMethod is a valid object.
I think the problem lies in TCint::CreateListOfMethods(TClass*).  I'm not
entirely sure but I think it might be because TCint::CreateListOfMethods
uses the G__MethodInfo copy constructor, but there is no explicit copy
constructor for G__MethodInfo....perhaps this is a problem with CInt...

Anyhow, this is quite an annoying problem as it prevents the use of
interpreted class member functions in Draw commands.  I hope the above is
enough info...

Thanks
Matt



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:38 MET