~ubuntu-branches/ubuntu/maverick/protobuf/maverick

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Manny Vindiola
  • Date: 2008-12-18 01:26:29 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20081218012629-l93kqt3jptydn9zh
Tags: 2.0.3-0ubuntu1
* Merge from new upstream version (LP: #309237), remaining changes:
   * debian/control Moving python-support from Build-Depends-Indep
     to Build-Depends to fix build failures.  
* Fix FTBFS on ia64 architecture due to lack of clone(2)
   - src/gtest/internal/gtest-port.h (LP: #308829)
     disable death tests if architecture is IA64
     adapted from gtest upstream fix at:
     http://codereview.appspot.com/8690/show
* Fix FTBFS on x64 architectures due to python 2.x int vs long issue
  test expects return type long but on x64 architecture return type 
  unpacks to int
   -python/google/protobuf/internal/decoder_test.py
    explicitly type the result value as long 
   taken from upstream discussion:
   http://groups.google.com/group/protobuf/browse_thread
       /thread/2357176cb1f50e10/

Show diffs side-by-side

added added

removed removed

Lines of Context:
163
163
    "inline ::std::string* $classname$::mutable_$name$() {\n"
164
164
    "  _set_bit($index$);\n"
165
165
    "  if ($name$_ == &_default_$name$_) {\n");
166
 
  if (descriptor_->has_default_value()) {
 
166
  if (descriptor_->default_value_string().empty()) {
 
167
    printer->Print(variables_,
 
168
      "    $name$_ = new ::std::string;\n");
 
169
  } else {
167
170
    printer->Print(variables_,
168
171
      "    $name$_ = new ::std::string(_default_$name$_);\n");
169
 
  } else {
170
 
    printer->Print(variables_,
171
 
      "    $name$_ = new ::std::string;\n");
172
172
  }
173
173
  printer->Print(variables_,
174
174
    "  }\n"
178
178
 
179
179
void StringFieldGenerator::
180
180
GenerateNonInlineAccessorDefinitions(io::Printer* printer) const {
181
 
  if (descriptor_->has_default_value()) {
 
181
  if (descriptor_->default_value_string().empty()) {
 
182
    printer->Print(variables_,
 
183
      "const ::std::string $classname$::_default_$name$_;");
 
184
  } else {
182
185
    printer->Print(variables_,
183
186
      "const ::std::string $classname$::_default_$name$_($default$);");
184
 
  } else {
185
 
    printer->Print(variables_,
186
 
      "const ::std::string $classname$::_default_$name$_;");
187
187
  }
188
188
}
189
189
 
190
190
void StringFieldGenerator::
191
191
GenerateClearingCode(io::Printer* printer) const {
192
 
  if (descriptor_->has_default_value()) {
 
192
  if (descriptor_->default_value_string().empty()) {
 
193
    printer->Print(variables_,
 
194
      "if ($name$_ != &_default_$name$_) {\n"
 
195
      "  $name$_->clear();\n"
 
196
      "}\n");
 
197
  } else {
193
198
    printer->Print(variables_,
194
199
      "if ($name$_ != &_default_$name$_) {\n"
195
200
      "  $name$_->assign(_default_$name$_);\n"
196
201
      "}\n");
197
 
  } else {
198
 
    printer->Print(variables_,
199
 
      "if ($name$_ != &_default_$name$_) {\n"
200
 
      "  $name$_->clear();\n"
201
 
      "}\n");
202
202
  }
203
203
}
204
204
 
208
208
}
209
209
 
210
210
void StringFieldGenerator::
 
211
GenerateSwappingCode(io::Printer* printer) const {
 
212
  printer->Print(variables_, "std::swap($name$_, other->$name$_);\n");
 
213
}
 
214
 
 
215
void StringFieldGenerator::
211
216
GenerateInitializer(io::Printer* printer) const {
212
217
  printer->Print(variables_,
213
218
    ",\n$name$_(const_cast< ::std::string*>(&_default_$name$_))");
350
355
}
351
356
 
352
357
void RepeatedStringFieldGenerator::
 
358
GenerateSwappingCode(io::Printer* printer) const {
 
359
  printer->Print(variables_, "$name$_.Swap(&other->$name$_);\n");
 
360
}
 
361
 
 
362
void RepeatedStringFieldGenerator::
353
363
GenerateInitializer(io::Printer* printer) const {
354
364
  // Not needed for repeated fields.
355
365
}