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

Method addFieldToDescriptorPrimitiveType

lib/generation/ProtobufDescriptor.cpp:86–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86google::protobuf::FieldDescriptorProto *
87ProtobufDescriptor::addFieldToDescriptorPrimitiveType(
88 google::protobuf::DescriptorProto &Desc, const std::string &FieldName,
89 const Type &T) {
90 assert(T.isPrimitiveType() && "Unexpected Program State");
91 google::protobuf::FieldDescriptorProto_Type FieldType;
92 if (T.isIntegerType()) {
93 if (T.isBoolean())
94 FieldType = google::protobuf::FieldDescriptorProto::TYPE_BOOL;
95 else if (T.getTypeSize() == 8) {
96 FieldType = T.isUnsigned()
97 ? google::protobuf::FieldDescriptorProto::TYPE_UINT64
98 : google::protobuf::FieldDescriptorProto::TYPE_SINT64;
99 } else {
100 FieldType = T.isUnsigned()
101 ? google::protobuf::FieldDescriptorProto::TYPE_UINT32
102 : google::protobuf::FieldDescriptorProto::TYPE_SINT32;
103 }
104 } else if (T.isFloatType()) {
105 FieldType = T.getTypeSize() == 8
106 ? google::protobuf::FieldDescriptorProto::TYPE_DOUBLE
107 : google::protobuf::FieldDescriptorProto::TYPE_FLOAT;
108 } else { // Unknown Type
109 return nullptr;
110 }
111 return addFieldToDescriptor(Desc, FieldName, FieldType);
112}
113
114google::protobuf::FieldDescriptorProto *
115ProtobufDescriptor::addFieldToDescriptorEnumType(

Callers

nothing calls this directly

Calls 6

isPrimitiveTypeMethod · 0.80
isIntegerTypeMethod · 0.80
isBooleanMethod · 0.80
getTypeSizeMethod · 0.80
isUnsignedMethod · 0.80
isFloatTypeMethod · 0.80

Tested by

no test coverage detected