Program.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using Clang.Ast;
  3. using System.IO;
  4. namespace SharpieBinder
  5. {
  6. class MainClass
  7. {
  8. const string Output = "../../bindings/Portable/Generated";
  9. public static int Main (string[] args)
  10. {
  11. Directory.CreateDirectory (Output);
  12. Console.WriteLine(Environment.CurrentDirectory);
  13. if (System.Runtime.InteropServices.Marshal.SizeOf(typeof (IntPtr)) == 4) {
  14. Console.Error.WriteLine ("This needs a 64-bit Mono to run");
  15. return 1;
  16. }
  17. if (args.Length == 0) {
  18. args = new [] { "../../bindings/Urho.pch" };
  19. }
  20. var reader = new AstReader ();
  21. var binder = new CxxBinder(Output);
  22. var lookup = new ScanBaseTypes ();
  23. reader.TranslationUnitParsed += tu => {
  24. tu.Accept(lookup);
  25. lookup.PrepareProperties();
  26. tu.Accept(binder);
  27. binder.GenerateProperties();
  28. };
  29. reader.Load (args [0]);
  30. binder.FixupOverrides();
  31. foreach (var st in binder.Generate()) {
  32. File.WriteAllText (Output + "/" + st.FileName, st.ToString ());
  33. }
  34. foreach (var a in binder.unhandledEnums)
  35. Console.WriteLine ("Missing special Enum processing for {0}", a);
  36. Console.WriteLine($"Dumped data into {Output}");
  37. binder.Close ();
  38. return 0;
  39. }
  40. }
  41. }