Пример #1
0
        static void Main(string[] args)
        {
            var files = Directory.GetFiles(
                Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.Parent.FullName +
                Path.DirectorySeparatorChar + "runtime" + Path.DirectorySeparatorChar + "src" +
                Path.DirectorySeparatorChar + "altv-c-api/");

            var genDirectory = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "gen" +
                               Path.DirectorySeparatorChar;

            if (Directory.Exists(genDirectory))
            {
                Directory.Delete(genDirectory, true);
            }

            Directory.CreateDirectory(genDirectory);
            foreach (var file in files)
            {
                if (!file.EndsWith(".h"))
                {
                    continue;
                }
                var methods       = ParseExports.Parse(File.ReadAllText(file));
                var methodsOutput = WritePInvokes.Write(methods);
                if (methodsOutput.Length == 0)
                {
                    continue;
                }
                File.WriteAllText(
                    genDirectory + GetAltNativeFileName(Path.GetFileName(file)),
                    methodsOutput);
            }
        }
Пример #2
0
        static void MainOld(string[] args)
        {
            var files = Directory.GetFiles(
                Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.Parent.FullName +
                Path.DirectorySeparatorChar + "runtime" + Path.DirectorySeparatorChar + "src" +
                Path.DirectorySeparatorChar + "altv-c-api/");

            var genDirectory = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "gen" +
                               Path.DirectorySeparatorChar;

            if (Directory.Exists(genDirectory))
            {
                Directory.Delete(genDirectory, true);
            }

            Directory.CreateDirectory(genDirectory);

            /*try
             * {
             *  foreach (var file in files)
             *  {
             *      if (!file.EndsWith(".h")) continue;
             *      var methods = ParseExports.Parse(File.ReadAllText(file));
             *      var methodsOutput = WritePInvokes.Write(methods);
             *      if (methodsOutput.Length == 0) continue;
             *      File.WriteAllText(
             *          genDirectory + GetAltNativeFileName(Path.GetFileName(file)),
             *          methodsOutput);
             *  }
             * }
             * catch (Exception exception)
             * {
             *  Console.WriteLine(exception);
             * }*/

            try
            {
                var methods = new List <ParseExports.CMethod>();
                foreach (var file in files)
                {
                    if (!file.EndsWith(".h"))
                    {
                        continue;
                    }
                    methods.AddRange(ParseExports.Parse(File.ReadAllText(file)));
                }

                methods.Sort((a, b) => string.Compare(a.Name, b.Name, StringComparison.Ordinal));

                var methodsOutput = WriteLibrary.Write(methods.ToArray());
                if (methodsOutput.Length != 0)
                {
                    File.WriteAllText(
                        genDirectory + "Library.cs",
                        methodsOutput);
                    //Console.WriteLine(methodsOutput);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }