Beispiel #1
0
    int GenInterpToNative(String[] args)
    {
        if (args.Length < 2)
        {
            Usage();
            return(1);
        }
        string outfileName = args [1];

        args = args.Skip(2).ToArray();

        var assemblies = new List <AssemblyDefinition> ();

        foreach (var fname in args)
        {
            assemblies.Add(AssemblyDefinition.ReadAssembly(fname));
        }

        List <Pinvoke>         pinvokes;
        List <PinvokeCallback> callbacks;

        PInvokeTableGenerator.CollectPInvokes(assemblies, out pinvokes, out callbacks);

        var gen = new InterpToNativeGenerator();

        foreach (var pinvoke in pinvokes)
        {
            gen.AddSignature(pinvoke.Method);
        }
        using (var w = File.CreateText(outfileName)) {
            gen.Emit(w);
        }
        return(0);
    }
Beispiel #2
0
    private void ExecuteInternal()
    {
        var pinvoke = new PInvokeTableGenerator(Log);
        var icall   = new IcallTableGenerator(Log);

        IEnumerable <string> cookies = Enumerable.Concat(
            pinvoke.GenPInvokeTable(PInvokeModules, Assemblies !, PInvokeOutputPath !),
            icall.GenIcallTable(RuntimeIcallTableFile, Assemblies !, IcallOutputPath)
            );

        var m2n = new InterpToNativeGenerator(Log);

        m2n.Generate(cookies, InterpToNativeOutputPath !);

        FileWrites = IcallOutputPath != null
            ? new string[] { PInvokeOutputPath, IcallOutputPath, InterpToNativeOutputPath }
            : new string[] { PInvokeOutputPath, InterpToNativeOutputPath };
    }
Beispiel #3
0
    int GenInterpToNative(String[] args)
    {
        if (args.Length < 2)
        {
            Usage();
            return(1);
        }
        string outfileName = args [1];

        args = args.Skip(2).ToArray();

        pinvokes = new List <Pinvoke> ();
        foreach (var fname in args)
        {
            var a = AssemblyDefinition.ReadAssembly(fname);

            foreach (var type in a.MainModule.Types)
            {
                ProcessTypeForPinvoke(pinvokes, type);
                foreach (var nested in type.NestedTypes)
                {
                    ProcessTypeForPinvoke(pinvokes, nested);
                }
            }
        }

        var gen = new InterpToNativeGenerator();

        foreach (var pinvoke in pinvokes)
        {
            gen.AddSignature(pinvoke.Method);
        }
        using (var w = File.CreateText(outfileName)) {
            gen.Emit(w);
        }
        return(0);
    }