mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-04 12:43:24 +00:00
@@ -238,7 +238,7 @@ static void GetStringField(const StructDef &struct_def,
|
||||
code += " " + MakeCamel(field.name);
|
||||
code += "() " + TypeName(field) + " ";
|
||||
code += OffsetPrefix(field) + "\t\treturn " + GenGetter(field.value.type);
|
||||
code += "(o + rcv._tab.Pos)\n\t}\n\treturn \"\"\n";
|
||||
code += "(o + rcv._tab.Pos)\n\t}\n\treturn nil\n";
|
||||
code += "}\n\n";
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ static void GetMemberOfVectorOfNonStruct(const StructDef &struct_def,
|
||||
code += NumToString(InlineSize(vectortype)) + "))\n";
|
||||
code += "\t}\n";
|
||||
if (vectortype.base_type == BASE_TYPE_STRING) {
|
||||
code += "\treturn \"\"\n";
|
||||
code += "\treturn nil\n";
|
||||
} else {
|
||||
code += "\treturn 0\n";
|
||||
}
|
||||
@@ -573,7 +573,7 @@ static void GenEnum(const EnumDef &enum_def, std::string *code_ptr) {
|
||||
// Returns the function name that is able to read a value of the given type.
|
||||
static std::string GenGetter(const Type &type) {
|
||||
switch (type.base_type) {
|
||||
case BASE_TYPE_STRING: return "rcv._tab.String";
|
||||
case BASE_TYPE_STRING: return "rcv._tab.ByteVector";
|
||||
case BASE_TYPE_UNION: return "rcv._tab.Union";
|
||||
case BASE_TYPE_VECTOR: return GenGetter(type.VectorType());
|
||||
default:
|
||||
@@ -626,7 +626,7 @@ static std::string GenTypeBasic(const Type &type) {
|
||||
static std::string GenTypePointer(const Type &type) {
|
||||
switch (type.base_type) {
|
||||
case BASE_TYPE_STRING:
|
||||
return "string";
|
||||
return "[]byte";
|
||||
case BASE_TYPE_VECTOR:
|
||||
return GenTypeGet(type.VectorType());
|
||||
case BASE_TYPE_STRUCT:
|
||||
|
||||
@@ -971,6 +971,8 @@ void Parser::ParseDecl() {
|
||||
CheckClash("Type", BASE_TYPE_UNION);
|
||||
CheckClash("_length", BASE_TYPE_VECTOR);
|
||||
CheckClash("Length", BASE_TYPE_VECTOR);
|
||||
CheckClash("_byte_vector", BASE_TYPE_STRING);
|
||||
CheckClash("ByteVector", BASE_TYPE_STRING);
|
||||
Expect('}');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user