From 504f57fd2bb694235d763d3dae2cf28bbb308e38 Mon Sep 17 00:00:00 2001
From: Paul Russo <russo@fnal.gov>
Date: Wed, 26 Mar 2008 01:56:28 +0000
Subject: [PATCH] Flush out all current cint7 dictionary fixes.

-- Paul Russo


git-svn-id: http://root.cern.ch/svn/root/trunk@22834 27541ba8-7e3a-0410-8455-c3a389f83636
---
 cint/cint7/src/Shadow.cxx      | 318 ++++++++++++++++-----------
 cint/cint7/src/Type.cxx        |  10 +-
 cint/cint7/src/common.h        |   1 +
 cint/cint7/src/expr.cxx        |   1 +
 cint/cint7/src/fproto.h        |  76 +++----
 cint/cint7/src/ifunc.cxx       |   1 +
 cint/cint7/src/inherit.cxx     |   1 +
 cint/cint7/src/newlink.cxx     | 243 +++++++++-----------
 cint/cint7/src/rflxutil.cxx    | 391 ++++++++++++++++++++++++---------
 cint/cint7/src/struct.cxx      |  10 +-
 cint/cint7/src/var.cxx         |  22 +-
 cint/reflex/src/NameLookup.cxx | 371 ++++++++++++++++---------------
 cint/reflex/src/NameLookup.h   |  91 +++-----
 cint/reflex/src/Tools.cxx      |   4 +
 14 files changed, 881 insertions(+), 659 deletions(-)

diff --git a/cint/cint7/src/Shadow.cxx b/cint/cint7/src/Shadow.cxx
index 920b99b9a32..76e77f1e28a 100644
--- a/cint/cint7/src/Shadow.cxx
+++ b/cint/cint7/src/Shadow.cxx
@@ -393,51 +393,62 @@ std::string Cint::G__ShadowMaker::GetNonConstTypeName(G__DataMemberInfo &m, bool
 }
 
 //______________________________________________________________________________
-void Cint::G__ShadowMaker::WriteShadowClass(G__ClassInfo &cl, int level /*=0*/)
+void Cint::G__ShadowMaker::WriteShadowClass(G__ClassInfo& cl, int level /*=0*/)
 {
-   // This function writes or make available a class named fNSPrefix::Shadow::ClassName
-   // for which all data member are the same as the one in the class but are
-   // all public.
+   // This function writes or make available a class named
+   // fNSPrefix::Shadow::ClassName for which all data member
+   // are the same as the one in the class but are all public.
+   //fprintf(stderr, "G__ShadowMaker::WriteShadowClass: Begin for class '%s'\n", cl.Name());
 
-   if (!fCacheNeedShadow[cl.Tagnum()]) return;
+   if (!fCacheNeedShadow[cl.Tagnum()]) {
+      return;
+   }
 
-   // if nested class let the enclosing class generate the shadow
-   G__ClassInfo encClass=cl.EnclosingClass();
-   if (!level && encClass.IsValid() && fCacheNeedShadow[encClass.Tagnum()])
+   // If nested class let the enclosing class generate the shadow.
+   G__ClassInfo encClass = cl.EnclosingClass();
+   if (!level && encClass.IsValid() && fCacheNeedShadow[encClass.Tagnum()]) {
       return;
+   }
 
-   // Here we copy the shadow only if !TypedefShadow(cl) class does not have a ClassDef
-   // in it.
+   // Here we copy the shadow only if !TypedefShadow(cl)
+   // class does not have a ClassDef in it.
    std::string classname = G__map_cpp_name((char*)cl.Name());
 
    int closing_brackets = 0;
-   if (!level) closing_brackets = WriteNamespaceHeader(cl);
-   if (closing_brackets) fOut << std::endl;
+   if (!level) {
+      closing_brackets = WriteNamespaceHeader(cl);
+   }
+   if (closing_brackets) {
+      fOut << std::endl;
+   }
    std::string indent;
-   for (int iIndent=0; iIndent<level; ++iIndent) indent+="   ";
+   for (int iIndent = 0; iIndent < level; ++iIndent) {
+      indent += "   ";
+   }
 
    std::string fullname;
-   GetFullyQualifiedName(cl,fullname);
+   GetFullyQualifiedName(cl, fullname);
 
-   if (fCacheNeedShadow[cl.Tagnum()]!=2 
-      && fNeedTypedefShadow  && fNeedTypedefShadow(cl)) {
+   if ((fCacheNeedShadow[cl.Tagnum()] != 2) && fNeedTypedefShadow && fNeedTypedefShadow(cl)) {
       fOut << indent << "      typedef " << fullname << " " << classname << ";" << std::endl;
-   } else {
+   }
+   else {
       fOut << indent << "      #if !(defined(R__ACCESS_IN_SYMBOL) || defined(R__USE_SHADOW_CLASS))" << std::endl;
-      fOut << indent << "      typedef " << fullname<< " " << classname << ";" << std::endl
-          << indent << "      #else" << std::endl;
+      fOut << indent << "      typedef " << fullname << " " << classname << ";" << std::endl;
+      fOut << indent << "      #else" << std::endl;
 
-      if (cl.Property() & G__BIT_ISENUM)
+      if (cl.Property() & G__BIT_ISENUM) {
          fOut << indent << "      enum " << classname << " ";
-      else
+      }
+      else {
          fOut << indent << "      class " << classname << " ";
+      }
 
       // Write ShowMembers for base class(es) when they have the ShowMember() method
       G__BaseClassInfo b(cl);
       bool first = true;
       while (b.Next()) {
-         if (  (b.Property() & G__BIT_ISVIRTUALBASE) &&
-              !(b.Property() & G__BIT_ISDIRECTINHERIT)) {
+         if ((b.Property() & G__BIT_ISVIRTUALBASE) && !(b.Property() & G__BIT_ISDIRECTINHERIT)) {
             // CINT duplicates the remote virtual base class in the list scanned
             // by G__BaseClassInfo, we need to skip them.
             continue;
@@ -445,67 +456,79 @@ void Cint::G__ShadowMaker::WriteShadowClass(G__ClassInfo &cl, int level /*=0*/)
          if (first) {
             fOut << " : ";
             first = false;
-         } else {
+         }
+         else {
             fOut << ", ";
          }
-         if (b.Property() & G__BIT_ISVIRTUALBASE)
+         if (b.Property() & G__BIT_ISVIRTUALBASE) {
             fOut << " virtual";
-         if (b.Property() & G__BIT_ISPRIVATE)
+         }
+         if (b.Property() & G__BIT_ISPRIVATE) {
             fOut << " private ";
-         else if (b.Property() & G__BIT_ISPROTECTED)
+         }
+         else if (b.Property() & G__BIT_ISPROTECTED) {
             fOut << " protected ";
-         else if (b.Property() & G__BIT_ISPUBLIC)
+         }
+         else if (b.Property() & G__BIT_ISPUBLIC) {
             fOut << " public ";
-         else
+         }
+         else {
             fOut << " UNKNOWN inheritance ";
+         }
 
          std::string type_name;
-         GetFullyQualifiedName(b,type_name);
+         GetFullyQualifiedName(b, type_name);
          fOut << type_name;
       }
       fOut << " {" << std::endl;
       if (!(cl.Property() & G__BIT_ISENUM)) {
-         fOut << indent << "         public:" << std::endl
-              << indent << "         //friend XX;" << std::endl;
+         fOut << indent << "         public:" << std::endl;
+         fOut << indent << "         //friend XX;" << std::endl;
       }
 
       G__ClassInfo clContained;
       clContained.Init();
       while (clContained.Next()) {
-         if (clContained.IsValid() && 
+         if (
+            clContained.IsValid() &&
             clContained.EnclosingClass().IsValid() &&
-            clContained.EnclosingClass().Tagnum()==cl.Tagnum()
-            && strcmp(clContained.Name(),"$"))
-            WriteShadowClass(clContained, level+1);
+            (clContained.EnclosingClass().Tagnum() == cl.Tagnum()) &&
+            strcmp(clContained.Name(), "$")
+         ) {
+            WriteShadowClass(clContained, level + 1);
+         }
       }
 
       // Loop over all types, generating shadows for types contained in this class
       G__TypedefInfo tdContained;
       tdContained.Init();
       while (tdContained.Next()) {
-         if (tdContained.IsValid() && 
+         if (
+            tdContained.IsValid() &&
             tdContained.EnclosingClassOfTypedef().IsValid() &&
-            tdContained.EnclosingClassOfTypedef().Tagnum()==cl.Tagnum()) {
+            (tdContained.EnclosingClassOfTypedef().Tagnum() == cl.Tagnum())
+         ) {
             std::string nsprefixOriginal("::");
 
             std::string typedefedTypename = tdContained.Name();
-            //remove leading scopes, as we want to have it defined locally
-            size_t posLastScope=typedefedTypename.rfind("::");
-            if (posLastScope!=std::string::npos && posLastScope>0)
-               typedefedTypename.erase(0, posLastScope+2);
+            // Remove leading scopes, as we want to have it defined locally.
+            size_t posLastScope = typedefedTypename.rfind("::");
+            if ((posLastScope != std::string::npos) && (posLastScope > 0)) {
+               typedefedTypename.erase(0, posLastScope + 2);
+            }
 
             std::string typenameOriginal;
             if (tdContained.Fullname()) {
-               typenameOriginal=tdContained.TrueName();
+               typenameOriginal = tdContained.TrueName();
                // don't generate dummy typedefs for template default params
-               if (!typedefedTypename.empty()
-                   && typedefedTypename[typedefedTypename.length()-1]=='>')
-                 continue;
+               if (!typedefedTypename.empty() && (typedefedTypename[typedefedTypename.length()-1] == '>')) {
+                  continue;
+               }
                // Cint doesn't put the FQI as the template arg's type,
                // so they end up in the shadow namespace, as in
                // typedef ::SomeType<AnotherType> SomeTypeDefInShadow;
                // AnotherType should really be ::AnotherType.
-               // We need to fix that, by putting all but built-in template 
+               // We need to fix that, by putting all but built-in template
                // arg types into the global namespace
 
                size_t posTemplArg = typenameOriginal.find('<');
@@ -513,70 +536,82 @@ void Cint::G__ShadowMaker::WriteShadowClass(G__ClassInfo &cl, int level /*=0*/)
                   int level = 0;
                   size_t posArgEnd = posTemplArg;
                   do {
-                    posArgEnd = typenameOriginal.find_first_of("<,>",posArgEnd + 1);
-                    if(posArgEnd !=  std::string::npos) {
-                      if(typenameOriginal[posArgEnd] == '<') 
-                        ++level; 
-                      if(typenameOriginal[posArgEnd] == '>') {
-                        --level;
-                        if(level == -1) break;
-                      }
-                      if(typenameOriginal[posArgEnd] == ',' && level == 0)
-                        break;
-                    }
-                  } while(posArgEnd != std::string::npos);
-                  
-                  if(posArgEnd == std::string::npos) {
-                     printf("WARNING: error extracting template aruments for %s!", 
-                        typenameOriginal.c_str());
+                     posArgEnd = typenameOriginal.find_first_of("<,>", posArgEnd + 1);
+                     if (posArgEnd !=  std::string::npos) {
+                        if (typenameOriginal[posArgEnd] == '<') {
+                           ++level;
+                        }
+                        if (typenameOriginal[posArgEnd] == '>') {
+                           --level;
+                           if (level == -1) {
+                              break;
+                           }
+                        }
+                        if ((typenameOriginal[posArgEnd] == ',') && !level) {
+                           break;
+                        }
+                     }
+                  }
+                  while (posArgEnd != std::string::npos);
+
+                  if (posArgEnd == std::string::npos) {
+                     printf("WARNING: error extracting template aruments for %s!", typenameOriginal.c_str());
                      break;
                   }
 
-                  std::string arg = typenameOriginal.substr(posTemplArg+1,posArgEnd - posTemplArg - 1);
-                  std::string::size_type posRef=std::string::npos;
-                  while ((posRef = arg.find_first_of(" *&"))!=std::string::npos)
+                  std::string arg = typenameOriginal.substr(posTemplArg + 1, posArgEnd - posTemplArg - 1);
+                  std::string::size_type posRef = std::string::npos;
+                  posRef = arg.find_first_of(" *&");
+                  while (posRef != std::string::npos) {
                      arg.erase(posRef, 1);
+                     posRef = arg.find_first_of(" *&");
+                  }
                   // if the type is not defined (i.e. it's fundamental)
                   // and if we don't have a real shadoew for it, use the
                   // global scope's type.
                   int tagname = G__defined_tagname(arg.c_str(), 1);
-
                   if (tagname != -1) {
                      G__ClassInfo ciArg(tagname);
                      // templates or function without shadow
                      // need to have explicit namespace
-                     if (arg.find('<')!= std::string::npos ||
-                         fCacheNeedShadow[tagname] != 1 
-                         && ((ciArg.Property() & G__BIT_ISCLASS)
-                             || (ciArg.Property() & G__BIT_ISSTRUCT))) {
+                     if (
+                        (arg.find('<') != std::string::npos) ||
+                        (
+                           (fCacheNeedShadow[tagname] != 1) &&
+                           (
+                              (ciArg.Property() & G__BIT_ISCLASS) ||
+                              (ciArg.Property() & G__BIT_ISSTRUCT)
+                           )
+                        )
+                     ) {
                         // replace "pair" by "std::pair"
-                        if (arg == "pair") arg.insert(0, "std::");
+                        if (arg == "pair") {
+                           arg.insert(0, "std::");
+                        }
                         // we don't have a (full) shadow for this guy
                         // need space before "::" to prevent "<:"
-                        typenameOriginal.insert(posTemplArg+1, " ::");
+                        typenameOriginal.insert(posTemplArg + 1, " ::");
                         posArgEnd += 3;
                      }
                   }
-                  posTemplArg = typenameOriginal.find_first_of("<,", posTemplArg+1);
+                  posTemplArg = typenameOriginal.find_first_of("<,", posTemplArg + 1);
+               }
+               if (IsSTLCont(tdContained.Fullname()) || IsStdPair(tdContained)) {
+                  nsprefixOriginal = "::std::";
                }
-
-               if (IsSTLCont(tdContained.Fullname()) || IsStdPair(tdContained)) 
-                  nsprefixOriginal="::std::";
             }
 
             if (!tdContained.Fullname()) {
                // func ptr, make typedefedTypename contain the full typedef
-               // and make the func be void (func)() - the exact signature is 
+               // and make the func be void (func)() - the exact signature is
                // irrelevant for the shadow, and we can't extract the params from Cint.
                typenameOriginal =  "void* (*";
                typenameOriginal += typedefedTypename + ")()";
-               typedefedTypename="";
-               nsprefixOriginal="";
+               typedefedTypename = "";
+               nsprefixOriginal = "";
             }
 
-            fOut << indent << "         typedef " 
-                 << nsprefixOriginal << typenameOriginal << " " 
-                 << typedefedTypename << ";" << std::endl;
+            fOut << indent << "         typedef " << nsprefixOriginal << typenameOriginal << " " << typedefedTypename << ";" << std::endl;
          }
       }
 
@@ -584,101 +619,119 @@ void Cint::G__ShadowMaker::WriteShadowClass(G__ClassInfo &cl, int level /*=0*/)
       G__MethodInfo methods(cl);
       while (methods.Next()) {
          // fprintf(stderr,"%s::%s has property 0x%x\n",cl.Fullname(),methods.Name(),methods.Property());
-         if (methods.Property() &
-             (G__BIT_ISVIRTUALBASE|G__BIT_ISVIRTUAL|G__BIT_ISPUREVIRTUAL)) {
-            fOut << indent << "         // To force the creation of a virtual table, throw just in case." << std::endl
-                << indent << "         virtual ~" << classname << "() throw() {};" << std::endl;
+         if (methods.Property() & (G__BIT_ISVIRTUALBASE | G__BIT_ISVIRTUAL | G__BIT_ISPUREVIRTUAL)) {
+            fOut << indent << "         // To force the creation of a virtual table, throw just in case." << std::endl;
+            fOut << indent << "         virtual ~" << classname << "() throw() {};" << std::endl;
             break;
          }
       }
 
-      if (fCacheNeedShadow[cl.Tagnum()]==1) {
+      if (fCacheNeedShadow[cl.Tagnum()] == 1) { // If real shadow class, not just enclosing scope.
          // Write data members
          G__DataMemberInfo d(cl);
          while (d.Next()) {
-            // fprintf(stderr,"%s %s %ld\n",d.Type()->Name(),d.Name(),d.Property());
-
-            if ((d.Type()->Property() & G__BIT_ISCONSTANT) 
-               && (d.Type()->Property() & G__BIT_ISENUM)  // an enum const
-               || (d.Property() & G__BIT_ISSTATIC)) // a static member
+            //fprintf(stderr, "G__ShadowMaker::WriteShadowClass: name: '%-16s' type: '%s' property: %08lX\n", d.Name(), d.Type()->Name(), d.Property());
+            if (
+               (d.Property() & G__BIT_ISSTATIC) || // a static member, or
+               (
+                  (d.Type()->Property() & G__BIT_ISCONSTANT) &&
+                  (d.Type()->Property() & G__BIT_ISENUM)  // an enum const
+               )
+            ) {
                continue;
-            if (strcmp("G__virtualinfo",d.Name())==0) continue;
-
-            std::string type_name = GetNonConstTypeName(d,true); // .Type()->Name();
-
-            if ((d.Type()->Property() & G__BIT_ISENUM) &&
-                (type_name.length()==0 || type_name=="enum") ||
-                 type_name.find("::")==type_name.length()-2 ) {
+            }
+            if (!strcmp("G__virtualinfo", d.Name())) {
+               continue;
+            }
+            std::string type_name = GetNonConstTypeName(d, true); // .Type()->Name();
+            if (
+               (
+                  (d.Type()->Property() & G__BIT_ISENUM) &&
+                  (
+                     !type_name.length() ||
+                     (type_name == "enum") ||
+                     !type_name.compare(0, 10, "$G__NONAME")
+                  )
+               ) ||
+               (type_name.find("::") == (type_name.length() - 2))
+            ) {
                // We have unamed enums, let's fake it:
                fOut << indent << "         enum {kDummy} " << d.Name();
-            } else {
-               if (d.Type()->Name() && strstr(d.Type()->Name(),"(*)")) {
+            }
+            else {
+               if (d.Type()->Name() && strstr(d.Type()->Name(), "(*)")) {
                   // func ptr
                   std::string funcptr_name = d.Type()->Name();
-                  size_t posName=funcptr_name.find("(*)");
-                  funcptr_name.insert(posName+2, d.Name());
+                  size_t posName = funcptr_name.find("(*)");
+                  funcptr_name.insert(posName + 2, d.Name());
                   fOut << indent << "         " << " " << funcptr_name;
-               } else {
+               }
+               else {
                   // Keep original "time_t", as it's not "long" on all platforms
-                  if (!strcmp(d.Type()->Name(),"time_t"))
+                  if (!strcmp(d.Type()->Name(), "time_t")) {
                      type_name = "time_t";
+                  }
                   // for p2memfunc, take original type instead of Cint's para-type
-                  if (d.Type()->Type()=='a' && d.Type()->Name())
-                     if (d.Type()->TrueName() 
-                        && !strcmp(d.Type()->TrueName(),"G__p2memfunc")) {
-                        fOut << indent << "         " 
-                             << "void (" << cl.Name() << "::*" << d.Name() << ")()";
-                        type_name="";
+                  if ((d.Type()->Type() == 'a') && d.Type()->Name()) {
+                     if (d.Type()->TrueName() && !strcmp(d.Type()->TrueName(), "G__p2memfunc")) {
+                        fOut << indent << "         " << "void (" << cl.Name() << "::*" << d.Name() << ")()";
+                        type_name = "";
                      }
-                     else
+                     else {
                         type_name = d.Type()->Name();
+                     }
+                  }
                   if (!type_name.empty()) {
                      // Replace 'long long' and 'unsigned long long' by 'Long64_t' and 'ULong64_t'
                      const char* ulonglong_s = "unsigned long long";
-                     const char* longlong_s  = ulonglong_s+9;
+                     const char* longlong_s  = ulonglong_s + 9;
                      const unsigned int ulonglong_len = 18;
                      const unsigned int longlong_len  = 9;
-
                      int pos = 0;
-                     while( (pos = type_name.find(ulonglong_s,pos) ) >=0 ) {
+                     pos = type_name.find(ulonglong_s, pos);
+                     while (pos >= 0) {
                         type_name.replace(pos, ulonglong_len, "G__uint64");
+                        pos = type_name.find(ulonglong_s, pos);
                      }
                      pos = 0;
-                     while( (pos = type_name.find(longlong_s,pos) ) >=0 ) {
+                     pos = type_name.find(longlong_s, pos);
+                     while (pos >= 0) {
                         type_name.replace(pos, longlong_len, "G__int64");
-                     }         
-
-                     if (type_name[type_name.length()-1]=='&') {
-                        type_name[type_name.length()-1]='*';
+                        pos = type_name.find(longlong_s, pos);
+                     }
+                     if (type_name[type_name.length()-1] == '&') {
+                        type_name[type_name.length()-1] = '*';
                      }
                      // if type is contained in cl, remove sope (so it points to nested shadow)
-                     if (!strncmp(type_name.c_str(), fullname.c_str(), fullname.length()) 
-                        && type_name[fullname.length()]==':')
-                        type_name.erase(0, fullname.length()+2);
-
+                     if (
+                        !strncmp(type_name.c_str(), fullname.c_str(), fullname.length()) &&
+                        (type_name[fullname.length()] == ':')
+                     ) {
+                        type_name.erase(0, fullname.length() + 2);
+                     }
                      fOut << indent << "         " << type_name << " " << d.Name();
                   }
                }
             }
-
-            for(int dim = 0; dim < d.ArrayDim(); dim++) {
+            for (int dim = 0; dim < d.ArrayDim(); ++dim) {
                fOut << "[" << d.MaxIndex(dim) << "]";
             }
             fOut << "; //" << d.Title() << std::endl;
          }
-      } // if fCacheNeedShadow[cl.Tagnum()]==1 (i.e. real shadow class, not just enclosing scope)
+      }
       fOut << indent << "      };" << std::endl;
-
       fOut << indent << "      #endif" << std::endl;
    }
-   if (closing_brackets) fOut << indent << "      ";
-   for(int brack=0; brack<closing_brackets; brack++) {
+   if (closing_brackets) {
+      fOut << indent << "      ";
+   }
+   for (int brack = 0; brack < closing_brackets; ++brack) {
       fOut << "} ";
    }
    fOut << std::endl;
 }
 
-
+//______________________________________________________________________________
 void Cint::G__ShadowMaker::WriteAllShadowClasses() {
    if (fgVetoShadow) return;
 
@@ -719,3 +772,4 @@ void Cint::G__ShadowMaker::WriteAllShadowClasses() {
    }
    fOut << "// END OF SHADOWS" << std::endl << std::endl;
 }
+
diff --git a/cint/cint7/src/Type.cxx b/cint/cint7/src/Type.cxx
index 1d5da6fc333..ad89391f2ee 100644
--- a/cint/cint7/src/Type.cxx
+++ b/cint/cint7/src/Type.cxx
@@ -168,9 +168,13 @@ const char* Cint::G__TypeInfo::Name()
 #else
 #pragma message(FIXME("Get rid of static G__buf by proper lookup"))
 #endif
-
-  strcpy(G__buf,G__type2string(G__get_type(typenum),(int)tagnum,G__get_typenum(typenum),
-                               G__get_reftype(typenum),G__get_isconst(typenum)));
+  char type = '\0';
+  int cint5_tagnum = -1;
+  int cint5_typenum = -1;
+  int reftype = 0;
+  int constvar = 0;
+  G__get_cint5_type_tuple(typenum, &type, &cint5_tagnum, &cint5_typenum, &reftype, &constvar);
+  strcpy(G__buf, G__type2string(type, cint5_tagnum, cint5_typenum, reftype, constvar));
   return G__buf;
 }
 
diff --git a/cint/cint7/src/common.h b/cint/cint7/src/common.h
index b1c1a946ddc..1db7c93ffdf 100644
--- a/cint/cint7/src/common.h
+++ b/cint/cint7/src/common.h
@@ -1332,6 +1332,7 @@ public:
    BuilderHolder builder;
    void* vtable;
    bool isBytecodeArena;
+   int statictype;
 };
 
 class G__RflxVarProperties: public G__RflxProperties {
diff --git a/cint/cint7/src/expr.cxx b/cint/cint7/src/expr.cxx
index e3be7488346..b5de8358873 100644
--- a/cint/cint7/src/expr.cxx
+++ b/cint/cint7/src/expr.cxx
@@ -1919,6 +1919,7 @@ G__value Cint::Internal::G__getitem(char* item)
          known = 0;
          G__var_type = 'p';
          /* variable */
+         //fprintf(stderr, "G__get_item: Lookup up variable '%s' in scope '%s'\n", item, G__p_local.Name(Reflex::SCOPED | Reflex::QUALIFIED).c_str());
          result3 = G__getvariable(item, &known,::Reflex::Scope::GlobalScope(), G__p_local);
          if (!known && G__get_tagnum(G__value_typenum(result3)) != -1 && result3.obj.i == 0) {
             // this is "a.b", we know "a", but it has no "b" - there is no use
diff --git a/cint/cint7/src/fproto.h b/cint/cint7/src/fproto.h
index 60735d7e03a..1a6d2e56acd 100644
--- a/cint/cint7/src/fproto.h
+++ b/cint/cint7/src/fproto.h
@@ -654,41 +654,42 @@ void G__setmemtestbreak(int n,int m);
 void G__clear_errordictpos();
 void G__setcopyflag(int flag);
 
-int G__get_type(const ::Reflex::Type& in);
+void G__get_cint5_type_tuple(const ::Reflex::Type in_type, char* out_type, int* out_tagnum, int* out_typenum, int* out_reftype, int* out_constvar);
+int G__get_type(const ::Reflex::Type in);
 int G__get_type(const G__value& in);
-int G__get_tagtype(const ::Reflex::Type& in);
-int G__get_tagtype(const ::Reflex::Scope& in);
-int G__get_reftype(const ::Reflex::Type& in);
-G__SIGNEDCHAR_T G__get_isconst(const ::Reflex::Type& in);
-int G__get_tagnum(const ::Reflex::Type& in);
-int G__get_tagnum(const ::Reflex::Scope& in);
-int G__get_typenum(const ::Reflex::Type& in);
-int G__get_nindex(const ::Reflex::Type& in);
-std::vector<int> G__get_index(const ::Reflex::Type& in);
-int G__get_varlabel(const ::Reflex::Type& in, int idx);
-int G__get_varlabel(const ::Reflex::Member& in, int idx);
-bool G__is_localstaticbody(const Reflex::Member& var);
-int G__get_paran(const Reflex::Member& var);
+int G__get_tagtype(const ::Reflex::Type in);
+int G__get_tagtype(const ::Reflex::Scope in);
+int G__get_reftype(const ::Reflex::Type in);
+G__SIGNEDCHAR_T G__get_isconst(const ::Reflex::Type in);
+int G__get_tagnum(const ::Reflex::Type in);
+int G__get_tagnum(const ::Reflex::Scope in);
+int G__get_typenum(const ::Reflex::Type in);
+int G__get_nindex(const ::Reflex::Type in);
+std::vector<int> G__get_index(const ::Reflex::Type in);
+int G__get_varlabel(const ::Reflex::Type in, int idx);
+int G__get_varlabel(const ::Reflex::Member in, int idx);
+bool G__is_localstaticbody(const Reflex::Member var);
+int G__get_paran(const Reflex::Member var);
 
 void G__get_stack_varname(std::string &output,const char *varname,const ::Reflex::Member &m,int tagnum);
 
-::G__RflxProperties *G__get_properties(const ::Reflex::Type& in);
-::G__RflxProperties *G__get_properties(const ::Reflex::Scope& in);
-::G__RflxVarProperties *G__get_properties(const ::Reflex::Member& in);
-::G__RflxFuncProperties *G__get_funcproperties(const ::Reflex::Member& in);
+::G__RflxProperties* G__get_properties(const ::Reflex::Type in);
+::G__RflxProperties* G__get_properties(const ::Reflex::Scope in);
+::G__RflxVarProperties* G__get_properties(const ::Reflex::Member in);
+::G__RflxFuncProperties* G__get_funcproperties(const ::Reflex::Member in);
 size_t GetReflexPropertyID();
 template< class T, class Prop >
 void G__set_properties(const T& in, const Prop& rp) {
    in.Properties().AddProperty(GetReflexPropertyID(), rp);
 }
-size_t G__get_bitfield_width(const ::Reflex::Member &in);
-size_t G__get_bitfield_start(const ::Reflex::Member &in);
+size_t G__get_bitfield_width(const ::Reflex::Member in);
+size_t G__get_bitfield_start(const ::Reflex::Member in);
 
 int G__sizeof_deref(const G__value*);
-::Reflex::Type G__strip_array(const ::Reflex::Type &typein);
-::Reflex::Type G__strip_one_array(const Reflex::Type &typein);
-::Reflex::Type G__deref(const ::Reflex::Type &typein);
-::Reflex::Type G__modify_type(const ::Reflex::Type& typein
+::Reflex::Type G__strip_array(const ::Reflex::Type typein);
+::Reflex::Type G__strip_one_array(const Reflex::Type typein);
+::Reflex::Type G__deref(const ::Reflex::Type typein);
+::Reflex::Type G__modify_type(const ::Reflex::Type typein
                                     ,bool ispointer
                                     ,int reftype,int isconst
                                     ,int nindex, int *index);
@@ -696,7 +697,7 @@ int G__sizeof_deref(const G__value*);
 ::Reflex::Type G__get_from_type(int type, int createpointer, int isconst = 0);
 ::Reflex::Type G__find_type(const char *type_name, int errorflag, int templateflag);
 ::Reflex::Type G__find_typedef(const char*);
-::Reflex::Type G__findInScope(const ::Reflex::Scope& scope, const char* name);
+::Reflex::Type G__findInScope(const ::Reflex::Scope scope, const char* name);
 ::Reflex::Type G__declare_typedef(const char *typenamein,
                                         int typein,int tagnum,int reftype,
                                         int isconst, int globalcomp,
@@ -711,18 +712,19 @@ int G__sizeof_deref(const G__value*);
                                   ,int isdecl);
 ::Reflex::Type G__get_Type(int type, int tagnum, int typenum, int isconst);
 
-bool G__test_access(const ::Reflex::Member &var, int access);
-bool G__is_cppmacro(const ::Reflex::Member &var);
-bool G__test_static(const ::Reflex::Member &var, int what_static, int filenum = -1);
-bool G__test_const(const ::Reflex::Member &var, int what_const);
-bool G__test_const(const ::Reflex::Type &type, int what_const);
-int G__get_access(const ::Reflex::Member &mem);
-int G__get_static(const ::Reflex::Member &mem);
-char*& G__get_offset(const ::Reflex::Member& var);
-Reflex::Type G__replace_rawtype(const Reflex::Type& target, const Reflex::Type& raw);
-
-void G__set_G__tagnum(const ::Reflex::Scope&);
-void G__set_G__tagnum(const ::Reflex::Type&);
+bool G__test_access(const ::Reflex::Member var, int access);
+bool G__is_cppmacro(const ::Reflex::Member var);
+bool G__filescopeaccess(int filenum, int statictype);
+bool G__test_static(const ::Reflex::Member var, int what_static, int filenum = -1);
+bool G__test_const(const ::Reflex::Member var, int what_const);
+bool G__test_const(const ::Reflex::Type type, int what_const);
+int G__get_access(const ::Reflex::Member mem);
+int G__get_static(const ::Reflex::Member mem);
+char*& G__get_offset(const ::Reflex::Member var);
+Reflex::Type G__replace_rawtype(const Reflex::Type target, const Reflex::Type raw);
+
+void G__set_G__tagnum(const ::Reflex::Scope);
+void G__set_G__tagnum(const ::Reflex::Type);
 void G__set_G__tagnum(const G__value&);
 
 void G__dumpreflex();
diff --git a/cint/cint7/src/ifunc.cxx b/cint/cint7/src/ifunc.cxx
index 5a546d0f995..6fd1cd1dea2 100644
--- a/cint/cint7/src/ifunc.cxx
+++ b/cint/cint7/src/ifunc.cxx
@@ -976,6 +976,7 @@ void Cint::Internal::G__make_ifunctable(char* funcheader)
       builder.prop.entry.line_number = -1;
       builder.ispurevirtual = 1;
       if (G__tagdefining) {
+         //fprintf(stderr, "G__make_ifunctable: Incrementing abstract count of class '%s' cnt: %d  for: '%s'\n", G__tagdefining.Name(Reflex::SCOPED).c_str(), G__struct.isabstract[G__get_tagnum(G__tagdefining)], funcheader);
          ++G__struct.isabstract[G__get_tagnum(G__tagdefining)];
       }
       if (funcname.c_str()[0] == '~') {
diff --git a/cint/cint7/src/inherit.cxx b/cint/cint7/src/inherit.cxx
index 7c19c59d5ee..a863817b4ad 100644
--- a/cint/cint7/src/inherit.cxx
+++ b/cint/cint7/src/inherit.cxx
@@ -83,6 +83,7 @@ void Cint::Internal::G__inheritclass(int to_tagnum,int from_tagnum,char baseacce
 #endif
   }
 
+  //fprintf(stderr, "G__inheritclass: Incrementing abstract count for '%s' by: %d because of '%s'\n", G__Dict::GetDict().GetScope(to_tagnum).Name(Reflex::SCOPED).c_str(), G__struct.isabstract[from_tagnum], G__Dict::GetDict().GetScope(from_tagnum).Name(Reflex::SCOPED).c_str());
   G__struct.isabstract[to_tagnum]+=G__struct.isabstract[from_tagnum];
   G__struct.funcs[to_tagnum] |= (G__struct.funcs[from_tagnum]&0xf0);
 
diff --git a/cint/cint7/src/newlink.cxx b/cint/cint7/src/newlink.cxx
index f04085ab5f8..ec380845a88 100644
--- a/cint/cint7/src/newlink.cxx
+++ b/cint/cint7/src/newlink.cxx
@@ -2418,8 +2418,9 @@ static void G__if_ary_union_reset(const ::Reflex::Member& ifunc)
 
    for (k = 0; k < m; ++k) {
       if (ifunc.FunctionParameterNameAt(k).c_str()[0]) {
-         p = strchr((char*)ifunc.FunctionParameterNameAt(k).c_str(), '[');
+         p = strchr(ifunc.FunctionParameterNameAt(k).c_str(), '[');
          if (p) {
+            fprintf(stderr, "G__if_ary_union_reset: idx: %d  name: '%s'\n", k, ifunc.FunctionParameterNameAt(k).c_str());
             assert(0);
             //int pointlevel = 1;
             //*p = 0;
@@ -4411,21 +4412,21 @@ int Cint::Internal::G__cppif_returntype(FILE* fp, const ::Reflex::Member& ifunc,
 //______________________________________________________________________________
 void Cint::Internal::G__cppif_paratype(FILE* fp, const ::Reflex::Member& ifunc, int k)
 {
-   // -- FIXME: Describe this function!
+   // TODO: Describe this function!
 #ifndef G__SMALLOBJECT
    ::Reflex::Type param_type(ifunc.TypeOf().FunctionParameterAt(k));
    std::string param_name(ifunc.FunctionParameterNameAt(k));
-   int type = G__get_type(param_type);
-   int tagnum = G__get_tagnum(param_type.RawType());
-   int typenum = G__get_typenum(param_type);
-   int reftype = G__get_reftype(param_type);
-   int isconst = G__get_isconst(param_type);
+   char type = '\0';
+   int tagnum = -1;
+   int typenum = -1;
+   int reftype = 0;
+   int isconst = 0;
+   G__get_cint5_type_tuple(param_type, &type, &tagnum, &typenum, &reftype, &isconst);
    // Promote link-off typedef to link-on if used in function.
    if (
-      typenum &&
-      G__get_properties(param_type) &&
-      G__get_properties(param_type)->globalcomp == G__NOLINK &&
-      G__get_properties(param_type)->iscpplink == G__NOLINK
+      (typenum != -1) &&
+      (G__get_properties(param_type)->globalcomp == G__NOLINK) &&
+      (G__get_properties(param_type)->iscpplink == G__NOLINK)
    ) {
       G__get_properties(param_type)->globalcomp = G__globalcomp;
    }
@@ -4435,8 +4436,8 @@ void Cint::Internal::G__cppif_paratype(FILE* fp, const ::Reflex::Member& ifunc,
    if (k) {
       fprintf(fp, ", ");
    }
-   if (param_name.c_str()[0]) {
-      char* p = strchr((char*) param_name.c_str(), '[');
+   if (param_name.size()) {
+      char* p = strchr(param_name.c_str(), '[');
       if (p) {
          fprintf(fp, "G__Ap%d->a", k);
          return;
@@ -4451,37 +4452,19 @@ void Cint::Internal::G__cppif_paratype(FILE* fp, const ::Reflex::Member& ifunc,
 #endif // G__OLDIMPLEMENTATION2191
       // --
    ) {
-      std::string castname;
       switch (reftype) {
          case G__PARANORMAL:
-            if (!param_type.IsTypedef()) {
-               break;
+            if ((typenum != -1) && param_type.IsTypedef() && param_type.ToType().IsReference()) {
+               reftype = G__PARAREFERENCE;
+               typenum = -1;
             }
-            if (G__get_reftype(param_type.ToType()) != G__PARAREFERENCE) {
+            else {
                break;
             }
-            reftype = G__PARAREFERENCE;
-            typenum = -1;
             // Note: Intentionally fall through here!
          case G__PARAREFERENCE: 
             {
-               // NOTE: It would be better if we could keep the constness ...
-               // using the unqualified name remove both the 'reference' and the 'constness'
-               if (param_type.IsReference()) {
-                  castname = param_type.Name(Reflex::SCOPED); // Want unqualified name
-               } else {
-                  Reflex::Type current = param_type.ToType();
-                  while( current.IsTypedef() ) current = current.ToType();
-                  castname = current.Name(Reflex::SCOPED);
-               }
-               //if (param_type.FinalType().IsReference()) {
-               //   // In cint5, there was only one level of typedef (recorded in the database)
-               //   // and the ref type was always in the tuple directly.  This is not true
-               //   // for Reflex and hence the trick of not passing reftype to G__type2string is
-               //   // not sufficient, we also need to make sure we strip it explicitly from the
-               //   // type. 
-               //   castname = param_type.FinalType().Name(); // Want unqualified name
-               //}
+               std::string castname(G__type2string(type, tagnum, typenum, 0, 0));
                if (islower(type)) {
                   switch (type) {
                      case 'u':
@@ -4489,192 +4472,164 @@ void Cint::Internal::G__cppif_paratype(FILE* fp, const ::Reflex::Member& ifunc,
                         break;
 #ifndef G__OLDIMPLEMENTATION1167
                      case 'd':
-                        fprintf(fp, "*(%s*) G__Doubleref(&libp->para[%d])"
-                           , castname.c_str(), k);
+                        fprintf(fp, "*(%s*) G__Doubleref(&libp->para[%d])", castname.c_str(), k);
                         break;
                      case 'l':
-                        fprintf(fp, "*(%s*) G__Longref(&libp->para[%d])"
-                           , castname.c_str(), k);
+                        fprintf(fp, "*(%s*) G__Longref(&libp->para[%d])", castname.c_str(), k);
                         break;
                      case 'i':
-                        if (tagnum == -1) /* int */
-                           fprintf(fp, "*(%s*) G__Intref(&libp->para[%d])"
-                           , castname.c_str(), k);
-                        else /* enum type */
-                           fprintf(fp, "*(%s*) libp->para[%d].ref"
-                           , castname.c_str() , k);
+                        if (tagnum == -1) { // int
+                           fprintf(fp, "*(%s*) G__Intref(&libp->para[%d])", castname.c_str(), k);
+                        }
+                        else { // enum type
+                           fprintf(fp, "*(%s*) libp->para[%d].ref", castname.c_str() , k);
+                        }
                         break;
                      case 's':
-                        fprintf(fp, "*(%s*) G__Shortref(&libp->para[%d])"
-                           , castname.c_str(), k);
+                        fprintf(fp, "*(%s*) G__Shortref(&libp->para[%d])", castname.c_str(), k);
                         break;
                      case 'c':
-                        fprintf(fp, "*(%s*) G__Charref(&libp->para[%d])"
-                           , castname.c_str(), k);
+                        fprintf(fp, "*(%s*) G__Charref(&libp->para[%d])", castname.c_str(), k);
                         break;
                      case 'h':
-                        fprintf(fp, "*(%s*) G__UIntref(&libp->para[%d])"
-                           , castname.c_str(), k);
+                        fprintf(fp, "*(%s*) G__UIntref(&libp->para[%d])", castname.c_str(), k);
                         break;
                      case 'r':
-                        fprintf(fp, "*(%s*) G__UShortref(&libp->para[%d])"
-                           , castname.c_str(), k);
+                        fprintf(fp, "*(%s*) G__UShortref(&libp->para[%d])", castname.c_str(), k);
                         break;
                      case 'b':
-                        fprintf(fp, "*(%s*) G__UCharref(&libp->para[%d])"
-                           , castname.c_str(), k);
+                        fprintf(fp, "*(%s*) G__UCharref(&libp->para[%d])", castname.c_str(), k);
                         break;
                      case 'k':
-                        fprintf(fp, "*(%s*) G__ULongref(&libp->para[%d])"
-                           , castname.c_str(), k);
+                        fprintf(fp, "*(%s*) G__ULongref(&libp->para[%d])", castname.c_str(), k);
                         break;
                      case 'n':
-                        fprintf(fp, "*(%s*) G__Longlongref(&libp->para[%d])"
+                        fprintf(fp, "*(%s*) G__Longlongref(&libp->para[%d])",
 #if defined(_MSC_VER) && (_MSC_VER < 1310) /*vc6 and vc7.0*/
-                           , "__int64", k);
+                           "__int64",
 #else // _MSC_VER && (_MSC_VER < 1310)
-                           , castname.c_str(), k);
+                           castname.c_str(),
 #endif // _MSC_VER && (_MSC_VER < 1310)
+                        k);
                         break;
                      case 'm':
-                        fprintf(fp, "*(%s*) G__ULonglongref(&libp->para[%d])"
+                        fprintf(fp, "*(%s*) G__ULonglongref(&libp->para[%d])",
 #if defined(_MSC_VER) && (_MSC_VER < 1310) /*vc6 and vc7.0*/
-                           , "unsigned __int64", k);
+                           "unsigned __int64",
 #else // _MSC_VER && (_MSC_VER < 1310)
-                           , castname.c_str(), k);
+                           castname.c_str(),
 #endif // _MSC_VER && (_MSC_VER < 1310)
+                        k);
                         break;
                      case 'q':
-                        fprintf(fp, "*(%s*) G__Longdoubleref(&libp->para[%d])"
-                           , castname.c_str(), k);
+                        fprintf(fp, "*(%s*) G__Longdoubleref(&libp->para[%d])", castname.c_str(), k);
                         break;
                      case 'g':
-                        fprintf(fp, "*(%s*) G__Boolref(&libp->para[%d])"
-                           , castname.c_str(), k);
+                        fprintf(fp, "*(%s*) G__Boolref(&libp->para[%d])", castname.c_str(), k);
                         break;
                      case 'f':
-                        fprintf(fp, "*(%s*) G__Floatref(&libp->para[%d])"
-                           , castname.c_str(), k);
+                        fprintf(fp, "*(%s*) G__Floatref(&libp->para[%d])", castname.c_str(), k);
                         break;
 #else // G__OLDIMPLEMENTATION1167
                      case 'd':
-                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mdouble(libp->para[%d])"
-                           , k, castname.c_str() , k, k);
+                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mdouble(libp->para[%d])", k, castname.c_str(), k, k);
                         break;
                      case 'l':
-                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mlong(libp->para[%d])"
-                           , k, castname.c_str() , k , k);
+                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mlong(libp->para[%d])", k, castname.c_str(), k, k);
                         break;
                      case 'i':
-                        if (-1 == tagnum) /* int */
-                           fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mint(libp->para[%d])"
-                           , k, castname.c_str() , k , k);
-                        else /* enum type */
-                           fprintf(fp, "*(%s*) libp->para[%d].ref"
-                           , castname.c_str() , k);
+                        if (-1 == tagnum) { // int
+                           fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mint(libp->para[%d])", k, castname.c_str(), k, k);
+                        }
+                        else { // enum type
+                           fprintf(fp, "*(%s*) libp->para[%d].ref", castname.c_str(), k);
+                        }
                         break;
                      case 's':
-                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mshort(libp->para[%d])"
-                           , k, castname.c_str() , k , k);
+                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mshort(libp->para[%d])", k, castname.c_str(), k, k);
                         break;
                      case 'c':
-                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mchar(libp->para[%d])"
-                           , k, castname.c_str() , k , k);
+                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mchar(libp->para[%d])", k, castname.c_str(), k, k);
                         break;
                      case 'h':
-                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Muint(libp->para[%d])"
-                           , k, castname.c_str() , k , k);
+                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Muint(libp->para[%d])", k, castname.c_str(), k, k);
                         break;
                      case 'r':
-                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mushort(libp->para[%d])"
-                           , k, castname.c_str() , k , k);
+                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mushort(libp->para[%d])", k, castname.c_str(), k, k);
                         break;
                      case 'b':
-                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Muchar(libp->para[%d])"
-                           , k, castname.c_str() , k , k);
+                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Muchar(libp->para[%d])", k, castname.c_str(), k, k);
                         break;
                      case 'k':
-                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mulong(libp->para[%d])"
-                           , k, castname.c_str() , k , k);
+                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mulong(libp->para[%d])", k, castname.c_str(), k, k);
                         break;
                      case 'n':
-                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mlonglong(libp->para[%d])"
-                           , k, castname.c_str() , k , k);
+                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mlonglong(libp->para[%d])", k, castname.c_str(), k, k);
                         break;
                      case 'm':
-                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mulonglong(libp->para[%d])"
-                           , k, castname.c_str() , k , k);
+                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mulonglong(libp->para[%d])", k, castname.c_str(), k, k);
                         break;
                      case 'q':
-                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mlongdouble(libp->para[%d])"
-                           , k, castname.c_str() , k , k);
+                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mlongdouble(libp->para[%d])", k, castname.c_str(), k, k);
                         break;
                      case 'g':
                         // --
 #ifdef G__BOOL4BYTE
-                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mint(libp->para[%d])"
-                           , k, castname.c_str() , k , k
-                           );
+                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mint(libp->para[%d])", k, castname.c_str(), k, k);
 #else // G__BOOL4BYTE
-                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Muchar(libp->para[%d])"
-                           , k, castname.c_str() , k , k
-                           );
+                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Muchar(libp->para[%d])", k, castname.c_str(), k, k);
 #endif // G__BOOL4BYTE
                         break;
                      case 'f':
-                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mfloat(libp->para[%d])"
-                           , k, castname.c_str() , k , k
-                           );
+                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : G__Mfloat(libp->para[%d])", k, castname.c_str(), k, k);
                         break;
 #endif // G__OLDIMPLEMENTATION1167
                         // --
                      default:
-                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : (%s) G__int(libp->para[%d])"
-                           , k, castname.c_str()
-                           , k, castname.c_str()
-                           , k
-                           );
+                        fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : (%s) G__int(libp->para[%d])", k, castname.c_str(), k, castname.c_str(), k);
                         break;
                   }
                }
                else {
-                  fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : *(%s*) (&G__Mlong(libp->para[%d]))"
-                     , k, castname.c_str()
-                     , k, castname.c_str()
-                     , k);
-
-               //   if (param_type.IsTypedef() && param_type.ToType().FinalType().IsPointer()) {
-               //      /* This part is not perfect. Cint data structure bug.
-               //      * typedef char* value_type;
-               //      * void f(value_type& x);  // OK
-               //      * void f(value_type x);   // OK
-               //      * void f(value_type* x);  // OK
-               //      * void f(value_type*& x); // bad
-               //      *  reference and pointer to pointer can not happen at once */
-               //      fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : *(%s*) (&G__Mlong(libp->para[%d]))"
-               //         , k, G__type2string(type, tagnum, typenum, 0, isconst & G__CONSTVAR)
-               //         , k, G__type2string(type, tagnum, typenum, 0, isconst & G__CONSTVAR)
-               //         , k);
-               //      /* above is , in fact, not good. G__type2string returns pointer to
-               //      * static buffer. This relies on the fact that the 2 calls are
-               //      * identical */
-               //   }
-               //   else {
-               //      fprintf(fp, "libp->para[%d].ref ? *(%s) libp->para[%d].ref : *(%s) (&G__Mlong(libp->para[%d]))"
-               //         , k, G__type2string(type, tagnum, typenum, 2, isconst & G__CONSTVAR)
-               //         , k, G__type2string(type, tagnum, typenum, 2, isconst & G__CONSTVAR)
-               //         , k);
-               //      /* above is , in fact, not good. G__type2string returns pointer to
-               //      * static buffer. This relies on the fact that the 2 calls are
-               //      * identical */
-               //   }
+                  if ((typenum != -1) && param_type.IsTypedef() && isupper(G__get_type(param_type.ToType()))) {
+                     // This part is not perfect. Cint data structure bug.
+                     // typedef char* value_type;
+                     // void f(value_type& x);  // OK
+                     // void f(value_type x);   // OK
+                     // void f(value_type* x);  // OK
+                     // void f(value_type*& x); // bad
+                     //  reference and pointer to pointer can not happen at once
+                     fprintf(
+                          fp
+                        , "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : *(%s*) (&G__Mlong(libp->para[%d]))"
+                        , k
+                        , G__type2string(type, tagnum, typenum, 0, isconst & G__CONSTVAR)
+                        , k
+                        , G__type2string(type, tagnum, typenum, 0, isconst & G__CONSTVAR)
+                        , k
+                     );
+                  }
+                  else {
+                     fprintf(
+                          fp
+                        , "libp->para[%d].ref ? *(%s) libp->para[%d].ref : *(%s) (&G__Mlong(libp->para[%d]))"
+                        , k
+                        , G__type2string(type, tagnum, typenum, 2, isconst&G__CONSTVAR)
+                        , k
+                        , G__type2string(type, tagnum, typenum, 2, isconst&G__CONSTVAR)
+                        , k
+                     );
+                     // above is , in fact, not good. G__type2string returns pointer to
+                     // static buffer. This relies on the fact that the 2 calls are
+                     // identical
+                  }
                }
                return;
             }
          case G__PARAREFP2P:
          case G__PARAREFP2P2P:
             reftype = G__PLVL(reftype);
-            if (param_type.IsTypedef() && param_type.ToType().RawType().IsPointer()) {
+            if ((typenum != -1) && param_type.IsTypedef() && isupper(G__get_type(param_type.ToType()))) {
                fprintf(fp, "libp->para[%d].ref ? *(%s*) libp->para[%d].ref : *(%s*) (&G__Mlong(libp->para[%d]))"
                        , k, G__type2string(type, tagnum, typenum, reftype, isconst)
                        , k, G__type2string(type, tagnum, typenum, reftype, isconst), k
@@ -4742,7 +4697,7 @@ void Cint::Internal::G__cppif_paratype(FILE* fp, const ::Reflex::Member& ifunc,
          fprintf(fp, "(%s) G__double(libp->para[%d])", G__type2string(type, tagnum, typenum, 0, isconst), k);
          break;
       case 'u':
-         if ('e' == G__struct.type[tagnum]) {
+         if (G__struct.type[tagnum] == 'e') {
             fprintf(fp, "(%s) G__int(libp->para[%d])", G__type2string(type, tagnum, typenum, 0, isconst), k);
          }
          else {
diff --git a/cint/cint7/src/rflxutil.cxx b/cint/cint7/src/rflxutil.cxx
index 5ba8f6070f0..bcab84373ac 100644
--- a/cint/cint7/src/rflxutil.cxx
+++ b/cint/cint7/src/rflxutil.cxx
@@ -36,6 +36,133 @@ size_t Cint::Internal::GetReflexPropertyID()
    return reflexPropertyID;
 }
 
+//______________________________________________________________________________
+void Cint::Internal::G__get_cint5_type_tuple(const ::Reflex::Type in_type, char* out_type, int* out_tagnum, int* out_typenum, int* out_reftype, int* out_constvar)
+{
+   // Return the cint5 type tuple for a reflex type.
+   //
+   // Note: Some C++ types cannot be represented by a cint5 type tuple.
+   //
+   //--
+   //
+   //  Get the type part.
+   //
+   *out_type = G__get_type(in_type);
+   //
+   //  Get the tagnum part.
+   //
+   {
+      *out_tagnum = -1;
+      for (::Reflex::Type current = in_type; current; current = current.ToType()) {
+         if (current.IsClass() || current.IsUnion() || current.IsEnum()) {
+            *out_tagnum = G__get_properties(current)->tagnum;
+            break;
+         }
+      }
+   }
+   //
+   //  Get the typenum part.
+   //
+   //  Note: This is not right because cint5 can only have certain type nodes
+   //        above a typedef, but this is good enough for now.
+   //
+   {
+      *out_typenum = -1;
+      for (::Reflex::Type current = in_type; current; current = current.ToType()) {
+         if (current.IsTypedef()) {
+            *out_typenum = G__get_properties(current)->typenum;
+            break;
+         }
+      }
+   }
+   //
+   // Get CINT reftype for a type (PARANORMAL, PARAREFERENCE, etc.).
+   //
+   // Given this:
+   //
+   //      typedef char& cref;
+   //      void f(cref a);
+   //
+   // cint v5 does not consider function parameter "a" to be a reference.
+   //
+   // Type in cint v5 is a five-tuple (type, tagnum, typenum, reftype=(ref,ptr-level), const)
+   // and here it would be: ('c', -1, ('c', -1, -1, (ref, 0), 0), (notref,0), 0).
+   //
+   // Given this:
+   //
+   //      typedef char* ch;
+   //      void f(ch**& a);
+   //
+   // cint v5 considers "a" to be: ('C', -1, ('C', -1, -1, (notref, 0), 0), (ref, 2), 0)
+   //
+   // Given this:
+   //
+   //      typedef char* cp;
+   //      typedef cp*   cpp;
+   //      void f(cpp**& a);
+   //
+   // cint v5 considers "a" to be: ('C', -1, ('C', -1, -1, (notref, 2), 0), (ref, 2), 0)
+   //
+   // Note that cint v5 cannot remember more than one level of typedef deep.
+   //
+   {
+      bool isref = in_type.IsReference();
+      ::Reflex::Type current = in_type; 
+      for (; !isref && current && current.IsTypedef();) {
+         current = current.ToType();
+         isref = current.IsReference();
+      }
+      // Count pointer levels.
+      int pointers = 0;
+      for (; current && current.IsPointer(); current = current.ToType()) {
+         ++pointers;
+      }
+      *out_reftype = G__PARANORMAL;
+      if (pointers > 1) {
+         *out_reftype = (isref * G__PARAREF) + pointers;
+      } else if (isref) {
+         *out_reftype = G__PARAREFERENCE;
+      }
+   }
+   //
+   //  Now get the constvar part.
+   //
+   //  Note: This is not right, the correct setting of G__PCONSTVAR depends
+   //        on where the space characters were in the declaration in the
+   //        source code.  We do not have that information available.
+   //
+   {
+      *out_constvar = 0;
+      if (in_type.IsFunction()) {
+         if (in_type.IsConst()) {
+            *out_constvar |= G__CONSTFUNC;
+         }
+         if (in_type.ReturnType().IsConst()) {
+            *out_constvar |= G__CONSTVAR;
+         }
+      }
+      else {
+         bool ptr_or_ref_seen = false;
+         bool accumulated_const = false;
+         for (::Reflex::Type current = in_type; current; current = current.ToType()) {
+            accumulated_const = accumulated_const || current.IsConst();
+            if (current.IsPointer() || current.IsReference()) {
+               accumulated_const = false;
+               if (!ptr_or_ref_seen) {
+                  ptr_or_ref_seen = true;
+                  if (current.IsConst()) {
+                     *out_constvar |= G__PCONSTVAR;
+                  }
+               }
+            }
+         }
+         if (accumulated_const) {
+            *out_constvar |= G__CONSTVAR;
+         }
+      }
+   }
+}
+
 //______________________________________________________________________________
 extern "C" int G__value_get_type(G__value *buf)
 {
@@ -43,7 +170,7 @@ extern "C" int G__value_get_type(G__value *buf)
 }
 
 //______________________________________________________________________________
-int Cint::Internal::G__get_type(const ::Reflex::Type& in)
+int Cint::Internal::G__get_type(const ::Reflex::Type in)
 {
    // -- Get CINT type code for data type.
    // Note: Structures are all 'u'.
@@ -141,7 +268,7 @@ int Cint::Internal::G__get_type(const G__value& in)
 }
 
 //______________________________________________________________________________
-int Cint::Internal::G__get_tagtype(const ::Reflex::Type& in)
+int Cint::Internal::G__get_tagtype(const ::Reflex::Type in)
 {
    // -- Get CINT type code for a structure (c,s,e,u).
    switch (in.RawType().TypeType()) {
@@ -155,7 +282,7 @@ int Cint::Internal::G__get_tagtype(const ::Reflex::Type& in)
 }
 
 //______________________________________________________________________________
-int Cint::Internal::G__get_tagtype(const ::Reflex::Scope& in)
+int Cint::Internal::G__get_tagtype(const ::Reflex::Scope in)
 {
    // -- Get CINT type code for a structure (c,s,e,u).
    
@@ -171,7 +298,7 @@ int Cint::Internal::G__get_tagtype(const ::Reflex::Scope& in)
 }
 
 //______________________________________________________________________________
-int Cint::Internal::G__get_reftype(const ::Reflex::Type& in)
+int Cint::Internal::G__get_reftype(const ::Reflex::Type in)
 {
    // -- Get CINT reftype for a type (PARANORMAL, PARAREFERENCE, etc.).
    //
@@ -229,7 +356,7 @@ int Cint::Internal::G__get_reftype(const ::Reflex::Type& in)
 }
 
 //______________________________________________________________________________
-G__RflxProperties *Cint::Internal::G__get_properties(const ::Reflex::Type& in)
+G__RflxProperties* Cint::Internal::G__get_properties(const ::Reflex::Type in)
 {
    // -- Get REFLEX property list from a data type.
    if (!in) {
@@ -243,7 +370,7 @@ G__RflxProperties *Cint::Internal::G__get_properties(const ::Reflex::Type& in)
 }
 
 //______________________________________________________________________________
-G__RflxProperties *Cint::Internal::G__get_properties(const ::Reflex::Scope& in)
+G__RflxProperties* Cint::Internal::G__get_properties(const ::Reflex::Scope in)
 {
    // -- Get REFLEX property list from a scope.
    if (!in) {
@@ -257,7 +384,7 @@ G__RflxProperties *Cint::Internal::G__get_properties(const ::Reflex::Scope& in)
 }
 
 //______________________________________________________________________________
-G__RflxVarProperties *Cint::Internal::G__get_properties(const ::Reflex::Member& in)
+G__RflxVarProperties* Cint::Internal::G__get_properties(const ::Reflex::Member in)
 {
    // -- Get REFLEX property list from a class member.
    if (!in || !in.IsDataMember()) {
@@ -272,7 +399,7 @@ G__RflxVarProperties *Cint::Internal::G__get_properties(const ::Reflex::Member&
 }
 
 //______________________________________________________________________________
-G__RflxFuncProperties *Cint::Internal::G__get_funcproperties(const ::Reflex::Member& in)
+G__RflxFuncProperties* Cint::Internal::G__get_funcproperties(const ::Reflex::Member in)
 {
    // -- Get REFLEX property list from a class member function.
    if (!in || !(in.IsFunctionMember() || in.IsTemplateInstance())) {
@@ -288,7 +415,7 @@ G__RflxFuncProperties *Cint::Internal::G__get_funcproperties(const ::Reflex::Mem
 }
 
 //______________________________________________________________________________
-G__SIGNEDCHAR_T Cint::Internal::G__get_isconst(const ::Reflex::Type& in)
+G__SIGNEDCHAR_T Cint::Internal::G__get_isconst(const ::Reflex::Type in)
 {
    // -- Is data type const qualified?
    ::Reflex::Type current = in; // .FinalType(); is currently buggy
@@ -318,7 +445,7 @@ G__SIGNEDCHAR_T Cint::Internal::G__get_isconst(const ::Reflex::Type& in)
 }
 
 //______________________________________________________________________________
-int Cint::Internal::G__get_nindex(const ::Reflex::Type& passed_type)
+int Cint::Internal::G__get_nindex(const ::Reflex::Type passed_type)
 {
    // -- Get dimensionality of a data type.
 
@@ -341,7 +468,7 @@ int Cint::Internal::G__get_nindex(const ::Reflex::Type& passed_type)
 }
 
 //______________________________________________________________________________
-std::vector<int> Cint::Internal::G__get_index(const ::Reflex::Type& passed_var)
+std::vector<int> Cint::Internal::G__get_index(const ::Reflex::Type passed_var)
 {
    // -- Get CINT array maximum dimensions as a std::vector<int> for a data type.
    //
@@ -509,14 +636,14 @@ std::vector<int> Cint::Internal::G__get_varlabel_as_vector(const ::Reflex::Type&
 #endif
 
 //______________________________________________________________________________
-int Cint::Internal::G__get_varlabel(const Reflex::Member& var, int idx)
+int Cint::Internal::G__get_varlabel(const Reflex::Member var, int idx)
 {
    // -- Get CINT varlabel for a class member.
    return G__get_varlabel(var.TypeOf(), idx);
 }
 
 //______________________________________________________________________________
-int Cint::Internal::G__get_varlabel(const Reflex::Type& passed_var, int idx)
+int Cint::Internal::G__get_varlabel(const Reflex::Type passed_var, int idx)
 {
    // -- Get CINT varlabel for a data type.
    //
@@ -638,7 +765,7 @@ int Cint::Internal::G__get_varlabel(const Reflex::Type& passed_var, int idx)
 }
 
 //______________________________________________________________________________
-int Cint::Internal::G__get_typenum(const ::Reflex::Type& in)
+int Cint::Internal::G__get_typenum(const ::Reflex::Type in)
 {
    // -- Get CINT typenum for a given typedef type.
    if (!in.IsTypedef()) {
@@ -652,7 +779,7 @@ int Cint::Internal::G__get_typenum(const ::Reflex::Type& in)
 }
 
 //______________________________________________________________________________
-int Cint::Internal::G__get_tagnum(const ::Reflex::Type& in)
+int Cint::Internal::G__get_tagnum(const ::Reflex::Type in)
 {
    // -- Get CINT tagnum for a given type.
    // Note: Only class types have a tagnum.
@@ -664,7 +791,7 @@ int Cint::Internal::G__get_tagnum(const ::Reflex::Type& in)
 }
 
 //______________________________________________________________________________
-int Cint::Internal::G__get_tagnum(const ::Reflex::Scope& in)
+int Cint::Internal::G__get_tagnum(const ::Reflex::Scope in)
 {
    // -- Get CINT tagnum for a given scope.
    // Note: Only class scopes have a tagnum.
@@ -733,7 +860,7 @@ const ::Reflex::Type& Cint::Internal::G__value_typenum(const G__value& gv)
        *   z : switchDefault
        *   Z : codeBreak (continue, break, goto)
        ****************************************************/
-   case 'a': return ::Reflex::Type::ByName("switchStart$");
+   //case 'a': return ::Reflex::Type::ByName("switchStart$");
    case 'z': return ::Reflex::Type::ByName("switchDefault$");
    case 'Z': return ::Reflex::Type::ByName("codeBreak$");
    case 'p': return ::Reflex::Type::ByName("macroInt$");
@@ -801,7 +928,7 @@ const ::Reflex::Type& Cint::Internal::G__value_typenum(const G__value& gv)
 }
 
 //______________________________________________________________________________
-bool Cint::Internal::G__is_localstaticbody(const Reflex::Member& var)
+bool Cint::Internal::G__is_localstaticbody(const Reflex::Member var)
 {
    // -- Is var is a static variable in an interpreted function body?
 
@@ -810,7 +937,7 @@ bool Cint::Internal::G__is_localstaticbody(const Reflex::Member& var)
 }
 
 //______________________________________________________________________________
-int Cint::Internal::G__get_paran(const Reflex::Member& var) {
+int Cint::Internal::G__get_paran(const Reflex::Member var) {
    // -- Get the CINT paran for a REFLEX class member.
    // Note: This is zero if the member is not an array,
    //       otherwise it is the number of array dimensions.
@@ -818,25 +945,25 @@ int Cint::Internal::G__get_paran(const Reflex::Member& var) {
 }
 
 //______________________________________________________________________________
-size_t Cint::Internal::G__get_bitfield_width(const Reflex::Member& var)
+size_t Cint::Internal::G__get_bitfield_width(const Reflex::Member var)
 {
    return G__get_properties(var)->bitfield_width;
 }
 
 //______________________________________________________________________________
-size_t Cint::Internal::G__get_bitfield_start(const Reflex::Member& var)
+size_t Cint::Internal::G__get_bitfield_start(const Reflex::Member var)
 {
    return G__get_properties(var)->bitfield_start;
 }
 
 //______________________________________________________________________________
-char*& Cint::Internal::G__get_offset(const ::Reflex::Member& var) 
+char*& Cint::Internal::G__get_offset(const ::Reflex::Member var) 
 {
    return G__get_properties(var)->addressOffset;
 }
 
 //______________________________________________________________________________
-Reflex::Type Cint::Internal::G__strip_array(const Reflex::Type &typein)
+Reflex::Type Cint::Internal::G__strip_array(const Reflex::Type typein)
 {
    // Return the type obtains after stripping all array dimensions.
 
@@ -853,7 +980,7 @@ Reflex::Type Cint::Internal::G__strip_array(const Reflex::Type &typein)
 }
 
 //______________________________________________________________________________
-Reflex::Type Cint::Internal::G__strip_one_array(const Reflex::Type &typein)
+Reflex::Type Cint::Internal::G__strip_one_array(const Reflex::Type typein)
 {
    // Remove one array node from the type.
 
@@ -868,7 +995,7 @@ Reflex::Type Cint::Internal::G__strip_one_array(const Reflex::Type &typein)
 }
 
 //______________________________________________________________________________
-Reflex::Type Cint::Internal::G__deref(const Reflex::Type &typein)
+Reflex::Type Cint::Internal::G__deref(const Reflex::Type typein)
 {
    // Return the type equivalent to the return type of the default unary operator*
    // of the type 'typein' (aka for float* returns float).
@@ -884,7 +1011,7 @@ Reflex::Type Cint::Internal::G__deref(const Reflex::Type &typein)
 }
 
 //______________________________________________________________________________
-::Reflex::Type Cint::Internal::G__modify_type(const ::Reflex::Type& typein, bool ispointer, int reftype, int isconst, int nindex, int* index)
+::Reflex::Type Cint::Internal::G__modify_type(const ::Reflex::Type typein, bool ispointer, int reftype, int isconst, int nindex, int* index)
 {
    // -- Construct a new REFLEX Type based on a given type.
    int ref = G__REF(reftype);
@@ -955,39 +1082,48 @@ Reflex::Type Cint::Internal::G__deref(const Reflex::Type &typein)
 }
 
 //______________________________________________________________________________
-static void G__dumpreflex(const ::Reflex::Scope& scope, int level)
+void G__dumpreflex_atlevel(const ::Reflex::Scope scope, int level)
 {
+   for (
+      ::Reflex::Member_Iterator m = scope.DataMember_Begin();
+      m != scope.DataMember_End();
+      ++m
+   ) {
+         for (int i=0; i<level; ++i)
+            fprintf(stderr, " ");
+         fprintf(stderr, "data member: '%s'\n", m->Name(Reflex::SCOPED | Reflex::QUALIFIED).c_str());
+   }
    for (::Reflex::Scope_Iterator iscope = scope.SubScope_Begin();
       iscope != scope.SubScope_End(); ++iscope) {
          for (int i=0; i<level; ++i)
-            printf(" ");
-         printf("%s %s\n", iscope->IsClass()?"class":"scope", iscope->Name().c_str());
-         G__dumpreflex(*iscope, level+1);
+            fprintf(stderr, " ");
+         fprintf(stderr, "%s %s\n", iscope->IsClass()?"class":"scope", iscope->Name(Reflex::SCOPED | Reflex::QUALIFIED).c_str());
+         G__dumpreflex_atlevel(*iscope, level+1);
    }
    for (::Reflex::Type_Iterator itype = scope.SubType_Begin();
       itype != scope.SubType_End(); ++itype) {
          if (itype->IsClass()) continue;
          for (int i=0; i<level; ++i)
-            printf(" ");
-         printf("%s %s\n", itype->TypeTypeAsString().c_str(), itype->Name().c_str());
+            fprintf(stderr, " ");
+         fprintf(stderr, "%s %s\n", itype->TypeTypeAsString().c_str(), itype->Name(Reflex::SCOPED | Reflex::QUALIFIED).c_str());
    }
 }
 
 //______________________________________________________________________________
-static void G__dumpreflex_function(const ::Reflex::Scope& scope, int level)
+void G__dumpreflex_function(const ::Reflex::Scope scope, int level)
 {
    for (::Reflex::Scope_Iterator iscope = scope.SubScope_Begin();
       iscope != scope.SubScope_End(); ++iscope) {
          for (int i=0; i<level; ++i)
-            printf(" ");
-         printf("%s %s\n", iscope->IsClass()?"class":"scope", iscope->Name().c_str());
+            fprintf(stderr, " ");
+         fprintf(stderr, "%s %s\n", iscope->IsClass()?"class":"scope", iscope->Name(Reflex::SCOPED | Reflex::QUALIFIED).c_str());
          G__dumpreflex_function(*iscope, level+1);
    }
    for (::Reflex::Member_Iterator itype = scope.FunctionMember_Begin();
       itype != scope.FunctionMember_End(); ++itype) {
          for (int i=0; i<level; ++i)
-            printf(" ");
-         printf("%s\n", itype->Name().c_str());
+            fprintf(stderr, " ");
+         fprintf(stderr, "%s\n", itype->Name(Reflex::SCOPED | Reflex::QUALIFIED).c_str());
    }
 }
 
@@ -995,11 +1131,11 @@ static void G__dumpreflex_function(const ::Reflex::Scope& scope, int level)
 void Cint::Internal::G__dumpreflex()
 {
    return;
-   ::G__dumpreflex(::Reflex::Scope::GlobalScope(), 0);
+   ::G__dumpreflex_atlevel(::Reflex::Scope::GlobalScope(), 0);
 }
 
 //______________________________________________________________________________
-::Reflex::Type Cint::Internal::G__findInScope(const ::Reflex::Scope& scope, const char* name)
+::Reflex::Type Cint::Internal::G__findInScope(const ::Reflex::Scope scope, const char* name)
 {
    // -- Find a REFLEX Type in a REFLEX Scope by name.
    ::Reflex::Type cl;
@@ -1021,7 +1157,7 @@ void Cint::Internal::G__dumpreflex()
 }
 
 //______________________________________________________________________________
-bool Cint::Internal::G__test_access(const ::Reflex::Member &var, int access)
+bool Cint::Internal::G__test_access(const ::Reflex::Member var, int access)
 {
    // Return true if the member (var or function) is accessible
    // with the access level described by 'access'
@@ -1037,41 +1173,38 @@ bool Cint::Internal::G__test_access(const ::Reflex::Member &var, int access)
 }
 
 //______________________________________________________________________________
-bool Cint::Internal::G__is_cppmacro(const ::Reflex::Member &var)
+bool Cint::Internal::G__is_cppmacro(const ::Reflex::Member var)
 {
    return (var.TypeOf().RawType().Name() == "$MACRO$");
 }
 
 //______________________________________________________________________________
-bool Cint::Internal::G__test_const(const ::Reflex::Type &type, int what_const)
+bool Cint::Internal::G__test_const(const ::Reflex::Type type, int what_const)
 {
-   switch(what_const){
-      case G__VARIABLE:
-         {
-            G__SIGNEDCHAR_T what = G__get_isconst( type );
-            return what == what_const;
-         }
+   switch (what_const) {
+      case G__VARIABLE: {
+         G__SIGNEDCHAR_T what = G__get_isconst(type);
+         return what == what_const;
+      }
       case G__CONSTVAR:
       case G__PCONSTVAR:
       case G__PCONSTCONSTVAR:
-      case G__CONSTFUNC:
-         {
-            G__SIGNEDCHAR_T what = G__get_isconst( type );
-            return what & what_const;
-         }
-      case G__STATICCONST:
-         {
-            assert(0); // return var.IsStatic() && var.TypeOf().IsConst();
-         }
+      case G__CONSTFUNC: {
+         G__SIGNEDCHAR_T what = G__get_isconst(type);
+         return what & what_const;
+      }
+      case G__STATICCONST: {
+         assert(0); // return var.IsStatic() && var.TypeOf().IsConst();
+      }
       case G__LOCKVAR:
          // case G__DYNCONST: aliased to something else!
-         assert (0); // return G__get_properties(var)->lock;
+         assert(0);  // return G__get_properties(var)->lock;
    }
-   return false; 
+   return false;
 }
 
 //______________________________________________________________________________
-bool Cint::Internal::G__test_const(const ::Reflex::Member &var, int what_const)
+bool Cint::Internal::G__test_const(const ::Reflex::Member var, int what_const)
 {
    switch(what_const){
    case G__VARIABLE:
@@ -1099,38 +1232,78 @@ bool Cint::Internal::G__test_const(const ::Reflex::Member &var, int what_const)
 }
 
 //______________________________________________________________________________
-bool Cint::Internal::G__test_static(const ::Reflex::Member &var, int what_static, int filenum)
+bool Cint::Internal::G__filescopeaccess(int filenum, int statictype)
 {
-   switch(what_static) {
-   case G__AUTO:
-      return !var.IsStatic() && !G__get_properties(var)->isCompiledGlobal;
-   case G__LOCALSTATIC:
-      return var.IsStatic();
-      // was: break;
-   case G__LOCALSTATICBODY:
-      if (var.IsStatic()) {
-         ::Reflex::Scope d( var.DeclaringScope() );
-         if (! (d.IsClass() || d.IsEnum() || d.IsUnion() || d.IsNamespace() ) ) {
-            assert ( (d.Name()[d.Name().length()-1]=='$') );
-            // The declaring scope is a block or function scope
+   int store_filenum = filenum;
+   int store_statictype = statictype;
+
+   // Return true if filenum describe a file including the file defining
+   // the static variable.
+   if (filenum == statictype) {
+      return true;
+   }
+
+   while (statictype >= 0) {
+      statictype = G__srcfile[statictype].included_from;
+      if (filenum == statictype) {
+         return true;
+      }
+   }
+
+   // Return true if the static variable is defined in any of the
+   // file including the file describe by 'filenum'
+   statictype = store_statictype;
+   while (statictype >= 0) {
+      filenum = store_filenum;
+      if (filenum == statictype) {
+         return true;
+      }
+      statictype = G__srcfile[statictype].included_from;
+      while (filenum >= 0) {
+         if (filenum == statictype) {
             return true;
          }
+         filenum = G__srcfile[filenum].included_from;
       }
-      return false;
-      break;
-   case G__AUTOARYDISCRETEOBJ:
-      return !var.IsStatic() && var.TypeOf().FinalType().IsArray();
-      break;
-   case G__COMPILEDGLOBAL:
-      return G__get_properties(var)->isCompiledGlobal;
+   }
+   return false;
+}
+
+//______________________________________________________________________________
+bool Cint::Internal::G__test_static(const ::Reflex::Member var, int what_static, int filenum)
+{
+   switch (what_static) {
+      case G__AUTO:
+         return !var.IsStatic() && !G__get_properties(var)->isCompiledGlobal;
+      case G__LOCALSTATIC:
+         return var.IsStatic();
+      case G__LOCALSTATICBODY:
+         if (var.IsStatic()) {
+            ::Reflex::Scope d(var.DeclaringScope());
+            if (!(d.IsClass() || d.IsEnum() || d.IsUnion() || d.IsNamespace())) {
+               assert((d.Name()[d.Name().length()-1] == '$'));
+               // The declaring scope is a block or function scope
+               return true;
+            }
+         }
+         return false;
+      case G__AUTOARYDISCRETEOBJ:
+         return !var.IsStatic() && var.TypeOf().FinalType().IsArray();
+      case G__COMPILEDGLOBAL:
+         return G__get_properties(var)->isCompiledGlobal;
    }
 
 
-   if (what_static == 0) {
+   if (!what_static) {
       // Need to return true if any of the case above are true!
 
-      if (!var.IsStatic()) return true;
-      if (var.DeclaringScope().IsClass()) return true;
+      if (!var.IsStatic()) {
+         return true;
+      }
+
+      if (var.DeclaringScope().IsClass()) {
+         return true;
+      }
 
       int statictype = G__get_properties(var)->filenum;
       int store_filenum = filenum;
@@ -1138,32 +1311,40 @@ bool Cint::Internal::G__test_static(const ::Reflex::Member &var, int what_static
 
       // Return true if filenum describe a file including the file defining
       // the static variable.
-      if(filenum==statictype) return true;
-      while(statictype>=0) {
+      if (filenum == statictype) {
+         return true;
+      }
+
+      while (statictype >= 0) {
          statictype = G__srcfile[statictype].included_from;
-         if(filenum==statictype) return true;
+         if (filenum == statictype) {
+            return true;
+         }
       }
 
       // Return true if the static variable is defined in any of the
       // file including the file describe by 'filenum'
       statictype = store_statictype;
-      while(statictype>=0) {
+      while (statictype >= 0) {
          filenum = store_filenum;
-         if(filenum==statictype) return true;
+         if (filenum == statictype) {
+            return true;
+         }
          statictype = G__srcfile[statictype].included_from;
-         while(filenum>=0) {
-            if(filenum==statictype) return true;
+         while (filenum >= 0) {
+            if (filenum == statictype) {
+               return true;
+            }
             filenum = G__srcfile[filenum].included_from;
          }
       }
-      return false;
    }
 
    return false;
 }
 
 //______________________________________________________________________________
-Reflex::Type Cint::Internal::G__replace_rawtype(const Reflex::Type& target, const Reflex::Type& raw)
+Reflex::Type Cint::Internal::G__replace_rawtype(const Reflex::Type target, const Reflex::Type raw)
 {
    // copy with modifiers
    if (target.FinalType().ToType() != target.FinalType()) {
@@ -1194,7 +1375,7 @@ Reflex::Type Cint::Internal::G__replace_rawtype(const Reflex::Type& target, cons
 }
 
 //______________________________________________________________________________
-void Cint::Internal::G__set_G__tagnum(const ::Reflex::Scope& scope)
+void Cint::Internal::G__set_G__tagnum(const ::Reflex::Scope scope)
 {
    if (scope) {
       G__tagnum = scope;
@@ -1205,7 +1386,7 @@ void Cint::Internal::G__set_G__tagnum(const ::Reflex::Scope& scope)
 }
 
 //______________________________________________________________________________
-void Cint::Internal::G__set_G__tagnum(const ::Reflex::Type& type)
+void Cint::Internal::G__set_G__tagnum(const ::Reflex::Type type)
 {
    ::Reflex::Scope s = type.RawType();
    G__set_G__tagnum(s);
@@ -1263,7 +1444,7 @@ void Cint::Internal::G__set_G__tagnum(const G__value& result)
 }
 
 //______________________________________________________________________________
-int ::Cint::Internal::G__get_access(const ::Reflex::Member& mem) 
+int ::Cint::Internal::G__get_access(const ::Reflex::Member mem) 
 {
    if (mem.IsPublic()) return G__PUBLIC;
    else if(mem.IsProtected()) return G__PROTECTED;
@@ -1272,7 +1453,7 @@ int ::Cint::Internal::G__get_access(const ::Reflex::Member& mem)
 }
 
 //______________________________________________________________________________
-int ::Cint::Internal::G__get_static(const ::Reflex::Member& mem) 
+int ::Cint::Internal::G__get_static(const ::Reflex::Member mem) 
 {
    if (mem.IsDataMember() && G__get_properties(mem)->isCompiledGlobal) {
       return G__COMPILEDGLOBAL;
@@ -1520,12 +1701,15 @@ void Cint::Internal::G__BuilderInfo::AddParameter(int ifn, int type, int numeric
    //        add the created function type as a member of any Reflex::Scope.
    //
    ::Reflex::Type ftype = Reflex::FunctionTypeBuilder(returnType, params_type, typeid(::Reflex::UnknownType));
+   //if (!G__tagdefining.Name().compare("TMatrixT<double>")) {
+   //   fprintf(stderr, "G__BuilderInfo::Build: Abstract count for '%s' count: %d  for: '%s'\n", G__tagdefining.Name(Reflex::SCOPED).c_str(), G__struct.isabstract[G__get_properties(G__tagdefining)->tagnum], name.c_str());
+   //}
    //fprintf(stderr, "G__BuilderInfo::Build: processing function '%s' type '%s'.\n", name.c_str(), ftype.Name(Reflex::SCOPED | Reflex::QUALIFIED).c_str());
    //fprintf(stderr, "G__Builderinfo::Build: isconst: %d\n", isconst);
    //fprintf(stderr, "G__Builderinfo::Build: isexplicit: %d\n", isexplicit);
    //fprintf(stderr, "G__Builderinfo::Build: staticalloc: %d\n", (int) staticalloc);
    //fprintf(stderr, "G__Builderinfo::Build: isvirtual: %d\n", isvirtual);
-   //fprintf(stderr, "G__Builderinfo::Build: ispurvirtual: %d\n", ispurevirtual);
+   //fprintf(stderr, "G__Builderinfo::Build: ispurevirtual: %d\n", ispurevirtual);
    for (
       std::vector<Reflex::Type>::iterator iter = params_type.begin();
       iter != params_type.end();
@@ -1578,11 +1762,9 @@ void Cint::Internal::G__BuilderInfo::AddParameter(int ifn, int type, int numeric
    //  Check if we should be virtual because we
    //  are declared virtual in a base class.
    //
-   if ( // not previously declared, and is not virtual, and is a member function
-      !m && // not previous declared, and
-      !isvirtual && // is not virtual, and
-      (G__tagdefining && !G__tagdefining.IsTopScope()) // is a member function
-      // TODO: Add: && (G__tagdefining && !G__tagdefining.IsNamespace()) if we can call for non-class members.
+   if ( // is a member function, and not previously declared
+      (G__tagdefining && G__tagdefining.IsClass()) && // is a member function, and
+      !m // not previous declared
    ) {
       struct G__inheritance* baseclass = G__struct.baseclass[G__get_tagnum(G__tagdefining)];
       for (int basen = 0; basen < baseclass->basen; ++basen) {
@@ -1592,6 +1774,7 @@ void Cint::Internal::G__BuilderInfo::AddParameter(int ifn, int type, int numeric
          if (base_m) {
             int tagnum_tagdefining  = G__get_tagnum(G__tagdefining);
             if (base_m.IsAbstract() && G__struct.isabstract[tagnum_tagdefining]) {
+               //fprintf(stderr, "G__BuilderInfo::Build: Decrement abstract count for '%s' count: %d\n", G__tagdefining.Name(Reflex::SCOPED).c_str(), G__struct.isabstract[tagnum_tagdefining]);
                --G__struct.isabstract[tagnum_tagdefining]; // We now have one less pure virtual member function.
             }
             if (base_m.IsVirtual()) {
@@ -1650,6 +1833,7 @@ void Cint::Internal::G__BuilderInfo::AddParameter(int ifn, int type, int numeric
          // if (m.IsConst() != isconst)
          if (ispurevirtual & !m.IsAbstract()) {
             if (G__tagdefining) {
+               //fprintf(stderr, "G__BuilderInfo::Build: 2 Decrement abstract count for '%s' count: %d\n", G__tagdefining.Name(Reflex::SCOPED).c_str(), G__struct.isabstract[G__get_tagnum(G__tagdefining)]);
                --G__struct.isabstract[G__get_tagnum(G__tagdefining)];
             }
          }
@@ -1674,6 +1858,7 @@ void Cint::Internal::G__BuilderInfo::AddParameter(int ifn, int type, int numeric
       }
       else {
          if (ispurevirtual && G__tagdefining) {
+            //fprintf(stderr, "G__BuilderInfo::Build: 3 Decrement abstract count for '%s' count: %d\n", G__tagdefining.Name(Reflex::SCOPED).c_str(), G__struct.isabstract[G__get_tagnum(G__tagdefining)]);
             --G__struct.isabstract[G__get_tagnum(G__tagdefining)];
          }
       }
@@ -1800,7 +1985,7 @@ void Cint::Internal::G__BuilderInfo::AddParameter(int ifn, int type, int numeric
       //::Reflex::FunctionBuilder funcBuilder(ftype, fullname.c_str(), 0 /*stubFP*/, 0 /*stubCtx*/, GetParamNames().c_str(), modifiers);
       //m = funcBuilder.ToMember();
       if (!m) {
-         fprintf(stderr, "G__BuilderInfo::Build: Something went wrong creating entry for '%s' in '%s'\n", name.c_str(), G__p_ifunc.Name(::Reflex::SCOPED | ::Reflex::QUALIFIED).c_str());
+         //fprintf(stderr, "G__BuilderInfo::Build: Something went wrong creating entry for '%s' in '%s'\n", name.c_str(), G__p_ifunc.Name(::Reflex::SCOPED | ::Reflex::QUALIFIED).c_str());
          G__dumpreflex_function(G__p_ifunc, 1);
          return m;
       }
diff --git a/cint/cint7/src/struct.cxx b/cint/cint7/src/struct.cxx
index 8df0e7abfef..83cb54482af 100644
--- a/cint/cint7/src/struct.cxx
+++ b/cint/cint7/src/struct.cxx
@@ -1033,6 +1033,7 @@ extern "C" int G__search_tagname(const char *tagname, int type)
                   // -- Enum.
                {
                   //::Reflex::EnumBuilder *b = new ::Reflex::EnumBuilder( fullname.c_str() );
+                  //fprintf(stderr, "G__search_tagname: Building enum '%s'\n", fullname.c_str());
                   cl = ::Reflex::EnumTypeBuilder(fullname.c_str());
                   //G__get_properties(cl)->builder.Set(b);
                   break;
@@ -1236,7 +1237,7 @@ extern "C" int G__search_tagname(const char *tagname, int type)
       };
    }
    // Mutable and Register are ignored
-   if (var_statictype != G__AUTO && var_statictype != G__AUTOARYDISCRETEOBJ && var_statictype != G__COMPILEDGLOBAL) {
+   if (var_statictype == G__LOCALSTATIC) {
       modifiers |= ::Reflex::STATIC;
    }
 
@@ -1245,6 +1246,7 @@ extern "C" int G__search_tagname(const char *tagname, int type)
 
    G__get_offset(d) = offset;
    G__get_properties(d)->isCompiledGlobal = (var_statictype == G__COMPILEDGLOBAL);
+   G__get_properties(d)->statictype = var_statictype; // We need this to distinguish file-static variables.
 
    return d;
 }
@@ -1313,6 +1315,7 @@ static void G__add_anonymousunion(const ::Reflex::Type &uniontype, int def_struc
 * [struct|union|enum] tagname { member }      ;
 *
 ******************************************************************/
+void G__dumpreflex_atlevel(const ::Reflex::Scope& scope, int level);
 void Cint::Internal::G__define_struct(char type)
 {
    //fprintf(stderr, "G__define_struct: Begin.\n");
@@ -1500,7 +1503,9 @@ void Cint::Internal::G__define_struct(char type)
       case ':':
       case ';':
          // 0x100: define struct if not found
+         //fprintf(stderr, "G__define_struct: Creating scope '%s'\n", tagname);
          G__tagnum = G__Dict::GetDict().GetScope(G__search_tagname(tagname, type + 0x100));
+         //G__dumpreflex_atlevel(G__tagnum, 0);
          break;
       default:
          G__tagnum = G__Dict::GetDict().GetScope(G__search_tagname(tagname, type));
@@ -1858,6 +1863,7 @@ void Cint::Internal::G__define_struct(char type)
          }
 
       }
+      //fprintf(stderr, "G__define_struct: Setting abstract cnt for '%s' to: %d\n", G__tagnum.Name(Reflex::SCOPED).c_str(), purecount);
       G__struct.isabstract[G__get_tagnum(G__tagnum)] = purecount;
    }
 
@@ -1948,7 +1954,9 @@ void Cint::Internal::G__define_struct(char type)
                   store_decl = G__decl;
                   G__decl = 1;
                }
+               //fprintf(stderr, "G__define_struct: Setting enum '%-32s' member '%-16s' to value %d\n", G__p_local.Name(Reflex::SCOPED | Reflex::QUALIFIED).c_str(), memname, enumval.obj.i);
                G__letvariable(memname, enumval,::Reflex::Scope::GlobalScope() , G__p_local);
+               //G__dumpreflex_atlevel(G__p_local, 0);
                if (store_tagnum && !store_tagnum.IsTopScope()) {
                   G__def_struct_member = store_def_struct_member;
                   G__static_alloc = 0;
diff --git a/cint/cint7/src/var.cxx b/cint/cint7/src/var.cxx
index 4e33c17bfba..23ac873b171 100644
--- a/cint/cint7/src/var.cxx
+++ b/cint/cint7/src/var.cxx
@@ -4015,7 +4015,7 @@ static G__value Cint::Internal::G__allocvariable(G__value result, G__value para[
    //
    if (var_type.IsAbstract()) {
       // -- Do *not* create abstract class variable!
-      G__fprinterr(G__serr, "Error: abstract class object '%s %s' declared", G__tagnum.Name().c_str(), item);
+      G__fprinterr(G__serr, "Error: 4018: abstract class object '%s %s' declared", G__tagnum.Name().c_str(), item);
       G__genericerror(0);
       G__display_purevirtualfunc(G__get_tagnum(G__tagnum));
       return result;
@@ -4388,8 +4388,9 @@ static G__value Cint::Internal::G__allocvariable(G__value result, G__value para[
             (G__reftype == G__PARANORMAL) &&
             ((G__globalcomp != G__CPPLINK) || (G__tagdefining != G__tagnum))
          ) {
-            G__fprinterr(G__serr, "Error: abstract class object '%s %s' declared", G__tagnum.Name().c_str(), item);
+            G__fprinterr(G__serr, "Error: Attempt to allocate memory for data member of an abstract class: '%s::%s'  %s:%d", G__tagnum.Name(Reflex::SCOPED).c_str(), item, __FILE__, __LINE__);
             G__genericerror(0);
+            G__fprinterr(G__serr, "Error: Pure virtual functions are:  %s:%d\n", __FILE__, __LINE__);
             G__display_purevirtualfunc(G__get_tagnum(G__tagnum));
             // --
          }
@@ -6416,6 +6417,7 @@ G__value Cint::Internal::G__getvariable(char* item, int* known, const ::Reflex::
 G__value Cint::Internal::G__getstructmem(int store_var_type, char* varname, char* membername, char* tagname, int* known2, const ::Reflex::Scope& varglobal, int objptr /* 1 : object, 2 : pointer */)
 {
    // -- FIXME: Describe me!
+   fprintf(stderr, "G__getstructmem: varname: '%s' membername: '%s' tagname: '%s' objptr: %d\n", varname, membername, tagname, objptr);
    ::Reflex::Scope store_tagnum;
    char* store_struct_offset = 0;
    int flag = 0;
@@ -7310,6 +7312,8 @@ void Cint::Internal::G__get_stack_varname(std::string& output, const char* varna
          next_base:
          ig15 = 0;
          for (::Reflex::Member_Iterator iter = var.DataMember_Begin(); iter != var.DataMember_End(); ++iter, ++ig15) {
+            // --
+/*
             if (
                *iter && // member has a name, and
                !strcmp(iter->Name().c_str(), varname.c_str()) && // Names match, and FIXME: need to use strcmp because varname.c_str() was manipulated directly (G__scopeoperator)
@@ -7325,6 +7329,20 @@ void Cint::Internal::G__get_stack_varname(std::string& output, const char* varna
                return *iter;
             }
             //--
+*/
+            if (*iter && !strcmp(iter->Name().c_str(), varname.c_str())) {
+               if (
+                  (G__get_properties(*iter)->statictype < 0) || // Not file scope, or
+                  G__filescopeaccess(G__ifile.filenum, G__get_properties(*iter)->filenum) // File scope access match.
+               ) {
+                  if (G__test_access(*iter, accesslimit)) { // Access limit match.
+                     if (pig15) {
+                        *pig15 = ig15;
+                     }
+                     return *iter;
+                  }
+               }
+            }
          }
          // Next base class if searching for class member.
          if (
diff --git a/cint/reflex/src/NameLookup.cxx b/cint/reflex/src/NameLookup.cxx
index 03a5cf76cf6..81af6afa32a 100644
--- a/cint/reflex/src/NameLookup.cxx
+++ b/cint/reflex/src/NameLookup.cxx
@@ -20,141 +20,146 @@
 #include "Reflex/Tools.h"
 #include "Reflex/internal/OwnedMember.h"
 
-//-------------------------------------------------------------------------------
-Reflex::NameLookup::NameLookup(const std::string& name, const Scope& current):
-   fCurrentScope(current), fLookupName(name), fPartialSuccess(false), 
-   fPosNamePart(0), fPosNamePartLen(std::string::npos) {
+//______________________________________________________________________________
+Reflex::NameLookup::NameLookup(const std::string& name, const Scope& current)
+: fCurrentScope(current)
+, fLookupName(name)
+, fPartialSuccess(false)
+, fPosNamePart(0)
+, fPosNamePartLen(std::string::npos)
+{
    // Initialize a NameLookup object used internally to keep track of lookup
    // states.
-   }
-//-------------------------------------------------------------------------------
+}
 
-//-------------------------------------------------------------------------------
-Reflex::Type
-Reflex::NameLookup::LookupType( const std::string & nam, 
-                                      const Scope & current ) {
-//-------------------------------------------------------------------------------
-// Lookup up a (possibly scoped) type name appearing in the scope context 
-// current. This is the public interface for type lookup.
+//______________________________________________________________________________
+Reflex::Type Reflex::NameLookup::LookupType(const std::string& nam, const Scope& current)
+{
+   // Lookup up a (possibly scoped) type name appearing in the scope context
+   // current. This is the public interface for type lookup.
    NameLookup lookup(nam, current);
-   return lookup.Lookup< Type >();
+   return lookup.Lookup<Type>();
 }
 
-
-//-------------------------------------------------------------------------------
-Reflex::Scope 
-Reflex::NameLookup::LookupScope( const std::string & nam,
-                                         const Scope & current ) {
-//-------------------------------------------------------------------------------
-// Lookup up a (possibly scoped) scope name appearing in the scope context 
-// current. This is the public interface for scope lookup.
+//______________________________________________________________________________
+Reflex::Scope Reflex::NameLookup::LookupScope(const std::string& nam, const Scope& current)
+{
+   // Lookup up a (possibly scoped) scope name appearing in the scope context
+   // current. This is the public interface for scope lookup.
    NameLookup lookup(nam, current);
-   return lookup.Lookup< Scope >();
+   return lookup.Lookup<Scope>();
 }
 
 /*
-//-------------------------------------------------------------------------------
-Reflex::Member LookupMember( const std::string & nam,
-                                   const Scope & current ) {
-//-------------------------------------------------------------------------------
-// Lookup up a (possibly scoped) member name appearing in the scope context 
-// current. This is the public interface for member lookup.
+//______________________________________________________________________________
+Reflex::Member LookupMember(const std::string& nam, const Scope& current )
+{
+   // Lookup up a (possibly scoped) member name appearing in the scope context
+   // current. This is the public interface for member lookup.
    NameLookup lookup(nam, current);
-
    // this will not work, member lookup is too different from type lookup...
    return lookup.Lookup<Member>();
 }
 */
 
-
-//-------------------------------------------------------------------------------
-template< class T > T
-Reflex::NameLookup::Lookup() {
-//-------------------------------------------------------------------------------
-// Lookup a type using fLookupName, fCurrentScope.
+//______________________________________________________________________________
+template<class T> T Reflex::NameLookup::Lookup()
+{
+   // Lookup a type using fLookupName, fCurrentScope.
    fPartialSuccess = false;
    fPosNamePart = 0;
    fPosNamePartLen = std::string::npos;
    FindNextScopePos();
-
-   if ( fPosNamePart == 2 ) {
+   if (fPosNamePart == 2) {
       fLookedAtUsingDir.clear();
       // ::A...
       fCurrentScope = Scope::GlobalScope();
-      return LookupInScope< T >();
-   } else
-      // A...
-      return LookupInUnknownScope< T >();
+      return LookupInScope<T>();
+   }
+   // A...
+   return LookupInUnknownScope<T>();
 }
 
+//______________________________________________________________________________
+template<class T> T Reflex::NameLookup::LookupInScope()
+{
+   // Lookup a type in fCurrentScope.
+   // Checks sub-types, sub-scopes, using directives, and base classes for
+   // the name given by fLookupName, fPosNamePart, and fPosNamePartLen.
+   // If the name part is found, and another name part follows in fPosNamePart,
+   // LookupTypeInScope requests the scope found to lookup the next name
+   // part. fPartialMatch reflexts that the left part of the name was matched;
+   // even if the trailing part of fLookupName cannot be found, the lookup
+   // cannot continue on declaring scopes and has to fail.
+   // A list of lookups performed in namespaces pulled in via using directives is
+   // kept in fLookedAtUsingDir, to prevent infinite loops due to
+   //   namespace A{using namespace B;} namespace B{using namespace A;}
+   // loops.
+   // The lookup does not take the declaration order into account; the result of
+   // parts of the lookup algorithm which depend on the order will be unpredictable.
+
+   if (!fCurrentScope) {
+      return Dummy::Get<T>();
+   }
 
-//-------------------------------------------------------------------------------
-template< class T > T
-Reflex::NameLookup::LookupInScope() {
-//-------------------------------------------------------------------------------
-// Lookup a type in fCurrentScope.
-// Checks sub-types, sub-scopes, using directives, and base classes for
-// the name given by fLookupName, fPosNamePart, and fPosNamePartLen.
-// If the name part is found, and another name part follows in fPosNamePart,
-// LookupTypeInScope requests the scope found to lookup the next name
-// part. fPartialMatch reflexts that the left part of the name was matched;
-// even if the trailing part of fLookupName cannot be found, the lookup 
-// cannot continue on declaring scopes and has to fail.
-// A list of lookups performed in namespaces pulled in via using directives is 
-// kept in fLookedAtUsingDir, to prevent infinite loops due to 
-//   namespace A{using namespace B;} namespace B{using namespace A;}
-// loops.
-// The lookup does not take the declaration order into account; the result of
-// parts of the lookup algorithm which depend on the order will be unpredictable.
-
-   if (!fCurrentScope) return Dummy::Get< T >();
-   if (fLookedAtUsingDir.find(fCurrentScope) != fLookedAtUsingDir.end())
-      // prevent inf loop from
-      // ns A { using ns B; } ns B {using ns A;}
-      return Dummy::Get< T >();
+   // prevent inf loop from
+   // ns A { using ns B; } ns B {using ns A;}
+   if (fLookedAtUsingDir.find(fCurrentScope) != fLookedAtUsingDir.end()) {
+      return Dummy::Get<T>();
+   }
 
-   //Type_Iterator subtype_end( fCurrentScope.SubType_End() );
    int len = fCurrentScope.SubTypeSize();
    int i = 0;
-   for ( Type_Iterator it = fCurrentScope.SubType_Begin(); /* it != subtype_end */ i<len; ++it, ++i ) {
+   for (Type_Iterator it = fCurrentScope.SubType_Begin(); i < len; ++it, ++i) {
       const Type& type = *it;
-      const TypeBase *base = type.ToTypeBase();      
-      if ( base ) {
+      const TypeBase* base = type.ToTypeBase();
+      if (base) {
          size_t pos;
-         const std::string &name( base->SimpleName(pos) );
+         const std::string &name(base->SimpleName(pos));
          //fprintf(stderr, "Reflex::NameLookup::LookupInScope<T>: looking up '%s', considering subscope '%s' ...\n", fLookupName.c_str(), name.c_str());
-         if (fLookupName[fPosNamePart]==name[pos] &&
-             0 == fLookupName.compare(fPosNamePart, fPosNamePartLen, name, pos, name.length() ) ) {
+         if (
+            (fLookupName[fPosNamePart] == name[pos]) &&
+            !fLookupName.compare(fPosNamePart, fPosNamePartLen, name, pos, name.length())
+         ) {
             //fprintf(stderr, "Reflex::NameLookup::LookupInScope<T>: lookup up '%s', partial success with subscope '%s' ...\n", fLookupName.c_str(), name.c_str());
             fPartialSuccess = true;
             fLookedAtUsingDir.clear();
             FindNextScopePos();
-            if (fPosNamePart == std::string::npos) return type;
-            if (it->IsTypedef()) fCurrentScope = it->FinalType();
-            else fCurrentScope = type;
+            if (fPosNamePart == std::string::npos) {
+               return type;
+            }
+            if (it->IsTypedef()) {
+               fCurrentScope = it->FinalType();
+            }
+            else {
+               fCurrentScope = type;
+            }
             return LookupInScope< T >();
          }
       }
    }
-   
-   Scope_Iterator subscope_end(  fCurrentScope.SubScope_End() );
-   for ( Scope_Iterator in = fCurrentScope.SubScope_Begin(); in != subscope_end; ++in ) {
+
+   Scope_Iterator subscope_end(fCurrentScope.SubScope_End());
+   for (Scope_Iterator in = fCurrentScope.SubScope_Begin(); in != subscope_end; ++in) {
       // only take namespaces into account - classes were checked as part of SubType
-      if (in->IsNamespace()){
-         const Scope &scope = *in;
-         const ScopeBase *base = scope.ToScopeBase();
+      if (in->IsNamespace()) {
+         const Scope& scope = *in;
+         const ScopeBase* base = scope.ToScopeBase();
          if (base) {
             size_t pos;
-            const std::string &name( base->SimpleName(pos) );
-            
-            if (fLookupName[fPosNamePart]==name[pos] && 
-                0 == fLookupName.compare(fPosNamePart, fPosNamePartLen, name, pos, name.length() ) ) {
+            const std::string& name(base->SimpleName(pos));
+            if (
+               (fLookupName[fPosNamePart] == name[pos]) &&
+               !fLookupName.compare(fPosNamePart, fPosNamePartLen, name, pos, name.length())
+            ) {
                fPartialSuccess = true;
                fLookedAtUsingDir.clear();
                FindNextScopePos();
-               if (fPosNamePart == std::string::npos) return (T) (*in);
+               if (fPosNamePart == std::string::npos) {
+                  return (T) (*in);
+               }
                fCurrentScope = (Scope) (*in);
-               return LookupInScope< T >();
+               return LookupInScope<T>();
             }
          }
       }
@@ -163,23 +168,27 @@ Reflex::NameLookup::LookupInScope() {
    if (fCurrentScope.UsingDirectiveSize()) {
       fLookedAtUsingDir.insert(fCurrentScope);
       Scope storeCurrentScope = fCurrentScope;
-      Scope_Iterator usingscope_end(  storeCurrentScope.UsingDirective_End() );
-      for ( Scope_Iterator si = storeCurrentScope.UsingDirective_Begin(); si != usingscope_end; ++si ) {
+      Scope_Iterator usingscope_end(storeCurrentScope.UsingDirective_End());
+      for (Scope_Iterator si = storeCurrentScope.UsingDirective_Begin(); si != usingscope_end; ++si) {
          fCurrentScope = *si;
-         T t = LookupInScope< T >();
-         if (fPartialSuccess) return t;
+         T t = LookupInScope<T>();
+         if (fPartialSuccess) {
+            return t;
+         }
       }
       fCurrentScope = storeCurrentScope;
    }
 
-   if (fPosNamePart == 0) { // only for "BaseClass...", not for "A::BaseClass..."
-      Base_Iterator base_end( fCurrentScope.Base_End() );
-      for ( Base_Iterator bi = fCurrentScope.Base_Begin(); bi != base_end; ++bi ) {
-         if ( 0 == fLookupName.compare(fPosNamePart, fPosNamePartLen, (*bi).Name() ) ) {
+   if (!fPosNamePart) { // only for "BaseClass...", not for "A::BaseClass..."
+      Base_Iterator base_end(fCurrentScope.Base_End());
+      for (Base_Iterator bi = fCurrentScope.Base_Begin(); bi != base_end; ++bi) {
+         if (!fLookupName.compare(fPosNamePart, fPosNamePartLen, bi->Name())) {
             fPartialSuccess = true;
             fLookedAtUsingDir.clear();
             FindNextScopePos();
-            if (fPosNamePart == std::string::npos) return bi->ToType();
+            if (fPosNamePart == std::string::npos) {
+               return bi->ToType();
+            }
             fCurrentScope = bi->ToType().FinalType();
             return LookupInScope< T >();
          }
@@ -188,111 +197,106 @@ Reflex::NameLookup::LookupInScope() {
 
    if (fCurrentScope.BaseSize()) {
       Scope storeCurrentScope = fCurrentScope;
-      Base_Iterator base_end( storeCurrentScope.Base_End() ); 
-      for ( Base_Iterator bi = storeCurrentScope.Base_Begin(); bi != base_end; ++bi ) {
+      Base_Iterator base_end(storeCurrentScope.Base_End());
+      for (Base_Iterator bi = storeCurrentScope.Base_Begin(); bi != base_end; ++bi) {
          fCurrentScope = bi->ToScope();
-         T t = LookupInScope< T >();
-         if (fPartialSuccess) return t;
+         T t = LookupInScope<T>();
+         if (fPartialSuccess) {
+            return t;
+         }
       }
       fCurrentScope = storeCurrentScope;
    }
 
-   return Dummy::Get< T >();
+   return Dummy::Get<T>();
 }
 
-
-//-------------------------------------------------------------------------------
-template< class T > T
-Reflex::NameLookup::LookupInUnknownScope() {
-//-------------------------------------------------------------------------------
-// Lookup a type in fCurrentScope and its declaring scopes.
+//______________________________________________________________________________
+template<class T> T Reflex::NameLookup::LookupInUnknownScope()
+{
+   // Lookup a type in fCurrentScope and its declaring scopes.
    for (fPartialSuccess = false; !fPartialSuccess && fCurrentScope; fCurrentScope = fCurrentScope.DeclaringScope()) {
       fLookedAtUsingDir.clear();
-      T t = LookupInScope< T >();
-      if (fPartialSuccess) return t;
-      if (fCurrentScope.IsTopScope()) break;
+      T t = LookupInScope<T>();
+      if (fPartialSuccess) {
+         return t;
+      }
+      if (fCurrentScope.IsTopScope()) {
+         break;
+      }
    }
-   return Dummy::Get< T >();
+   return Dummy::Get<T>();
 }
 
-
-//-------------------------------------------------------------------------------
-Reflex::Member
-Reflex::NameLookup::LookupMember( const std::string & nam, 
-                                        const Scope & current ) {
-//-------------------------------------------------------------------------------
-// Lookup a member.
-   if ( Tools::GetBasePosition(nam)) return LookupMemberQualified( nam );
-   else                              return LookupMemberUnqualified( nam, current );
-
+//______________________________________________________________________________
+Reflex::Member Reflex::NameLookup::LookupMember(const std::string& nam, const Scope& current)
+{
+   // Lookup a member.
+   if (Tools::GetBasePosition(nam)) {
+      return LookupMemberQualified(nam);
+   }
+   return LookupMemberUnqualified(nam, current);
 }
 
-
-//-------------------------------------------------------------------------------
-Reflex::Member
-Reflex::NameLookup::LookupMemberQualified( const std::string & nam ) {
-//-------------------------------------------------------------------------------
-// Lookup of a qualified member.
+//______________________________________________________________________________
+Reflex::Member Reflex::NameLookup::LookupMemberQualified(const std::string& nam)
+{
+   // Lookup of a qualified member.
    Scope bscope = Scope::ByName(Tools::GetScopeName(nam));
-   if ( bscope ) {
-      return LookupMemberUnqualified( Tools::GetBaseName(nam), bscope);
+   if (bscope) {
+      return LookupMemberUnqualified(Tools::GetBaseName(nam), bscope);
    }
-   else {
-      return Dummy::Member();
-   }
-
+   return Dummy::Member();
 }
 
-
-
-//-------------------------------------------------------------------------------
-Reflex::Member
-Reflex::NameLookup::LookupMemberUnqualified( const std::string & nam,
-                                                   const Scope & current ) {
-//-------------------------------------------------------------------------------
-// Lookup of an unqualified member.
-   Member m0 = current.MemberByName(nam);
-   if ( m0 ) return m0;
-      
-   for ( Scope_Iterator si = current.UsingDirective_Begin(); si != current.UsingDirective_End(); ++si ) {
-      Member m1 = LookupMember( nam, *si );
-      if ( m1 ) return m1;
+//______________________________________________________________________________
+Reflex::Member Reflex::NameLookup::LookupMemberUnqualified(const std::string& nam, const Scope& current)
+{
+   // Lookup of an unqualified member.
+   {
+      Member m = current.MemberByName(nam);
+      if (m) {
+         return m;
+      }
    }
-
-   for ( Base_Iterator bi = current.Base_Begin(); bi != current.Base_End(); ++ bi ) {
-      Member m2 = LookupMember( nam, bi->ToScope() );
-      if ( m2 ) return m2;
+   for (Scope_Iterator si = current.UsingDirective_Begin(); si != current.UsingDirective_End(); ++si) {
+      Member m = LookupMember(nam, *si);
+      if (m) {
+         return m;
+      }
+   }
+   for (Base_Iterator bi = current.Base_Begin(); bi != current.Base_End(); ++bi) {
+      Member m = LookupMember(nam, bi->ToScope());
+      if (m) {
+         return m;
+      }
+   }
+   if (!current.IsTopScope()) {
+      return LookupMember(nam, current.DeclaringScope());
    }
-         
-   if ( ! current.IsTopScope() ) return LookupMember( nam, current.DeclaringScope() );
-
    return Dummy::Member();
-
 }
 
-
-
-//-------------------------------------------------------------------------------
-Reflex::Type Reflex::NameLookup::AccessControl( const Type & typ,
-                                                            const Scope & /* current */ ) {
-//-------------------------------------------------------------------------------
-// Check access .
-   
-   //if ( typ.IsPublic()) return true;
-
-   //else if ( typ.IsProtected() && current.HasBase(typ.DeclaringScope()) ) return true;
-
+//______________________________________________________________________________
+Reflex::Type Reflex::NameLookup::AccessControl(const Type& typ, const Scope& /*current*/)
+{
+   // Check access.
+   // if (typ.IsPublic()) {
+   //    return true;
+   // }
+   // else if (typ.IsProtected() && current.HasBase(typ.DeclaringScope())) {
+   //    return true;
+   // }
    return typ;
-
 }
 
-//-------------------------------------------------------------------------------
-void Reflex::NameLookup::FindNextScopePos() {
-//-------------------------------------------------------------------------------
-// Move fPosNamePart to point to the next scope in fLookupName, updating 
-// fPosNamePartLen. If fPosNamePartLen == std::string::npos, initialize
-// fPosNamePart and fPosNamePartLen. If there is no next scope left, fPosNamePart
-// will be set to std::string::npos and fPosNamePartLen will be set to 0.
+//______________________________________________________________________________
+void Reflex::NameLookup::FindNextScopePos()
+{
+   // Move fPosNamePart to point to the next scope in fLookupName, updating
+   // fPosNamePartLen. If fPosNamePartLen == std::string::npos, initialize
+   // fPosNamePart and fPosNamePartLen. If there is no next scope left, fPosNamePart
+   // will be set to std::string::npos and fPosNamePartLen will be set to 0.
    if (fPosNamePartLen != std::string::npos) {
       // we know the length, so jump
       fPosNamePart += fPosNamePartLen + 2;
@@ -306,14 +310,17 @@ void Reflex::NameLookup::FindNextScopePos() {
    else {
       // uninitialized
       // set fPosNamePartLen and check that fLookupName doesn't start with '::'
-      if (fLookupName.compare(0, 2, "::") == 0)
+      fPosNamePart = 0;
+      if (!fLookupName.compare(0, 2, "::")) {
          fPosNamePart = 2;
-      else fPosNamePart = 0;
+      }
    }
    fPosNamePartLen = Tools::GetFirstScopePosition(fLookupName.substr(fPosNamePart));
-   if (fPosNamePartLen == 0)
-      // no next "::"
+   if (!fPosNamePartLen) { // no next "::"
       fPosNamePartLen = fLookupName.length();
-   else fPosNamePartLen -= 2; // no "::"
-   // fPosNamePartLen -= fPosNamePart; No! We already look in substr()
+   }
+   else { // no "::"
+      fPosNamePartLen -= 2;
+   }
 }
+
diff --git a/cint/reflex/src/NameLookup.h b/cint/reflex/src/NameLookup.h
index b682a3d81b8..4974e8c895c 100644
--- a/cint/reflex/src/NameLookup.h
+++ b/cint/reflex/src/NameLookup.h
@@ -13,66 +13,47 @@
 #define Reflex_NameLookup
 
 // Include files
+#include "Reflex/Member.h"
+#include "Reflex/Scope.h"
+#include "Reflex/Type.h"
+#include <cstddef>
 #include <string>
 #include <vector>
 #include <set>
-#include "Reflex/Scope.h"
 
 namespace Reflex {
 
-   // forward declarations
-   class Type;
-   class Member;
-
-   /*
-   * point of declaration (3.3.1 [basic.scope.pdecl]) is not taken into account 
-   */
-
-   class NameLookup {
-   public:
-
-      // 1. Lookup
-      static Type LookupType( const std::string & nam,
-         const Scope & current );
-
-      static Scope LookupScope( const std::string & nam,
-         const Scope & current );
-
-      static Member LookupMember( const std::string & nam,
-         const Scope & current );
-
-      static Member LookupMemberUnqualified( const std::string & nam,
-         const Scope & current );
-
-      static Member LookupMemberQualified( const std::string & nam );
-
-      // 2. OverloadResolution
-      static Member OverloadResultion( const std::string & nam,
-         const std::vector< Member > & funcs );
-
-
-      // 3. AccessControl
-      static Type AccessControl( const Type & typ,
-         const Scope & current );
-
-   private:
-      NameLookup(const std::string& name, const Scope& current);
-
-      template <class T> T Lookup();
-      template <class T> T LookupInScope();
-      template <class T> T LookupInUnknownScope();
-
-      void FindNextScopePos();
-
-      Scope fCurrentScope; // scope where lookup is carried out
-      const std::string fLookupName; // we're looking for a type / member of this name
-      bool fPartialSuccess; // found part of the qualified name
-      std::set<Scope> fLookedAtUsingDir; // already checked these using directives
-      size_t fPosNamePart; // start position in fLookupName of name part to look up
-      size_t fPosNamePartLen; // length of name part to look up
-   }; // struct  NameLookup
-
-} //namespace Reflex
-
+// TODO: Point of declaration (3.3.1 [basic.scope.pdecl]) is not taken into account.
+
+class NameLookup {
+private: // Data Members.
+   const std::string fLookupName; // we're looking for a type / member of this name
+   std::size_t fPosNamePart; // Start position in fLookupName of name currently being looked up.
+   std::size_t fPosNamePartLen; // Length of name currently being looked up.
+   std::set<Scope> fLookedAtUsingDir; // Set of using-directive-nominated scopes already considered.
+   Scope fCurrentScope; // Scope where lookup is currently occuring.
+   bool fPartialSuccess; // Flag indicating that a left-prefix has matched.
+private: // Internal Utility Functions.
+   NameLookup(const std::string& name, const Scope& current); // We can only be created by our static func members.
+   template <class T> T Lookup();
+   template <class T> T LookupInScope();
+   template <class T> T LookupInUnknownScope();
+   void FindNextScopePos(); // Utility function, advance to the next name part in a qualified id.
+public: // Public Interface.
+   // 1. Lookup
+   static Type LookupType(const std::string& nam, const Scope& current);
+   static Scope LookupScope(const std::string& nam, const Scope& current);
+   static Member LookupMember(const std::string& nam, const Scope& current);
+   static Member LookupMemberUnqualified(const std::string& nam, const Scope& current);
+   static Member LookupMemberQualified(const std::string& nam);
+
+   // 2. OverloadResolution
+   static Member OverloadResultion(const std::string& nam, const std::vector<Member>& funcs);
+
+   // 3. AccessControl
+   static Type AccessControl(const Type& typ, const Scope& current);
+};
+
+} // namespace Reflex
 
 #endif // Reflex_NameLookup
diff --git a/cint/reflex/src/Tools.cxx b/cint/reflex/src/Tools.cxx
index 34b36301d9a..a6cd88675b0 100644
--- a/cint/reflex/src/Tools.cxx
+++ b/cint/reflex/src/Tools.cxx
@@ -335,6 +335,10 @@ void Tools::StringSplit( std::vector < std::string > & splitValues,
                          const std::string & delim ) {
 //-------------------------------------------------------------------------------
 // Split a string by a delimiter and return it's vector of strings.
+   if (!str.size()) {
+      return;
+   }
+
    std::string str2 = str;
   
    size_t pos = 0;
-- 
GitLab