summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2015-09-20 14:12:19 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2015-09-20 14:29:39 +0300
commitb03be4fa4d863e6beb362cfef6d834d14c96b7e1 (patch)
tree31bdb84f1be4ce5104d4a67d3e5c321f12639b83
parent6e72df4808aa138f1396ad098ce2d06a6feba882 (diff)
Add syntax specification to .proto files (issue #167)
Eliminates a warning on protoc 3.0.
-rw-r--r--examples/cmake_simple/simple.proto2
-rw-r--r--examples/network_server/fileproto.proto2
-rw-r--r--examples/simple/simple.proto2
-rw-r--r--examples/using_double_on_avr/doubleproto.proto2
-rw-r--r--examples/using_union_messages/unionproto.proto2
-rw-r--r--tests/alltypes/alltypes.proto3
-rw-r--r--tests/backwards_compatibility/alltypes_legacy.proto2
-rw-r--r--tests/callbacks/callbacks.proto2
-rw-r--r--tests/common/person.proto2
-rw-r--r--tests/common/unittestproto.proto2
-rw-r--r--tests/cyclic_messages/cyclic.proto2
-rw-r--r--tests/enum_sizes/enumsizes.proto2
-rw-r--r--tests/extensions/extensions.proto2
-rw-r--r--tests/field_size_16/alltypes.proto2
-rw-r--r--tests/field_size_32/alltypes.proto2
-rw-r--r--tests/fuzztest/SConscript15
-rw-r--r--tests/intsizes/intsizes.proto2
-rw-r--r--tests/message_sizes/messages1.proto2
-rw-r--r--tests/message_sizes/messages2.proto2
-rw-r--r--tests/missing_fields/missing_fields.proto2
-rw-r--r--tests/multiple_files/multifile1.proto2
-rw-r--r--tests/multiple_files/multifile2.proto2
-rw-r--r--tests/no_messages/no_messages.proto2
-rw-r--r--tests/oneof/oneof.proto2
-rw-r--r--tests/options/options.proto2
-rw-r--r--tests/package_name/SConscript16
-rw-r--r--tests/regression/issue_118/enumdef.proto2
-rw-r--r--tests/regression/issue_118/enumuse.proto2
-rw-r--r--tests/regression/issue_125/extensionbug.proto2
-rw-r--r--tests/regression/issue_141/testproto.proto2
-rw-r--r--tests/regression/issue_145/comments.proto2
-rw-r--r--tests/regression/issue_166/enums.proto2
-rw-r--r--tests/special_characters/funny-proto+name has.characters.proto1
33 files changed, 80 insertions, 13 deletions
diff --git a/examples/cmake_simple/simple.proto b/examples/cmake_simple/simple.proto
index 26e72f46..5c73a3b2 100644
--- a/examples/cmake_simple/simple.proto
+++ b/examples/cmake_simple/simple.proto
@@ -1,6 +1,8 @@
// A very simple protocol definition, consisting of only
// one message.
+syntax = "proto2";
+
message SimpleMessage {
required int32 lucky_number = 1;
}
diff --git a/examples/network_server/fileproto.proto b/examples/network_server/fileproto.proto
index 3e70c492..5640b8d5 100644
--- a/examples/network_server/fileproto.proto
+++ b/examples/network_server/fileproto.proto
@@ -2,6 +2,8 @@
//
// See also the nanopb-specific options in fileproto.options.
+syntax = "proto2";
+
message ListFilesRequest {
optional string path = 1 [default = "/"];
}
diff --git a/examples/simple/simple.proto b/examples/simple/simple.proto
index 26e72f46..5c73a3b2 100644
--- a/examples/simple/simple.proto
+++ b/examples/simple/simple.proto
@@ -1,6 +1,8 @@
// A very simple protocol definition, consisting of only
// one message.
+syntax = "proto2";
+
message SimpleMessage {
required int32 lucky_number = 1;
}
diff --git a/examples/using_double_on_avr/doubleproto.proto b/examples/using_double_on_avr/doubleproto.proto
index d8b7f2db..72d3f9c1 100644
--- a/examples/using_double_on_avr/doubleproto.proto
+++ b/examples/using_double_on_avr/doubleproto.proto
@@ -1,4 +1,6 @@
// A message containing doubles, as used by other applications.
+syntax = "proto2";
+
message DoubleMessage {
required double field1 = 1;
required double field2 = 2;
diff --git a/examples/using_union_messages/unionproto.proto b/examples/using_union_messages/unionproto.proto
index d7c9de2d..209df0d2 100644
--- a/examples/using_union_messages/unionproto.proto
+++ b/examples/using_union_messages/unionproto.proto
@@ -5,6 +5,8 @@
// but they are commonly implemented by filling out exactly one of
// several optional fields.
+syntax = "proto2";
+
message MsgType1
{
required int32 value = 1;
diff --git a/tests/alltypes/alltypes.proto b/tests/alltypes/alltypes.proto
index 28eaf0be..3995c552 100644
--- a/tests/alltypes/alltypes.proto
+++ b/tests/alltypes/alltypes.proto
@@ -1,3 +1,6 @@
+syntax = "proto2";
+// package name placeholder
+
message SubMessage {
required string substuff1 = 1 [default = "1"];
required int32 substuff2 = 2 [default = 2];
diff --git a/tests/backwards_compatibility/alltypes_legacy.proto b/tests/backwards_compatibility/alltypes_legacy.proto
index d7631eb6..f5bc35ce 100644
--- a/tests/backwards_compatibility/alltypes_legacy.proto
+++ b/tests/backwards_compatibility/alltypes_legacy.proto
@@ -1,3 +1,5 @@
+syntax = "proto2";
+
message SubMessage {
required string substuff1 = 1 [default = "1"];
required int32 substuff2 = 2 [default = 2];
diff --git a/tests/callbacks/callbacks.proto b/tests/callbacks/callbacks.proto
index ccd1edd8..96ac744d 100644
--- a/tests/callbacks/callbacks.proto
+++ b/tests/callbacks/callbacks.proto
@@ -1,3 +1,5 @@
+syntax = "proto2";
+
message SubMessage {
optional string stringvalue = 1;
repeated int32 int32value = 2;
diff --git a/tests/common/person.proto b/tests/common/person.proto
index dafcf934..becefdf3 100644
--- a/tests/common/person.proto
+++ b/tests/common/person.proto
@@ -1,3 +1,5 @@
+syntax = "proto2";
+
import "nanopb.proto";
message Person {
diff --git a/tests/common/unittestproto.proto b/tests/common/unittestproto.proto
index 0ecb1f0b..23b5b97f 100644
--- a/tests/common/unittestproto.proto
+++ b/tests/common/unittestproto.proto
@@ -1,3 +1,5 @@
+syntax = "proto2";
+
import 'nanopb.proto';
message IntegerArray {
diff --git a/tests/cyclic_messages/cyclic.proto b/tests/cyclic_messages/cyclic.proto
index a9d158cb..8cab0b14 100644
--- a/tests/cyclic_messages/cyclic.proto
+++ b/tests/cyclic_messages/cyclic.proto
@@ -2,6 +2,8 @@
// These can only be handled in pointer/callback mode,
// see associated .options files.
+syntax = "proto2";
+
message TreeNode
{
optional int32 leaf = 1;
diff --git a/tests/enum_sizes/enumsizes.proto b/tests/enum_sizes/enumsizes.proto
index f9ab0b7f..a85d4160 100644
--- a/tests/enum_sizes/enumsizes.proto
+++ b/tests/enum_sizes/enumsizes.proto
@@ -4,6 +4,8 @@
* a bit of a problem for the encoder/decoder (issue #164).
*/
+syntax = "proto2";
+
import 'nanopb.proto';
option (nanopb_fileopt).long_names = false;
diff --git a/tests/extensions/extensions.proto b/tests/extensions/extensions.proto
index 79c01245..fcd5b43b 100644
--- a/tests/extensions/extensions.proto
+++ b/tests/extensions/extensions.proto
@@ -1,3 +1,5 @@
+syntax = "proto2";
+
import 'alltypes.proto';
extend AllTypes {
diff --git a/tests/field_size_16/alltypes.proto b/tests/field_size_16/alltypes.proto
index 039391fc..ba1ec383 100644
--- a/tests/field_size_16/alltypes.proto
+++ b/tests/field_size_16/alltypes.proto
@@ -1,3 +1,5 @@
+syntax = "proto2";
+
message SubMessage {
required string substuff1 = 1 [default = "1"];
required int32 substuff2 = 2 [default = 2];
diff --git a/tests/field_size_32/alltypes.proto b/tests/field_size_32/alltypes.proto
index 5749e0d4..02ee1a6a 100644
--- a/tests/field_size_32/alltypes.proto
+++ b/tests/field_size_32/alltypes.proto
@@ -1,3 +1,5 @@
+syntax = "proto2";
+
message SubMessage {
required string substuff1 = 1 [default = "1"];
required int32 substuff2 = 2 [default = 2];
diff --git a/tests/fuzztest/SConscript b/tests/fuzztest/SConscript
index 35b697f9..973148c2 100644
--- a/tests/fuzztest/SConscript
+++ b/tests/fuzztest/SConscript
@@ -2,16 +2,19 @@
Import("env", "malloc_env")
+def set_pkgname(src, dst, pkgname):
+ data = open(str(src)).read()
+ placeholder = '// package name placeholder'
+ assert placeholder in data
+ data = data.replace(placeholder, 'package %s;' % pkgname)
+ open(str(dst), 'w').write(data)
+
# We want both pointer and static versions of the AllTypes message
# Prefix them with package name.
env.Command("alltypes_static.proto", "#alltypes/alltypes.proto",
- lambda target, source, env:
- open(str(target[0]), 'w').write("package alltypes_static;\n"
- + open(str(source[0])).read()))
+ lambda target, source, env: set_pkgname(source[0], target[0], 'alltypes_static'))
env.Command("alltypes_pointer.proto", "#alltypes/alltypes.proto",
- lambda target, source, env:
- open(str(target[0]), 'w').write("package alltypes_pointer;\n"
- + open(str(source[0])).read()))
+ lambda target, source, env: set_pkgname(source[0], target[0], 'alltypes_pointer'))
p1 = env.NanopbProto(["alltypes_pointer", "alltypes_pointer.options"])
p2 = env.NanopbProto(["alltypes_static", "alltypes_static.options"])
diff --git a/tests/intsizes/intsizes.proto b/tests/intsizes/intsizes.proto
index 236bf183..91444d41 100644
--- a/tests/intsizes/intsizes.proto
+++ b/tests/intsizes/intsizes.proto
@@ -6,6 +6,8 @@
* otherwise. E.g. uint32 + IS_8 => uint8_t
*/
+syntax = "proto2";
+
import 'nanopb.proto';
message IntSizes {
diff --git a/tests/message_sizes/messages1.proto b/tests/message_sizes/messages1.proto
index 48af55a3..b66fad71 100644
--- a/tests/message_sizes/messages1.proto
+++ b/tests/message_sizes/messages1.proto
@@ -1,3 +1,5 @@
+syntax = "proto2";
+
enum MessageStatus {
FAIL = 0;
OK = 1;
diff --git a/tests/message_sizes/messages2.proto b/tests/message_sizes/messages2.proto
index 19fc11ef..67614080 100644
--- a/tests/message_sizes/messages2.proto
+++ b/tests/message_sizes/messages2.proto
@@ -1,3 +1,5 @@
+syntax = "proto2";
+
import 'nanopb.proto';
import 'messages1.proto';
diff --git a/tests/missing_fields/missing_fields.proto b/tests/missing_fields/missing_fields.proto
index cbb23ba1..cc5e550b 100644
--- a/tests/missing_fields/missing_fields.proto
+++ b/tests/missing_fields/missing_fields.proto
@@ -1,5 +1,7 @@
/* Test for one missing field among many */
+syntax = "proto2";
+
message AllFields
{
required int32 field1 = 1;
diff --git a/tests/multiple_files/multifile1.proto b/tests/multiple_files/multifile1.proto
index d804b67d..18f2c672 100644
--- a/tests/multiple_files/multifile1.proto
+++ b/tests/multiple_files/multifile1.proto
@@ -1,3 +1,5 @@
+syntax = "proto2";
+
message SubMessage {
optional string stringvalue = 1;
repeated int32 int32value = 2;
diff --git a/tests/multiple_files/multifile2.proto b/tests/multiple_files/multifile2.proto
index 66cb8a0b..4af45fd9 100644
--- a/tests/multiple_files/multifile2.proto
+++ b/tests/multiple_files/multifile2.proto
@@ -1,5 +1,7 @@
// Test if including generated header file for this file + implicit include of
// multifile2.pb.h still compiles. Used with test_compiles.c.
+syntax = "proto2";
+
import "multifile1.proto";
message Callback2Message {
diff --git a/tests/no_messages/no_messages.proto b/tests/no_messages/no_messages.proto
index 279216b0..45bb2e66 100644
--- a/tests/no_messages/no_messages.proto
+++ b/tests/no_messages/no_messages.proto
@@ -1,5 +1,7 @@
/* Test that a file without any messages works. */
+syntax = "proto2";
+
enum Test {
First = 1;
}
diff --git a/tests/oneof/oneof.proto b/tests/oneof/oneof.proto
index 00f1ceca..b4fe56f2 100644
--- a/tests/oneof/oneof.proto
+++ b/tests/oneof/oneof.proto
@@ -1,3 +1,5 @@
+syntax = "proto2";
+
import 'nanopb.proto';
message SubMessage
diff --git a/tests/options/options.proto b/tests/options/options.proto
index b7050418..aa722b52 100644
--- a/tests/options/options.proto
+++ b/tests/options/options.proto
@@ -2,6 +2,8 @@
* options.expected lists the patterns that are searched for in the output.
*/
+syntax = "proto2";
+
import "nanopb.proto";
// File level options
diff --git a/tests/package_name/SConscript b/tests/package_name/SConscript
index 897bc99c..4afc5037 100644
--- a/tests/package_name/SConscript
+++ b/tests/package_name/SConscript
@@ -3,14 +3,16 @@
Import("env")
-# Build a modified alltypes.proto
-def modify_proto(target, source, env):
- '''Add a "package test.package;" directive to the beginning of the .proto file.'''
- data = open(str(source[0]), 'r').read()
- open(str(target[0]), 'w').write("package test.package;\n\n" + data)
- return 0
+def set_pkgname(src, dst, pkgname):
+ data = open(str(src)).read()
+ placeholder = '// package name placeholder'
+ assert placeholder in data
+ data = data.replace(placeholder, 'package %s;' % pkgname)
+ open(str(dst), 'w').write(data)
-env.Command("alltypes.proto", "#alltypes/alltypes.proto", modify_proto)
+# Build a modified alltypes.proto
+env.Command("alltypes.proto", "#alltypes/alltypes.proto",
+ lambda target, source, env: set_pkgname(source[0], target[0], 'test.package'))
env.Command("alltypes.options", "#alltypes/alltypes.options", Copy("$TARGET", "$SOURCE"))
env.NanopbProto(["alltypes", "alltypes.options"])
diff --git a/tests/regression/issue_118/enumdef.proto b/tests/regression/issue_118/enumdef.proto
index 830d2988..46845bc9 100644
--- a/tests/regression/issue_118/enumdef.proto
+++ b/tests/regression/issue_118/enumdef.proto
@@ -1,3 +1,5 @@
+syntax = "proto2";
+
import 'nanopb.proto';
enum MyEnum {
diff --git a/tests/regression/issue_118/enumuse.proto b/tests/regression/issue_118/enumuse.proto
index d778fb8f..4afc4521 100644
--- a/tests/regression/issue_118/enumuse.proto
+++ b/tests/regression/issue_118/enumuse.proto
@@ -1,3 +1,5 @@
+syntax = "proto2";
+
import 'enumdef.proto';
message MyMessage {
diff --git a/tests/regression/issue_125/extensionbug.proto b/tests/regression/issue_125/extensionbug.proto
index c4ac6860..fd1e74f1 100644
--- a/tests/regression/issue_125/extensionbug.proto
+++ b/tests/regression/issue_125/extensionbug.proto
@@ -1,3 +1,5 @@
+syntax = "proto2";
+
message Message1
{
optional uint32 fieldA = 1;
diff --git a/tests/regression/issue_141/testproto.proto b/tests/regression/issue_141/testproto.proto
index 21598b45..a445c68a 100644
--- a/tests/regression/issue_141/testproto.proto
+++ b/tests/regression/issue_141/testproto.proto
@@ -1,3 +1,5 @@
+syntax = "proto2";
+
import 'nanopb.proto';
message SubMessage
diff --git a/tests/regression/issue_145/comments.proto b/tests/regression/issue_145/comments.proto
index 4e86b302..621779f5 100644
--- a/tests/regression/issue_145/comments.proto
+++ b/tests/regression/issue_145/comments.proto
@@ -1,3 +1,5 @@
+syntax = "proto2";
+
message DummyMessage {
required string foo = 1;
required string bar = 2;
diff --git a/tests/regression/issue_166/enums.proto b/tests/regression/issue_166/enums.proto
index a0964ab4..36948044 100644
--- a/tests/regression/issue_166/enums.proto
+++ b/tests/regression/issue_166/enums.proto
@@ -1,3 +1,5 @@
+syntax = "proto2";
+
enum SignedEnum {
SE_MIN = -1;
SE_MAX = 255;
diff --git a/tests/special_characters/funny-proto+name has.characters.proto b/tests/special_characters/funny-proto+name has.characters.proto
index e69de29b..26b2cb1b 100644
--- a/tests/special_characters/funny-proto+name has.characters.proto
+++ b/tests/special_characters/funny-proto+name has.characters.proto
@@ -0,0 +1 @@
+syntax="proto2";