{$MODE OBJFPC}
uses
  protobuf,
  descriptor_pb,
  plugin_pb;

function Parse(Data: Pointer; Size: LongInt): LongInt;
var
  P: PByte absolute Data;
begin
  Result := 0;
  while (Result < Size) and not Eof do begin
    Read(AnsiChar(P^));
    Inc(P);
    Inc(Result);
  end;
end;

function Serialize(Data: Pointer; Size: LongInt): LongInt;
var
  P: PByte absolute Data;
begin
  while Size > 0 do begin
    Write(AnsiChar(P^));
    Inc(P);
    Dec(Size);
  end;
  Result := 0;
end;

var
  Request: TCodeGeneratorRequest;
  Response: TCodeGeneratorResponse;

begin
  Request.Parse(@Parse);
  Response.Serialize(@Serialize);
end.
