Beispiel #1
0
        static void Main(string[] args)
        {
            var       exports = DllReader.ReadFunctions(@"D:\MyDocuments\Documents\Visual Studio 2019\Projects\libLLVM_8.0.0\x64\Release\libLLVM_8.0.0.dll");
            Generator g       = new Generator();

            g.TypeVisitor = new LLVMTypeVisitor(g.Processor);
            g.Visitor     = new LLVMVisitor(g.Processor);
            g.Renamer     = new LLVMRenamer(g.Processor);
            g.AddExports(exports, "libLLVM_8.0.0");
            g.IncludeDirs.Add(@"D:\Develop\LLVM-8.0.0\include");

            foreach (var header in Directory.GetFiles(@"D:\Develop\LLVM-8.0.0\include\llvm-c"))
            {
                g.Parse($@"llvm-c\{Path.GetFileName(header)}");
            }
            g.ParseFinal();

            //using (var writer = new CSharpWriter(@"Z:\macro.cs", new CSharpWriterConfig { Namespace = "Saar.LLVM" })) {
            //	using (writer.BeginClass("Constant")) {
            //		writer.WriteMacros(g.Processor.Units);
            //	}
            //}
            using (var writer = new CSharpWriter(@"Z:\LLVM.Enums.cs", CSharpWriterConfig.GetDefaultEnumConfig("Saar.LLVM"))) {
                writer.WriteEnums(g.Processor.Units);
            }
            using (var writer = new CSharpWriter(@"Z:\LLVM.Structs.cs", CSharpWriterConfig.GetDefaultStructConfig("Saar.LLVM"))) {
                writer.WriteStructs(g.Processor.Units);
            }
            using (var writer = new CSharpWriter(@"Z:\LLVM.Delegates.cs", CSharpWriterConfig.GetDefaultDelegateConfig("Saar.LLVM"))) {
                writer.WriteDelegates(g.Processor.Units);
            }
            using (var writer = new CSharpWriter(@"Z:\LLVM.Functions.cs", CSharpWriterConfig.GetDefaultFunctionConfig("Saar.LLVM"))) {
                using (writer.BeginClass("LLVM")) {
                    writer.WriteFunctions(g.Processor.Units);
                }
            }
            //using (var writer = new CSharpWriter(@"Z:\array.cs", CSharpWriterConfig.GetDefaultFixedArrayConfig("Saar.LLVM"))) {
            //	writer.WriteFixedArrays(g.Processor.Units);
            //}
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var avutilExports  = DllReader.ReadFunctions(@"D:\Develop\ffmpeg-4.1-win64-shared\bin\avutil-56.dll");
            var avcodecExports = DllReader.ReadFunctions(@"D:\Develop\ffmpeg-4.1-win64-shared\bin\avcodec-58.dll");
            var g = new Generator();

            g.AddExports(avutilExports, "avutil-56");
            g.AddExports(avcodecExports, "avcodec-58");
            g.Processor.MacroProcessor.Filter += MacroProcessor_Filter;

            g.IncludeDirs.Add(@"D:\Develop\ffmpeg-4.1-win64-dev\include");
            g.Defines.Add("__STDC_CONSTANT_MACROS");

            g.Parse("libavutil/avutil.h");
            g.Parse("libavutil/audio_fifo.h");
            g.Parse("libavutil/channel_layout.h");
            g.Parse("libavutil/cpu.h");
            g.Parse("libavutil/frame.h");
            g.Parse("libavutil/opt.h");
            g.Parse("libavutil/imgutils.h");
            g.Parse("libavutil/timecode.h");
            g.Parse("libavutil/hwcontext.h");
            g.Parse("libavutil/hwcontext_dxva2.h");
            g.Parse("libavutil/hwcontext_d3d11va.h");

            g.Parse("libswresample/swresample.h");

            g.Parse("libpostproc/postprocess.h");

            g.Parse("libswscale/swscale.h");

            g.Parse("libavcodec/avcodec.h");

            g.Parse("libavformat/avformat.h");

            g.Parse("libavfilter/avfilter.h");
            g.Parse("libavfilter/buffersrc.h");
            g.Parse("libavfilter/buffersink.h");

            g.Parse("libavdevice/avdevice.h");

            g.ParseFinal();

            using (var writer = new CSharpWriter(@"Z:\macro.cs")) {
                using (writer.BeginClass("Constant")) {
                    writer.WriteMacros(g.Processor.Units);
                }
            }
            using (var writer = new CSharpWriter(@"Z:\enum.cs", CSharpWriterConfig.GetDefaultEnumConfig("Saar"))) {
                writer.WriteEnums(g.Processor.Units);
            }
            using (var writer = new CSharpWriter(@"Z:\struct.cs", CSharpWriterConfig.GetDefaultStructConfig("Saar"))) {
                writer.WriteStructs(g.Processor.Units);
            }
            using (var writer = new CSharpWriter(@"Z:\delegate.cs", CSharpWriterConfig.GetDefaultDelegateConfig("Saar"))) {
                writer.WriteDelegates(g.Processor.Units);
            }
            using (var writer = new CSharpWriter(@"Z:\function.cs", CSharpWriterConfig.GetDefaultFunctionConfig("Saar"))) {
                using (writer.BeginClass("FFmpeg")) {
                    writer.WriteFunctions(g.Processor.Units);
                }
            }
            using (var writer = new CSharpWriter(@"Z:\array.cs", CSharpWriterConfig.GetDefaultFixedArrayConfig("Saar"))) {
                writer.WriteFixedArrays(g.Processor.Units);
            }
        }