internal static void Load(this JavaParameter p, XmlReader reader)
 {
     p.Name    = XmlUtil.GetRequiredAttribute(reader, "name");
     p.Type    = XmlUtil.GetRequiredAttribute(reader, "type");
     p.JniType = reader.GetAttribute("jni-type");
     reader.Skip();
 }
Exemple #2
0
        static void LoadMethodBase(this JavaMethodBase methodBase, string elementName, XmlReader reader)
        {
            var method = methodBase as JavaMethod;             // kind of ugly hack yeah...

            methodBase.LoadMemberAttributes(reader);
            //methodBase.ExtendedJniSignature = reader.GetAttribute ("jni-signature");
            methodBase.ExtendedJniReturn = reader.GetAttribute("jni-return");
            methodBase.ExtendedSynthetic = XmlConvert.ToBoolean(reader.GetAttribute("synthetic") ?? "false");
            methodBase.ExtendedBridge    = XmlConvert.ToBoolean(reader.GetAttribute("bridge") ?? "false");

            reader.MoveToElement();
            if (reader.IsEmptyElement)
            {
                reader.Read();
            }
            else
            {
                reader.Read();
                do
                {
                    reader.MoveToContent();
                    if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }
                    if (reader.NodeType != XmlNodeType.Element)
                    {
                        throw XmlUtil.UnexpectedElementOrContent(elementName, reader, "parameter");
                    }
                    if (reader.LocalName == "typeParameters")
                    {
                        var tp = new JavaTypeParameters(methodBase);
                        tp.Load(reader);
                        methodBase.TypeParameters = tp;
                    }
                    else if (reader.LocalName == "parameter")
                    {
                        var p = new JavaParameter(methodBase);
                        p.Load(reader);
                        methodBase.Parameters.Add(p);
                    }
                    else if (reader.LocalName == "exception")
                    {
                        var p = new JavaException();
                        p.Load(reader);
                        methodBase.Exceptions.Add(p);
                    }
                    else
                    {
                        throw XmlUtil.UnexpectedElementOrContent(elementName, reader, "parameter");
                    }
                } while (true);
                XmlUtil.VerifyEndElement(reader, elementName);
                reader.Read();
            }
        }
		static bool IsParameterAssignableTo (this JavaParameter dp, JavaParameter bp, JavaMethod derived, JavaMethod basis, IDictionary<JavaTypeReference,JavaTypeReference> genericInstantiation)
		{
			// If type names are equivalent, they simply match... except that the generic type parameter names match.
			// Generic type arguments need more check, so do not examine them just by name.
			//
			// FIXME: It is likely that this check should NOT result in "this method is not an override",
			// but rather like "this method is an override, but it should be still generated in the resulting XML".
			// For example, this results in that java.util.EnumMap#put() is NOT an override of
			// java.util.AbstractMap#put(), it is an override, not just that it is still generated in the XML.
			if (bp.ResolvedType.ReferencedTypeParameter != null && dp.ResolvedType.ReferencedTypeParameter != null &&
			    bp.ResolvedType.ReferencedTypeParameter.ToString () != dp.ResolvedType.ReferencedTypeParameter.ToString ())
				return false;
			if (bp.Type == dp.Type)
				return true;

			if (bp.ResolvedType.ArrayPart != bp.ResolvedType.ArrayPart)
				return false;
			
			// if base is type with generic type parameters and derived is without any generic args, that's OK.
			// java.lang.Class should match java.lang.Class<T>.
			if (bp.ResolvedType.ReferencedType != null && dp.ResolvedType.ReferencedType != null &&
			    bp.ResolvedType.ReferencedType.FullName == dp.ResolvedType.ReferencedType.FullName &&
			    dp.ResolvedType.TypeParameters == null)
				return true;
				
			// generic instantiation check.
			var baseGTP = bp.ResolvedType.ReferencedTypeParameter;
			if (baseGTP != null) {
				if (baseGTP.Parent.ParentMethod != null && baseGTP.IsConformantType (dp.ResolvedType))
					return true;
				var k = genericInstantiation.Keys.FirstOrDefault (tr => bp.ResolvedType.Equals (tr));
				if (k == null)
					// the specified generic type parameter is not part of
					// the mappings e.g. non-instantiated ones.
					return false;
				if (genericInstantiation [k].Equals (dp.ResolvedType))
					// the specified generic type parameter exactly matches
					// whatever specified at the derived method.
					return true;
			}

			// FIXME: implement variance check.

			return false;
		}
Exemple #4
0
        public static string GetVisibleTypeName(this JavaParameter parameter)
        {
            var r = GetVisibleNonSpecialType(parameter);

            return(r != null?r.ToString() : parameter.Type);
        }
Exemple #5
0
 public static JavaTypeReference GetVisibleNonSpecialType(this JavaParameter parameter)
 {
     return(GetVisibleNonSpecialType(parameter.Parent, parameter.ResolvedType));
 }