You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2014/09/11 22:48:22 UTC

git commit: THRIFT-1040 Can't end typedef lines with a semicolon Client: Compiler (General) Patch: Konrad Grochowski

Repository: thrift
Updated Branches:
  refs/heads/master 684ccab5e -> 089bcd3f8


THRIFT-1040 Can't end typedef lines with a semicolon
Client: Compiler (General)
Patch: Konrad Grochowski


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/089bcd3f
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/089bcd3f
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/089bcd3f

Branch: refs/heads/master
Commit: 089bcd3f8cd643091cd29126b236271c069b18e9
Parents: 684ccab
Author: Jens Geyer <je...@apache.org>
Authored: Thu Sep 11 22:36:41 2014 +0200
Committer: Jens Geyer <je...@apache.org>
Committed: Thu Sep 11 22:36:41 2014 +0200

----------------------------------------------------------------------
 compiler/cpp/src/thrifty.yy  | 18 +++++++++---------
 lib/cpp/test/Makefile.am     | 15 ++++++++++-----
 lib/cpp/test/TypedefTest.cpp | 27 +++++++++++++++++++++++++++
 test/TypedefTest.thrift      | 36 ++++++++++++++++++++++++++++++++++++
 4 files changed, 82 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/089bcd3f/compiler/cpp/src/thrifty.yy
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy
index 3755d13..40e7a06 100644
--- a/compiler/cpp/src/thrifty.yy
+++ b/compiler/cpp/src/thrifty.yy
@@ -545,8 +545,16 @@ TypeDefinition:
       }
     }
 
+CommaOrSemicolonOptional:
+  ','
+    {}
+| ';'
+    {}
+|
+    {}
+
 Typedef:
-  tok_typedef FieldType tok_identifier TypeAnnotations
+  tok_typedef FieldType tok_identifier TypeAnnotations CommaOrSemicolonOptional
     {
       pdebug("TypeDef -> tok_typedef FieldType tok_identifier");
       validate_simple_identifier( $3);
@@ -558,14 +566,6 @@ Typedef:
       }
     }
 
-CommaOrSemicolonOptional:
-  ','
-    {}
-| ';'
-    {}
-|
-    {}
-
 Enum:
   tok_enum tok_identifier '{' EnumDefList '}' TypeAnnotations
     {

http://git-wip-us.apache.org/repos/asf/thrift/blob/089bcd3f/lib/cpp/test/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/cpp/test/Makefile.am b/lib/cpp/test/Makefile.am
index b3f66bd..9c9b8d8 100755
--- a/lib/cpp/test/Makefile.am
+++ b/lib/cpp/test/Makefile.am
@@ -20,16 +20,17 @@
 noinst_LTLIBRARIES = libtestgencpp.la libprocessortest.la
 nodist_libtestgencpp_la_SOURCES = \
 	gen-cpp/DebugProtoTest_types.cpp \
+	gen-cpp/DebugProtoTest_types.h \
 	gen-cpp/EnumTest_types.cpp \
 	gen-cpp/EnumTest_types.h \
 	gen-cpp/OptionalRequiredTest_types.cpp \
-	gen-cpp/DebugProtoTest_types.cpp \
-	gen-cpp/ThriftTest_types.cpp \
-	gen-cpp/DebugProtoTest_types.h \
 	gen-cpp/OptionalRequiredTest_types.h \
 	gen-cpp/Recursive_types.cpp \
 	gen-cpp/Recursive_types.h \
+	gen-cpp/ThriftTest_types.cpp \
 	gen-cpp/ThriftTest_types.h \
+	gen-cpp/TypedefTest_types.cpp \
+	gen-cpp/TypedefTest_types.h \
 	ThriftTest_extras.cpp \
 	DebugProtoTest_extras.cpp
 
@@ -86,7 +87,8 @@ UnitTests_SOURCES = \
 	TMemoryBufferTest.cpp \
 	TBufferBaseTest.cpp \
 	Base64Test.cpp \
-	ToStringTest.cpp
+	ToStringTest.cpp \
+	TypedefTest.cpp
 
 if !WITH_BOOSTTHREADS
 UnitTests_SOURCES += \
@@ -120,7 +122,7 @@ EnumTest_SOURCES = \
 
 EnumTest_LDADD = \
   libtestgencpp.la \
-  -l:libboost_unit_test_framework.a 
+  -l:libboost_unit_test_framework.a
 
 TFileTransportTest_SOURCES = \
 	TFileTransportTest.cpp
@@ -246,6 +248,9 @@ gen-cpp/DebugProtoTest_types.cpp gen-cpp/DebugProtoTest_types.h: $(top_srcdir)/t
 gen-cpp/EnumTest_types.cpp gen-cpp/EnumTest_types.h: $(top_srcdir)/test/EnumTest.thrift
 	$(THRIFT) --gen cpp:pure_enums $<
 
+gen-cpp/TypedefTest_types.cpp gen-cpp/TypedefTest_types.h: $(top_srcdir)/test/TypedefTest.thrift
+	$(THRIFT) --gen cpp $<
+
 gen-cpp/OptionalRequiredTest_types.cpp gen-cpp/OptionalRequiredTest_types.h: $(top_srcdir)/test/OptionalRequiredTest.thrift
 	$(THRIFT) --gen cpp:dense $<
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/089bcd3f/lib/cpp/test/TypedefTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/TypedefTest.cpp b/lib/cpp/test/TypedefTest.cpp
new file mode 100644
index 0000000..45eb1e7
--- /dev/null
+++ b/lib/cpp/test/TypedefTest.cpp
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <boost/type_traits/is_same.hpp>
+#include <boost/static_assert.hpp>
+
+#include "gen-cpp/TypedefTest_types.h"
+
+BOOST_STATIC_ASSERT(boost::is_same<int32_t, thrift::test::MyInt32>::value);
+BOOST_STATIC_ASSERT(boost::is_same<std::string, thrift::test::MyString>::value);
+BOOST_STATIC_ASSERT(boost::is_same<thrift::test::TypedefTestStruct, thrift::test::MyStruct>::value);

http://git-wip-us.apache.org/repos/asf/thrift/blob/089bcd3f/test/TypedefTest.thrift
----------------------------------------------------------------------
diff --git a/test/TypedefTest.thrift b/test/TypedefTest.thrift
new file mode 100644
index 0000000..9437478
--- /dev/null
+++ b/test/TypedefTest.thrift
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * Contains some contributions under the Thrift Software License.
+ * Please see doc/old-thrift-license.txt in the Thrift distribution for
+ * details.
+ */
+
+namespace cpp thrift.test
+
+typedef i32 MyInt32
+typedef string MyString;
+
+struct TypedefTestStruct {
+  1: MyInt32 field_MyInt32;
+  2: MyString field_MyString;
+  3: i32 field_Int32;
+  4: string field_String;
+}
+
+typedef TypedefTestStruct MyStruct,
\ No newline at end of file