summaryrefslogtreecommitdiff
path: root/ruby/src
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2019-06-21 22:22:14 +0200
committerJose <jose@zeroc.com>2019-06-21 22:22:14 +0200
commitd1b7c66fab777fe72e5cf77fd284218e2080b017 (patch)
treeb48615b2d9d2f59195c8a560e07585b9cbb77cb5 /ruby/src
parentAdd ice_isFixed - Close #356 (diff)
downloadice-d1b7c66fab777fe72e5cf77fd284218e2080b017.tar.bz2
ice-d1b7c66fab777fe72e5cf77fd284218e2080b017.tar.xz
ice-d1b7c66fab777fe72e5cf77fd284218e2080b017.zip
Enable -Wconversion with clang - Close #363
Diffstat (limited to 'ruby/src')
-rw-r--r--ruby/src/IceRuby/Operation.cpp10
-rw-r--r--ruby/src/IceRuby/Properties.cpp2
-rw-r--r--ruby/src/IceRuby/Proxy.cpp4
-rw-r--r--ruby/src/IceRuby/Types.cpp63
-rw-r--r--ruby/src/IceRuby/Util.cpp2
-rw-r--r--ruby/src/IceRuby/Util.h18
6 files changed, 49 insertions, 50 deletions
diff --git a/ruby/src/IceRuby/Operation.cpp b/ruby/src/IceRuby/Operation.cpp
index 24c4a3be763..e69b5059ae1 100644
--- a/ruby/src/IceRuby/Operation.cpp
+++ b/ruby/src/IceRuby/Operation.cpp
@@ -64,8 +64,8 @@ private:
bool _returnsClasses;
string _deprecateMessage;
- void convertParams(VALUE, ParamInfoList&, int, bool&);
- ParamInfoPtr convertParam(VALUE, int);
+ void convertParams(VALUE, ParamInfoList&, long, bool&);
+ ParamInfoPtr convertParam(VALUE, long);
void prepareRequest(const Ice::ObjectPrx&, VALUE, Ice::OutputStream*, pair<const Ice::Byte*, const Ice::Byte*>&);
VALUE unmarshalResults(const vector<Ice::Byte>&, const Ice::CommunicatorPtr&);
VALUE unmarshalException(const vector<Ice::Byte>&, const Ice::CommunicatorPtr&);
@@ -367,7 +367,7 @@ IceRuby::OperationI::deprecate(const string& msg)
}
void
-IceRuby::OperationI::convertParams(VALUE v, ParamInfoList& params, int posOffset, bool& usesClasses)
+IceRuby::OperationI::convertParams(VALUE v, ParamInfoList& params, long posOffset, bool& usesClasses)
{
assert(TYPE(v) == T_ARRAY);
@@ -383,14 +383,14 @@ IceRuby::OperationI::convertParams(VALUE v, ParamInfoList& params, int posOffset
}
ParamInfoPtr
-IceRuby::OperationI::convertParam(VALUE v, int pos)
+IceRuby::OperationI::convertParam(VALUE v, long pos)
{
assert(TYPE(v) == T_ARRAY);
ParamInfoPtr param = new ParamInfo;
param->type = getType(RARRAY_AREF(v, 0));
param->optional = static_cast<bool>(RTEST(RARRAY_AREF(v, 1)));
param->tag = static_cast<int>(getInteger(RARRAY_AREF(v, 2)));
- param->pos = pos;
+ param->pos = static_cast<int>(pos);
return param;
}
diff --git a/ruby/src/IceRuby/Properties.cpp b/ruby/src/IceRuby/Properties.cpp
index 567c315b405..edd5f7fe059 100644
--- a/ruby/src/IceRuby/Properties.cpp
+++ b/ruby/src/IceRuby/Properties.cpp
@@ -136,7 +136,7 @@ IceRuby_Properties_getPropertyAsIntWithDefault(VALUE self, VALUE key, VALUE def)
{
Ice::PropertiesPtr p = getProperties(self);
string k = getString(key);
- Ice::Int d = getInteger(def);
+ Ice::Int d = static_cast<Ice::Int>(getInteger(def));
Ice::Int v = p->getPropertyAsIntWithDefault(k, d);
return INT2FIX(v);
}
diff --git a/ruby/src/IceRuby/Proxy.cpp b/ruby/src/IceRuby/Proxy.cpp
index c06588261fe..f51e5e03f46 100644
--- a/ruby/src/IceRuby/Proxy.cpp
+++ b/ruby/src/IceRuby/Proxy.cpp
@@ -153,7 +153,7 @@ IceRuby_ObjectPrx_ice_ids(int argc, VALUE* argv, VALUE self)
checkArgs("ice_ids", 0, argc, argv, ctx);
vector<string> ids = p->ice_ids(ctx);
- volatile VALUE result = createArray(ids.size());
+ volatile VALUE result = createArray(static_cast<long>(ids.size()));
long i = 0;
for(vector<string>::iterator q = ids.begin(); q != ids.end(); ++q, ++i)
{
@@ -307,7 +307,7 @@ IceRuby_ObjectPrx_ice_getEndpoints(VALUE self)
Ice::ObjectPrx p = getProxy(self);
Ice::EndpointSeq seq = p->ice_getEndpoints();
- volatile VALUE result = createArray(seq.size());
+ volatile VALUE result = createArray(static_cast<long>(seq.size()));
long i = 0;
for(Ice::EndpointSeq::iterator q = seq.begin(); q != seq.end(); ++q, ++i)
{
diff --git a/ruby/src/IceRuby/Types.cpp b/ruby/src/IceRuby/Types.cpp
index 5563b6fb57e..29f79f15ae5 100644
--- a/ruby/src/IceRuby/Types.cpp
+++ b/ruby/src/IceRuby/Types.cpp
@@ -75,9 +75,9 @@ escapeString(const string& str)
{
if(charSet.find(*c) == charSet.end())
{
- unsigned char uc = *c; // char may be signed, so make it positive
+ unsigned char uc = static_cast<unsigned char>(*c); // char may be signed, so make it positive
ostringstream s;
- s << "\\"; // Print as octal if not in basic source character set
+ s << "\\"; // Print as octal if not in basic source character set
s.width(3);
s.fill('0');
s << oct;
@@ -240,8 +240,7 @@ IceRuby::StreamUtil::setSlicedDataMember(VALUE obj, const Ice::SlicedDataPtr& sl
volatile VALUE sd = callRuby(rb_class_new_instance, 0, static_cast<VALUE*>(0), _slicedDataType);
- Ice::Int sz = slicedData->slices.size();
- volatile VALUE slices = createArray(sz);
+ volatile VALUE slices = createArray(static_cast<long>(slicedData->slices.size()));
callRuby(rb_iv_set, sd, "@slices", slices);
@@ -271,13 +270,14 @@ IceRuby::StreamUtil::setSlicedDataMember(VALUE obj, const Ice::SlicedDataPtr& sl
//
// bytes
//
- volatile VALUE bytes = callRuby(rb_str_new, reinterpret_cast<const char*>(&(*p)->bytes[0]), (*p)->bytes.size());
+ volatile VALUE bytes = callRuby(rb_str_new, reinterpret_cast<const char*>(&(*p)->bytes[0]),
+ static_cast<long>((*p)->bytes.size()));
callRuby(rb_iv_set, slice, "@bytes", bytes);
//
// instances
//
- volatile VALUE instances = createArray((*p)->instances.size());
+ volatile VALUE instances = createArray(static_cast<long>((*p)->instances.size()));
callRuby(rb_iv_set, slice, "@instances", instances);
int j = 0;
@@ -1012,7 +1012,7 @@ IceRuby::StructInfo::marshal(VALUE p, Ice::OutputStream* os, ObjectMap* objectMa
p = _nullMarshalValue;
}
- Ice::OutputStream::size_type sizePos = -1;
+ Ice::OutputStream::size_type sizePos;
if(optional)
{
if(_variableLength)
@@ -1187,7 +1187,7 @@ IceRuby::SequenceInfo::marshal(VALUE p, Ice::OutputStream* os, ObjectMap* object
volatile VALUE arr = Qnil;
- Ice::OutputStream::size_type sizePos = -1;
+ Ice::OutputStream::size_type sizePos;
if(optional)
{
if(elementType->variableLength())
@@ -1395,10 +1395,10 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU
case PrimitiveInfo::KindBool:
{
long sz = RARRAY_LEN(arr);
- Ice::BoolSeq seq(sz);
+ Ice::BoolSeq seq(static_cast<size_t>(sz));
for(long i = 0; i < sz; ++i)
{
- seq[i] = RTEST(RARRAY_AREF(arr, i));
+ seq[static_cast<size_t>(i)] = RTEST(RARRAY_AREF(arr, i));
}
os->write(seq);
break;
@@ -1421,7 +1421,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU
else
{
long sz = RARRAY_LEN(arr);
- Ice::ByteSeq seq(sz);
+ Ice::ByteSeq seq(static_cast<size_t>(sz));
for(long i = 0; i < sz; ++i)
{
long val = getInteger(RARRAY_AREF(arr, i));
@@ -1429,7 +1429,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU
{
throw RubyException(rb_eTypeError, "invalid value for element %ld of sequence<byte>", i);
}
- seq[i] = static_cast<Ice::Byte>(val);
+ seq[static_cast<size_t>(i)] = static_cast<Ice::Byte>(val);
}
os->write(&seq[0], &seq[0] + seq.size());
}
@@ -1438,7 +1438,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU
case PrimitiveInfo::KindShort:
{
long sz = RARRAY_LEN(arr);
- Ice::ShortSeq seq(sz);
+ Ice::ShortSeq seq(static_cast<size_t>(sz));
for(long i = 0; i < sz; ++i)
{
long val = getInteger(RARRAY_AREF(arr, i));
@@ -1446,7 +1446,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU
{
throw RubyException(rb_eTypeError, "invalid value for element %ld of sequence<short>", i);
}
- seq[i] = static_cast<Ice::Short>(val);
+ seq[static_cast<size_t>(i)] = static_cast<Ice::Short>(val);
}
os->write(&seq[0], &seq[0] + seq.size());
break;
@@ -1454,7 +1454,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU
case PrimitiveInfo::KindInt:
{
long sz = RARRAY_LEN(arr);
- Ice::IntSeq seq(sz);
+ Ice::IntSeq seq(static_cast<size_t>(sz));
for(long i = 0; i < sz; ++i)
{
long val = getInteger(RARRAY_AREF(arr, i));
@@ -1462,7 +1462,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU
{
throw RubyException(rb_eTypeError, "invalid value for element %ld of sequence<int>", i);
}
- seq[i] = static_cast<Ice::Int>(val);
+ seq[static_cast<size_t>(i)] = static_cast<Ice::Int>(val);
}
os->write(&seq[0], &seq[0] + seq.size());
break;
@@ -1470,10 +1470,10 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU
case PrimitiveInfo::KindLong:
{
long sz = RARRAY_LEN(arr);
- Ice::LongSeq seq(sz);
+ Ice::LongSeq seq(static_cast<size_t>(sz));
for(long i = 0; i < sz; ++i)
{
- seq[i] = getLong(RARRAY_AREF(arr, i));
+ seq[static_cast<size_t>(i)] = getLong(RARRAY_AREF(arr, i));
}
os->write(&seq[0], &seq[0] + seq.size());
break;
@@ -1481,7 +1481,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU
case PrimitiveInfo::KindFloat:
{
long sz = RARRAY_LEN(arr);
- Ice::FloatSeq seq(sz);
+ Ice::FloatSeq seq(static_cast<size_t>(sz));
for(long i = 0; i < sz; ++i)
{
volatile VALUE v = callRuby(rb_Float, RARRAY_AREF(arr, i));
@@ -1490,7 +1490,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU
throw RubyException(rb_eTypeError, "unable to convert array element %ld to a float", i);
}
assert(TYPE(v) == T_FLOAT);
- seq[i] = static_cast<Ice::Float>(RFLOAT_VALUE(v));
+ seq[static_cast<size_t>(i)] = static_cast<Ice::Float>(RFLOAT_VALUE(v));
}
os->write(&seq[0], &seq[0] + seq.size());
break;
@@ -1498,7 +1498,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU
case PrimitiveInfo::KindDouble:
{
long sz = RARRAY_LEN(arr);
- Ice::DoubleSeq seq(sz);
+ Ice::DoubleSeq seq(static_cast<size_t>(sz));
for(long i = 0; i < sz; ++i)
{
volatile VALUE v = callRuby(rb_Float, RARRAY_AREF(arr, i));
@@ -1507,7 +1507,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU
throw RubyException(rb_eTypeError, "unable to convert array element %ld to a double", i);
}
assert(TYPE(v) == T_FLOAT);
- seq[i] = RFLOAT_VALUE(v);
+ seq[static_cast<size_t>(i)] = RFLOAT_VALUE(v);
}
os->write(&seq[0], &seq[0] + seq.size());
break;
@@ -1515,10 +1515,10 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU
case PrimitiveInfo::KindString:
{
long sz = RARRAY_LEN(arr);
- Ice::StringSeq seq(sz);
+ Ice::StringSeq seq(static_cast<size_t>(sz));
for(long i = 0; i < sz; ++i)
{
- seq[i] = getString(RARRAY_AREF(arr, i));
+ seq[static_cast<size_t>(i)] = getString(RARRAY_AREF(arr, i));
}
#ifdef HAVE_RUBY_ENCODING_H
os->write(&seq[0], &seq[0] + seq.size(), false); // Bypass string conversion.
@@ -1658,12 +1658,9 @@ IceRuby::SequenceInfo::unmarshalPrimitiveSequence(const PrimitiveInfoPtr& pi, Ic
long sz = static_cast<long>(seq.size());
result = createArray(sz);
- if(sz > 0)
+ for(long i = 0; i < sz; ++i)
{
- for(long i = 0; i < sz; ++i)
- {
- RARRAY_ASET(result, i, createString(seq[i]));
- }
+ RARRAY_ASET(result, i, createString(seq[static_cast<size_t>(i)]));
}
break;
}
@@ -1762,13 +1759,13 @@ IceRuby::DictionaryInfo::marshal(VALUE p, Ice::OutputStream* os, ObjectMap* obje
}
}
- int sz = 0;
+ Ice::Int sz = 0;
if(!NIL_P(hash))
{
- sz = RHASH_SIZE(hash);
+ sz = static_cast<Ice::Int>(RHASH_SIZE(hash));
}
- Ice::OutputStream::size_type sizePos = 0;
+ Ice::OutputStream::size_type sizePos;
if(optional)
{
if(_variableLength)
@@ -2356,7 +2353,7 @@ IceRuby::ProxyInfo::optionalFormat() const
void
IceRuby::ProxyInfo::marshal(VALUE p, Ice::OutputStream* os, ObjectMap*, bool optional)
{
- Ice::OutputStream::size_type sizePos = -1;
+ Ice::OutputStream::size_type sizePos;
if(optional)
{
sizePos = os->startSize();
diff --git a/ruby/src/IceRuby/Util.cpp b/ruby/src/IceRuby/Util.cpp
index 978a6bac56d..2c4a58233b4 100644
--- a/ruby/src/IceRuby/Util.cpp
+++ b/ruby/src/IceRuby/Util.cpp
@@ -762,7 +762,7 @@ setExceptionMembers(const Ice::LocalException& ex, VALUE p)
}
VALUE
-IceRuby::createArrayHelper(long sz)
+IceRuby::createArray(long sz)
{
volatile VALUE arr = callRuby(rb_ary_new2, sz);
if(sz > 0)
diff --git a/ruby/src/IceRuby/Util.h b/ruby/src/IceRuby/Util.h
index 19fa928d392..765278b5555 100644
--- a/ruby/src/IceRuby/Util.h
+++ b/ruby/src/IceRuby/Util.h
@@ -8,6 +8,14 @@
#include <Config.h>
#include <Ice/Ice.h>
+//
+// Avoid clang conversion warnings in "callRuby" calls
+//
+#if defined(__clang__)
+# pragma clang diagnostic ignored "-Wconversion"
+# pragma clang diagnostic ignored "-Wsign-conversion"
+#endif
+
namespace IceRuby
{
@@ -228,7 +236,7 @@ class RF_2
public:
RF_2(Fun f, T1 t1, T2 t2) : _f(f), _t1(t1), _t2(t2) {}
- inline VALUE operator()() { return _f(_t1, _t2); }
+ inline VALUE operator()(){ return _f(_t1, _t2); }
static inline VALUE call(VALUE f)
{
return (*reinterpret_cast<RF_2*>(f))();
@@ -468,8 +476,6 @@ inline void callRubyVoid(Fun fun, T1 t1, T2 t2, T3 t3, T4 t4)
callProtected(RubyFunction(RF::call), reinterpret_cast<VALUE>(&f));
}
-VALUE createArrayHelper(long);
-
//
// Create an array with the given size. May raise RubyException.
//
@@ -485,11 +491,7 @@ VALUE createArrayHelper(long);
// RARRAY_ASET(arr, i, val);
// }
//
-template<typename T>
-inline VALUE createArray(T sz)
-{
- return createArrayHelper(static_cast<long>(sz));
-}
+VALUE createArray(long);
//
// Create the Ruby equivalent of an Ice local exception.