Exemplo n.º 1
0
        List <ClassDeclaration> ReflectClassDeclarations(string code)
        {
            using (TempDirectoryFilenameProvider fileProvider = new TempDirectoryFilenameProvider(null, false)) {
                CustomSwiftCompiler  compiler = Utils.DefaultSwiftCompiler(fileProvider);
                SwiftCompilerOptions options  = new SwiftCompilerOptions("NameNotImportant", null, null, null);
                compiler.CompileString(options, code);

                List <ModuleDeclaration> modules = compiler.ReflectToModules(new string [] { compiler.DirectoryPath },
                                                                             new string [] { compiler.DirectoryPath }, "", "NameNotImportant");
                Assert.AreEqual(1, modules.Count);
                return(modules [0].AllClasses);
            }
        }
Exemplo n.º 2
0
        public static CustomSwiftCompiler CompileSwift(string swiftCode, DisposableTempDirectory provider = null, string moduleName = "Xython", string target = "x86_64-apple-macosx10.9")
        {
            CustomSwiftCompiler compiler = DefaultSwiftCompiler(provider, target: target);

            string []     includeDirectories = null;
            List <string> libraryDirectories = new List <string> {
                compiler.DirectoryPath, Compiler.kSwiftRuntimeGlueDirectory
            };

            if (provider != null)
            {
                includeDirectories = new string [] { provider.DirectoryPath };
                libraryDirectories.Add(provider.DirectoryPath);
            }

            SwiftCompilerOptions options = new SwiftCompilerOptions(moduleName, includeDirectories, libraryDirectories.ToArray(), new string [] { "XamGlue" });

            compiler.CompileString(options, swiftCode);
            return(compiler);
        }