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);
 }
Ejemplo n.º 2
0
 public static void Resolve(this JavaField f)
 {
     if (f.TypeGeneric == null)
     {
         return;
     }
     f.ResolvedType = f.GetApi().Parse(f.TypeGeneric, f.Parent?.TypeParameters);
 }
 static void Load(this JavaField field, Field gf)
 {
     field.Deprecated  = gf.DeprecatedComment;
     field.Final       = gf.IsFinal;
     field.Name        = gf.JavaName;
     field.Static      = gf.IsStatic;
     field.Visibility  = gf.Visibility;
     field.Type        = gf.TypeName;      // FIXME: this is managed name. Should there be Java typename?
     field.TypeGeneric = gf.TypeName;      // FIXME: this is NOT generic.
     field.Value       = gf.Value;
 }
        public static void Load(this JavaField field, XmlReader reader)
        {
            field.LoadMemberAttributes(reader);
            field.Transient   = XmlConvert.ToBoolean(XmlUtil.GetRequiredAttribute(reader, "transient"));
            field.Volatile    = XmlConvert.ToBoolean(XmlUtil.GetRequiredAttribute(reader, "transient"));
            field.Type        = XmlUtil.GetRequiredAttribute(reader, "type");
            field.TypeGeneric = XmlUtil.GetRequiredAttribute(reader, "type-generic-aware");
            field.Value       = reader.GetAttribute("value");

            reader.Skip();
        }
        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);
            }
        }
        static void Save(this JavaField field, XmlWriter writer)
        {
            var value = field.Value;

            if (value != null && (field.Type == "double" || field.Type == "float"))
            {
                value = value.Replace("E+", "E");
            }
            SaveCommon(field, writer, "field", null, null, null, null,
                       XmlConvert.ToString(field.Transient),
                       field.Type,
                       field.TypeGeneric,
                       value,
                       XmlConvert.ToString(field.Volatile),
                       null,
                       null,
                       null);
        }
 public static void Resolve(this JavaField f)
 {
     f.ResolvedType = f.GetApi().Parse(f.TypeGeneric, f.Parent.TypeParameters);
 }