MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / LookupCreateStruct

Method LookupCreateStruct

native/thirdpart/flatbuffers/idl_parser.cpp:2047–2093  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2045}
2046
2047StructDef *Parser::LookupCreateStruct(const std::string &name,
2048 bool create_if_new, bool definition) {
2049 std::string qualified_name = current_namespace_->GetFullyQualifiedName(name);
2050 // See if it exists pre-declared by an unqualified use.
2051 auto struct_def = LookupStruct(name);
2052 if (struct_def && struct_def->predecl) {
2053 if (definition) {
2054 // Make sure it has the current namespace, and is registered under its
2055 // qualified name.
2056 struct_def->defined_namespace = current_namespace_;
2057 structs_.Move(name, qualified_name);
2058 }
2059 return struct_def;
2060 }
2061 // See if it exists pre-declared by an qualified use.
2062 struct_def = LookupStruct(qualified_name);
2063 if (struct_def && struct_def->predecl) {
2064 if (definition) {
2065 // Make sure it has the current namespace.
2066 struct_def->defined_namespace = current_namespace_;
2067 }
2068 return struct_def;
2069 }
2070 if (!definition && !struct_def) {
2071 struct_def = LookupStructThruParentNamespaces(name);
2072 }
2073 if (!struct_def && create_if_new) {
2074 struct_def = new StructDef();
2075 if (definition) {
2076 structs_.Add(qualified_name, struct_def);
2077 struct_def->name = name;
2078 struct_def->defined_namespace = current_namespace_;
2079 } else {
2080 // Not a definition.
2081 // Rather than failing, we create a "pre declared" StructDef, due to
2082 // circular references, and check for errors at the end of parsing.
2083 // It is defined in the current namespace, as the best guess what the
2084 // final namespace will be.
2085 structs_.Add(name, struct_def);
2086 struct_def->name = name;
2087 struct_def->defined_namespace = current_namespace_;
2088 struct_def->original_location.reset(
2089 new std::string(file_being_parsed_ + ":" + NumToString(line_)));
2090 }
2091 }
2092 return struct_def;
2093}
2094
2095const EnumVal *EnumDef::MinValue() const {
2096 return vals.vec.empty() ? nullptr : vals.vec.front();

Callers

nothing calls this directly

Calls 5

NumToStringFunction · 0.85
GetFullyQualifiedNameMethod · 0.80
MoveMethod · 0.80
AddMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected