// @(#)root/meta:$Id$ // Author: Philippe Canal November 2013. /************************************************************************* * 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. * *************************************************************************/ ////////////////////////////////////////////////////////////////////////// // // // Dictionary for function template // // This class describes one single function template. // // // ////////////////////////////////////////////////////////////////////////// #include "TFunctionTemplate.h" #include "TInterpreter.h" #include "TClass.h" #include "TROOT.h" ClassImp(TFunctionTemplate) //______________________________________________________________________________ TFunctionTemplate::TFunctionTemplate(FuncTempInfo_t *info, TClass *cl) : TDictionary(), fInfo(info), fClass(cl) { // Default TFunctionTemplate ctor. if (fInfo) { gCling->FuncTempInfo_Name(fInfo,fName); gCling->FuncTempInfo_Title(fInfo,fTitle); } } //______________________________________________________________________________ TFunctionTemplate::TFunctionTemplate(const TFunctionTemplate &orig) : TDictionary(orig) { // Copy operator. if (orig.fInfo) { fInfo = gCling->FuncTempInfo_FactoryCopy(orig.fInfo); } else fInfo = 0; fClass = orig.fClass; } //______________________________________________________________________________ TFunctionTemplate& TFunctionTemplate::operator=(const TFunctionTemplate &rhs) { // Assignment operator. if (this != &rhs) { gCling->FuncTempInfo_Delete(fInfo); if (rhs.fInfo) { fInfo = gCling->FuncTempInfo_FactoryCopy(rhs.fInfo); gCling->FuncTempInfo_Name(fInfo,fName); gCling->FuncTempInfo_Title(fInfo,fTitle); } else fInfo = 0; } return *this; } //______________________________________________________________________________ TFunctionTemplate::~TFunctionTemplate() { // TFunctionTemplate dtor deletes adopted CINT FuncTempInfo. gCling->FuncTempInfo_Delete(fInfo); } //______________________________________________________________________________ TObject *TFunctionTemplate::Clone(const char *newname) const { // Clone method. TNamed *newobj = new TFunctionTemplate(*this); if (newname && strlen(newname)) newobj->SetName(newname); return newobj; } //______________________________________________________________________________ Bool_t TFunctionTemplate::IsValid() { // Return true if this function template object is pointing to a currently // loaded function. If a function is unloaded after the TFunction // is created, the TFunction will be set to be invalid. // Register the transaction when checking the validity of the object. if (!fInfo && UpdateInterpreterStateMarker()) { // Only for global functions. For data member functions TMethod does it. DeclId_t newId = gInterpreter->GetFunction(0, fName); if (newId) { FuncTempInfo_t *info = gInterpreter->FuncTempInfo_Factory(newId); Update(info); } return newId != 0; } return fInfo != 0; } //______________________________________________________________________________ UInt_t TFunctionTemplate::GetTemplateNargs() const { // Number of function arguments. return fInfo ? gCling->FuncTempInfo_TemplateNargs(fInfo) : 0; } //______________________________________________________________________________ UInt_t TFunctionTemplate::GetTemplateMinReqArgs() const { // Number of function optional (default) arguments. // FIXME: when unload this is an over-estimate. return fInfo ? gCling->FuncTempInfo_TemplateMinReqArgs(fInfo) : 0; } //______________________________________________________________________________ Long_t TFunctionTemplate::Property() const { // Get property description word. For meaning of bits see EProperty. return fInfo ? gCling->FuncTempInfo_Property(fInfo) : 0; } //______________________________________________________________________________ TDictionary::DeclId_t TFunctionTemplate::GetDeclId() const { return gInterpreter->GetDeclId(fInfo); } //______________________________________________________________________________ Bool_t TFunctionTemplate::Update(FuncTempInfo_t *info) { // Update the TFunctionTemplate to reflect the new info. // // This can be used to implement unloading (info == 0) and then reloading // (info being the 'new' decl address). if (info == 0) { if (fInfo) gCling->FuncTempInfo_Delete(fInfo); fInfo = 0; return kTRUE; } else { if (fInfo) gCling->FuncTempInfo_Delete(fInfo); fInfo = info; gCling->FuncTempInfo_Title(fInfo,fTitle); return kTRUE; } }