39 TMethod::TMethod(MethodInfo_t *info, TClass *cl) : TFunction(info)
44 fMenuItem = kMenuNoMenu;
47 SetMenuItem(gCling->MethodInfo_Title(fInfo));
54 TMethod::TMethod(
const TMethod& orig) : TFunction(orig)
57 fMenuItem = orig.fMenuItem;
58 fGetter = orig.fGetter;
66 TMethod& TMethod::operator=(
const TMethod& rhs)
69 TFunction::operator=(rhs);
71 fMenuItem = rhs.fMenuItem;
72 fGetter = rhs.fGetter;
95 TObject *TMethod::Clone(
const char *newname)
const
97 TNamed *newobj =
new TMethod(*
this);
98 if (newname && strlen(newname)) newobj->SetName(newname);
105 const char *TMethod::GetCommentString()
107 return fInfo ? gCling->MethodInfo_Title(fInfo) :
"";
114 void TMethod::CreateSignature()
116 TFunction::CreateSignature();
118 if (Property() & kIsConstMethod) fSignature +=
" const";
132 TDataMember *TMethod::FindDataMember()
134 Char_t *argstring = (
char*)strstr(GetCommentString(),
"*ARGS={");
145 if (!fMethodArgs)
return 0;
147 Int_t nchs = strlen(argstring);
148 char *argstr =
new char[nchs+1];
154 strlcpy(argstr,argstring,nchs+1);
156 ptr2 = R__STRTOK_R(argstr,
"{}", &rest);
158 Fatal(
"FindDataMember",
"Internal error found '*ARGS=\"' but not \"{}\" in %s",GetCommentString());
162 ptr2 = R__STRTOK_R((
char *)0,
"{}", &rest);
169 ptr1 = R__STRTOK_R((
char *)(cnt++ ? 0 : ptr2),
",;", &rest);
172 Int_t nch = strlen(ptr1);
173 tok =
new char[nch+1];
174 strlcpy(tok,ptr1,nch+1);
175 tokens[token_cnt] = tok;
184 TDataMember *member = 0;
186 for (i=0; i<token_cnt;i++) {
188 ptr1 = R__STRTOK_R(tokens[i],
"=>", &rest);
189 ptr2 = R__STRTOK_R((
char *)0,
"=>", &rest);
195 TIter nextarg(fMethodArgs);
196 while ((ar = (TMethodArg*)nextarg())) {
197 if (!strcmp(ptr1,ar->GetName())) {
204 cl = GetClass()->GetBaseDataMember(ptr2);
206 member = cl->GetDataMember(ptr2);
207 if (a) a->fDataMember = member;
219 if (fMethodArgs->GetSize() != 1)
return 0;
222 if (fMethodArgs) a = (TMethodArg*)(fMethodArgs->First());
224 char dataname[67] =
"";
225 char basename[64] =
"";
226 const char *funcname = GetName();
227 if ( strncmp(funcname,
"Get",3) == 0 || strncmp(funcname,
"Set",3) == 0 )
228 snprintf(basename,64,
"%s",funcname+3);
229 else if ( strncmp(funcname,
"Is",2) == 0 )
230 snprintf(basename,64,
"%s",funcname+2);
231 else if (strncmp(funcname,
"Has", 3) == 0)
232 snprintf(basename,64,
"%s", funcname+3);
236 snprintf(dataname,67,
"f%s",basename);
238 TClass *cl = GetClass()->GetBaseDataMember(dataname);
240 TDataMember *member = cl->GetDataMember(dataname);
241 if (a) a->fDataMember = member;
244 snprintf(dataname,67,
"fIs%s",basename);
246 cl = GetClass()->GetBaseDataMember(dataname);
248 TDataMember *member = cl->GetDataMember(dataname);
249 if (a) a->fDataMember = member;
263 TMethodCall *TMethod::GetterMethod()
265 if (!fGetterMethod && fMenuItem == kMenuToggle && fGetter !=
"" && fClass) {
266 fGetterMethod =
new TMethodCall(fClass, Getter(),
"");
268 return fGetterMethod;
276 Bool_t TMethod::IsValid()
279 if (!fInfo && UpdateInterpreterStateMarker()) {
280 DeclId_t newId = gInterpreter->GetFunction(fClass->GetClassInfo(), fName);
282 MethodInfo_t *info = gInterpreter->MethodInfo_Factory(newId);
294 TMethodCall *TMethod::SetterMethod()
296 if (!fSetterMethod && fMenuItem == kMenuToggle && fClass) {
297 fSetterMethod =
new TMethodCall(fClass, GetName(),
"1");
299 return fSetterMethod;
306 TList *TMethod::GetListOfMethodArgs()
309 TFunction::GetListOfMethodArgs();
318 void TMethod::SetMenuItem(
const char *docstring)
320 if (docstring && strstr(docstring,
"*TOGGLE")) {
321 fMenuItem = kMenuToggle;
323 if ((s = strstr(docstring,
"*GETTER="))) {
325 fGetter = fGetter.Strip(TString::kBoth);
328 if (docstring && strstr(docstring,
"*MENU"))
329 fMenuItem = kMenuDialog;
331 if (docstring && strstr(docstring,
"*SUBMENU"))
332 fMenuItem = kMenuSubMenu;
334 fMenuItem = kMenuNoMenu;
343 Bool_t TMethod::Update(MethodInfo_t *info)
345 if (TFunction::Update(info)) {
346 delete fGetterMethod; fGetterMethod = 0;
347 delete fSetterMethod; fSetterMethod = 0;
349 SetMenuItem(gCling->MethodInfo_Title(fInfo));