// @(#)root/meta:$Id$
// Author: Rene Brun   04/02/95

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "TMethodArg.h"
#include "TROOT.h"
#include "TInterpreter.h"
#include "Strlen.h"
#include "TMethod.h"
#include "TMethodCall.h"
#include "TDataMember.h"

//////////////////////////////////////////////////////////////////////////
//                                                                      //
//  Each ROOT method (see TMethod) has a linked list of its arguments.  //
//  This class describes one single method argument.                    //
//  The method argument info is obtained via the CINT api.              //
//  See class TCling.                                                    //
//                                                                      //
//  The method argument information is used a.o. in the TContextMenu    //
//  and THtml classes.                                                  //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

ClassImp(TMethodArg)

//______________________________________________________________________________
TMethodArg::TMethodArg(MethodArgInfo_t *info, TFunction *method) : TDictionary()
{
   // Default TMethodArg ctor. TMethodArgs are constructed in TFunction
   // via a call to TCling::CreateListOfMethodArgs().

   fDataMember = 0;
   fInfo       = info;
   fMethod     = method;
   if (fInfo) {
      SetName(gCling->MethodArgInfo_Name(fInfo));
      SetTitle(gCling->MethodArgInfo_TypeName(fInfo));
   }
}

//______________________________________________________________________________
TMethodArg::~TMethodArg()
{
   // TMethodArg dtor deletes adopted CINT MethodArgInfo object.

   if (fInfo) gCling->MethodArgInfo_Delete(fInfo);
}

//______________________________________________________________________________
const char *TMethodArg::GetDefault() const
{
   // Get default value of method argument.

   return gCling->MethodArgInfo_DefaultValue(fInfo);
}

//______________________________________________________________________________
const char *TMethodArg::GetTypeName() const
{
   // Get type of method argument, e.g.: "class TDirectory*" -> "TDirectory"
   // Result needs to be used or copied immediately.

   return gCling->TypeName(gCling->MethodArgInfo_TypeName(fInfo));
}

//______________________________________________________________________________
const char *TMethodArg::GetFullTypeName() const
{
   // Get full type description of method argument, e.g.: "class TDirectory*".

   return gCling->MethodArgInfo_TypeName(fInfo);
}

//______________________________________________________________________________
std::string TMethodArg::GetTypeNormalizedName() const
{
   // Get the normalized name of the return type.  A normalized name is fully
   // qualified and has all typedef desugared except for the 'special' typedef
   // which include Double32_t, Float16_t, [U]Long64_t and std::string.  It
   // also has std:: removed [This is subject to change].
   //

   return gCling->MethodArgInfo_TypeNormalizedName(fInfo);
}

//______________________________________________________________________________
Long_t TMethodArg::Property() const
{
   // Get property description word. For meaning of bits see EProperty.

   return gCling->MethodArgInfo_Property(fInfo);
}

//______________________________________________________________________________
TList *TMethodArg::GetOptions() const
{
   // Returns list of possible options - according to pointed datamember.
   // If there is no datamember field assigned to this methodarg - returns 0.

   return (TList*)(fDataMember ? fDataMember->GetOptions() : 0);
}

//______________________________________________________________________________
TDataMember *TMethodArg::GetDataMember() const
{
   // Returns TDataMember pointed by this methodarg.
   // If you want to specify list of options or current value for your
   // MethodArg (i.e. it is used as initial values in argument-asking dialogs
   // popped up from context-meny),you can get this value from one of data
   // members of the class.
   // The only restriction is, that this DataMember object must have its
   // Getter/Setter methods set-up correctly - for details look at TDataMember.
   // To learn how to specify the data member to which the argument should
   // "point", look at TMethod. This is TMethod which sets up fDataMember,
   // so it could work correctly.

   return fDataMember;
}

//______________________________________________________________________________
void TMethodArg::Update(MethodArgInfo_t *info)
{
   // Update fInfo (to 0 for unloading and non-zero for reloading).
   // This takes ownership of 'info'

   if (fInfo) gCling->MethodArgInfo_Delete(fInfo);
   fInfo = info;
   if (fInfo) {
      SetTitle(gCling->MethodArgInfo_TypeName(fInfo));
   }
}
 TMethodArg.cxx:1
 TMethodArg.cxx:2
 TMethodArg.cxx:3
 TMethodArg.cxx:4
 TMethodArg.cxx:5
 TMethodArg.cxx:6
 TMethodArg.cxx:7
 TMethodArg.cxx:8
 TMethodArg.cxx:9
 TMethodArg.cxx:10
 TMethodArg.cxx:11
 TMethodArg.cxx:12
 TMethodArg.cxx:13
 TMethodArg.cxx:14
 TMethodArg.cxx:15
 TMethodArg.cxx:16
 TMethodArg.cxx:17
 TMethodArg.cxx:18
 TMethodArg.cxx:19
 TMethodArg.cxx:20
 TMethodArg.cxx:21
 TMethodArg.cxx:22
 TMethodArg.cxx:23
 TMethodArg.cxx:24
 TMethodArg.cxx:25
 TMethodArg.cxx:26
 TMethodArg.cxx:27
 TMethodArg.cxx:28
 TMethodArg.cxx:29
 TMethodArg.cxx:30
 TMethodArg.cxx:31
 TMethodArg.cxx:32
 TMethodArg.cxx:33
 TMethodArg.cxx:34
 TMethodArg.cxx:35
 TMethodArg.cxx:36
 TMethodArg.cxx:37
 TMethodArg.cxx:38
 TMethodArg.cxx:39
 TMethodArg.cxx:40
 TMethodArg.cxx:41
 TMethodArg.cxx:42
 TMethodArg.cxx:43
 TMethodArg.cxx:44
 TMethodArg.cxx:45
 TMethodArg.cxx:46
 TMethodArg.cxx:47
 TMethodArg.cxx:48
 TMethodArg.cxx:49
 TMethodArg.cxx:50
 TMethodArg.cxx:51
 TMethodArg.cxx:52
 TMethodArg.cxx:53
 TMethodArg.cxx:54
 TMethodArg.cxx:55
 TMethodArg.cxx:56
 TMethodArg.cxx:57
 TMethodArg.cxx:58
 TMethodArg.cxx:59
 TMethodArg.cxx:60
 TMethodArg.cxx:61
 TMethodArg.cxx:62
 TMethodArg.cxx:63
 TMethodArg.cxx:64
 TMethodArg.cxx:65
 TMethodArg.cxx:66
 TMethodArg.cxx:67
 TMethodArg.cxx:68
 TMethodArg.cxx:69
 TMethodArg.cxx:70
 TMethodArg.cxx:71
 TMethodArg.cxx:72
 TMethodArg.cxx:73
 TMethodArg.cxx:74
 TMethodArg.cxx:75
 TMethodArg.cxx:76
 TMethodArg.cxx:77
 TMethodArg.cxx:78
 TMethodArg.cxx:79
 TMethodArg.cxx:80
 TMethodArg.cxx:81
 TMethodArg.cxx:82
 TMethodArg.cxx:83
 TMethodArg.cxx:84
 TMethodArg.cxx:85
 TMethodArg.cxx:86
 TMethodArg.cxx:87
 TMethodArg.cxx:88
 TMethodArg.cxx:89
 TMethodArg.cxx:90
 TMethodArg.cxx:91
 TMethodArg.cxx:92
 TMethodArg.cxx:93
 TMethodArg.cxx:94
 TMethodArg.cxx:95
 TMethodArg.cxx:96
 TMethodArg.cxx:97
 TMethodArg.cxx:98
 TMethodArg.cxx:99
 TMethodArg.cxx:100
 TMethodArg.cxx:101
 TMethodArg.cxx:102
 TMethodArg.cxx:103
 TMethodArg.cxx:104
 TMethodArg.cxx:105
 TMethodArg.cxx:106
 TMethodArg.cxx:107
 TMethodArg.cxx:108
 TMethodArg.cxx:109
 TMethodArg.cxx:110
 TMethodArg.cxx:111
 TMethodArg.cxx:112
 TMethodArg.cxx:113
 TMethodArg.cxx:114
 TMethodArg.cxx:115
 TMethodArg.cxx:116
 TMethodArg.cxx:117
 TMethodArg.cxx:118
 TMethodArg.cxx:119
 TMethodArg.cxx:120
 TMethodArg.cxx:121
 TMethodArg.cxx:122
 TMethodArg.cxx:123
 TMethodArg.cxx:124
 TMethodArg.cxx:125
 TMethodArg.cxx:126
 TMethodArg.cxx:127
 TMethodArg.cxx:128
 TMethodArg.cxx:129
 TMethodArg.cxx:130
 TMethodArg.cxx:131
 TMethodArg.cxx:132
 TMethodArg.cxx:133
 TMethodArg.cxx:134
 TMethodArg.cxx:135
 TMethodArg.cxx:136
 TMethodArg.cxx:137
 TMethodArg.cxx:138
 TMethodArg.cxx:139