/// <summary> /// We extract the class info for a ROOT class that is a template. We properly deal with the class being templatized /// being another crazy class (or just a vector of int, etc.). /// </summary> /// <param name="container"></param> /// <param name="memberName"></param> /// <param name="className"></param> /// <returns></returns> private IEnumerable <ROOTClassShell> ExtractROOTTemplateClass(ROOTClassShell container, string memberName, string className) { /// /// Currently only setup to deal with some very specific types of vectors! /// var parsedMatch = TemplateParser.ParseForTemplates(className) as TemplateParser.TemplateInfo; if (parsedMatch == null) { SimpleLogging.Log("Type '{0}' is a template, but we can't parse it, so '{1}' will be ignored", className, memberName); return(Enumerable.Empty <ROOTClassShell>()); } if (parsedMatch.TemplateName != "vector") { SimpleLogging.Log("We can only deal with the vector type (not '{0}'), so member '{1}' will be ignored", className, memberName); return(Enumerable.Empty <ROOTClassShell>()); } if (!(parsedMatch.Arguments[0] is TemplateParser.RegularDecl)) { SimpleLogging.Log("We can't yet deal with nested templates - '{0}' - so member '{1}' will be ignored", className, memberName); return(Enumerable.Empty <ROOTClassShell>()); } var templateArgClass = (parsedMatch.Arguments[0] as TemplateParser.RegularDecl).Type; // // Now we take a look at the class. // // One case is that it is a simple class, like "Unsigned int" that // isn't known to root at all. That means we hvae no dictionary for vector<unsigned int> - otherwise // we never would have gotten into here. So ignore it. :-) // var classInfo = ROOTNET.NTClass.GetClass(templateArgClass); if (classInfo == null) { return(Enumerable.Empty <ROOTClassShell>()); } // // If this class is known by root then we will have // a very easy time. No new classes are created or defined and there is nothing // extra to do other than making the element. if (!classInfo.IsShellTClass()) { container.Add(new ItemVector(TemplateParser.TranslateToCSharp(parsedMatch), memberName)); return(Enumerable.Empty <ROOTClassShell>()); } // // If the class isn't known by ROOT then we have only one hope - building it out of the // streamer (at this point, where we are in the code path, it is also the case that there // aren't leaf sub-branches here). // var newClassDefs = ExtractUnsplitUnknownClass(classInfo); container.Add(new ItemVector(TemplateParser.TranslateToCSharp(parsedMatch), memberName)); return(newClassDefs); }
/// <summary> /// We are going to deal with a template of some sort for a simple item. At the moment we can deal only /// with simple STL's... /// </summary> /// <param name="leaf"></param> /// <param name="templateInfo"></param> /// <returns></returns> private IClassItem ExtractTemplateItem(SimpleLeafInfo leaf, TemplateParser.TemplateInfo templateInfo) { if (templateInfo.TemplateName == "vector") { return new ItemVector(TemplateParser.TranslateToCSharp(templateInfo), ExtractVarName(leaf).SanitizedName()); } else { throw new NotImplementedException("We rae not able to handle template classes other than vector: '" + templateInfo.TemplateName + "'"); } }