// ------------------------------------------------------------------------------------------------------------- // CIL implementation public static MethodBuilder CreateCilPInvokeMethod( Universe universe, IEssentials essentials, TypeBuilder builder, Method m, MethodAttributes methodAttributes, Type resolvedReturnType, Type[] resolvedParameterTypes) { var mb = builder.DefinePInvokeMethod( m.Name, m.Source.Package.Name + "-PInvoke.dll", PInvokeBackend.CName(m), methodAttributes | MethodAttributes.PinvokeImpl, CallingConventions.Standard, resolvedReturnType, null, null, resolvedParameterTypes, GetRequiredModifiers(universe, m.Parameters), null, CallingConvention.Cdecl, CharSet.Unicode); mb.SetImplementationFlags(MethodImplAttributes.PreserveSig); var rb = mb.DefineParameter(0, ParameterAttributes.None, null); var customReturnAttribute = GetCustomAttribute(universe, essentials, m.ReturnType); if (customReturnAttribute != null) { rb.SetCustomAttribute(customReturnAttribute); } int i = 1; foreach (var param in m.Parameters) { var pb = mb.DefineParameter(i, GetParameterTypeAttributes(param.Type), param.Name); var customAttribute = GetCustomAttribute(universe, essentials, param.Type); if (customAttribute != null) { pb.SetCustomAttribute(customAttribute); } ++i; } return(mb); }
public PInvokeWriter(PInvokeBackend backend, string fileName) : base(backend, fileName) { _backend = backend; }
public PInvokeWriter(PInvokeBackend backend, StringBuilder sb, Function context) : base(backend, sb, context) { _backend = backend; }
public PInvokeDecompiler(PInvokeBackend backend) { _backend = backend; }