-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix errors resulting from -Wconversion -Wno-sign-conversion
#349
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,22 +92,21 @@ template <typename T> | |
enable_if_integral<T, T> as_cpp(SEXP from) { | ||
if (Rf_isInteger(from)) { | ||
if (Rf_xlength(from) == 1) { | ||
return INTEGER_ELT(from, 0); | ||
return static_cast<T>(INTEGER_ELT(from, 0)); | ||
} | ||
} else if (Rf_isReal(from)) { | ||
if (Rf_xlength(from) == 1) { | ||
if (ISNA(REAL_ELT(from, 0))) { | ||
return NA_INTEGER; | ||
} | ||
double value = REAL_ELT(from, 0); | ||
if (is_convertible_without_loss_to_integer(value)) { | ||
return value; | ||
if (ISNA(value) && sizeof(T) >= sizeof(int)) { | ||
return static_cast<T>(NA_INTEGER); | ||
} else if (!ISNA(value) && is_convertible_without_loss_to_integer(value)) { | ||
return static_cast<T>(value); | ||
} | ||
} | ||
} else if (Rf_isLogical(from)) { | ||
if (Rf_xlength(from) == 1) { | ||
if (LOGICAL_ELT(from, 0) == NA_LOGICAL) { | ||
return NA_INTEGER; | ||
if (LOGICAL_ELT(from, 0) == NA_LOGICAL && sizeof(T) >= sizeof(int)) { | ||
return static_cast<T>(NA_INTEGER); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment what happens in the "else" case? Do we never return |
||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ class data_frame : public list { | |
return R_NilValue; | ||
} | ||
|
||
static int calc_nrow(SEXP x) { | ||
static R_xlen_t calc_nrow(SEXP x) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done on |
||
auto nms = get_attrib0(x, R_RowNamesSymbol); | ||
bool has_short_rownames = | ||
(Rf_isInteger(nms) && Rf_xlength(nms) == 2 && INTEGER(nms)[0] == NA_INTEGER); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,8 @@ class r_string { | |
r_string(SEXP data) : data_(data) {} | ||
r_string(const char* data) : data_(safe[Rf_mkCharCE](data, CE_UTF8)) {} | ||
r_string(const std::string& data) | ||
: data_(safe[Rf_mkCharLenCE](data.c_str(), data.size(), CE_UTF8)) {} | ||
: data_( | ||
safe[Rf_mkCharLenCE](data.c_str(), static_cast<int>(data.size()), CE_UTF8)) {} | ||
Comment on lines
-20
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably not important |
||
|
||
operator SEXP() const { return data_; } | ||
operator sexp() const { return data_; } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ class sexp { | |
|
||
operator SEXP() const { return data_; } | ||
operator double() const { return REAL_ELT(data_, 0); } | ||
operator size_t() const { return REAL_ELT(data_, 0); } | ||
operator size_t() const { return static_cast<size_t>(REAL_ELT(data_, 0)); } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trying to remove these in #390 |
||
operator bool() const { return LOGICAL_ELT(data_, 0); } | ||
SEXP data() const { return data_; } | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gave me pause. Perhaps: