[ROOT] TClass::GetMethod

From: Matthew Palmer (mjp39@cam.ac.uk)
Date: Tue Jan 15 2002 - 15:12:40 MET


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