Fixed .proto -> .fbs translating type bytes incorrectly.

Change-Id: Idb607360123d12c73dd1e045305007120b12131b
Tested: on Linux.
parent 00d726fc
...@@ -1970,22 +1970,29 @@ CheckedError Parser::ParseProtoOption() { ...@@ -1970,22 +1970,29 @@ CheckedError Parser::ParseProtoOption() {
// Parse a protobuf type, and map it to the corresponding FlatBuffer one. // Parse a protobuf type, and map it to the corresponding FlatBuffer one.
CheckedError Parser::ParseTypeFromProtoType(Type *type) { CheckedError Parser::ParseTypeFromProtoType(Type *type) {
struct type_lookup { const char *proto_type; BaseType fb_type; }; struct type_lookup { const char *proto_type; BaseType fb_type, element; };
static type_lookup lookup[] = { static type_lookup lookup[] = {
{ "float", BASE_TYPE_FLOAT }, { "double", BASE_TYPE_DOUBLE }, { "float", BASE_TYPE_FLOAT, BASE_TYPE_NONE },
{ "int32", BASE_TYPE_INT }, { "int64", BASE_TYPE_LONG }, { "double", BASE_TYPE_DOUBLE, BASE_TYPE_NONE },
{ "uint32", BASE_TYPE_UINT }, { "uint64", BASE_TYPE_ULONG }, { "int32", BASE_TYPE_INT, BASE_TYPE_NONE },
{ "sint32", BASE_TYPE_INT }, { "sint64", BASE_TYPE_LONG }, { "int64", BASE_TYPE_LONG, BASE_TYPE_NONE },
{ "fixed32", BASE_TYPE_UINT }, { "fixed64", BASE_TYPE_ULONG }, { "uint32", BASE_TYPE_UINT, BASE_TYPE_NONE },
{ "sfixed32", BASE_TYPE_INT }, { "sfixed64", BASE_TYPE_LONG }, { "uint64", BASE_TYPE_ULONG, BASE_TYPE_NONE },
{ "bool", BASE_TYPE_BOOL }, { "sint32", BASE_TYPE_INT, BASE_TYPE_NONE },
{ "string", BASE_TYPE_STRING }, { "sint64", BASE_TYPE_LONG, BASE_TYPE_NONE },
{ "bytes", BASE_TYPE_STRING }, { "fixed32", BASE_TYPE_UINT, BASE_TYPE_NONE },
{ nullptr, BASE_TYPE_NONE } { "fixed64", BASE_TYPE_ULONG, BASE_TYPE_NONE },
{ "sfixed32", BASE_TYPE_INT, BASE_TYPE_NONE },
{ "sfixed64", BASE_TYPE_LONG, BASE_TYPE_NONE },
{ "bool", BASE_TYPE_BOOL, BASE_TYPE_NONE },
{ "string", BASE_TYPE_STRING, BASE_TYPE_NONE },
{ "bytes", BASE_TYPE_VECTOR, BASE_TYPE_UCHAR },
{ nullptr, BASE_TYPE_NONE, BASE_TYPE_NONE }
}; };
for (auto tl = lookup; tl->proto_type; tl++) { for (auto tl = lookup; tl->proto_type; tl++) {
if (attribute_ == tl->proto_type) { if (attribute_ == tl->proto_type) {
type->base_type = tl->fb_type; type->base_type = tl->fb_type;
type->element = tl->element;
NEXT(); NEXT();
return NoError(); return NoError();
} }
......
...@@ -36,7 +36,7 @@ table ProtoMessage { ...@@ -36,7 +36,7 @@ table ProtoMessage {
/// doc comment for l on 2 /// doc comment for l on 2
/// lines /// lines
l:string (required); l:string (required);
m:string; m:[ubyte];
n:_proto._test._ProtoMessage.OtherMessage; n:_proto._test._ProtoMessage.OtherMessage;
o:[string]; o:[string];
z:_proto._test.ImportedMessage; z:_proto._test.ImportedMessage;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment