MCPcopy Create free account
hub / github.com/Samsung/UTopia / addFieldToDescriptor

Method addFieldToDescriptor

lib/generation/ProtobufDescriptor.cpp:63–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63google::protobuf::FieldDescriptorProto *
64ProtobufDescriptor::addFieldToDescriptor(
65 google::protobuf::DescriptorProto &Desc, const std::string &FieldName,
66 const Type &T) {
67 bool Array = false;
68 const auto *BaseType = &T;
69 if (BaseType->isFixedLengthArrayPtr() && !BaseType->isStringType()) {
70 Array = true;
71 BaseType = BaseType->getPointeeType();
72 }
73 google::protobuf::FieldDescriptorProto *Field = nullptr;
74 if (BaseType->isPointerType()) {
75 Field = addFieldToDescriptorPointerType(Desc, FieldName, *BaseType);
76 } else if (BaseType->isEnumType()) {
77 Field = addFieldToDescriptorEnumType(Desc, FieldName, *BaseType);
78 } else if (BaseType->isPrimitiveType()) {
79 Field = addFieldToDescriptorPrimitiveType(Desc, FieldName, *BaseType);
80 }
81 if (Field && Array)
82 Field->set_label(google::protobuf::FieldDescriptorProto::LABEL_REPEATED);
83 return Field;
84}
85
86google::protobuf::FieldDescriptorProto *
87ProtobufDescriptor::addFieldToDescriptorPrimitiveType(

Callers

nothing calls this directly

Calls 7

isFixedLengthArrayPtrMethod · 0.80
isStringTypeMethod · 0.80
getPointeeTypeMethod · 0.80
isPointerTypeMethod · 0.80
isEnumTypeMethod · 0.80
isPrimitiveTypeMethod · 0.80
emptyMethod · 0.80

Tested by

no test coverage detected