Example #1
0
        private static void AddAnnotations(ClassFileWriter writer, IAttributeOwner target, MemberInfo source)
        {
#if !FIRST_PASS && !STUB_GENERATOR
            if (source != null)
            {
                RuntimeVisibleAnnotationsAttribute attr = null;
                foreach (CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(source))
                {
                    object[] ann = GetAnnotation(cad);
                    if (ann != null)
                    {
                        if (attr == null)
                        {
                            attr = new RuntimeVisibleAnnotationsAttribute(writer);
                        }
                        attr.Add(UnpackArray((IList <CustomAttributeTypedArgument>)cad.ConstructorArguments[0].Value));
                    }
                }
                if (attr != null)
                {
                    target.AddAttribute(attr);
                }
            }
#endif
        }
        private static void AddAnnotations(ClassFileWriter writer, IAttributeOwner target, MemberInfo source)
        {
#if !FIRST_PASS && !STUB_GENERATOR
#if !WINRT
            if (source != null)
            {
                RuntimeVisibleAnnotationsAttribute attr = null;
                foreach (CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(source))
                {
                    object[] ann = GetAnnotation(cad);
                    if (ann != null)
                    {
                        if (attr == null)
                        {
                            attr = new RuntimeVisibleAnnotationsAttribute(writer);
                        }
                        attr.Add(ann);
                    }
                }
                if (attr != null)
                {
                    target.AddAttribute(attr);
                }
            }
#else
            throw new NotImplementedException();
#endif
#endif
        }
        private static void AddTypeAnnotations(ClassFileWriter writer, IAttributeOwner target, TypeWrapper tw, byte[] typeAnnotations)
        {
#if !FIRST_PASS && !STUB_GENERATOR
            if (typeAnnotations != null)
            {
                typeAnnotations = (byte[])typeAnnotations.Clone();
                object[] constantPool = tw.GetConstantPool();
                try
                {
                    int    pos             = 0;
                    ushort num_annotations = ReadUInt16BE(typeAnnotations, ref pos);
                    for (int i = 0; i < num_annotations; i++)
                    {
                        FixupTypeAnnotationConstantPoolIndexes(writer, typeAnnotations, constantPool, ref pos);
                    }
                }
                catch (IndexOutOfRangeException)
                {
                    // if the attribute is malformed, we add it anyway and hope the Java parser will agree and throw the right error
                }
                target.AddAttribute(new RuntimeVisibleTypeAnnotationsAttribute(writer, typeAnnotations));
            }
#endif
        }
Example #4
0
 private static void AddAnnotations(ClassFileWriter writer, IAttributeOwner target, MemberInfo source)
 {
     #if !FIRST_PASS && !STUB_GENERATOR
     if (source != null)
     {
         RuntimeVisibleAnnotationsAttribute attr = null;
         foreach (CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(source))
         {
             object[] ann = GetAnnotation(cad);
             if (ann != null)
             {
                 if (attr == null)
                 {
                     attr = new RuntimeVisibleAnnotationsAttribute(writer);
                 }
                 attr.Add(ann);
             }
         }
         if (attr != null)
         {
             target.AddAttribute(attr);
         }
     }
     #endif
 }
Example #5
0
		private static void AddTypeAnnotations(ClassFileWriter writer, IAttributeOwner target, TypeWrapper tw, byte[] typeAnnotations)
		{
#if !FIRST_PASS && !STUB_GENERATOR
			if (typeAnnotations != null)
			{
				typeAnnotations = (byte[])typeAnnotations.Clone();
				object[] constantPool = tw.GetConstantPool();
				try
				{
					int pos = 0;
					ushort num_annotations = ReadUInt16BE(typeAnnotations, ref pos);
					for (int i = 0; i < num_annotations; i++)
					{
						FixupTypeAnnotationConstantPoolIndexes(writer, typeAnnotations, constantPool, ref pos);
					}
				}
				catch (IndexOutOfRangeException)
				{
					// if the attribute is malformed, we add it anyway and hope the Java parser will agree and throw the right error
				}
				target.AddAttribute(new RuntimeVisibleTypeAnnotationsAttribute(writer, typeAnnotations));
			}
#endif
		}
Example #6
0
 private static void AddAnnotations(ClassFileWriter writer, IAttributeOwner target, MemberInfo source)
 {
     #if !FIRST_PASS && !STUB_GENERATOR
     if (source != null)
     {
         RuntimeVisibleAnnotationsAttribute attr = null;
         foreach (CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(source))
         {
             object[] ann = GetAnnotation(cad);
             if (ann != null)
             {
                 if (attr == null)
                 {
                     attr = new RuntimeVisibleAnnotationsAttribute(writer);
                 }
                 attr.Add(UnpackArray((IList<CustomAttributeTypedArgument>)cad.ConstructorArguments[0].Value));
             }
         }
         if (attr != null)
         {
             target.AddAttribute(attr);
         }
     }
     #endif
 }