python_generator.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. grpc::string grpc_package_root;
  30. // TODO(https://github.com/grpc/grpc/issues/8622): Drop this.
  31. grpc::string beta_package_root;
  32. // TODO(https://github.com/google/protobuf/issues/888): Drop this.
  33. grpc::string import_prefix;
  34. std::vector<grpc::string> prefixes_to_filter;
  35. };
  36. class PythonGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
  37. public:
  38. PythonGrpcGenerator(const GeneratorConfiguration& config);
  39. ~PythonGrpcGenerator();
  40. bool Generate(const grpc::protobuf::FileDescriptor* file,
  41. const grpc::string& parameter,
  42. grpc::protobuf::compiler::GeneratorContext* context,
  43. grpc::string* error) const;
  44. private:
  45. GeneratorConfiguration config_;
  46. };
  47. } // namespace grpc_python_generator
  48. #endif // GRPC_INTERNAL_COMPILER_PYTHON_GENERATOR_H