コード例 #1
0
        static CilInterface ImportPlainInterface(CilType interfaceType, List <CilInterface> list)
        {
            foreach (var ifc in list)
            {
                if (ifc.InterfaceType.JavaName == interfaceType.JavaName &&
                    ifc.GenericTypes == null)
                {
                    return(ifc);
                }
            }

            var myInterface = new CilInterface();

            myInterface.InterfaceType = interfaceType;
            return(myInterface);
        }
コード例 #2
0
        static CilInterface ImportGenericInterface(CilType interfaceType, List <CilInterface> list)
        {
            var genericTypes = new List <CilType>();

            foreach (var genericParm in interfaceType.GenericParameters)
            {
                var genericMark = CilMain.GenericStack.Mark();
                var(type, index) = CilMain.GenericStack.Resolve(genericParm.JavaName);
                CilMain.GenericStack.Release(genericMark);

                genericTypes.Add(index == 0 ? type : genericParm);
            }

            int n = genericTypes.Count;

            foreach (var ifc in list)
            {
                if (ifc.InterfaceType.JavaName == interfaceType.JavaName &&
                    ifc.GenericTypes != null && ifc.GenericTypes.Count == n)
                {
                    bool allGenericTypesMatch = true;
                    for (int i = 0; i < n; i++)
                    {
                        if (ifc.GenericTypes[i].JavaName != genericTypes[i].JavaName)
                        {
                            allGenericTypesMatch = false;
                            break;
                        }
                    }
                    if (allGenericTypesMatch)
                    {
                        return(ifc);
                    }
                }
            }

            var myInterface = new CilInterface();

            myInterface.InterfaceType = interfaceType;
            myInterface.GenericTypes  = genericTypes;
            return(myInterface);
        }
コード例 #3
0
ファイル: TypeBuilder.cs プロジェクト: VPapazyan/bluebonnet
        public static List <CilInterface> ImportInterfaces(JavaClass jclass, CilType myType,
                                                           TypeDefinition cilType)
        {
            var myInterfaces = CilInterface.CollectAll(cilType);

            int n = myInterfaces.Count;

            if (n > 0)
            {
                jclass.Interfaces = new List <string>(n);
                for (int i = 0; i < n; i++)
                {
                    if (myInterfaces[i].DirectReference)
                    {
                        var ifcJavaName = myInterfaces[i].InterfaceType.JavaName;
                        if (ifcJavaName != "system.ValueMethod")
                        {
                            jclass.AddInterface(ifcJavaName);
                        }
                    }
                }
            }

            if ((cilType.Attributes & TypeAttributes.Serializable) != 0)
            {
                jclass.AddInterface("java.io.Serializable");
            }

            if ((cilType.Attributes & TypeAttributes.Interface) != 0)
            {
                // super of interface is always java.lang.Object, per JLS 4.1
                jclass.Super = JavaType.ObjectType.ClassName;
            }

            return(myInterfaces);
        }