You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by sb...@apache.org on 2010/04/05 19:03:43 UTC
svn commit: r930908 - in /hadoop/avro/trunk: ./ lang/c++/ lang/c++/api/
lang/c++/impl/ lang/c++/parser/ lang/c++/scripts/
Author: sbanacho
Date: Mon Apr 5 17:03:42 2010
New Revision: 930908
URL: http://svn.apache.org/viewvc?rev=930908&view=rev
Log:
AVRO-497. Minor changes to C++ autotools, makefiles, and code generator.
Modified:
hadoop/avro/trunk/CHANGES.txt
hadoop/avro/trunk/lang/c++/Makefile.am
hadoop/avro/trunk/lang/c++/api/ValidSchema.hh
hadoop/avro/trunk/lang/c++/api/Validator.hh
hadoop/avro/trunk/lang/c++/configure.in
hadoop/avro/trunk/lang/c++/impl/ValidSchema.cc
hadoop/avro/trunk/lang/c++/impl/Validator.cc
hadoop/avro/trunk/lang/c++/parser/AvroLex.ll
hadoop/avro/trunk/lang/c++/scripts/gen-cppcode.py
Modified: hadoop/avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=930908&r1=930907&r2=930908&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Mon Apr 5 17:03:42 2010
@@ -16,6 +16,8 @@ Avro 1.4.0 (unreleased)
AVRO-501. missing function in C api to access array elements after
decoding an array. (Bruce Mitchener via massie)
+ AVRO-497. Minor changes to C++ autotools, makefiles, and code generator. (sbanacho)
+
BUG FIXES
AVRO-461. Skipping primitives in the ruby side (jmhodges)
Modified: hadoop/avro/trunk/lang/c++/Makefile.am
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c%2B%2B/Makefile.am?rev=930908&r1=930907&r2=930908&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c++/Makefile.am (original)
+++ hadoop/avro/trunk/lang/c++/Makefile.am Mon Apr 5 17:03:42 2010
@@ -1,5 +1,5 @@
-AM_CXXFLAGS= -I$(top_srcdir)/api $(BOOST_CPPFLAGS)
+AM_CXXFLAGS= -I$(top_srcdir)/api $(BOOST_CPPFLAGS) -Wall -Werror -Wno-invalid-offsetof
ACLOCAL_AMFLAGS=-I m4
BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
@@ -117,7 +117,6 @@ unittest_LDFLAGS = -static -no-install $
unittest_LDADD = $(top_builddir)/libavrocpp.la $(BOOST_REGEX_LIB)
testgen_SOURCES = test/testgen.cc testgen.hh testgen2.hh
-testgen_CXXFLAGS = $(AM_CXXFLAGS) -Wno-invalid-offsetof
testgen_LDFLAGS = -static -no-install $(BOOST_LDFLAGS)
testgen_LDADD = $(top_builddir)/libavrocpp.la $(BOOST_REGEX_LIB)
Modified: hadoop/avro/trunk/lang/c++/api/ValidSchema.hh
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c%2B%2B/api/ValidSchema.hh?rev=930908&r1=930907&r2=930908&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c++/api/ValidSchema.hh (original)
+++ hadoop/avro/trunk/lang/c++/api/ValidSchema.hh Mon Apr 5 17:03:42 2010
@@ -19,8 +19,6 @@
#ifndef avro_ValidSchema_hh__
#define avro_ValidSchema_hh__
-#include <boost/noncopyable.hpp>
-
#include "Node.hh"
namespace avro {
@@ -39,11 +37,12 @@ class SymbolMap;
/// parsers/serializers, converted to a json schema, etc.
///
-class ValidSchema : private boost::noncopyable
+class ValidSchema
{
public:
explicit ValidSchema(const Schema &schema);
+ explicit ValidSchema(const ValidSchema &schema);
ValidSchema();
void setSchema(const Schema &schema);
@@ -61,6 +60,12 @@ class ValidSchema : private boost::nonco
bool validate(const NodePtr &node, SymbolMap &symbolMap);
NodePtr root_;
+
+ private:
+
+ // not implemented, only copy construct allowed
+ ValidSchema &operator=(const Schema &rhs);
+
};
} // namespace avro
Modified: hadoop/avro/trunk/lang/c++/api/Validator.hh
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c%2B%2B/api/Validator.hh?rev=930908&r1=930907&r2=930908&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c++/api/Validator.hh (original)
+++ hadoop/avro/trunk/lang/c++/api/Validator.hh Mon Apr 5 17:03:42 2010
@@ -24,11 +24,10 @@
#include <stdint.h>
#include "Types.hh"
-#include "Node.hh"
+#include "ValidSchema.hh"
namespace avro {
-class ValidSchema;
class OutputStreamer;
/// This class is used by both the ValidatingSerializer and ValidationParser
@@ -80,13 +79,7 @@ class Validator : private boost::noncopy
void setupFlag(Type type);
- const ValidSchema &schema_;
-
- // since this only keeps a reference to the schema, to ensure its parse
- // tree is not deleted, keep a copy of a shared pointer to the root of the
- // tree
-
- const NodePtr parseTree_;
+ const ValidSchema schema_;
Type nextType_;
flag_t expectedTypesFlag_;
Modified: hadoop/avro/trunk/lang/c++/configure.in
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c%2B%2B/configure.in?rev=930908&r1=930907&r2=930908&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c++/configure.in (original)
+++ hadoop/avro/trunk/lang/c++/configure.in Mon Apr 5 17:03:42 2010
@@ -1,7 +1,7 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
-AC_PREREQ(2.61)
+AC_PREREQ(2.59)
AC_INIT([avro-cpp], m4_esyscmd([cat ../../share/VERSION.txt]), [avro-devel@apache.org])
AC_CONFIG_AUX_DIR([config])
AM_INIT_AUTOMAKE
@@ -30,15 +30,6 @@ AC_CHECK_HEADERS([inttypes.h libintl.h m
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
-AC_TYPE_INT16_T
-AC_TYPE_INT32_T
-AC_TYPE_INT64_T
-AC_TYPE_INT8_T
-AC_TYPE_SIZE_T
-AC_TYPE_UINT16_T
-AC_TYPE_UINT32_T
-AC_TYPE_UINT64_T
-AC_TYPE_UINT8_T
# Checks for library functions.
AC_FUNC_MALLOC
Modified: hadoop/avro/trunk/lang/c++/impl/ValidSchema.cc
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c%2B%2B/impl/ValidSchema.cc?rev=930908&r1=930907&r2=930908&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c++/impl/ValidSchema.cc (original)
+++ hadoop/avro/trunk/lang/c++/impl/ValidSchema.cc Mon Apr 5 17:03:42 2010
@@ -25,13 +25,17 @@
namespace avro {
- ValidSchema::ValidSchema(const Schema &schema) :
+ValidSchema::ValidSchema(const Schema &schema) :
root_(schema.root())
{
SymbolMap symbolMap;
validate(root_, symbolMap);
}
+ValidSchema::ValidSchema(const ValidSchema &schema) :
+ root_(schema.root())
+{ }
+
ValidSchema::ValidSchema() :
root_(NullSchema().root())
{ }
Modified: hadoop/avro/trunk/lang/c++/impl/Validator.cc
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c%2B%2B/impl/Validator.cc?rev=930908&r1=930907&r2=930908&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c++/impl/Validator.cc (original)
+++ hadoop/avro/trunk/lang/c++/impl/Validator.cc Mon Apr 5 17:03:42 2010
@@ -26,14 +26,13 @@ namespace avro {
Validator::Validator(const ValidSchema &schema) :
schema_(schema),
- parseTree_(schema.root()),
nextType_(AVRO_NULL),
expectedTypesFlag_(0),
compoundStarted_(false),
waitingForCount_(false),
count_(0)
{
- setupOperation(parseTree_);
+ setupOperation(schema_.root());
}
void
Modified: hadoop/avro/trunk/lang/c++/parser/AvroLex.ll
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c%2B%2B/parser/AvroLex.ll?rev=930908&r1=930907&r2=930908&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c++/parser/AvroLex.ll (original)
+++ hadoop/avro/trunk/lang/c++/parser/AvroLex.ll Mon Apr 5 17:03:42 2010
@@ -73,7 +73,7 @@ int yylex(int *val, void *ctx)
ws [ \t\r\n]
nonws [^ \t\r\n]
delim {ws}*:{ws}*
-avrotext [a-zA-Z_][a-zA-Z0-9_]*
+avrotext [a-zA-Z_][a-zA-Z0-9_.]*
startunion \[
startobject \{
integer [0-9]+
Modified: hadoop/avro/trunk/lang/c++/scripts/gen-cppcode.py
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c%2B%2B/scripts/gen-cppcode.py?rev=930908&r1=930907&r2=930908&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c++/scripts/gen-cppcode.py (original)
+++ hadoop/avro/trunk/lang/c++/scripts/gen-cppcode.py Mon Apr 5 17:03:42 2010
@@ -1,22 +1,24 @@
#!/usr/bin/python
-#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.
-
-done = False
+license = '''
+/**
+ * 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.
+ */
+'''
headers = '''
#include <stdint.h>
@@ -30,6 +32,8 @@ headers = '''
#include "Layout.hh"
'''
+done = False
+
typeToC= { 'int' : 'int32_t', 'long' :'int64_t', 'float' : 'float', 'double' : 'double',
'boolean' : 'bool', 'null': 'avro::Null', 'string' : 'std::string', 'bytes' : 'std::vector<uint8_t>'}
@@ -162,7 +166,7 @@ $setfuncs$
static void *genericSet($name$ *u, int64_t choice) {
boost::any *val = &(u->value);
- void *data;
+ void *data = NULL;
switch (choice) {$switch$
}
return data;
@@ -594,9 +598,12 @@ def getNextLine():
globals()["done"] = True
return line.split(' ')
-def writeHeader():
- print "#ifndef %s_AvroGenerated_hh__" % namespace
- print "#define %s_AvroGenerated_hh__" % namespace
+def writeHeader(filebase, namespace):
+ headerstring = "%s_%s_hh__" % (namespace, filebase)
+
+ print license
+ print "#ifndef %s" % headerstring
+ print "#define %s" % headerstring
print headers
print "namespace %s {\n" % namespace
@@ -615,7 +622,7 @@ def writeHeader():
print "\n} // namespace avro\n"
- print "#endif // %s_AvroGenerated_hh__" % namespace
+ print "#endif // %s" % headerstring
def usage():
@@ -642,6 +649,7 @@ if __name__ == "__main__":
saveout = sys.stdout
inputFile = False
outputFile = False
+ outputFileBase = 'AvroGenerated'
for o, a in opts:
if o in ("-i", "--input"):
@@ -657,6 +665,7 @@ if __name__ == "__main__":
sys.stdout = outputFile
except:
print "Could not open file " + a
+ outputFileBase = a.rstrip('.hp') # strip for .h, .hh, .hpp
elif o in ("-n", "--namespace"):
namespace = a
elif o in ("-h", "--help"):
@@ -668,7 +677,7 @@ if __name__ == "__main__":
sys.exit()
generateCode()
- writeHeader()
+ writeHeader(outputFileBase, namespace)
sys.stdin = savein
sys.stdout = saveout