Example #1
0
 public static void LoadMemberAttributes(this JavaMember member, XmlReader reader)
 {
     member.Deprecated = XmlUtil.GetRequiredAttribute(reader, "deprecated");
     member.Final      = XmlConvert.ToBoolean(XmlUtil.GetRequiredAttribute(reader, "final"));
     member.Name       = XmlUtil.GetRequiredAttribute(reader, "name");
     member.Static     = XmlConvert.ToBoolean(XmlUtil.GetRequiredAttribute(reader, "static"));
     member.Visibility = XmlUtil.GetRequiredAttribute(reader, "visibility");
 }
 static void ResolveWithTryCatch(Action resolve, JavaMember m)
 {
     try {
         resolve();
     } catch (JavaTypeResolutionException ex) {
         Log.LogError("Error while processing '{0}' in '{1}': {2}", m, m.Parent, ex.Message);
         m.Parent.Members.Remove(m);
     }
 }
Example #3
0
 static void ResolveWithTryCatch(Action resolve, JavaMember m)
 {
     try {
         resolve();
     } catch (JavaTypeResolutionException ex) {
         Console.Error.WriteLine(string.Format("Error while processing '{0}' in '{1}': {2}", m, m.Parent, ex.Message));
         m.Parent.Members.Remove(m);
     }
 }
 public static JavaApi GetApi(this JavaMember member)
 {
     return(member.Parent.Parent.Parent);
 }
Example #5
0
 public static JavaApi GetApi(this JavaMember member)
 {
     return(member.Parent?.Parent?.Parent ?? throw new InvalidOperationException("`JavaApi` via JavaMethod.Parent.Parent.Parent not set!"));;
 }
Example #6
0
        static void SaveCommon(this JavaMember m, XmlWriter writer, string elementName,
                               string abs, string native, string ret, string sync,
                               string transient, string type, string typeGeneric,
                               string value, string volat,
                               JavaTypeParameters typeParameters,
                               IEnumerable <JavaParameter> parameters,
                               IEnumerable <JavaException> exceptions,
                               bool?extBridge, string jniReturn, bool?extSynthetic)
        {
            // If any of the parameters contain reference to non-public type, it cannot be generated.
            if (parameters != null && parameters.Any(p => p.ResolvedType.ReferencedType != null && string.IsNullOrEmpty(p.ResolvedType.ReferencedType.Visibility)))
            {
                return;
            }

            writer.WriteStartElement(elementName);
            if (abs != null)
            {
                writer.WriteAttributeString("abstract", abs);
            }
            writer.WriteAttributeString("deprecated", m.Deprecated);
            writer.WriteAttributeString("final", XmlConvert.ToString(m.Final));
            writer.WriteAttributeString("name", m.Name);
            writer.WriteAttributeString("jni-signature", m.ExtendedJniSignature);
            if (extBridge.HasValue)
            {
                writer.WriteAttributeString("bridge", extBridge.Value ? "true" : "false");
            }
            if (native != null)
            {
                writer.WriteAttributeString("native", native);
            }
            if (ret != null)
            {
                writer.WriteAttributeString("return", ret);
            }
            if (jniReturn != null)
            {
                writer.WriteAttributeString("jni-return", jniReturn);
            }
            writer.WriteAttributeString("static", XmlConvert.ToString(m.Static));
            if (sync != null)
            {
                writer.WriteAttributeString("synchronized", sync);
            }
            if (transient != null)
            {
                writer.WriteAttributeString("transient", transient);
            }
            if (type != null)
            {
                writer.WriteAttributeString("type", type);
            }
            if (typeGeneric != null)
            {
                writer.WriteAttributeString("type-generic-aware", typeGeneric);
            }
            if (value != null)
            {
                writer.WriteAttributeString("value", value);
            }
            if (extSynthetic.HasValue)
            {
                writer.WriteAttributeString("synthetic", extSynthetic.Value ? "true" : "false");
            }
            writer.WriteAttributeString("visibility", m.Visibility);
            if (volat != null)
            {
                writer.WriteAttributeString("volatile", volat);
            }

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

            if (parameters != null)
            {
                foreach (var p in parameters)
                {
                    writer.WriteStartElement("parameter");
                    writer.WriteAttributeString("name", p.Name);
                    writer.WriteAttributeString("type", p.GetVisibleTypeName());
                    if (!string.IsNullOrEmpty(p.JniType))
                    {
                        writer.WriteAttributeString("jni-type", p.JniType);
                    }
                    writer.WriteString("\n        ");
                    writer.WriteFullEndElement();
                }
            }

            if (exceptions != null)
            {
                foreach (var e in exceptions.OrderBy(e => e.Name.Substring(e.Name.LastIndexOf('/') + 1).Replace('$', '.'), StringComparer.Ordinal))
                {
                    writer.WriteStartElement("exception");
                    writer.WriteAttributeString("name", e.Name.Substring(e.Name.LastIndexOf('/') + 1).Replace('$', '.'));
                    writer.WriteAttributeString("type", e.Type);
                    if (!string.IsNullOrEmpty(e.TypeGenericAware))
                    {
                        writer.WriteAttributeString("type-generic-aware", e.TypeGenericAware);
                    }
                    writer.WriteString("\n        ");
                    writer.WriteFullEndElement();
                }
            }

            writer.WriteString("\n      ");
            writer.WriteFullEndElement();
        }