internal static bool TryLoadCommonElement(this JavaType type, XmlReader reader)
 {
     if (reader.LocalName == "implements")
     {
         var implements = new JavaImplements();
         implements.Load(reader);
         type.Implements.Add(implements);
     }
     else if (reader.LocalName == "typeParameters")
     {
         var tp = new JavaTypeParameters(type);
         tp.Load(reader);
         type.TypeParameters = tp;
     }
     else if (reader.LocalName == "field")
     {
         var field = new JavaField(type);
         field.Load(reader);
         type.Members.Add(field);
     }
     else if (reader.LocalName == "method")
     {
         var method = new JavaMethod(type);
         method.Load(reader);
         type.Members.Add(method);
     }
     else
     {
         return(false);
     }
     return(true);
 }
示例#2
0
 static void FindDefects(this JavaType type)
 {
     foreach (var m in type.Members.OfType <JavaMethodBase> ())
     {
         m.FindParametersDefects();
     }
 }
 static ManagedType()
 {
     dummy_system_package = new JavaPackage(null)
     {
         Name = "System"
     };
     system_object = new ManagedType(dummy_system_package)
     {
         Name = "Object"
     };
     system_exception = new ManagedType(dummy_system_package)
     {
         Name = "Exception"
     };
     dummy_system_package.Types.Add(system_object);
     dummy_system_package.Types.Add(system_exception);
     dummy_system_io_package = new JavaPackage(null)
     {
         Name = "System.IO"
     };
     system_io_stream = new ManagedType(dummy_system_io_package)
     {
         Name = "Stream"
     };
     dummy_system_io_package.Types.Add(system_io_stream);
     dummy_system_xml_package = new JavaPackage(null)
     {
         Name = "System.Xml"
     };
     system_xml_xmlreader = new ManagedType(dummy_system_xml_package)
     {
         Name = "XmlReader"
     };
     dummy_system_io_package.Types.Add(system_xml_xmlreader);
 }
 public JavaTypeReference(JavaType referencedType, IList <JavaTypeReference>?typeParameters, string?arrayPart)
 {
     if (referencedType == null)
     {
         throw new ArgumentNullException("referencedType");
     }
     ReferencedType = referencedType;
     TypeParameters = typeParameters;
     ArrayPart      = arrayPart;
 }
 internal static void LoadTypeAttributes(this JavaType type, XmlReader reader, params string [] otherAllowedAttributes)
 {
     type.Abstract             = XmlConvert.ToBoolean(XmlUtil.GetRequiredAttribute(reader, "abstract"));
     type.Deprecated           = XmlUtil.GetRequiredAttribute(reader, "deprecated");
     type.Final                = XmlConvert.ToBoolean(XmlUtil.GetRequiredAttribute(reader, "final"));
     type.Name                 = XmlUtil.GetRequiredAttribute(reader, "name");
     type.Static               = XmlConvert.ToBoolean(XmlUtil.GetRequiredAttribute(reader, "static"));
     type.Visibility           = XmlUtil.GetRequiredAttribute(reader, "visibility");
     type.ExtendedJniSignature = reader.GetAttribute("jni-signature");
     XmlUtil.CheckExtraneousAttributes(reader.LocalName, reader, expected_type_attributes.Concat(otherAllowedAttributes).ToArray());
 }
        static void SaveTypeCommon(this JavaType cls, XmlWriter writer, string elementName, string abs, string ext, string extgen)
        {
            writer.WriteStartElement(elementName);
            if (abs != null)
            {
                writer.WriteAttributeString("abstract", abs);
            }
            writer.WriteAttributeString("deprecated", cls.Deprecated);
            if (ext != null)
            {
                writer.WriteAttributeString("extends", ext);
            }
            if (ext != null)
            {
                writer.WriteAttributeString("extends-generic-aware", extgen);
            }
            writer.WriteAttributeString("final", XmlConvert.ToString(cls.Final));
            writer.WriteAttributeString("name", cls.Name);
            writer.WriteAttributeString("static", XmlConvert.ToString(cls.Static));
            writer.WriteAttributeString("visibility", cls.Visibility);

            foreach (var imp in cls.Implements.OrderBy(i => i.Name, StringComparer.Ordinal))
            {
                writer.WriteStartElement("implements");
                writer.WriteAttributeString("name", imp.Name);
                writer.WriteAttributeString("name-generic-aware", imp.NameGeneric);
                writer.WriteString("\n      ");
                writer.WriteFullEndElement();
            }

            if (cls.TypeParameters != null)
            {
                cls.TypeParameters.Save(writer, "      ");
            }

            foreach (var m in cls.Members.OfType <JavaConstructor> ().OrderBy(m => m.Name, StringComparer.Ordinal).ThenBy(m => string.Join(", ", m.Parameters.Select(p => p.Type))).ThenBy(m => m.ExtendedSynthetic))
            {
                m.Save(writer);
            }
            foreach (var m in cls.Members.OfType <JavaMethod> ().OrderBy(m => m.Name, StringComparer.Ordinal).ThenBy(m => string.Join(", ", m.Parameters.Select(p => p.Type))).ThenBy(m => m.ExtendedSynthetic))
            {
                m.Save(writer);
            }
            foreach (var m in cls.Members.OfType <JavaField> ().OrderBy(m => m.Name, StringComparer.Ordinal))
            {
                m.Save(writer);
            }

            writer.WriteFullEndElement();
        }
示例#7
0
        public void AddType(JavaType type)
        {
            // If this is a duplicate key, add it to existing list
            if (Types.TryGetValue(type.Name !, out var list))
            {
                list.Add(type);
                return;
            }

            // Add to a new list
            var new_list = new List <JavaType> ();

            new_list.Add(type);

            types.Add(type.Name !, new_list);
        }
        static void Load(this JavaType type, GenBase gen)
        {
            type.IsReferenceOnly = true;

            type.Name = gen.JavaSimpleName;
            type.ExtendedJniSignature = gen.JniName;
            type.Deprecated           = gen.DeprecatedComment;
            type.Visibility           = gen.RawVisibility;
            type.Implements           = gen.Interfaces.Select(_ => new JavaImplements()
            {
                Name            = _.JavaName,
                ExtendedJniType = _.JniName,
            }).ToArray();
            if (gen.TypeParameters != null && gen.TypeParameters.Any())
            {
                type.TypeParameters = new JavaTypeParameters(type);
                type.TypeParameters.Load(gen.TypeParameters);
            }
            foreach (var f in gen.Fields.Where(_ => _.IsAcw))
            {
                var fld = new JavaField(type);
                fld.Load(f);
                type.Members.Add(fld);
            }
            foreach (var p in gen.Properties)
            {
                if (p.Getter != null && p.Getter.IsAcw)
                {
                    var getter = new JavaMethod(type);
                    getter.Load(p.Getter);
                    type.Members.Add(getter);
                }
                if (p.Setter != null && p.Setter.IsAcw)
                {
                    var setter = new JavaMethod(type);
                    setter.Load(p.Setter);
                    type.Members.Add(setter);
                }
            }
            foreach (var m in gen.Methods.Where(_ => _.IsAcw))
            {
                var method = new JavaMethod(type);
                method.Load(m);
                type.Members.Add(method);
            }
        }
示例#9
0
        public void RemoveType(JavaType type)
        {
            if (!Types.TryGetValue(type.Name !, out var list))
            {
                return;
            }

            // Remove 1 type from list if it contains multiple types
            if (list.Count > 1)
            {
                list.Remove(type);
                return;
            }

            // Remove the whole dictionary entry
            types.Remove(type.Name !);
        }
        static void ResolveType(this JavaType type)
        {
            if (type.TypeParameters != null)
            {
                type.TypeParameters.Resolve(type.GetApi(), type.TypeParameters);
            }
            foreach (var t in type.Implements)
            {
                t.ResolvedName = type.GetApi().Parse(t.NameGeneric, type.TypeParameters);
            }

            foreach (var m in type.Members.OfType <JavaField> ().ToArray())
            {
                ResolveWithTryCatch(m.Resolve, m);
            }
            foreach (var m in type.Members.OfType <JavaMethod> ().ToArray())
            {
                ResolveWithTryCatch(m.Resolve, m);
            }
        }
示例#11
0
 public JavaTypeParameters(JavaType parent)
 {
     ParentType     = parent;
     TypeParameters = new List <JavaTypeParameter> ();
 }
示例#12
0
 public JavaMethod(JavaType parent)
     : base(parent)
 {
 }
示例#13
0
 public JavaConstructor(JavaType parent)
     : base(parent)
 {
 }
示例#14
0
 protected JavaMethodBase(JavaType parent)
     : base(parent)
 {
     Parameters = new List <JavaParameter> ();
     Exceptions = new List <JavaException> ();
 }
示例#15
0
 public JavaField(JavaType parent)
     : base(parent)
 {
 }
示例#16
0
 protected JavaMember(JavaType parent)
 {
     Parent = parent;
 }
 public static JavaApi GetApi(this JavaType type)
 {
     return(type.Parent.Parent);
 }
示例#18
0
 public static JavaApi GetApi(this JavaType type)
 {
     return(type.Parent?.Parent ?? throw new InvalidOperationException("`JavaApi` via JavaType.Parent.Parent not set!"));
 }