[gRPC] Update the code generator for Python to produce typed handlers (#8326)

* Move `namer.h` and `idl_namer.h` to `include/codegen` so they can be reused from `grpc` dirqectory.

* [gRPC] Update the Python generator to produce typed handlers and Python stubs if requested.

* [gRPC] Document the newly added compiler flags.
This commit is contained in:
Anton Bobukh
2024-06-18 16:02:57 -07:00
committed by GitHub
parent dafd2f1f29
commit fb9afbafc7
22 changed files with 1177 additions and 665 deletions

View File

@@ -268,6 +268,8 @@ const static FlatCOption flatc_options[] = {
{ "", "grpc-use-system-headers", "",
"Use <> for headers included from the generated code." },
{ "", "grpc-search-path", "PATH", "Prefix to any gRPC includes." },
{ "", "grpc-python-typed-handlers", "",
"The handlers will use the generated classes rather than raw bytes." },
};
auto cmp = [](FlatCOption a, FlatCOption b) { return a.long_opt < b.long_opt; };
@@ -720,6 +722,12 @@ FlatCOptions FlatCompiler::ParseFromCommandLineArguments(int argc,
} else if (arg == "--no-grpc-use-system-headers" ||
arg == "--grpc-use-system-headers=false") {
opts.grpc_use_system_headers = false;
} else if (arg == "--grpc-python-typed-handlers" ||
arg == "--grpc-python-typed-handlers=true") {
opts.grpc_python_typed_handlers = true;
} else if (arg == "--no-grpc-python-typed-handlers" ||
arg == "--grpc-python-typed-handlers=false") {
opts.grpc_python_typed_handlers = false;
} else {
if (arg == "--proto") { opts.proto_mode = true; }