本文整理汇总了C#中IKVM.Internal.MethodWrapper类的典型用法代码示例。如果您正苦于以下问题:C# MethodWrapper类的具体用法?C# MethodWrapper怎么用?C# MethodWrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodWrapper类属于IKVM.Internal命名空间,在下文中一共展示了MethodWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProxyGenerator
static ProxyGenerator()
{
ClassLoaderWrapper bootClassLoader = ClassLoaderWrapper.GetBootstrapClassLoader();
proxyClass = bootClassLoader.LoadClassByDottedNameFast("java.lang.reflect.Proxy");
errorClass = bootClassLoader.LoadClassByDottedNameFast("java.lang.Error");
runtimeExceptionClass = bootClassLoader.LoadClassByDottedNameFast("java.lang.RuntimeException");
undeclaredThrowableExceptionConstructor = bootClassLoader.LoadClassByDottedNameFast("java.lang.reflect.UndeclaredThrowableException").GetMethodWrapper("<init>", "(Ljava.lang.Throwable;)V", false);
undeclaredThrowableExceptionConstructor.Link();
invocationHandlerField = proxyClass.GetFieldWrapper("h", "Ljava.lang.reflect.InvocationHandler;");
invocationHandlerField.Link();
javaLangReflectMethod = bootClassLoader.LoadClassByDottedNameFast("java.lang.reflect.Method");
javaLangNoSuchMethodException = bootClassLoader.LoadClassByDottedNameFast("java.lang.NoSuchMethodException");
javaLangNoClassDefFoundErrorConstructor = bootClassLoader.LoadClassByDottedNameFast("java.lang.NoClassDefFoundError").GetMethodWrapper("<init>", "(Ljava.lang.String;)V", false);
javaLangNoClassDefFoundErrorConstructor.Link();
javaLangThrowable_getMessage = bootClassLoader.LoadClassByDottedNameFast("java.lang.Throwable").GetMethodWrapper("getMessage", "()Ljava.lang.String;", false);
javaLangThrowable_getMessage.Link();
javaLangClass_getMethod = CoreClasses.java.lang.Class.Wrapper.GetMethodWrapper("getMethod", "(Ljava.lang.String;[Ljava.lang.Class;)Ljava.lang.reflect.Method;", false);
javaLangClass_getMethod.Link();
invocationHandlerClass = bootClassLoader.LoadClassByDottedNameFast("java.lang.reflect.InvocationHandler");
invokeMethod = invocationHandlerClass.GetMethodWrapper("invoke", "(Ljava.lang.Object;Ljava.lang.reflect.Method;[Ljava.lang.Object;)Ljava.lang.Object;", false);
proxyConstructor = proxyClass.GetMethodWrapper("<init>", "(Ljava.lang.reflect.InvocationHandler;)V", false);
proxyConstructor.Link();
hashCodeMethod = CoreClasses.java.lang.Object.Wrapper.GetMethodWrapper("hashCode", "()I", false);
equalsMethod = CoreClasses.java.lang.Object.Wrapper.GetMethodWrapper("equals", "(Ljava.lang.Object;)Z", false);
toStringMethod = CoreClasses.java.lang.Object.Wrapper.GetMethodWrapper("toString", "()Ljava.lang.String;", false);
}
示例2: InlineJsrs
internal static void InlineJsrs(ClassLoaderWrapper classLoader, MethodWrapper mw, ClassFile classFile, ClassFile.Method m)
{
JsrInliner inliner;
do
{
ClassFile.Method.Instruction[] codeCopy = (ClassFile.Method.Instruction[])m.Instructions.Clone();
InstructionFlags[] flags = new InstructionFlags[codeCopy.Length];
JsrMethodAnalyzer ma = new JsrMethodAnalyzer(mw, classFile, m, classLoader, flags);
inliner = new JsrInliner(codeCopy, flags, m, ma);
} while (inliner.InlineJsrs());
}
示例3: Boxer
static Boxer()
{
ClassLoaderWrapper bootClassLoader = ClassLoaderWrapper.GetBootstrapClassLoader();
javaLangByte = bootClassLoader.LoadClassByDottedNameFast("java.lang.Byte");
byteValue = javaLangByte.GetMethodWrapper("byteValue", "()B", false);
byteValue.Link();
valueOfByte = javaLangByte.GetMethodWrapper("valueOf", "(B)Ljava.lang.Byte;", false);
valueOfByte.Link();
javaLangBoolean = bootClassLoader.LoadClassByDottedNameFast("java.lang.Boolean");
booleanValue = javaLangBoolean.GetMethodWrapper("booleanValue", "()Z", false);
booleanValue.Link();
valueOfBoolean = javaLangBoolean.GetMethodWrapper("valueOf", "(Z)Ljava.lang.Boolean;", false);
valueOfBoolean.Link();
javaLangShort = bootClassLoader.LoadClassByDottedNameFast("java.lang.Short");
shortValue = javaLangShort.GetMethodWrapper("shortValue", "()S", false);
shortValue.Link();
valueOfShort = javaLangShort.GetMethodWrapper("valueOf", "(S)Ljava.lang.Short;", false);
valueOfShort.Link();
javaLangCharacter = bootClassLoader.LoadClassByDottedNameFast("java.lang.Character");
charValue = javaLangCharacter.GetMethodWrapper("charValue", "()C", false);
charValue.Link();
valueOfCharacter = javaLangCharacter.GetMethodWrapper("valueOf", "(C)Ljava.lang.Character;", false);
valueOfCharacter.Link();
javaLangInteger = bootClassLoader.LoadClassByDottedNameFast("java.lang.Integer");
intValue = javaLangInteger.GetMethodWrapper("intValue", "()I", false);
intValue.Link();
valueOfInteger = javaLangInteger.GetMethodWrapper("valueOf", "(I)Ljava.lang.Integer;", false);
valueOfInteger.Link();
javaLangFloat = bootClassLoader.LoadClassByDottedNameFast("java.lang.Float");
floatValue = javaLangFloat.GetMethodWrapper("floatValue", "()F", false);
floatValue.Link();
valueOfFloat = javaLangFloat.GetMethodWrapper("valueOf", "(F)Ljava.lang.Float;", false);
valueOfFloat.Link();
javaLangLong = bootClassLoader.LoadClassByDottedNameFast("java.lang.Long");
longValue = javaLangLong.GetMethodWrapper("longValue", "()J", false);
longValue.Link();
valueOfLong = javaLangLong.GetMethodWrapper("valueOf", "(J)Ljava.lang.Long;", false);
valueOfLong.Link();
javaLangDouble = bootClassLoader.LoadClassByDottedNameFast("java.lang.Double");
doubleValue = javaLangDouble.GetMethodWrapper("doubleValue", "()D", false);
doubleValue.Link();
valueOfDouble = javaLangDouble.GetMethodWrapper("valueOf", "(D)Ljava.lang.Double;", false);
valueOfDouble.Link();
}
示例4: GetReplacedMethodsFor
internal IKVM.Internal.MapXml.ReplaceMethodCall[] GetReplacedMethodsFor(MethodWrapper mw)
{
if(mapxml_ReplacedMethods == null)
{
return null;
}
IKVM.Internal.MapXml.ReplaceMethodCall[] rmc;
mapxml_ReplacedMethods.TryGetValue(new MethodKey(mw.DeclaringType.Name, mw.Name, mw.Signature), out rmc);
return rmc;
}
示例5: GetPropertyMethodAttributes
private static MethodAttributes GetPropertyMethodAttributes(MethodWrapper mw, bool final)
{
MethodAttributes attribs = MethodAttributes.HideBySig;
if(mw.IsStatic)
{
attribs |= MethodAttributes.Static;
}
else
{
// NOTE in order for IntelliSense to consider the property a "real" property,
// the getter and setter methods need to have substantially the same method attributes,
// so we may need to look at our peer to determine whether we should be final
// or not (and vice versa).
attribs |= MethodAttributes.Virtual | MethodAttributes.NewSlot | MethodAttributes.CheckAccessOnOverride;
if(final)
{
attribs |= MethodAttributes.Final;
}
}
// TODO what happens if accessibility doesn't match our peer?
if(mw.IsPublic)
{
attribs |= MethodAttributes.Public;
}
else if(mw.IsProtected)
{
attribs |= MethodAttributes.FamORAssem;
}
else if(mw.IsPrivate)
{
attribs |= MethodAttributes.Private;
}
else
{
attribs |= MethodAttributes.Assembly;
}
return attribs;
}
示例6: EmitMapXmlMetadata
protected override void EmitMapXmlMetadata(TypeBuilder typeBuilder, ClassFile classFile, FieldWrapper[] fields, MethodWrapper[] methods)
{
Dictionary<string, IKVM.Internal.MapXml.Class> mapxml = classLoader.GetMapXmlClasses();
if(mapxml != null)
{
IKVM.Internal.MapXml.Class clazz;
if(mapxml.TryGetValue(classFile.Name, out clazz))
{
if(clazz.Attributes != null)
{
PublishAttributes(typeBuilder, clazz);
}
if(clazz.Properties != null)
{
PublishProperties(typeBuilder, clazz);
}
if(clazz.Fields != null)
{
foreach(IKVM.Internal.MapXml.Field field in clazz.Fields)
{
if(field.Attributes != null)
{
foreach(FieldWrapper fw in fields)
{
if(fw.Name == field.Name && fw.Signature == field.Sig)
{
FieldBuilder fb = fw.GetField() as FieldBuilder;
if(fb != null)
{
foreach(IKVM.Internal.MapXml.Attribute attr in field.Attributes)
{
AttributeHelper.SetCustomAttribute(classLoader, fb, attr);
}
}
}
}
}
}
}
if(clazz.Constructors != null)
{
// HACK this isn't the right place to do this, but for now it suffices
foreach(IKVM.Internal.MapXml.Constructor constructor in clazz.Constructors)
{
// are we adding a new constructor?
if(GetMethodWrapper(StringConstants.INIT, constructor.Sig, false) == null)
{
if(constructor.body == null)
{
Console.Error.WriteLine("Error: Constructor {0}.<init>{1} in xml remap file doesn't have a body.", clazz.Name, constructor.Sig);
continue;
}
bool setmodifiers = false;
MethodAttributes attribs = 0;
MapModifiers(constructor.Modifiers, true, out setmodifiers, ref attribs);
Type returnType;
Type[] parameterTypes;
MapSignature(constructor.Sig, out returnType, out parameterTypes);
MethodBuilder cb = ReflectUtil.DefineConstructor(typeBuilder, attribs, parameterTypes);
if(setmodifiers)
{
AttributeHelper.SetModifiers(cb, (Modifiers)constructor.Modifiers, false);
}
CompilerClassLoader.AddDeclaredExceptions(cb, constructor.throws);
CodeEmitter ilgen = CodeEmitter.Create(cb);
constructor.Emit(classLoader, ilgen);
ilgen.DoEmit();
if(constructor.Attributes != null)
{
foreach(IKVM.Internal.MapXml.Attribute attr in constructor.Attributes)
{
AttributeHelper.SetCustomAttribute(classLoader, cb, attr);
}
}
}
}
foreach(IKVM.Internal.MapXml.Constructor constructor in clazz.Constructors)
{
if(constructor.Attributes != null)
{
foreach(MethodWrapper mw in methods)
{
if(mw.Name == "<init>" && mw.Signature == constructor.Sig)
{
MethodBuilder mb = mw.GetMethod() as MethodBuilder;
if(mb != null)
{
foreach(IKVM.Internal.MapXml.Attribute attr in constructor.Attributes)
{
AttributeHelper.SetCustomAttribute(classLoader, mb, attr);
}
}
}
}
}
}
}
if(clazz.Methods != null)
{
// HACK this isn't the right place to do this, but for now it suffices
//.........这里部分代码省略.........
示例7: ReplaceMethodWrapper
internal MethodWrapper ReplaceMethodWrapper(MethodWrapper mw)
{
if (replacedMethods != null)
{
foreach (MethodWrapper r in replacedMethods)
{
if (mw.DeclaringType == r.DeclaringType
&& mw.Name == r.Name
&& mw.Signature == r.Signature)
{
return r;
}
}
}
return mw;
}
示例8: WorkaroundBaseClass
internal WorkaroundBaseClass(AotTypeWrapper wrapper, TypeBuilder typeBuilder, MethodWrapper[] methods)
{
this.wrapper = wrapper;
this.typeBuilder = typeBuilder;
this.methods = methods;
}
示例9: BaseFinalMethodWrapper
internal BaseFinalMethodWrapper(DotNetTypeWrapper tw, MethodWrapper m)
: base(tw, m.Name, m.Signature, null, null, null, (m.Modifiers & ~Modifiers.Abstract) | Modifiers.Final, MemberFlags.None)
{
this.m = m;
}
示例10: LazyPublishMembers
protected override void LazyPublishMembers()
{
// special support for enums
if (type.IsEnum)
{
Type underlyingType = EnumHelper.GetUnderlyingType(type);
Type javaUnderlyingType;
if (underlyingType == Types.SByte)
{
javaUnderlyingType = Types.Byte;
}
else if (underlyingType == Types.UInt16)
{
javaUnderlyingType = Types.Int16;
}
else if (underlyingType == Types.UInt32)
{
javaUnderlyingType = Types.Int32;
}
else if (underlyingType == Types.UInt64)
{
javaUnderlyingType = Types.Int64;
}
else
{
javaUnderlyingType = underlyingType;
}
TypeWrapper fieldType = ClassLoaderWrapper.GetWrapperFromType(javaUnderlyingType);
FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Static);
List<FieldWrapper> fieldsList = new List<FieldWrapper>();
for (int i = 0; i < fields.Length; i++)
{
if (fields[i].FieldType == type)
{
string name = fields[i].Name;
if (name == "Value")
{
name = "_Value";
}
else if (name.StartsWith("_") && name.EndsWith("Value"))
{
name = "_" + name;
}
object val = EnumHelper.GetPrimitiveValue(underlyingType, fields[i].GetRawConstantValue());
fieldsList.Add(new ConstantFieldWrapper(this, fieldType, name, fieldType.SigName, Modifiers.Public | Modifiers.Static | Modifiers.Final, fields[i], val, MemberFlags.None));
}
}
fieldsList.Add(new EnumValueFieldWrapper(this, fieldType));
SetFields(fieldsList.ToArray());
SetMethods(new MethodWrapper[] { new EnumWrapMethodWrapper(this, fieldType) });
}
else
{
List<FieldWrapper> fieldsList = new List<FieldWrapper>();
FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
for (int i = 0; i < fields.Length; i++)
{
// TODO for remapped types, instance fields need to be converted to static getter/setter methods
if (fields[i].FieldType.IsPointer)
{
// skip, pointer fields are not supported
}
else
{
// TODO handle name/signature clash
fieldsList.Add(CreateFieldWrapperDotNet(AttributeHelper.GetModifiers(fields[i], true).Modifiers, fields[i].Name, fields[i].FieldType, fields[i]));
}
}
SetFields(fieldsList.ToArray());
Dictionary<string, MethodWrapper> methodsList = new Dictionary<string, MethodWrapper>();
// special case for delegate constructors!
if (IsDelegate(type))
{
TypeWrapper iface = InnerClasses[0];
DelegateMethodWrapper mw = new DelegateMethodWrapper(this, (DelegateInnerClassTypeWrapper)iface);
methodsList.Add(mw.Name + mw.Signature, mw);
}
// add a protected default constructor to MulticastDelegate to make it easier to define a delegate in Java
if (type == Types.MulticastDelegate)
{
methodsList.Add("<init>()V", new MulticastDelegateCtorMethodWrapper(this));
}
ConstructorInfo[] constructors = type.GetConstructors(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
for (int i = 0; i < constructors.Length; i++)
{
string name;
string sig;
TypeWrapper[] args;
TypeWrapper ret;
if (MakeMethodDescriptor(constructors[i], out name, out sig, out args, out ret))
{
MethodWrapper mw = CreateMethodWrapper(name, sig, args, ret, constructors[i], false);
string key = mw.Name + mw.Signature;
if (!methodsList.ContainsKey(key))
{
methodsList.Add(key, mw);
//.........这里部分代码省略.........
示例11: BaseFinalMethodWrapper
internal BaseFinalMethodWrapper(DotNetTypeWrapper tw, MethodWrapper m)
: base(tw, m.Name, m.Signature, m.GetMethod(), m.ReturnType, m.GetParameters(), (m.Modifiers & ~Modifiers.Abstract) | Modifiers.Final, MemberFlags.None)
{
this.m = m;
}
示例12: SetImpl
internal static void SetImpl(MethodWrapper mw, MethodInfo impl)
{
DefaultInterfaceMethodWrapper dimw = mw as DefaultInterfaceMethodWrapper;
if (dimw != null)
{
dimw.impl = impl;
}
else
{
((GhostMethodWrapper)mw).SetDefaultImpl(impl);
}
}
示例13: GetImpl
internal static MethodInfo GetImpl(MethodWrapper mw)
{
DefaultInterfaceMethodWrapper dimw = mw as DefaultInterfaceMethodWrapper;
if (dimw != null)
{
return dimw.impl;
}
else
{
return ((GhostMethodWrapper)mw).GetDefaultImpl();
}
}
示例14: AddConflictError
protected virtual MirandaMethodWrapper AddConflictError(MethodWrapper mw)
{
return new ErrorMirandaMethodWrapper(DeclaringType, ifmethod, "Conflicting default methods:")
.AddConflictError(ifmethod)
.AddConflictError(mw);
}
示例15: AddParameterMetadata
private void AddParameterMetadata(MethodBuilder method, MethodWrapper mw)
{
ParameterBuilder[] pbs;
if((mw.DeclaringType.IsPublic && (mw.IsPublic || mw.IsProtected)) || classLoader.EmitDebugInfo)
{
string[] parameterNames = new string[mw.GetParameters().Length];
GetParameterNamesFromXml(mw.Name, mw.Signature, parameterNames);
GetParameterNamesFromSig(mw.Signature, parameterNames);
pbs = GetParameterBuilders(method, parameterNames.Length, parameterNames);
}
else
{
pbs = GetParameterBuilders(method, mw.GetParameters().Length, null);
}
if((mw.Modifiers & Modifiers.VarArgs) != 0 && pbs.Length > 0)
{
AttributeHelper.SetParamArrayAttribute(pbs[pbs.Length - 1]);
}
AddXmlMapParameterAttributes(method, Name, mw.Name, mw.Signature, ref pbs);
}