YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/gen_yrpc/forward_generator.cc
Line
Count
Source (jump to first uncovered line)
1
// Copyright (c) YugaByte, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4
// in compliance with the License.  You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software distributed under the License
9
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10
// or implied.  See the License for the specific language governing permissions and limitations
11
// under the License.
12
//
13
14
#include "yb/gen_yrpc/forward_generator.h"
15
16
#include "yb/gen_yrpc/model.h"
17
18
namespace yb {
19
namespace gen_yrpc {
20
21
namespace {
22
23
0
void MessageForward(YBPrinter printer, const google::protobuf::Descriptor* message) {
24
0
  for (auto i = 0; i != message->nested_type_count(); ++i) {
25
0
    MessageForward(printer, message->nested_type(i));
26
0
  }
27
28
0
  ScopedSubstituter message_substituter(printer, message);
29
0
  printer("class $message_name$;\n");
30
0
}
31
32
} // namespace
33
34
0
void ForwardGenerator::Header(YBPrinter printer, const google::protobuf::FileDescriptor* file) {
35
0
  printer(
36
0
      "// THIS FILE IS AUTOGENERATED FROM $path$\n"
37
0
      "\n"
38
0
      "#ifndef $upper_case$_MESSAGES_H\n"
39
0
      "#define $upper_case$_MESSAGES_H\n"
40
0
      "\n"
41
0
  );
42
43
0
  auto deps = ListDependencies(file);
44
0
  if (!deps.empty()) {
45
0
    for (const auto& dep : deps) {
46
0
      printer(
47
0
          "#include \"" + dep + ".fwd.h\"\n"
48
0
      );
49
0
    }
50
0
    printer("\n");
51
0
  }
52
53
0
  printer(
54
0
      "$open_namespace$\n"
55
0
  );
56
57
0
  for (int i = 0; i != file->message_type_count(); ++i) {
58
0
    MessageForward(printer, file->message_type(i));
59
0
  }
60
61
0
  printer(
62
0
      "\n$close_namespace$\n"
63
0
      "#endif // $upper_case$_MESSAGES_H\n"
64
0
  );
65
0
}
66
67
}  // namespace gen_yrpc
68
}  // namespace yb