Esempio n. 1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (obj.GetType() == typeof(CppTypes))
            {
                return(Equals(new CppType(obj)));
            }
            if (obj.GetType() != typeof(CppType))
            {
                return(false);
            }
            CppType other = (CppType)obj;

            return((((internalModifiers == null || !internalModifiers.Any()) &&
                     (other.internalModifiers == null || !other.internalModifiers.Any())) ||
                    (internalModifiers != null && other.internalModifiers != null &&
                     CppModifiers.NormalizeOrder(internalModifiers).SequenceEqual(CppModifiers.NormalizeOrder(other.internalModifiers)))) &&

                   (((Namespaces == null || !Namespaces.Any()) &&
                     (other.Namespaces == null || !other.Namespaces.Any())) ||
                    (Namespaces != null && other.Namespaces != null &&
                     Namespaces.SequenceEqual(other.Namespaces))) &&

                   ElementType == other.ElementType &&
                   ElementTypeName == other.ElementTypeName);
        }
Esempio n. 2
0
        public CppType Subtract(CppModifiers modifier)
        {
            CppType newType = this;

            newType.internalModifiers = new List <CppModifiers> (((IEnumerable <CppModifiers>)newType.Modifiers).Reverse().WithoutFirst(modifier));
            return(newType);
        }
Esempio n. 3
0
        // note: this adds modifiers "backwards" (it is mainly used by the generator)
        public CppType Modify(CppModifiers modifier)
        {
            CppType newType     = this;
            var     newModifier = new CppModifiers [] { modifier };

            if (newType.internalModifiers != null)
            {
                newType.internalModifiers.AddFirst(newModifier);
            }
            else
            {
                newType.internalModifiers = new List <CppModifiers> (newModifier);
            }

            return(newType);
        }
Esempio n. 4
0
        // FIXME: This makes no attempt to actually verify that the parts compose a valid C++ type.
        private void Parse(object [] parts)
        {
            foreach (object part in parts)
            {
                if (part is CppModifiers)
                {
                    Modifiers.Add((CppModifiers)part);
                    continue;
                }

                if (part is CppModifiers [] || part is IEnumerable <CppModifiers> )
                {
                    Modifiers.AddRange((IEnumerable <CppModifiers>)part);
                    continue;
                }

                if (part is CppTypes)
                {
                    ElementType = (CppTypes)part;
                    continue;
                }

                Type managedType = part as Type;
                if (managedType != null)
                {
                    CppType mapped = CppType.ForManagedType(managedType);
                    CopyTypeFrom(mapped);
                    continue;
                }

                string strPart = part as string;
                if (strPart != null)
                {
                    var parsed = CppModifiers.Parse(strPart);
                    if (parsed.Count > 0)
                    {
                        if (internalModifiers == null)
                        {
                            internalModifiers = parsed;
                        }
                        else
                        {
                            internalModifiers.AddRange(parsed);
                        }

                        strPart = CppModifiers.Remove(strPart);
                    }

                    // if we have something left, it must be a type name
                    strPart = strPart.Trim();
                    if (strPart != "")
                    {
                        string [] qualifiedName = strPart.Split(new string [] { "::" }, StringSplitOptions.RemoveEmptyEntries);
                        int       numNamespaces = qualifiedName.Length - 1;
                        if (numNamespaces > 0)
                        {
                            Namespaces = new string [numNamespaces];
                            for (int i = 0; i < numNamespaces; i++)
                            {
                                Namespaces [i] = qualifiedName [i];
                            }
                        }
                        strPart = qualifiedName [numNamespaces];

                        // FIXME: Fix this mess
                        switch (strPart)
                        {
                        case "void":
                            ElementType = CppTypes.Void;
                            break;

                        case "bool":
                            ElementType = CppTypes.Bool;
                            break;

                        case "char":
                            ElementType = CppTypes.Char;
                            break;

                        case "int":
                            ElementType = CppTypes.Int;
                            break;

                        case "float":
                            ElementType = CppTypes.Float;
                            break;

                        case "double":
                            ElementType = CppTypes.Double;
                            break;

                        default:
                            // otherwise it is the element type name...
                            ElementTypeName = strPart;
                            break;
                        }
                    }
                }
            }
        }
Esempio n. 5
0
		// note: this adds modifiers "backwards" (it is mainly used by the generator)
		public CppType Modify (CppModifiers modifier)
		{
			CppType newType = this;
			var newModifier = new CppModifiers [] { modifier };

			if (newType.internalModifiers != null)
				newType.internalModifiers.AddFirst (newModifier);
			else
				newType.internalModifiers = new List<CppModifiers> (newModifier);

			return newType;
		}
Esempio n. 6
0
		public CppType Subtract (CppModifiers modifier)
		{
			CppType newType = this;
			newType.internalModifiers = new List<CppModifiers> (((IEnumerable<CppModifiers>)newType.Modifiers).Reverse ().WithoutFirst (modifier));
			return newType;
		}