mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-25 01:46:09 +00:00
Added support for imports and many other .proto features.
Change-Id: I6600021b7ec8c486794349511232c3e604421c5b Tested: on Linux.
This commit is contained in:
@@ -7,6 +7,7 @@ import java.lang.*;
|
||||
import java.util.*;
|
||||
import com.google.flatbuffers.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Monster extends Table {
|
||||
public static Monster getRootAsMonster(ByteBuffer _bb) { return getRootAsMonster(_bb, new Monster()); }
|
||||
public static Monster getRootAsMonster(ByteBuffer _bb, Monster obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.lang.*;
|
||||
import java.util.*;
|
||||
import com.google.flatbuffers.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Stat extends Table {
|
||||
public static Stat getRootAsStat(ByteBuffer _bb) { return getRootAsStat(_bb, new Stat()); }
|
||||
public static Stat getRootAsStat(ByteBuffer _bb, Stat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.lang.*;
|
||||
import java.util.*;
|
||||
import com.google.flatbuffers.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Test extends Struct {
|
||||
public Test __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.lang.*;
|
||||
import java.util.*;
|
||||
import com.google.flatbuffers.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class TestSimpleTableWithEnum extends Table {
|
||||
public static TestSimpleTableWithEnum getRootAsTestSimpleTableWithEnum(ByteBuffer _bb) { return getRootAsTestSimpleTableWithEnum(_bb, new TestSimpleTableWithEnum()); }
|
||||
public static TestSimpleTableWithEnum getRootAsTestSimpleTableWithEnum(ByteBuffer _bb, TestSimpleTableWithEnum obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.lang.*;
|
||||
import java.util.*;
|
||||
import com.google.flatbuffers.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Vec3 extends Struct {
|
||||
public Vec3 __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
|
||||
|
||||
|
||||
5
tests/prototest/imported.proto
Normal file
5
tests/prototest/imported.proto
Normal file
@@ -0,0 +1,5 @@
|
||||
package proto.test;
|
||||
|
||||
message ImportedMessage {
|
||||
optional int32 a = 26;
|
||||
}
|
||||
@@ -1,14 +1,22 @@
|
||||
// Generated from test.proto
|
||||
|
||||
namespace proto.test;
|
||||
namespace _proto._test;
|
||||
|
||||
/// Enum doc comment.
|
||||
enum ProtoEnum : short {
|
||||
enum ProtoEnum : int {
|
||||
FOO = 1,
|
||||
/// Enum 2nd value doc comment misaligned.
|
||||
BAR = 5,
|
||||
}
|
||||
|
||||
namespace _proto._test;
|
||||
|
||||
table ImportedMessage {
|
||||
a:int;
|
||||
}
|
||||
|
||||
namespace _proto._test;
|
||||
|
||||
/// 2nd table doc comment with
|
||||
/// many lines.
|
||||
table ProtoMessage {
|
||||
@@ -29,10 +37,13 @@ table ProtoMessage {
|
||||
/// lines
|
||||
l:string (required);
|
||||
m:string;
|
||||
n:OtherMessage;
|
||||
n:_proto._test._ProtoMessage.OtherMessage;
|
||||
o:[string];
|
||||
z:_proto._test.ImportedMessage;
|
||||
}
|
||||
|
||||
namespace _proto._test._ProtoMessage;
|
||||
|
||||
table OtherMessage {
|
||||
a:double;
|
||||
/// doc comment for b.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Sample .proto file that we can translate to the corresponding .fbs.
|
||||
|
||||
package proto.test;
|
||||
|
||||
option some_option = is_ignored;
|
||||
import "some_other_schema.proto";
|
||||
import "imported.proto";
|
||||
|
||||
package proto.test;
|
||||
|
||||
/// Enum doc comment.
|
||||
enum ProtoEnum {
|
||||
@@ -41,4 +41,5 @@ message ProtoMessage {
|
||||
optional bytes m = 11;
|
||||
optional OtherMessage n = 12;
|
||||
repeated string o = 14;
|
||||
optional ImportedMessage z = 16;
|
||||
}
|
||||
|
||||
@@ -428,7 +428,8 @@ void ParseProtoTest() {
|
||||
|
||||
// Parse proto.
|
||||
flatbuffers::Parser parser(false, true);
|
||||
TEST_EQ(parser.Parse(protofile.c_str(), nullptr), true);
|
||||
const char *include_directories[] = { "tests/prototest", nullptr };
|
||||
TEST_EQ(parser.Parse(protofile.c_str(), include_directories), true);
|
||||
|
||||
// Generate fbs.
|
||||
flatbuffers::GeneratorOptions opts;
|
||||
|
||||
Reference in New Issue
Block a user