Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SpecializedTemplateUserType"/> class.
        /// </summary>
        /// <param name="symbol">The symbol we are generating this user type from.</param>
        /// <param name="xmlType">The XML description of the type.</param>
        /// <param name="nameSpace">The namespace it belongs to.</param>
        /// <param name="factory">User type factory that contains this element.</param>
        public SpecializedTemplateUserType(Symbol symbol, XmlType xmlType, string nameSpace, UserTypeFactory factory)
            : base(symbol, xmlType, nameSpace, factory)
        {
            Factory         = CreateFactory(factory);
            OriginalFactory = factory;

            // Enumerate all template arguments as strings
            List <Symbol> allTemplateArguments       = new List <Symbol>();
            List <Symbol> templateArgumentsAsSymbols = new List <Symbol>();

            for (int i = 0; i < Symbol.Namespaces.Count - 1; i++)
            {
                if (!ParseTemplateArguments(Module, Symbol.Namespaces[i], allTemplateArguments))
                {
                    WronglyFormed = true;
                    break;
                }
            }
            if (!WronglyFormed)
            {
                WronglyFormed = !ParseTemplateArguments(Module, Symbol.Namespaces.Last(), templateArgumentsAsSymbols);
                allTemplateArguments.AddRange(templateArgumentsAsSymbols);
            }
            if (!WronglyFormed)
            {
                AllTemplateArguments       = allTemplateArguments;
                TemplateArgumentsAsSymbols = templateArgumentsAsSymbols;
            }
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserType"/> class.
 /// </summary>
 /// <param name="symbol">The symbol we are generating this user type from.</param>
 /// <param name="xmlType">The XML description of the type.</param>
 /// <param name="nameSpace">The namespace it belongs to.</param>
 /// <param name="factory">User type factory that contains this element.</param>
 public UserType(Symbol symbol, XmlType xmlType, string nameSpace, UserTypeFactory factory)
 {
     Symbol                  = symbol;
     Factory                 = factory;
     InnerTypes              = new List <UserType>();
     DerivedClasses          = new HashSet <UserType>();
     typeNameCache           = SimpleCache.CreateStruct(() => GetTypeName());
     fullTypeNameCache       = SimpleCache.CreateStruct(() => GetFullTypeName());
     constructorNameCache    = SimpleCache.CreateStruct(() => GetConstructorName());
     namespaceCache          = SimpleCache.CreateStruct(() => GetNamespace(nameSpace));
     membersCache            = SimpleCache.CreateStruct(() => GetMembers().ToArray());
     constructorsCache       = SimpleCache.CreateStruct(() => GetConstructors().ToArray());
     baseClassCache          = SimpleCache.CreateStruct(() => GetBaseClass(Symbol));
     memoryBufferOffsetCache = SimpleCache.CreateStruct(() => GetMemoryBufferOffset());
 }
Example #3
0
        /// <summary>
        /// Creates the user type factory based on this template user type.
        /// </summary>
        /// <param name="factory">The original user type factory.</param>
        private UserTypeFactory CreateFactory(UserTypeFactory factory)
        {
            // Check if we are trying to create factory from factory that we already created
            var templateFactory = factory as TemplateUserTypeFactory;

            if (templateFactory != null)
            {
                if (templateFactory.TemplateType != this)
                {
                    return(CreateFactory(templateFactory.OriginalFactory));
                }

                // TODO: Verify if we want to keep existing template factory or we want to add our type too
                return(templateFactory);
            }

            return(new TemplateUserTypeFactory(factory, this));
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NamespaceUserType"/> class.
 /// </summary>
 /// <param name="innerNamespaces">The list of inner namespaces (e.g. chrono in std::chrono).</param>
 /// <param name="topLevelNamespace">The top level namespace (e.g. module name).</param>
 /// <param name="factory">User type factory that contains this element.</param>
 internal NamespaceUserType(IEnumerable <string> innerNamespaces, string topLevelNamespace, UserTypeFactory factory)
     : base(symbol: null, xmlType: null, nameSpace: null, factory: factory)
 {
     namespaces = innerNamespaces.Select(s => CodeNaming.FixUserNaming(s)).ToList();
     if (topLevelNamespace != null)
     {
         namespaces.Insert(0, topLevelNamespace);
     }
 }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TemplateUserTypeFactory"/> class.
 /// </summary>
 /// <param name="originalFactory">The original user type factory.</param>
 /// <param name="templateType">The template user type.</param>
 public TemplateUserTypeFactory(UserTypeFactory originalFactory, SpecializedTemplateUserType templateType)
     : base(originalFactory)
 {
     TemplateType    = templateType;
     OriginalFactory = originalFactory;
 }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TemplateUserType"/> class.
 /// </summary>
 /// <param name="template">Specialized template user type that will be used as representative for generating code.</param>
 /// <param name="specializations"></param>
 /// <param name="factory">User type factory that contains this element.</param>
 public TemplateUserType(SpecializedTemplateUserType template, List <SpecializedTemplateUserType> specializations, UserTypeFactory factory)
     : base(template.Symbol, null, template.Namespace, factory)
 {
     Specializations           = specializations;
     SpecializedRepresentative = template;
     foreach (SpecializedTemplateUserType specialization in specializations)
     {
         specialization.TemplateType = this;
     }
 }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TemplateArgumentConstantUserType"/> class.
 /// </summary>
 /// <param name="symbol">The symbol we are generating this user type from.</param>
 /// <param name="factory">User type factory that contains this element.</param>
 public TemplateArgumentConstantUserType(Symbol symbol, UserTypeFactory factory)
     : base(symbol, null, null, factory)
 {
 }
Example #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserTypeFactory"/> class.
 /// </summary>
 /// <param name="factory">The user type factory.</param>
 public UserTypeFactory(UserTypeFactory factory)
     : this(factory.typeTransformations, factory.CodeNaming)
 {
 }
Example #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GlobalsUserType"/> class.
 /// </summary>
 /// <param name="symbol">The symbol we are generating this user type from.</param>
 /// <param name="xmlType">The XML description of the type.</param>
 /// <param name="nameSpace">The namespace it belongs to.</param>
 /// <param name="factory">User type factory that contains this element.</param>
 public GlobalsUserType(Symbol symbol, XmlType xmlType, string nameSpace, UserTypeFactory factory)
     : base(symbol, xmlType, nameSpace, factory)
 {
 }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EnumUserType"/> class.
 /// </summary>
 /// <param name="symbol">The symbol we are generating this user type from.</param>
 /// <param name="nameSpace">The namespace it belongs to.</param>
 /// <param name="factory">User type factory that contains this element.</param>
 public EnumUserType(Symbol symbol, string nameSpace, UserTypeFactory factory)
     : base(symbol, null, nameSpace, factory)
 {
     areValuesFlagsCache = SimpleCache.CreateStruct(CheckIfValuesAreFlags);
     basicTypeCache      = SimpleCache.CreateStruct(() => GetEnumBasicType(Symbol));
 }
Example #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PhysicalUserType"/> class.
 /// </summary>
 /// <param name="symbol">The symbol we are generating this user type from.</param>
 /// <param name="xmlType">The XML description of the type.</param>
 /// <param name="nameSpace">The namespace it belongs to.</param>
 /// <param name="factory">User type factory that contains this element.</param>
 public PhysicalUserType(Symbol symbol, XmlType xmlType, string nameSpace, UserTypeFactory factory)
     : base(symbol, xmlType, nameSpace, factory)
 {
 }
Example #12
0
 public bool UpdateTemplateArguments(UserTypeFactory userTypeFactory)
 {
     // TODO: This looks like it is not needed, verify with some huge example PDBs.
     //throw new NotImplementedException();
     return(true);
 }