Lines Matching refs:field
79 bool IsProto3SimpleField(const FieldDescriptor& field) { in IsProto3SimpleField() argument
80 assert(field.file()->syntax() == FileDescriptor::SYNTAX_PROTO3 || in IsProto3SimpleField()
81 field.file()->syntax() == FileDescriptor::SYNTAX_PROTO2); in IsProto3SimpleField()
82 return field.file()->syntax() == FileDescriptor::SYNTAX_PROTO3 && in IsProto3SimpleField()
83 field.cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE && in IsProto3SimpleField()
84 !field.containing_oneof() && !field.is_repeated(); in IsProto3SimpleField()
89 void ForType(const FieldInstance& field) const { in ForType()
91 field.GetDefault(&value); in ForType()
92 field.Create(value); in ForType()
98 void ForType(const FieldInstance& field) const { in ForType()
99 field.Delete(); in ForType()
106 const FieldInstance& field) const { in ForType()
109 field.Store(value); in ForType()
116 const FieldInstance& field) const { in ForType()
119 field.Create(value); in ForType()
163 const FieldInstance& field() const { return sampler_.selected().field; } in field() function in protobuf_mutator::__anonfbc755e10111::MutationSampler
175 const FieldDescriptor* field = descriptor->field(i); in Sample() local
176 if (const OneofDescriptor* oneof = field->containing_oneof()) { in Sample()
178 if (field->index_in_oneof() == 0) { in Sample()
184 oneof->field(GetRandomIndex(random_, oneof->field_count())); in Sample()
204 if (field->is_repeated()) { in Sample()
205 int field_size = reflection->FieldSize(*message, field); in Sample()
208 {{message, field, GetRandomIndex(random_, field_size + 1)}, in Sample()
213 if (field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) { in Sample()
215 {{message, field, random_index}, Mutation::Mutate}); in Sample()
218 {{message, field, random_index}, Mutation::Delete}); in Sample()
220 {{message, field, random_index}, Mutation::Copy}); in Sample()
223 if (reflection->HasField(*message, field) || in Sample()
224 IsProto3SimpleField(*field)) { in Sample()
225 if (field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) in Sample()
227 {{message, field}, Mutation::Mutate}); in Sample()
228 if (!IsProto3SimpleField(*field) && in Sample()
229 (!field->is_required() || !keep_initialized_)) { in Sample()
231 {{message, field}, Mutation::Delete}); in Sample()
234 {{message, field}, Mutation::Copy}); in Sample()
237 {{message, field}, Mutation::Add}); in Sample()
242 if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { in Sample()
243 if (field->is_repeated()) { in Sample()
244 const int field_size = reflection->FieldSize(*message, field); in Sample()
246 Sample(reflection->MutableRepeatedMessage(message, field, j)); in Sample()
247 } else if (reflection->HasField(*message, field)) { in Sample()
248 Sample(reflection->MutableMessage(message, field)); in Sample()
260 Result(const FieldInstance& f, Mutation m) : field(f), mutation(m) {} in Result()
262 FieldInstance field; member
278 const ConstFieldInstance& field() const { in field() function in protobuf_mutator::__anonfbc755e10111::DataSourceSampler
292 const FieldDescriptor* field = descriptor->field(i); in Sample() local
293 if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { in Sample()
294 if (field->is_repeated()) { in Sample()
295 const int field_size = reflection->FieldSize(*message, field); in Sample()
297 Sample(reflection->MutableRepeatedMessage(message, field, j)); in Sample()
299 } else if (reflection->HasField(*message, field)) { in Sample()
300 Sample(reflection->MutableMessage(message, field)); in Sample()
304 if (field->cpp_type() != match_.cpp_type()) continue; in Sample()
306 if (field->enum_type() != match_.enum_type()) continue; in Sample()
308 if (field->message_type() != match_.message_type()) continue; in Sample()
311 if (field->is_repeated()) { in Sample()
312 if (int field_size = reflection->FieldSize(*message, field)) { in Sample()
313 ConstFieldInstance source(message, field, in Sample()
320 if (reflection->HasField(*message, field)) { in Sample()
321 ConstFieldInstance source(message, field); in Sample()
423 void ForType(const FieldInstance& field, size_t size_increase_hint, in ForType()
426 field.Load(&value); in ForType()
427 FieldMutator(size_increase_hint, true, field.EnforceUtf8(), mutator) in ForType()
429 field.Store(value); in ForType()
436 void ForType(const FieldInstance& field, size_t size_increase_hint, in ForType()
439 field.GetDefault(&value); in ForType()
442 field.EnforceUtf8(), mutator); in ForType()
444 field.Create(value); in ForType()
461 CreateField()(mutation.field(), size_increase_hint / 2, this); in Mutate()
464 MutateField()(mutation.field(), size_increase_hint / 2, this); in Mutate()
467 DeleteField()(mutation.field()); in Mutate()
470 DataSourceSampler source(mutation.field(), random_, message); in Mutate()
475 CopyField()(source.field(), mutation.field()); in Mutate()
515 const FieldDescriptor* field = descriptor->field(i); in CrossOverImpl() local
517 if (field->is_repeated()) { in CrossOverImpl()
518 const int field_size1 = reflection->FieldSize(message1, field); in CrossOverImpl()
519 int field_size2 = reflection->FieldSize(*message2, field); in CrossOverImpl()
521 ConstFieldInstance source(&message1, field, j); in CrossOverImpl()
522 FieldInstance destination(message2, field, field_size2++); in CrossOverImpl()
526 assert(field_size2 == reflection->FieldSize(*message2, field)); in CrossOverImpl()
531 reflection->SwapElements(message2, field, j, j + k); in CrossOverImpl()
537 if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { in CrossOverImpl()
545 CrossOverImpl(reflection->GetRepeatedMessage(*message2, field, r), in CrossOverImpl()
546 reflection->MutableRepeatedMessage(message2, field, k)); in CrossOverImpl()
551 reflection->RemoveLast(message2, field); in CrossOverImpl()
552 assert(keep == reflection->FieldSize(*message2, field)); in CrossOverImpl()
554 } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { in CrossOverImpl()
555 if (!reflection->HasField(message1, field)) { in CrossOverImpl()
557 DeleteField()(FieldInstance(message2, field)); in CrossOverImpl()
558 } else if (!reflection->HasField(*message2, field)) { in CrossOverImpl()
560 ConstFieldInstance source(&message1, field); in CrossOverImpl()
561 CopyField()(source, FieldInstance(message2, field)); in CrossOverImpl()
564 CrossOverImpl(reflection->GetMessage(message1, field), in CrossOverImpl()
565 reflection->MutableMessage(message2, field)); in CrossOverImpl()
569 if (reflection->HasField(message1, field)) { in CrossOverImpl()
570 ConstFieldInstance source(&message1, field); in CrossOverImpl()
571 CopyField()(source, FieldInstance(message2, field)); in CrossOverImpl()
573 DeleteField()(FieldInstance(message2, field)); in CrossOverImpl()
584 const FieldDescriptor* field = descriptor->field(i); in InitializeAndTrim() local
585 if (keep_initialized_ && field->is_required() && in InitializeAndTrim()
586 !reflection->HasField(*message, field)) in InitializeAndTrim()
587 CreateDefaultField()(FieldInstance(message, field)); in InitializeAndTrim()
589 if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { in InitializeAndTrim()
590 if (max_depth <= 0 && !field->is_required()) { in InitializeAndTrim()
592 reflection->ClearField(message, field); in InitializeAndTrim()
593 if (field->is_repeated()) in InitializeAndTrim()
594 assert(!reflection->FieldSize(*message, field)); in InitializeAndTrim()
596 assert(!reflection->HasField(*message, field)); in InitializeAndTrim()
600 if (field->is_repeated()) { in InitializeAndTrim()
601 const int field_size = reflection->FieldSize(*message, field); in InitializeAndTrim()
604 reflection->MutableRepeatedMessage(message, field, j); in InitializeAndTrim()
607 } else if (reflection->HasField(*message, field)) { in InitializeAndTrim()
608 Message* nested_message = reflection->MutableMessage(message, field); in InitializeAndTrim()