Esempio n. 1
0
        public void Issue20()
        {
            RpcRequest <ArithmeticOperationRequest> rpcRequest = new RpcRequest <ArithmeticOperationRequest>();

            rpcRequest.Method = "AddTwoNumbers";

            ArithmeticOperationRequest request = new ArithmeticOperationRequest();

            request.NumA = 5;
            request.NumB = 8;

            rpcRequest.Request = request;

            var msg  = MessageBuilder.Create();
            var root = msg.BuildRoot <RpcRequest <ArithmeticOperationRequest> .WRITER>();

            rpcRequest.serialize(root);

            var mems = new MemoryStream();
            var pump = new FramePump(mems);

            pump.Send(msg.Frame);
            mems.Seek(0, SeekOrigin.Begin);

            var frame        = Framing.ReadSegments(mems);
            var deserializer = DeserializerState.CreateRoot(frame);
            var mainRequest  = new RpcRequest <ArithmeticOperationRequest> .READER(deserializer);

            var innerRequest = new ArithmeticOperationRequest.READER(mainRequest.Request);

            Console.WriteLine("Method Name: " + mainRequest.Method);
            Console.WriteLine("NumA: " + innerRequest.NumA.ToString());
            Console.WriteLine("NumB: " + innerRequest.NumB.ToString());
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Stream input;

            if (args.Length > 0)
            {
                input = new FileStream(args[0], FileMode.Open, FileAccess.Read);
            }
            else
            {
                input = Console.OpenStandardInput();
            }

            WireFrame segments;

            using (input)
            {
                segments = Framing.ReadSegments(input);
            }

            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();
        }
Esempio n. 3
0
        public static EsiSystem ConvertFromCGRMessage(EsiContext ctxt, Stream stream)
        {
            var frame        = Framing.ReadSegments(stream);
            var deserializer = DeserializerState.CreateRoot(frame);
            var reader       = CodeGeneratorRequest.READER.create(deserializer);

            return(Convert(ctxt, reader));
        }
        public void Issue45()
        {
            var input = CodeGeneratorSteps.LoadResource("Issue45.capnp.bin");

            using (input)
            {
                var frame = Framing.ReadSegments(input);
                var ds    = DeserializerState.CreateRoot(frame);
                var cgr   = CapnpSerializable.Create <CodeGeneratorRequest>(ds);
                Assert.IsTrue(cgr.Nodes.Count > 0);
            }
        }
Esempio n. 5
0
        static Model.SchemaModel Load(string inputName)
        {
            WireFrame segments;
            var       input = CodeGeneratorSteps.LoadResource(inputName);

            using (input)
            {
                segments = Framing.ReadSegments(input);
            }
            var dec    = DeserializerState.CreateRoot(segments);
            var reader = CodeGeneratorRequest.Reader.Create(dec);
            var model  = Model.SchemaModel.Create(reader);

            return(model);
        }
Esempio n. 6
0
        internal static void GenerateFromStream(Stream input)
        {
            WireFrame segments;

            using (input)
            {
                segments = Framing.ReadSegments(input);
            }

            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();
        }
        /// <summary>
        /// Generates C# code from given input stream
        /// </summary>
        /// <param name="input">input stream containing the binary code generation request, which the frontend capnpc emits</param>
        /// <returns>generation result</returns>
        /// <exception cref="ArgumentNullException">if <paramref name="input"/> is null</exception>
        public static GenerationResult GenerateFromStream(Stream input)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            try
            {
                var segments = Framing.ReadSegments(input);
                var dec      = DeserializerState.CreateRoot(segments);
                var reader   = Schema.CodeGeneratorRequest.Reader.Create(dec);
                var model    = Model.SchemaModel.Create(reader);
                var codeGen  = new CodeGen.CodeGenerator(model, new CodeGen.GeneratorOptions());
                return(new GenerationResult(codeGen.Generate()));
            }
            catch (Exception exception)
            {
                return(new GenerationResult(exception));
            }
        }