~ubuntu-branches/debian/experimental/protobuf/experimental

« back to all changes in this revision

Viewing changes to src/google/protobuf/compiler/cpp/cpp_field.cc

  • Committer: Package Import Robot
  • Author(s): Robert S. Edmonds, Micah Anderson, Colin Watson, Steve Langasek, Robert S. Edmonds
  • Date: 2013-10-12 18:32:37 UTC
  • mfrom: (1.3.1) (10.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20131012183237-jz6tvmj9tn68atrf
Tags: 2.5.0-1
[ Micah Anderson ]
* New upstream version. (Closes: #704731.)
* Update debian/watch.
* Refresh patches.

[ Colin Watson ]
* Use the autotools-dev dh addon to update config.guess/config.sub for
  arm64. (Closes: #725976.)

[ Steve Langasek ]
* Don't recommend protobuf-compiler from the bindings, it's not used and
  this doesn't need to be pulled in at runtime. (Closes: #703628.)
* Mark protobuf-compiler Multi-Arch: foreign; the output of this command
  is architecture-independent source, we don't need the version of the
  compiler to match the target arch.
* Bump to debhelper compat 9, so that our libs get installed to the
  multiarch locations.
* Mark the library packages Multi-Arch: same.
* Fix debian/rules to support cross-building of the python bindings.
* Build-depend on libpython-dev, not python-dev, for cross-build
  compatibility.
* (Closes: #726083.)

[ Robert S. Edmonds ]
* Upload to experimental.
* Bump ABI version from 7 to 8.
* Bump Standards-Version to 3.9.4.
* Convert from python-support to dh-python.
* Drop support for python2.6.
* python-protobuf: switch back to the pure Python implementation, as
  upstream appears to no longer be maintaining the current C++ based Python
  binding. See the following upstream issues for details:
  - https://code.google.com/p/protobuf/issues/detail?id=434
  - https://code.google.com/p/protobuf/issues/detail?id=503

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
using internal::WireFormat;
53
53
 
54
54
void SetCommonFieldVariables(const FieldDescriptor* descriptor,
55
 
                             map<string, string>* variables) {
 
55
                             map<string, string>* variables,
 
56
                             const Options& options) {
56
57
  (*variables)["name"] = FieldName(descriptor);
57
58
  (*variables)["index"] = SimpleItoa(descriptor->index());
58
59
  (*variables)["number"] = SimpleItoa(descriptor->number());
64
65
  (*variables)["deprecation"] = descriptor->options().deprecated()
65
66
      ? " PROTOBUF_DEPRECATED" : "";
66
67
 
 
68
  (*variables)["cppget"] = "Get";
67
69
}
68
70
 
69
71
FieldGenerator::~FieldGenerator() {}
80
82
 
81
83
}
82
84
 
83
 
FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor)
 
85
FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor,
 
86
                                     const Options& options)
84
87
  : descriptor_(descriptor),
85
 
    field_generators_(
86
 
      new scoped_ptr<FieldGenerator>[descriptor->field_count()]) {
 
88
    field_generators_(new scoped_ptr<FieldGenerator>[descriptor->field_count()]) {
87
89
  // Construct all the FieldGenerators.
88
90
  for (int i = 0; i < descriptor->field_count(); i++) {
89
 
    field_generators_[i].reset(MakeGenerator(descriptor->field(i)));
 
91
    field_generators_[i].reset(MakeGenerator(descriptor->field(i), options));
90
92
  }
91
93
}
92
94
 
93
 
FieldGenerator* FieldGeneratorMap::MakeGenerator(const FieldDescriptor* field) {
 
95
FieldGenerator* FieldGeneratorMap::MakeGenerator(const FieldDescriptor* field,
 
96
                                                 const Options& options) {
94
97
  if (field->is_repeated()) {
95
98
    switch (field->cpp_type()) {
96
99
      case FieldDescriptor::CPPTYPE_MESSAGE:
97
 
        return new RepeatedMessageFieldGenerator(field);
 
100
        return new RepeatedMessageFieldGenerator(field, options);
98
101
      case FieldDescriptor::CPPTYPE_STRING:
99
102
        switch (field->options().ctype()) {
100
103
          default:  // RepeatedStringFieldGenerator handles unknown ctypes.
101
104
          case FieldOptions::STRING:
102
 
            return new RepeatedStringFieldGenerator(field);
 
105
            return new RepeatedStringFieldGenerator(field, options);
103
106
        }
104
107
      case FieldDescriptor::CPPTYPE_ENUM:
105
 
        return new RepeatedEnumFieldGenerator(field);
 
108
        return new RepeatedEnumFieldGenerator(field, options);
106
109
      default:
107
 
        return new RepeatedPrimitiveFieldGenerator(field);
 
110
        return new RepeatedPrimitiveFieldGenerator(field, options);
108
111
    }
109
112
  } else {
110
113
    switch (field->cpp_type()) {
111
114
      case FieldDescriptor::CPPTYPE_MESSAGE:
112
 
        return new MessageFieldGenerator(field);
 
115
        return new MessageFieldGenerator(field, options);
113
116
      case FieldDescriptor::CPPTYPE_STRING:
114
117
        switch (field->options().ctype()) {
115
118
          default:  // StringFieldGenerator handles unknown ctypes.
116
119
          case FieldOptions::STRING:
117
 
            return new StringFieldGenerator(field);
 
120
            return new StringFieldGenerator(field, options);
118
121
        }
119
122
      case FieldDescriptor::CPPTYPE_ENUM:
120
 
        return new EnumFieldGenerator(field);
 
123
        return new EnumFieldGenerator(field, options);
121
124
      default:
122
 
        return new PrimitiveFieldGenerator(field);
 
125
        return new PrimitiveFieldGenerator(field, options);
123
126
    }
124
127
  }
125
128
}