blob: 9139307e63c2fdf85a9265695647ad4e32e6d0e2 [file] [log] [blame]
Masood Malekghassemif8e297a2015-02-19 15:39:32 -08001/*
2 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003 * Copyright 2015 gRPC authors.
Masood Malekghassemif8e297a2015-02-19 15:39:32 -08004 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02005 * 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
Masood Malekghassemif8e297a2015-02-19 15:39:32 -08008 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009 * http://www.apache.org/licenses/LICENSE-2.0
Masood Malekghassemif8e297a2015-02-19 15:39:32 -080010 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +020011 * 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.
Masood Malekghassemif8e297a2015-02-19 15:39:32 -080016 *
17 */
18
Nicolas "Pixel" Noble1ff52d52015-03-01 05:24:36 +010019#ifndef GRPC_INTERNAL_COMPILER_PYTHON_GENERATOR_H
20#define GRPC_INTERNAL_COMPILER_PYTHON_GENERATOR_H
Masood Malekghassemif8e297a2015-02-19 15:39:32 -080021
Masood Malekghassemi59d9ff42015-02-23 15:28:07 -080022#include <utility>
Masood Malekghassemif8e297a2015-02-19 15:39:32 -080023
Masood Malekghassemi65c803b2015-03-20 06:48:47 -070024#include "src/compiler/config.h"
Harsh Vardhan5b8fa872016-09-12 20:37:42 +053025#include "src/compiler/schema_interface.h"
Masood Malekghassemif8e297a2015-02-19 15:39:32 -080026
27namespace grpc_python_generator {
28
Masood Malekghassemi3bb52152015-03-17 21:52:52 -070029// Data pertaining to configuration of the generator with respect to anything
30// that may be used internally at Google.
31struct GeneratorConfiguration {
Masood Malekghassemi71448b22016-06-29 11:41:24 -070032 GeneratorConfiguration();
Nathaniel Manista45479402016-06-13 20:14:18 +000033 grpc::string grpc_package_root;
Nathaniel Manista40d55f92017-03-14 00:01:35 +000034 // TODO(https://github.com/grpc/grpc/issues/8622): Drop this.
Nathaniel Manistacd9ec0e2015-08-31 07:49:45 +000035 grpc::string beta_package_root;
Nathaniel Manista40d55f92017-03-14 00:01:35 +000036 // TODO(https://github.com/google/protobuf/issues/888): Drop this.
37 grpc::string import_prefix;
Masood Malekghassemi3bb52152015-03-17 21:52:52 -070038};
39
Masood Malekghassemi65c803b2015-03-20 06:48:47 -070040class PythonGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
Masood Malekghassemi3bb52152015-03-17 21:52:52 -070041 public:
42 PythonGrpcGenerator(const GeneratorConfiguration& config);
43 ~PythonGrpcGenerator();
44
Masood Malekghassemi65c803b2015-03-20 06:48:47 -070045 bool Generate(const grpc::protobuf::FileDescriptor* file,
46 const grpc::string& parameter,
47 grpc::protobuf::compiler::GeneratorContext* context,
48 grpc::string* error) const;
Masood Malekghassemiac592452016-07-01 11:58:04 -070049
Masood Malekghassemi3bb52152015-03-17 21:52:52 -070050 private:
51 GeneratorConfiguration config_;
52};
53
Masood Malekghassemif8e297a2015-02-19 15:39:32 -080054} // namespace grpc_python_generator
55
Nicolas "Pixel" Noble1ff52d52015-03-01 05:24:36 +010056#endif // GRPC_INTERNAL_COMPILER_PYTHON_GENERATOR_H