Exemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="facet">Facet</param>
 public CodeFacet(CodeFacet facet)
 {
     Name           = ObjCIdentifierFromManagedIdentifier(facet.Name);
     Type           = ObjCIdentifierFromManagedIdentifier(facet.Type);
     BaseName       = ObjCIdentifierFromManagedIdentifier(facet.BaseName);
     BaseType       = ObjCIdentifierFromManagedIdentifier(facet.BaseType);
     UnderlyingType = ObjCIdentifierFromManagedIdentifier(facet.UnderlyingType);
 }
Exemplo n.º 2
0
        private void OrderImplementedInterfacesByDerivation(InterfaceFacet facet, IList <InterfaceFacet> facets, IList <InterfaceFacet> orderedFacets)
        {
            // assign root
            InterfaceFacet interfaceFacet = facet;

            // if root already ordered then we are done
            if (orderedFacets.Contains(interfaceFacet))
            {
                return;
            }

            // add root
            orderedFacets.Add(interfaceFacet);

            // iterate over all implemented interfaces
            var implementedInterfaces = interfaceFacet.ImplementedInterfaces;

            foreach (ImplementedInterfaceFacet impIntFacet in implementedInterfaces)
            {
                // the cursor will initially reference an ImplementedInterfaceFacet
                // but may subsequently refer to an InterfaceFacet
                CodeFacet cursorFacet = impIntFacet;

                // loop until interface hierarchy is exhausted
                while (true)
                {
                    IEnumerable <InterfaceFacet> query = from f in facets where f.ObjCFacet.Type == cursorFacet.ObjCFacet.Type select f;

                    if (!query.Any())
                    {
                        //throw new Exception(String.Format("Facet not found for implemented interface type name{0}", cursorFacet.Type));
                        break;
                    }

                    if (query.Count() > 1)
                    {
                        throw new Exception(String.Format("Duplicate base interfaces ({0}) found for interface type {1}", query.Count(), cursorFacet.Type));
                    }

                    InterfaceFacet baseInterfaceFacet = query.First();

                    if (orderedFacets.Contains(baseInterfaceFacet))
                    {
                        break;
                    }

                    // insert base facet before its root
                    int idx = orderedFacets.IndexOf(interfaceFacet);
                    orderedFacets.Insert(idx, baseInterfaceFacet);

                    // use the base facet as the cursor for
                    // another interface search
                    cursorFacet    = baseInterfaceFacet;
                    interfaceFacet = baseInterfaceFacet;
                }
            }
        }
Exemplo n.º 3
0
        private void OrderBaseTypeByDerivation(CodeFacet facet, IList <CodeFacet> facets, IList <CodeFacet> orderedFacets)
        {
            // assign root
            CodeFacet rootFacet = facet;

            // if root already ordered then we are done
            if (orderedFacets.Contains(rootFacet))
            {
                return;
            }

            // add root
            orderedFacets.Add(rootFacet);

            // loop until base type hierarchy is exhausted
            while (true)
            {
                // System.Object won't have a base type
                if (rootFacet.BaseType == null)
                {
                    break;
                }

                // select base type facet
                IEnumerable <CodeFacet> query = from f in facets where f.ObjCFacet.Type == rootFacet.ObjCFacet.BaseType select f;
                if (!query.Any())
                {
                    //throw new Exception(String.Format("Facet not found for base type name{0}", rootFacet.BaseType));

                    break;
                }

                // validate
                if (query.Count() > 1)
                {
                    throw new Exception(String.Format("Duplicate base types ({0}) found for type {1}", query.Count(), rootFacet.Type));
                }

                // get the base facet
                CodeFacet baseFacet = query.First();

                // if this root is already ordered then we are done
                if (orderedFacets.Contains(baseFacet))
                {
                    break;
                }

                // insert base facet before its root
                int idx = orderedFacets.IndexOf(rootFacet);
                orderedFacets.Insert(idx, baseFacet);

                // use the base facet as the root for
                // another inheritance type search
                rootFacet = baseFacet;
            }
        }
Exemplo n.º 4
0
        public FacetList(XElement parent, string childname, CodeFacet Parent)
            : base()
        {
            IEnumerable <XElement> query = from element in parent.Elements(childname) select element;

            foreach (XElement element in query)
            {
                // Use the activator as we cannot call new T(arg)
                // TFacet facet = new TFacet(element)
                TFacet facet = (TFacet)Activator.CreateInstance(typeof(TFacet), new object[] { element });
                Add(facet);
                facet.Parent = Parent;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="xelement">XML element root node to load</param>
        public CodeFacet(XElement xelement)
        {
            Name           = XElementAttributeValue(xelement, "Name");
            FullName       = XElementAttributeValue(xelement, "FullName");
            Type           = XElementAttributeValue(xelement, "Type");
            IsReadable     = XElementAttributeBool(xelement, "IsReadable");
            IsWritable     = XElementAttributeBool(xelement, "IsWritable");
            IsEnum         = XElementAttributeBool(xelement, "IsEnum");
            IsValueType    = XElementAttributeBool(xelement, "IsValueType");
            IsByRef        = XElementAttributeBool(xelement, "IsByRef");
            IsInterface    = XElementAttributeBool(xelement, "IsInterface");
            IsDelegate     = XElementAttributeBool(xelement, "IsDelegate");
            IsNested       = XElementAttributeBool(xelement, "IsNested");
            IsPrimitive    = XElementAttributeBool(xelement, "IsPrimitive");
            IsPointer      = XElementAttributeBool(xelement, "IsPointer");
            IsArray        = XElementAttributeBool(xelement, "IsArray");
            ElementType    = XElementAttributeValue(xelement, "ElementType");
            ArrayRank      = Convert.ToInt32(XElementAttributeValue(xelement, "ArrayRank"));
            HandlerType    = XElementAttributeValue(xelement, "HandlerType");
            IsConstant     = XElementAttributeBool(xelement, "IsConstant");
            IsStatic       = XElementAttributeBool(xelement, "IsStatic");
            BaseName       = XElementAttributeValue(xelement, "BaseName");
            BaseType       = XElementAttributeValue(xelement, "BaseType");
            UnderlyingType = XElementAttributeValue(xelement, "UnderlyingType");
            ConstantValue  = XElementAttributeValue(xelement, "ConstantValue");

            // generic type info
            IsConstructedGenericType  = XElementAttributeBool(xelement, "IsConstructedGenericType");
            IsGenericType             = XElementAttributeBool(xelement, "IsGenericType");
            IsGenericTypeDefinition   = XElementAttributeBool(xelement, "IsGenericTypeDefinition");
            IsGenericParameter        = XElementAttributeBool(xelement, "IsGenericParameter");
            IsGenericParameterElement = XElementAttributeBool(xelement, "IsGenericParameterElement");
            ContainsGenericParameters = XElementAttributeBool(xelement, "ContainsGenericParameters");
            GenericParameterPosition  = Convert.ToInt32(XElementAttributeValue(xelement, "GenericParameterPosition"));
            DeclaredByMethod          = XElementAttributeBool(xelement, "DeclaredByMethod");

            // define ObjC code facet
            ObjCFacet = new CodeFacet(this);
        }