google-code-export / protobuf

Automatically exported from code.google.com/p/protobuf
Other
1 stars 1 forks source link

Function headers for has_ accessors within oneof are put as private for enum/string/int32/bool #692

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. define a message with a oneof field with different data types, e.g.
message test {
   oneof union_test {
      string Str   = 1;
      bool Boolean = 2;
      int32 Bumber = 3;
   }
}
2. look for all the has_ accessors inside the generated .pb.h, in this case 
has_str(), has_boolean() and has_number().

What is the expected output? What do you see instead?
These methods should be listed as public methods inside the test class but 
somehow there is a "private:" being inserted instead:
  ...
  // optional string Str = 1;
  private:
  inline bool has_str() const;
  public:
  inline void clear_str();
  static const int kStrFieldNumber = 3;
  ...

What version of the product are you using? On what operating system?
This happens in 3.0.0-alpha-1 and alpha-2 on Ubuntu 12.04.5 LTS

Please provide any additional information below.
- none

Original issue reported on code.google.com by alfred...@gmail.com on 9 Mar 2015 at 6:00

GoogleCodeExporter commented 9 years ago
The has_ method for an embedded message within a "oneof" is working properly, 
unlike for enum/string/int32/bool

Original comment by alfred...@gmail.com on 9 Mar 2015 at 6:05

GoogleCodeExporter commented 9 years ago
This bug should be about how "containing_oneof" wasn't check in 
src/google/protobuf/compiler/cpp/cpp_message.cc. My comments can be read in 
https://github.com/google/protobuf/commit/6ef984af4b0c63c1c33127a12dcfc8e6359f0c
9e#commitcomment-10125327

Original comment by alfred...@gmail.com on 10 Mar 2015 at 5:35