private static TypeWrapper[] LoadTypes(ClassLoaderWrapper loader, string[] classes) { if (classes == null || classes.Length == 0) { return(TypeWrapper.EmptyArray); } TypeWrapper[] tw = new TypeWrapper[classes.Length]; for (int i = 0; i < tw.Length; i++) { tw[i] = loader.LoadClassByDottedName(classes[i]); } return(tw); }
internal static void Create(ModuleBuilder modb, ClassLoaderWrapper loader) { TypeBuilder tb = modb.DefineType(DotNetTypeWrapper.GenericDelegateInterfaceTypeName, TypeAttributes.Interface | TypeAttributes.Abstract | TypeAttributes.Public); tb.DefineGenericParameters("T")[0].SetBaseTypeConstraint(Types.MulticastDelegate); genericDelegateInterfaceType = tb.CreateType(); TypeWrapper annotationTypeWrapper = loader.LoadClassByDottedName("java.lang.annotation.Annotation"); annotationTypeWrapper.Finish(); genericAttributeAnnotationType = CreateAnnotationType(modb, DotNetTypeWrapper.GenericAttributeAnnotationTypeName, annotationTypeWrapper); genericAttributeAnnotationMultipleType = CreateAnnotationType(modb, DotNetTypeWrapper.GenericAttributeAnnotationMultipleTypeName, annotationTypeWrapper); genericAttributeAnnotationReturnValueType = CreateAnnotationType(modb, DotNetTypeWrapper.GenericAttributeAnnotationReturnValueTypeName, annotationTypeWrapper); CreateEnumEnum(modb, loader); }
internal static void Finish(ClassLoaderWrapper loader) { TypeBuilder tb = (TypeBuilder)genericEnumEnumType; TypeWrapper enumTypeWrapper = loader.LoadClassByDottedName("java.lang.Enum"); enumTypeWrapper.Finish(); tb.SetParent(enumTypeWrapper.TypeAsBaseType); CodeEmitter ilgen = CodeEmitter.Create(ReflectUtil.DefineConstructor(tb, MethodAttributes.Private, new Type[] { Types.String, Types.Int32 })); ilgen.Emit(OpCodes.Ldarg_0); ilgen.Emit(OpCodes.Ldarg_1); ilgen.Emit(OpCodes.Ldarg_2); enumTypeWrapper.GetMethodWrapper("<init>", "(Ljava.lang.String;I)V", false).EmitCall(ilgen); ilgen.Emit(OpCodes.Ret); ilgen.DoEmit(); genericEnumEnumType = tb.CreateType(); }
private static void CreateEnumEnum(ModuleBuilder modb, ClassLoaderWrapper loader) { TypeWrapper enumTypeWrapper = loader.LoadClassByDottedName("java.lang.Enum"); enumTypeWrapper.Finish(); TypeBuilder tb = modb.DefineType(DotNetTypeWrapper.GenericEnumEnumTypeName, TypeAttributes.Class | TypeAttributes.Sealed | TypeAttributes.Public, enumTypeWrapper.TypeAsBaseType); GenericTypeParameterBuilder gtpb = tb.DefineGenericParameters("T")[0]; gtpb.SetBaseTypeConstraint(Types.Enum); CodeEmitter ilgen = CodeEmitter.Create(tb.DefineConstructor(MethodAttributes.Private, CallingConventions.Standard, new Type[] { Types.String, Types.Int32 })); ilgen.Emit(OpCodes.Ldarg_0); ilgen.Emit(OpCodes.Ldarg_1); ilgen.Emit(OpCodes.Ldarg_2); enumTypeWrapper.GetMethodWrapper("<init>", "(Ljava.lang.String;I)V", false).EmitCall(ilgen); ilgen.Emit(OpCodes.Ret); genericEnumEnumType = tb.CreateType(); }