48 lines
1.3 KiB
C#
Raw Normal View History

2019-06-12 21:56:55 +02:00
using Capnp;
using System;
using System.IO;
namespace CapnpC
{
class Program
{
static void Main(string[] args)
{
Stream input;
if (args.Length > 0)
{
input = new FileStream(args[0], FileMode.Open, FileAccess.Read);
}
else
2019-07-11 21:44:42 +02:00
{
Console.WriteLine("Cap'n Proto C# code generator backend");
Console.WriteLine("expecting binary-encoded code generation request from standard input");
2019-06-12 21:56:55 +02:00
input = Console.OpenStandardInput();
}
2019-07-11 21:44:42 +02:00
try
{
WireFrame segments;
using (input)
{
segments = Framing.ReadSegments(input);
}
2019-06-12 21:56:55 +02:00
2019-07-11 21:44:42 +02:00
var dec = DeserializerState.CreateRoot(segments);
var reader = Schema.CodeGeneratorRequest.Reader.Create(dec);
var model = Model.SchemaModel.Create(reader);
var codeGen = new Generator.CodeGenerator(model, new Generator.GeneratorOptions());
codeGen.Generate();
}
catch (Exception exception)
2019-06-12 21:56:55 +02:00
{
2019-07-11 21:44:42 +02:00
Console.Error.WriteLine(exception.Message);
Environment.ExitCode = -1;
2019-06-12 21:56:55 +02:00
}
}
}
}