Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            string inputFile         = "http://www.dev-c.com/nativedb/natives.json";
            string outputFile        = "NativeHashes.txt";
            bool   withUnnamedHashes = false;

            if (args.Length == 1)
            {
                outputFile = args[0];
            }
            if (args.Length == 2)
            {
                inputFile  = args[0];
                outputFile = args[1];
            }

            using (var wc = new WebClient())
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

                Console.WriteLine("Downloading natives.json");
                wc.Headers.Add("Accept-Encoding: gzip, deflate, sdch");

                string nativeFileRaw  = Decompress(wc.DownloadData(inputFile));
                string nativeTemplate = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NativeTemplate.txt"));

                NativeFile    nativeFile    = JsonConvert.DeserializeObject <NativeFile>(nativeFileRaw);
                StringBuilder resultBuilder = new StringBuilder();

                foreach (string nativeNamespaceKey in nativeFile.Keys)
                {
                    Console.WriteLine("Processing " + nativeNamespaceKey);
                    NativeNamespace nativeNamespace = nativeFile[nativeNamespaceKey];

                    resultBuilder.AppendLine("			/*");
                    resultBuilder.AppendLine("				"+ nativeNamespaceKey);
                    resultBuilder.AppendLine("			*/");

                    foreach (string nativeFuncKey in nativeNamespace.Keys)
                    {
                        NativeFunction nativeFunction = nativeNamespace[nativeFuncKey];

                        if (!string.IsNullOrEmpty(nativeFunction.Name))
                        {
                            resultBuilder.AppendLine("			"+ nativeFunction.Name + " = " + nativeFuncKey + ", // " + nativeFunction.JHash);
                        }
                        else if (withUnnamedHashes)
                        {
                            resultBuilder.AppendLine("			_"+ nativeFuncKey + " = " + nativeFuncKey + ", // " + nativeFunction.JHash);
                        }
                    }
                }

                File.WriteAllText(outputFile, string.Format(nativeTemplate, resultBuilder));

                Console.WriteLine("Finished generating native hash enum");
            }
        }
        public static void Main(string[] args)
        {
            using (WebClient wc = new WebClient())
            {
                Console.WriteLine("Downloading natives.json");
                wc.Headers.Add("Accept-Encoding: gzip, deflate, sdch");

                string nativeFileRaw  = Decompress(wc.DownloadData("http://www.dev-c.com/nativedb/natives.json"));
                string nativeTemplate = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NativeTemplate.txt"));

                NativeFile    nativeFile    = JsonConvert.DeserializeObject <NativeFile>(nativeFileRaw);
                StringBuilder resultBuilder = new StringBuilder();

                foreach (string nativeNamespaceKey in nativeFile.Keys)
                {
                    Console.WriteLine("Processing " + nativeNamespaceKey);
                    NativeNamespace nativeNamespace = nativeFile[nativeNamespaceKey];

                    resultBuilder.AppendLine("			/*");
                    resultBuilder.AppendLine("				"+ nativeNamespaceKey);
                    resultBuilder.AppendLine("			*/");

                    foreach (string nativeFuncKey in nativeNamespace.Keys)
                    {
                        NativeFunction nativeFunction = nativeNamespace[nativeFuncKey];

                        if (!string.IsNullOrEmpty(nativeFunction.Name))
                        {
                            resultBuilder.AppendLine("			"+ nativeFunction.Name + " = " + nativeFuncKey + ", // " + nativeFunction.JHash);
                        }
                    }
                }

                string outputFile = args.Length > 0 ? args[0] : "NativeHashes.hpp";

                File.WriteAllText(outputFile, string.Format(nativeTemplate, resultBuilder));

                Console.WriteLine("Finished generating native hash enum");
            }
        }