Пример #1
0
        // TODO: Unexpose this
        public bool CanFirstParameterBeInstance(IGeneratable parent, GenerationOptions opts)
        {
            var param = Parameters.FirstOrDefault();

            if (param == null)
            {
                return(false);
            }

            // hacky check for symbol equality
            return(param.Resolve(opts).GetType() == parent.GetType());
        }
Пример #2
0
        public void Generate(GenerationOptions opts, IGeneratable parent, IndentWriter writer)
        {
            writer.WriteDocumentation(Doc);

            // Simple uncorrect gen for now
            var managedType = this.GetSymbol(opts);

            // We need something that will tell us the equivalent C# type
            // including the number of pointers.
            // For now, generate normal info.

            writer.WriteLine($"{managedType.Name} {Name};");
        }
        public static void GenerateMembers(this IGeneratable gen, GenerationOptions opts, IndentWriter writer)
        {
            var array = gen.GetMemberGeneratables().ToArray();

            for (int i = 0; i < array.Length; ++i)
            {
                var member = array[i];
                member.Generate(opts, gen, writer);

                if (i != array.Length - 1 && member.NewlineAfterGeneration(opts))
                {
                    writer.WriteLine();
                }
            }
        }
Пример #4
0
        public static int Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Usage: gir.exe <file.gir>");
                return(0);
            }

            var opt = new OptionSet();

            foreach (string arg in args)
            {
                ParseArg(opt, arg);
            }

            opt.AllRepositories = Parser.Parse(args [0], opt.IncludeSearchDirectory, out opt.GenerationRepository);

            //GenerationInfo gen_info = null;
            //if (dir != "" || assembly_name != "" || glue_filename != "" || glue_includes != "" || gluelib_name != "")
            //gen_info = new GenerationInfo(dir, custom_dir, assembly_name, glue_filename, glue_includes, gluelib_name);

            var genOpts = new GenerationOptions(opt.OutputDirectory, opt.AllRepositories, opt.GenerationRepository);

            if (!Directory.Exists(opt.OutputDirectory))
            {
                Directory.CreateDirectory(opt.OutputDirectory);
            }

            foreach (IGeneratable gen in genOpts.AllGeneratables)
            {
                gen.Generate(genOpts);
            }

            genOpts.Statistics.ReportStatistics();
            return(0);
        }
Пример #5
0
 public bool IsInstanceCallable(IGeneratable parent, GenerationOptions opts) => CanFirstParameterBeInstance(parent, opts);
Пример #6
0
 public bool NewlineAfterGeneration(GenerationOptions opts) => true;
Пример #7
0
 public bool NewlineAfterGeneration(GenerationOptions opts)
 {
     return(true);
 }