Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            var options = CliOptions.ParseArgumentsStrict(args);

            if (options.Verbose)
            {
                Console.WriteLine("Working dir: " + Environment.CurrentDirectory);
                Console.WriteLine("Output dir: " + options.OutputDir);
                Console.WriteLine("headers dir: " + options.IncludesDir);
                Console.WriteLine("bin dir: " + options.BinDir);
                Console.WriteLine("Namespace name: " + options.Namespace);
                Console.WriteLine("Class name: " + options.ClassName);
            }

            var existingInlineFunctions =
                ExistingInlineFunctionsHelper.LoadInlineFunctions(Path.Combine(options.OutputDir,
                                                                               "Kedacom.functions.inline.g.cs"));

            var exports = FunctionExportHelper.LoadFunctionExports(options.BinDir, "ipcsdk.dll", (funcName) => funcName.StartsWith("IPC_")).ToArray();

            var astProcessor = new ASTProcessor
            {
                FunctionExportMap = exports
                                    .GroupBy(x => x.Name).Select(x => x.First()) // Eliminate duplicated names
                                    .ToDictionary(x => x.Name)
            };

            var defines = new string[] {};

            var g = new Generator(astProcessor)
            {
                IncludeDirs                   = new[] { options.IncludesDir },
                Defines                       = defines,
                Exports                       = exports,
                Namespace                     = options.Namespace,
                ClassName                     = options.ClassName,
                ExistingInlineFunctions       = existingInlineFunctions,
                SuppressUnmanagedCodeSecurity = options.SuppressUnmanagedCodeSecurity
            };

            g.Parse("ipcsdk/ipcdefine.h");
            g.Parse("ipcsdk/ipcstruct.h");
            g.Parse("ipcsdk/ipcsdk_c.h");
            g.Parse("ipcsdk/ipcsdk_c.cpp");

            g.WriteLibraries(Path.Combine(options.OutputDir, "Kedacom.libraries.g.cs"));
            g.WriteMacros(Path.Combine(options.OutputDir, "Kedacom.macros.g.cs"));
            g.WriteEnums(Path.Combine(options.OutputDir, "Kedacom.enums.g.cs"));
            g.WriteDelegates(Path.Combine(options.OutputDir, "Kedacom.delegates.g.cs"));
            g.WriteArrays(Path.Combine(options.OutputDir, "Kedacom.arrays.g.cs"));
            g.WriteStructures(Path.Combine(options.OutputDir, "Kedacom.structs.g.cs"));
            g.WriteIncompleteStructures(Path.Combine(options.OutputDir, "Kedacom.structs.incomplete.g.cs"));
            g.WriteExportFunctions(Path.Combine(options.OutputDir, "Kedacom.functions.export.g.cs"));
            g.WriteInlineFunctions(Path.Combine(options.OutputDir, "Kedacom.functions.inline.g.cs"));
        }
Ejemplo n.º 2
0
 private void Process(ASTContext context)
 {
     if (_astProcessor == null)
     {
         _astProcessor = new ASTProcessor {
             FunctionExportMap = Exports.ToDictionary(x => x.Name)
         }
     }
     ;
     _astProcessor.Process(context.TranslationUnits.Where(x => !x.IsSystemHeader));
 }
Ejemplo n.º 3
0
        private static readonly string[] Defines     = { "__STDC_CONSTANT_MACROS" }; //{ "__cplusplus", "_WIN32" };// {"__STDC_CONSTANT_MACROS"};

        private static void Main(string[] args)
        {
            Console.WriteLine("Current directory: " + Environment.CurrentDirectory);
            Console.WriteLine("Is 64 bit process: " + Environment.Is64BitProcess);

            var exports = FunctionExportHelper.LoadFunctionExports(OpenNIBinDir).ToArray();

            var astProcessor = new ASTProcessor {
                FunctionExportMap = exports.GroupBy(x => x.Name).Select(x => x.First()).ToDictionary(x => x.Name)
            };

            astProcessor.IgnoreUnitNames.Add("__NSConstantString_tag");
            astProcessor.TypeAliases.Add("int64_t", typeof(long));

            var g = new Generator(astProcessor)
            {
                IncludeDirs = IncludeDirs,
                Defines     = Defines,
                Exports     = exports,
                Namespace   = Namespace,
                ClassName   = ClassName
            };

            g.Parse("OniVersion.h");
            g.Parse("OniCProperties.h");
            g.Parse("OniCEnums.h");
            g.Parse("OniCTypes.h");
            g.Parse("OniCAPI.h");
            g.Parse("PrimeSense.h");
            g.Parse("PS1080.h");
            g.Parse("PSLink.h");

            g.WriteMacros(OutputDir + "OniCAPI.macros.g.cs");
            g.WriteConst(OutputDir + "OniCAPI.consts.g.cs");
            g.WriteEnums(OutputDir + "OniCAPI.enums.g.cs");
            g.WriteDelegates(OutputDir + "OniCAPI.delegates.g.cs");
            g.WriteArrays(OutputDir + "OniCAPI.arrays.g.cs");
            g.WriteStructures(OutputDir + "OniCAPI.structs.g.cs");
            g.WriteIncompleteStructures(OutputDir + "OniCAPI.structs.incomplete.g.cs");
            g.WriteFunctions(OutputDir + "OniCAPI.functions.g.cs");
        }
Ejemplo n.º 4
0
        private static void Main(string[] args)
        {
            CliOptions options = CliOptions.ParseArgumentsStrict(args);

            if (options.Verbose)
            {
                Console.WriteLine("Working dir: " + Environment.CurrentDirectory);
                Console.WriteLine("Output dir: " + options.OutputDir);
                Console.WriteLine("FFmpeg headers dir: " + options.FFmpegIncludesDir);
                Console.WriteLine("FFmpeg bin dir: " + options.FFmpegBinDir);
                Console.WriteLine("Namespace name: " + options.Namespace);
                Console.WriteLine("Class name: " + options.ClassName);
            }

            var defines = new[] { "__STDC_CONSTANT_MACROS" };

            FunctionExport[] exports = FunctionExportHelper.LoadFunctionExports(options.FFmpegBinDir).ToArray();

            var astProcessor = new ASTProcessor
            {
                FunctionExportMap = exports
                                    .GroupBy(x => x.Name).Select(x => x.First()) // Eliminate duplicated names
                                    .ToDictionary(x => x.Name)
            };

            astProcessor.IgnoreUnitNames.Add("__NSConstantString_tag");
            astProcessor.TypeAliases.Add("int64_t", typeof(long));
            astProcessor.WellKnownMaros.Add("FFERRTAG", typeof(int));
            astProcessor.WellKnownMaros.Add("MKTAG", typeof(int));
            astProcessor.WellKnownMaros.Add("UINT64_C", typeof(ulong));
            astProcessor.WellKnownMaros.Add("AV_VERSION_INT", typeof(int));
            astProcessor.WellKnownMaros.Add("AV_VERSION", typeof(string));

            var g = new Generator(astProcessor)
            {
                IncludeDirs = new[] { options.FFmpegIncludesDir },
                Defines     = defines,
                Exports     = exports,
                Namespace   = options.Namespace,
                ClassName   = options.ClassName,
                SuppressUnmanagedCodeSecurity = options.SuppressUnmanagedCodeSecurity
            };

            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/time.h");
            g.Parse("libavutil/timecode.h");
            g.Parse("libavutil/tree.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("libavcodec/dxva2.h");
            g.Parse("libavcodec/d3d11va.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.WriteLibraries(Path.Combine(options.OutputDir, "FFmpeg.libraries.g.cs"));
            g.WriteMacros(Path.Combine(options.OutputDir, "FFmpeg.macros.g.cs"));
            g.WriteEnums(Path.Combine(options.OutputDir, "FFmpeg.enums.g.cs"));
            g.WriteDelegates(Path.Combine(options.OutputDir, "FFmpeg.delegates.g.cs"));
            g.WriteArrays(Path.Combine(options.OutputDir, "FFmpeg.arrays.g.cs"));
            g.WriteStructures(Path.Combine(options.OutputDir, "FFmpeg.structs.g.cs"));
            g.WriteIncompleteStructures(Path.Combine(options.OutputDir, "FFmpeg.structs.incomplete.g.cs"));
            g.WriteExportFunctions(Path.Combine(options.OutputDir, "FFmpeg.functions.export.g.cs"));
            g.WriteInlineFunctions(Path.Combine(options.OutputDir, "FFmpeg.functions.inline.g.cs"));
        }
Ejemplo n.º 5
0
 public Visitor(ASTProcessor processor)
 {
     Processor = processor;
 }
Ejemplo n.º 6
0
 public Generator(ASTProcessor astProcessor) => _astProcessor = astProcessor;
Ejemplo n.º 7
0
 public LLVMRenamer(ASTProcessor processor) : base(processor)
 {
 }
Ejemplo n.º 8
0
 public LLVMTypeVisitor(ASTProcessor processor) : base(processor)
 {
 }
Ejemplo n.º 9
0
 public Renamer(ASTProcessor processor)
 {
     Processor = processor;
 }