public static void Translate(CodeTranslationConfiguration configuration)
        {
            var argBuilder = new ClangArgBuilder {
                PathToFrameworks = XCodeConfiguration.PathToFramewroks,
                SimMinVersion = XCodeConfiguration.SdkVersion,
                SysRoot = XCodeConfiguration.SdkPath,
                ResourceDir = FetchResourceDir (),
                PrefixHeaderFilePath = configuration.PCHFilePath
            };
            argBuilder.Frameworks.AddRange (configuration.Frameworks);
            argBuilder.IncludeDirs.AddRange (FetchHeaderDirs (configuration.HeaderFilePaths));

            var pathLocator = new XamarinPathLocator ();
            string xi = pathLocator.GetAssemblyPath (Platform.iOS);
            var locator = new BindingLocator (new string[] { xi });

            Console.WriteLine (argBuilder.ToString ());
            string[] clangArgs = argBuilder.Build ();
            var srcTranslator = new SourceCodeTranslator (clangArgs, locator);

            foreach (var file in configuration.SourceFilePaths) {
                Console.WriteLine (file);
                if (Path.GetFileName (file) == "main.m")
                    continue;
                var dstPath = GetDestanation (file, configuration.ProjectPath);
                using (var textWriter = File.CreateText (dstPath)) {
                    srcTranslator.Translate (file, configuration.ProjectNamespace, textWriter);
                }
                Console.WriteLine ("done: {0}", dstPath);
            }
        }
示例#2
0
        public static void Main(string[] args)
        {
            string[] clangArgs = new string[] {
                "-v",
                "-ObjC",
            //				"-I/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.4.sdk/usr/include",
                "-F/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.4.sdk/System/Library/Frameworks/",
                "-mios-simulator-version-min=8.4",
                "-fobjc-arc",

                "-fmodules",
                "-framework", "UIKit",
                "-framework", "Foundation",
                "-isysroot", "/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.4.sdk/",
                "-resource-dir", "/Users/rzaitov/llvm-clang/build/bin/../lib/clang/3.6.2",
                "-include", "/Users/rzaitov/Documents/Apps/Xamarin/samples/apple-samples/LazyTableImages/LazyTable_Prefix.pch"
            };

            // iOS samples:
            //			string file = "test/Cell.m";
            //			string file = "/Users/rzaitov/Documents/Apps/Xamarin/samples/apple-samples/HomeKitCatalogCreatingHomesPairingandControllingAccessoriesandSettingUpTriggers/HMCatalog/Supporting Files/Utilities/UITableView+Updating.m";
            //			string file = "/Users/rzaitov/Documents/Apps/Xamarin/samples/apple-samples/SoZoomy/SoZoomy/ViewController.m";
            //			string file = "/Users/rzaitov/Documents/Apps/Xamarin/samples/apple-samples/SoZoomy/SoZoomy/PreviewView.m";
            //			string file = "/Users/rzaitov/Documents/Apps/Xamarin/samples/apple-samples/SoZoomy/SoZoomy/FaceView.m";
            //			string file = "/Users/rzaitov/Documents/Apps/Xamarin/samples/apple-samples/LazyTableImages/Classes/LazyTableAppDelegate.m";
            string file = "/Users/rzaitov/Documents/Apps/Xamarin/samples/apple-samples/AVCam-iOSUsingAVFoundationtoCaptureImagesandMovies/AVCam/AAPLCameraViewController.m";

            // Mac samples
            //			string file = "/Users/rzaitov/Documents/Apps/Xamarin/samples/apple-samples/AddressBookCocoa/AddressBookCocoa.m";
            //			string file = "/Users/rzaitov/Documents/Apps/Xamarin/samples/apple-samples/LayoutManagerDemo/LayoutManagerDemo/main.m";

            Console.WriteLine ("**Playground**");

            var pathLocator = new XamarinPathLocator ();
            string xi = pathLocator.GetAssemblyPath (Platform.iOS);
            var locator = new BindingLocator (new string[] { xi });

            var sw = new StringWriter ();
            var srcTranslator = new SourceCodeTranslator (clangArgs, locator);
            var tu = srcTranslator.GetTranslationUnit (file);
            tu.Dump ();
            srcTranslator.Translate (file, "TestNamespace", sw);

            Console.WriteLine (sw.ToString ());
        }