You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2011/02/27 20:24:46 UTC
svn commit: r1075121 - in /thrift/trunk:
compiler/cpp/src/generate/t_cpp_generator.cc
lib/cpp/src/transport/TBufferTransports.h
Author: roger
Date: Sun Feb 27 19:24:45 2011
New Revision: 1075121
URL: http://svn.apache.org/viewvc?rev=1075121&view=rev
Log:
THRIFT-1070 C++ compiler and runtime have 32/64bit problems
Patch: Rich Salz
Modified:
thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc
thrift/trunk/lib/cpp/src/transport/TBufferTransports.h
Modified: thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc
URL: http://svn.apache.org/viewvc/thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc?rev=1075121&r1=1075120&r2=1075121&view=diff
==============================================================================
--- thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc (original)
+++ thrift/trunk/compiler/cpp/src/generate/t_cpp_generator.cc Sun Feb 27 19:24:45 2011
@@ -1917,8 +1917,8 @@ void t_cpp_generator::generate_service_m
indent() << function_signature(*f_iter, "") << " {" << endl;
indent_up();
f_header_ <<
- indent() << "uint32_t sz = ifaces_.size();" << endl <<
- indent() << "for (uint32_t i = 0; i < sz; ++i) {" << endl;
+ indent() << "size_t sz = ifaces_.size();" << endl <<
+ indent() << "for (size_t i = 0; i < sz; ++i) {" << endl;
if (!(*f_iter)->get_returntype()->is_void()) {
f_header_ <<
indent() << " if (i == sz - 1) {" << endl;
@@ -3622,17 +3622,17 @@ void t_cpp_generator::generate_serialize
"xfer += oprot->writeMapBegin(" <<
type_to_enum(((t_map*)ttype)->get_key_type()) << ", " <<
type_to_enum(((t_map*)ttype)->get_val_type()) << ", " <<
- prefix << ".size());" << endl;
+ "static_cast<uint32_t>(" << prefix << ".size()));" << endl;
} else if (ttype->is_set()) {
indent(out) <<
"xfer += oprot->writeSetBegin(" <<
type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " <<
- prefix << ".size());" << endl;
+ "static_cast<uint32_t>(" << prefix << ".size()));" << endl;
} else if (ttype->is_list()) {
indent(out) <<
"xfer += oprot->writeListBegin(" <<
type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " <<
- prefix << ".size());" << endl;
+ "static_cast<uint32_t>(" << prefix << ".size()));" << endl;
}
string iter = tmp("_iter");
Modified: thrift/trunk/lib/cpp/src/transport/TBufferTransports.h
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/cpp/src/transport/TBufferTransports.h?rev=1075121&r1=1075120&r2=1075121&view=diff
==============================================================================
--- thrift/trunk/lib/cpp/src/transport/TBufferTransports.h (original)
+++ thrift/trunk/lib/cpp/src/transport/TBufferTransports.h Sun Feb 27 19:24:45 2011
@@ -108,7 +108,7 @@ class TBufferBase : public TVirtualTrans
if (TDB_LIKELY(static_cast<ptrdiff_t>(*len) <= rBound_ - rBase_)) {
// With strict aliasing, writing to len shouldn't force us to
// refetch rBase_ from memory. TODO(dreiss): Verify this.
- *len = rBound_ - rBase_;
+ *len = static_cast<uint32_t>(rBound_ - rBase_);
return rBase_;
}
return borrowSlow(buf, len);
@@ -568,7 +568,7 @@ class TMemoryBuffer : public TVirtualTra
// TODO(dreiss): Make bufPtr const.
void getBuffer(uint8_t** bufPtr, uint32_t* sz) {
*bufPtr = rBase_;
- *sz = wBase_ - rBase_;
+ *sz = static_cast<uint32_t>(wBase_ - rBase_);
}
std::string getBufferAsString() {
@@ -656,11 +656,11 @@ class TMemoryBuffer : public TVirtualTra
uint32_t available_read() const {
// Remember, wBase_ is the real rBound_.
- return wBase_ - rBase_;
+ return static_cast<uint32_t>(wBase_ - rBase_);
}
uint32_t available_write() const {
- return wBound_ - wBase_;
+ return static_cast<uint32_t>(wBound_ - wBase_);
}
// Returns a pointer to where the client can write data to append to