| 116 | } |
| 117 | |
| 118 | int ProtoUtils::LoadExtension(const char *file_name, SyntaxTree *stree, DiskSourceTree &tree) { |
| 119 | MyErrorPrinter error; |
| 120 | |
| 121 | SourceTreeDescriptorDatabase db(&tree); |
| 122 | db.RecordErrorsTo(&error); |
| 123 | |
| 124 | FileDescriptorProto fd_proto; |
| 125 | |
| 126 | db.FindFileByName(file_name, &fd_proto); |
| 127 | |
| 128 | for (int i{0}; 1 > i && fd_proto.service_size() > i; ++i) { |
| 129 | const ServiceDescriptorProto &svc(fd_proto.service(i)); |
| 130 | |
| 131 | for (int j{0}; svc.method_size() > j; ++j) { |
| 132 | const MethodDescriptorProto &method(svc.method(j)); |
| 133 | |
| 134 | SyntaxFunc *func{stree->FindFunc(method.name().c_str())}; |
| 135 | |
| 136 | assert(nullptr != func); |
| 137 | |
| 138 | const MethodOptions &options(method.options()); |
| 139 | |
| 140 | for (int k{0}; options.uninterpreted_option_size() > k; ++k) { |
| 141 | const UninterpretedOption &opt(options.uninterpreted_option(k)); |
| 142 | |
| 143 | if (opt.name_size() > 0) { |
| 144 | if (nullptr != strstr(opt.name(0).name_part().c_str(), "OptString")) { |
| 145 | func->SetOptString(opt.string_value().c_str()); |
| 146 | } |
| 147 | |
| 148 | if (nullptr != strstr(opt.name(0).name_part().c_str(), "Usage")) { |
| 149 | func->SetUsage(opt.string_value().c_str()); |
| 150 | } |
| 151 | |
| 152 | if (nullptr != strstr(opt.name(0).name_part().c_str(), "CmdID")) { |
| 153 | func->SetCmdID(opt.positive_int_value()); |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | return 0; |
| 161 | } |
| 162 | |
| 163 | int ProtoUtils::AddEcho(SyntaxTree *stree) { |
| 164 | char name[256]{0}; |
nothing calls this directly
no test coverage detected