Hi,

Can we have a way to suppress emitting explicit accessors for protobuf 
message fields during protoc compilation? My server implementation is 
auto-generated from a backend component and uses the protobuf reflection 
mechanism instead of the explicit accessors. If I can suppress emitting 
those explicit accessors, that will reduce my compilation time.

To get a proof-of-concept, I added `option optimize_for = CODE_SIZE;` in 
helloworld.proto, re-wrote the SayHello method in greeter_server.cc using 
reflection:

auto nameDescriptor = request->GetDescriptor()->FindFieldByName("name");
std::string name = request->GetReflection()->GetString(*request, 
nameDescriptor);
auto messageDescriptor = reply->GetDescriptor()->FindFieldByName("message");
reply->GetReflection()->SetString(reply, messageDescriptor, prefix + name);

and then deleted all public accessor definitions from the generated 
helloworld.pb.h. The server-side is compiled and is running fine with these 
changes.

Regards,
Mainak


-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/9d926c5b-9a44-429b-87ec-f93ad2fdedd0n%40googlegroups.com.

Reply via email to