Search in sources :

Example 1 with IndentedWriter

use of sharpen.core.io.IndentedWriter in project XobotOS by xamarin.

the class NativeBuilder method printNativeType.

private static boolean printNativeType(NativeConfiguration config, Node unit, String fileName) {
    final URI projectRoot = my(APIDefinition.class).getProjectRoot();
    final String outputDir = my(ConfigFile.class).getSourceInfo().getOutputFolder();
    final String outputPath = projectRoot.getPath() + File.separatorChar + outputDir + File.separatorChar + config.getOutputDir();
    if (!new File(outputPath).exists())
        new File(outputPath).mkdirs();
    final String fullSourceName = outputPath + File.separatorChar + fileName;
    FileWriter output;
    try {
        output = new FileWriter(fullSourceName);
    } catch (IOException e) {
        Sharpen.Log(e, "Cannot create native glue file '%s'", fullSourceName);
        return false;
    }
    IndentedWriter writer = new IndentedWriter(output);
    Printer printer = new Printer(writer);
    unit.accept(printer);
    try {
        output.close();
    } catch (IOException e) {
        Sharpen.Log(e, "Cannot create native glue file '%s'", fullSourceName);
        return false;
    }
    return true;
}
Also used : IndentedWriter(sharpen.core.io.IndentedWriter) APIDefinition(sharpen.xobotos.api.APIDefinition) FileWriter(java.io.FileWriter) IOException(java.io.IOException) CSharpPrinter(sharpen.core.csharp.CSharpPrinter) URI(java.net.URI) File(java.io.File) ConfigFile(sharpen.xobotos.config.ConfigFile)

Aggregations

File (java.io.File)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 URI (java.net.URI)1 CSharpPrinter (sharpen.core.csharp.CSharpPrinter)1 IndentedWriter (sharpen.core.io.IndentedWriter)1 APIDefinition (sharpen.xobotos.api.APIDefinition)1 ConfigFile (sharpen.xobotos.config.ConfigFile)1