Ejemplo n.º 1
0
        PendingImplementation(TypeContainer container, MissingInterfacesInfo[] missing_ifaces, IList<MethodSpec> abstract_methods, int total)
        {
            var type_builder = container.Definition;

            this.container = container;
            pending_implementations = new TypeAndMethods [total];

            int i = 0;
            if (abstract_methods != null) {
                int count = abstract_methods.Count;
                pending_implementations [i].methods = new MethodSpec [count];
                pending_implementations [i].need_proxy = new MethodSpec [count];

                pending_implementations [i].methods = abstract_methods;
                pending_implementations [i].found = new MethodData [count];
                pending_implementations [i].type = type_builder;
                ++i;
            }

            foreach (MissingInterfacesInfo missing in missing_ifaces) {
                var iface = missing.Type;
                var mi = MemberCache.GetInterfaceMembers (iface);

                int count = mi.Count;
                pending_implementations [i].type = iface;
                pending_implementations [i].optional = missing.Optional;
                pending_implementations [i].methods = mi;
                pending_implementations [i].found = new MethodData [count];
                pending_implementations [i].need_proxy = new MethodSpec [count];
                i++;
            }
        }
Ejemplo n.º 2
0
        static MissingInterfacesInfo [] GetMissingInterfaces(TypeDefinition container)
        {
            //
            // Interfaces will return all interfaces that the container
            // implements including any inherited interfaces
            //
            var impl = container.Definition.Interfaces;

            if (impl == null || impl.Count == 0)
            {
                return(EmptyMissingInterfacesInfo);
            }

            var ret = new MissingInterfacesInfo[impl.Count];

            for (int i = 0; i < ret.Length; i++)
            {
                ret [i] = new MissingInterfacesInfo(impl [i]);
            }

            // we really should not get here because Object doesnt implement any
            // interfaces. But it could implement something internal, so we have
            // to handle that case.
            if (container.BaseType == null)
            {
                return(ret);
            }

            var base_impls = container.BaseType.Interfaces;

            if (base_impls != null)
            {
                foreach (TypeSpec t in base_impls)
                {
                    for (int i = 0; i < ret.Length; i++)
                    {
                        if (t == ret[i].Type)
                        {
                            ret[i].Optional = true;
                            break;
                        }
                    }
                }
            }

            return(ret);
        }
Ejemplo n.º 3
0
        static MissingInterfacesInfo [] GetMissingInterfaces(TypeContainer container)
        {
            //
            // Notice that Interfaces will only return the interfaces that the Type
            // is supposed to implement, not all the interfaces that the type implements.
            //
            var impl = container.Definition.Interfaces;

            if (impl == null || impl.Count == 0)
            {
                return(EmptyMissingInterfacesInfo);
            }

            MissingInterfacesInfo[] ret = new MissingInterfacesInfo[impl.Count];

            for (int i = 0; i < impl.Count; i++)
            {
                ret [i] = new MissingInterfacesInfo(impl [i]);
            }

            // we really should not get here because Object doesnt implement any
            // interfaces. But it could implement something internal, so we have
            // to handle that case.
            if (container.BaseType == null)
            {
                return(ret);
            }

            var base_impls = container.BaseType.Interfaces;

            if (base_impls != null)
            {
                foreach (TypeSpec t in base_impls)
                {
                    for (int i = 0; i < ret.Length; i++)
                    {
                        if (t == ret[i].Type)
                        {
                            ret[i].Optional = true;
                            break;
                        }
                    }
                }
            }

            return(ret);
        }
Ejemplo n.º 4
0
        static MissingInterfacesInfo [] GetMissingInterfaces(TypeBuilder type_builder)
        {
            //
            // Notice that TypeBuilders will only return the interfaces that the Type
            // is supposed to implement, not all the interfaces that the type implements.
            //
            // Even better -- on MS it returns an empty array, no matter what.
            //
            // Completely broken.  So we do it ourselves!
            //
            Type [] impl = TypeManager.GetExplicitInterfaces(type_builder);

            if (impl == null || impl.Length == 0)
            {
                return(EmptyMissingInterfacesInfo);
            }

            MissingInterfacesInfo [] ret = new MissingInterfacesInfo [impl.Length];

            for (int i = 0; i < impl.Length; i++)
            {
                ret [i] = new MissingInterfacesInfo(impl [i]);
            }

            // we really should not get here because Object doesnt implement any
            // interfaces. But it could implement something internal, so we have
            // to handle that case.
            if (type_builder.BaseType == null)
            {
                return(ret);
            }

            Type [] base_impls = TypeManager.GetInterfaces(type_builder.BaseType);

            foreach (Type t in base_impls)
            {
                for (int i = 0; i < ret.Length; i++)
                {
                    if (t == ret [i].Type)
                    {
                        ret [i].Optional = true;
                        break;
                    }
                }
            }
            return(ret);
        }
Ejemplo n.º 5
0
		static MissingInterfacesInfo [] GetMissingInterfaces (TypeContainer container)
		{
			//
			// Notice that Interfaces will only return the interfaces that the Type
			// is supposed to implement, not all the interfaces that the type implements.
			//
			var impl = container.Definition.Interfaces;

			if (impl == null || impl.Count == 0)
				return EmptyMissingInterfacesInfo;

			MissingInterfacesInfo[] ret = new MissingInterfacesInfo[impl.Count];

			for (int i = 0; i < impl.Count; i++)
				ret [i] = new MissingInterfacesInfo (impl [i]);

			// we really should not get here because Object doesnt implement any
			// interfaces. But it could implement something internal, so we have
			// to handle that case.
			if (container.BaseType == null)
				return ret;
			
			var base_impls = container.BaseType.Interfaces;
			if (base_impls != null) {
				foreach (TypeSpec t in base_impls) {
					for (int i = 0; i < ret.Length; i++) {
						if (t == ret[i].Type) {
							ret[i].Optional = true;
							break;
						}
					}
				}
			}

			return ret;
		}
Ejemplo n.º 6
0
		static MissingInterfacesInfo [] GetMissingInterfaces (TypeDefinition container)
		{
			//
			// Interfaces will return all interfaces that the container
			// implements including any inherited interfaces
			//
			var impl = container.Definition.Interfaces;

			if (impl == null || impl.Count == 0)
				return EmptyMissingInterfacesInfo;

			var ret = new MissingInterfacesInfo[impl.Count];

			for (int i = 0; i < ret.Length; i++)
				ret [i] = new MissingInterfacesInfo (impl [i]);

			// we really should not get here because Object doesnt implement any
			// interfaces. But it could implement something internal, so we have
			// to handle that case.
			if (container.BaseType == null)
				return ret;
			
			var base_impls = container.BaseType.Interfaces;
			if (base_impls != null) {
				foreach (TypeSpec t in base_impls) {
					for (int i = 0; i < ret.Length; i++) {
						if (t == ret[i].Type) {
							ret[i].Optional = true;
							break;
						}
					}
				}
			}

			return ret;
		}
Ejemplo n.º 7
0
		static MissingInterfacesInfo [] GetMissingInterfaces (TypeBuilder type_builder)
		{
			//
			// Notice that TypeBuilders will only return the interfaces that the Type
			// is supposed to implement, not all the interfaces that the type implements.
			//
			// Even better -- on MS it returns an empty array, no matter what.
			//
			// Completely broken.  So we do it ourselves!
			//
			Type [] impl = TypeManager.GetExplicitInterfaces (type_builder);

			if (impl == null || impl.Length == 0)
				return EmptyMissingInterfacesInfo;

			MissingInterfacesInfo [] ret = new MissingInterfacesInfo [impl.Length];

			for (int i = 0; i < impl.Length; i++)
				ret [i] = new MissingInterfacesInfo (impl [i]);

			// we really should not get here because Object doesnt implement any
			// interfaces. But it could implement something internal, so we have
			// to handle that case.
			if (type_builder.BaseType == null)
				return ret;
			
			Type [] base_impls = TypeManager.GetInterfaces (type_builder.BaseType);
			
			foreach (Type t in base_impls) {
				for (int i = 0; i < ret.Length; i ++) {
					if (t == ret [i].Type) {
						ret [i].Optional = true;
						break;
					}
				}
			}
			return ret;
		}
Ejemplo n.º 8
0
		PendingImplementation (TypeContainer container, MissingInterfacesInfo [] missing_ifaces, ArrayList abstract_methods, int total)
		{
			TypeBuilder type_builder = container.TypeBuilder;
			
			this.container = container;
			pending_implementations = new TypeAndMethods [total];

			int i = 0;
			if (abstract_methods != null) {
				int count = abstract_methods.Count;
				pending_implementations [i].methods = new MethodInfo [count];
				pending_implementations [i].need_proxy = new MethodInfo [count];
				
				abstract_methods.CopyTo (pending_implementations [i].methods, 0);
				pending_implementations [i].found = new MethodData [count];
				pending_implementations [i].args = new Type [count][];
				pending_implementations [i].mods = new Parameter.Modifier [count][];
				pending_implementations [i].type = type_builder;

				int j = 0;
				foreach (MemberInfo m in abstract_methods) {
					MethodInfo mi = (MethodInfo) m;
					
					AParametersCollection pd = TypeManager.GetParameterData (mi);
					Type [] types = pd.Types;
					
					pending_implementations [i].args [j] = types;
					pending_implementations [i].mods [j] = null;
					if (pd.Count > 0) {
						Parameter.Modifier [] pm = new Parameter.Modifier [pd.Count];
						for (int k = 0; k < pd.Count; k++)
							pm [k] = pd.FixedParameters[k].ModFlags;
						pending_implementations [i].mods [j] = pm;
					}
						
					j++;
				}
				++i;
			}

			foreach (MissingInterfacesInfo missing in missing_ifaces) {
				MethodInfo [] mi;
				Type t = missing.Type;
				
				if (!t.IsInterface)
					continue;

				if (t is TypeBuilder){
					TypeContainer iface;

					iface = TypeManager.LookupInterface (t);
					
					mi = iface.GetMethods ();
				} else 
					mi = t.GetMethods ();
				
				int count = mi.Length;
				pending_implementations [i].type = t;
				pending_implementations [i].optional = missing.Optional;
				pending_implementations [i].methods = mi;
				pending_implementations [i].args = new Type [count][];
				pending_implementations [i].mods = new Parameter.Modifier [count][];
				pending_implementations [i].found = new MethodData [count];
				pending_implementations [i].need_proxy = new MethodInfo [count];
				
				int j = 0;
				foreach (MethodInfo m in mi){
  					pending_implementations [i].args [j] = Type.EmptyTypes;
					pending_implementations [i].mods [j] = null;

					// If there is a previous error, just ignore
					if (m == null)
						continue;

 					AParametersCollection pd = TypeManager.GetParameterData (m);
					pending_implementations [i].args [j] = pd.Types;
 					
 					if (pd.Count > 0){
 						Parameter.Modifier [] pm = new Parameter.Modifier [pd.Count];
 						for (int k = 0; k < pd.Count; k++)
 							pm [k] = pd.FixedParameters [k].ModFlags;
 						pending_implementations [i].mods [j] = pm;
 					}
			
					j++;
				}
				i++;
			}
		}