python_generator.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. *
  3. * Copyright 2015 gRPC authors.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. #ifndef GRPC_INTERNAL_COMPILER_PYTHON_GENERATOR_H
  19. #define GRPC_INTERNAL_COMPILER_PYTHON_GENERATOR_H
  20. #include <utility>
  21. #include <vector>
  22. #include "src/compiler/config.h"
  23. #include "src/compiler/schema_interface.h"
  24. namespace grpc_python_generator {
  25. // Data pertaining to configuration of the generator with respect to anything
  26. // that may be used internally at Google.
  27. struct GeneratorConfiguration {
  28. GeneratorConfiguration();
  29. TString grpc_package_root;
  30. // TODO(https://github.com/grpc/grpc/issues/8622): Drop this.
  31. TString beta_package_root;
  32. // TODO(https://github.com/protocolbuffers/protobuf/issues/888): Drop this.
  33. TString import_prefix;
  34. std::vector<TString> prefixes_to_filter;
  35. };
  36. class PythonGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
  37. public:
  38. PythonGrpcGenerator(const GeneratorConfiguration& config);
  39. ~PythonGrpcGenerator();
  40. uint64_t GetSupportedFeatures() const override;
  41. bool Generate(const grpc::protobuf::FileDescriptor* file,
  42. const TString& parameter,
  43. grpc::protobuf::compiler::GeneratorContext* context,
  44. TString* error) const override;
  45. private:
  46. GeneratorConfiguration config_;
  47. };
  48. } // namespace grpc_python_generator
  49. #endif // GRPC_INTERNAL_COMPILER_PYTHON_GENERATOR_H