From 36921060f44d5d2fdbd74cd4d2735ef0ddb0e84a Mon Sep 17 00:00:00 2001 From: Rene Brun <Rene.Brun@cern.ch> Date: Wed, 25 Jun 2003 15:35:09 +0000 Subject: [PATCH] From Philippe: This patch introduces TClass::HasDefaultConstructor which return true if a default constructor is available through fNew OR through the interpreter. This will avoid an erroneous message when the class dictionary has not been generated by rootcint. git-svn-id: http://root.cern.ch/svn/root/trunk@6783 27541ba8-7e3a-0410-8455-c3a389f83636 --- base/src/TBuffer.cxx | 4 ++-- base/src/TKey.cxx | 4 ++-- io/src/TKey.cxx | 4 ++-- meta/inc/TClass.h | 3 ++- meta/src/TClass.cxx | 23 +++++++++++++++++++++-- 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/base/src/TBuffer.cxx b/base/src/TBuffer.cxx index b6539d855d2..9dd5f883635 100644 --- a/base/src/TBuffer.cxx +++ b/base/src/TBuffer.cxx @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TBuffer.cxx,v 1.52 2003/05/08 17:20:41 rdm Exp $ +// @(#)root/base:$Name: $:$Id: TBuffer.cxx,v 1.53 2003/06/11 16:57:45 brun Exp $ // Author: Fons Rademakers 04/05/96 /************************************************************************* @@ -1790,7 +1790,7 @@ void TBuffer::WriteObject(const void *actualObjectStart, TClass *actualClass) // A warning to let the user know it will need to change the class code // to be able to read this back. - if (actualClass->GetNew() == 0) { + if (actualClass->HasDefaultConstructor() == 0) { Warning("WriteObjectAny", "since %s had no public constructor\n" "\twhich can be called without argument, objects of this class\n" "\tcan not be read with the current library. You would need to\n" diff --git a/base/src/TKey.cxx b/base/src/TKey.cxx index 5f5c4a20570..f7b9404d74d 100644 --- a/base/src/TKey.cxx +++ b/base/src/TKey.cxx @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TKey.cxx,v 1.31 2003/02/26 10:11:51 brun Exp $ +// @(#)root/base:$Name: $:$Id: TKey.cxx,v 1.32 2003/04/28 16:28:22 brun Exp $ // Author: Rene Brun 28/12/94 /************************************************************************* @@ -142,7 +142,7 @@ TKey::TKey(TObject *obj, const char *name, Int_t bufsize) //*-*-*-*-*-*-*-*-*-*Create a TKey object and fill output buffer*-*-*-*-*-*-* //*-* =========================================== - if (!obj->IsA()->GetNew()) { + if (!obj->IsA()->HasDefaultConstructor()) { Warning("TKey", "since %s had no public constructor\n" "\twhich can be called without argument, objects of this class\n" "\tcan not be read with the current library. You would need to\n" diff --git a/io/src/TKey.cxx b/io/src/TKey.cxx index 5f5c4a20570..f7b9404d74d 100644 --- a/io/src/TKey.cxx +++ b/io/src/TKey.cxx @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TKey.cxx,v 1.31 2003/02/26 10:11:51 brun Exp $ +// @(#)root/base:$Name: $:$Id: TKey.cxx,v 1.32 2003/04/28 16:28:22 brun Exp $ // Author: Rene Brun 28/12/94 /************************************************************************* @@ -142,7 +142,7 @@ TKey::TKey(TObject *obj, const char *name, Int_t bufsize) //*-*-*-*-*-*-*-*-*-*Create a TKey object and fill output buffer*-*-*-*-*-*-* //*-* =========================================== - if (!obj->IsA()->GetNew()) { + if (!obj->IsA()->HasDefaultConstructor()) { Warning("TKey", "since %s had no public constructor\n" "\twhich can be called without argument, objects of this class\n" "\tcan not be read with the current library. You would need to\n" diff --git a/meta/inc/TClass.h b/meta/inc/TClass.h index 02a8f03d21a..d275cfc447a 100644 --- a/meta/inc/TClass.h +++ b/meta/inc/TClass.h @@ -1,4 +1,4 @@ -// @(#)root/meta:$Name: $:$Id: TClass.h,v 1.31 2002/12/05 10:01:50 brun Exp $ +// @(#)root/meta:$Name: $:$Id: TClass.h,v 1.32 2003/02/28 20:26:51 brun Exp $ // Author: Rene Brun 07/01/95 /************************************************************************* @@ -120,6 +120,7 @@ public: void Destructor(void *obj, Bool_t dtorOnly = kFALSE); void *DynamicCast(const TClass *base, void *obj, Bool_t up = kTRUE); char *EscapeChars(char * text) const; + Bool_t HasDefaultConstructor() const; UInt_t GetCheckSum(UInt_t code=0) const; Version_t GetClassVersion() const { ((TClass*)this)->fVersionUsed = kTRUE; return fClassVersion; } TDataMember *GetDataMember(const char *datamember) const; diff --git a/meta/src/TClass.cxx b/meta/src/TClass.cxx index d29f1346d20..cf6701516ff 100644 --- a/meta/src/TClass.cxx +++ b/meta/src/TClass.cxx @@ -1,4 +1,4 @@ -// @(#)root/meta:$Name: $:$Id: TClass.cxx,v 1.118 2003/06/21 06:07:46 brun Exp $ +// @(#)root/meta:$Name: $:$Id: TClass.cxx,v 1.119 2003/06/23 15:19:15 brun Exp $ // Author: Rene Brun 07/01/95 /************************************************************************* @@ -2213,9 +2213,28 @@ void TClass::SetDestructor(ROOT::DesFunc_t destructorFunc) fDestructor = destructorFunc; } +//______________________________________________________________________________ +Bool_t TClass::HasDefaultConstructor() const +{ + // Return true if we have access to a default construstor + + if (fNew) return true; + + if (!GetClassInfo()) return false; + + // Insure the existence of G__struct.rootspecial[GetClassInfo()->Tagnum()] + if (GetClassInfo()->Version()) {}; + Assert(G__struct.rootspecial[GetClassInfo()->Tagnum()]!=0); + + if (G__struct.rootspecial[GetClassInfo()->Tagnum()]->defaultconstructor!=0) + return true; + + return false; +} + //______________________________________________________________________________ ROOT::NewFunc_t TClass::GetNew() const -{ +{ return fNew; } -- GitLab