-
Notifications
You must be signed in to change notification settings - Fork 593
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 RSTRING_PTR usage in Ruby #2375
Conversation
@@ -79,39 +79,4 @@ extern "C" | |||
|
|||
#define CAST_METHOD(X) reinterpret_cast<ICE_RUBY_ENTRY_POINT>(X) | |||
|
|||
// |
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.
We can drop support for these ancient Ruby versions and remove the compatibility macros.
ruby/src/IceRuby/Util.cpp
Outdated
@@ -208,7 +208,7 @@ IceRuby::RubyException::operator<<(ostream& ostr) const | |||
{ | |||
volatile VALUE cls = rb_class_path(CLASS_OF(ex)); | |||
volatile VALUE msg = rb_obj_as_string(ex); | |||
ostr << RSTRING_PTR(cls) << ": " << RSTRING_PTR(msg); | |||
ostr << string(RSTRING_PTR(cls), RSTRING_LEN(cls)) << ": " << string(RSTRING_PTR(msg), RSTRING_LEN(msg)); |
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.
It would be cleaner to use string_view here and {}
for the ctor:
ostr << string_view{s, count} << ....
ruby/src/IceRuby/Operation.cpp
Outdated
@@ -574,7 +574,7 @@ IceRuby::OperationI::unmarshalException(const vector<byte>& bytes, const Ice::Co | |||
volatile VALUE cls = CLASS_OF(ex); | |||
volatile VALUE path = callRuby(rb_class_path, cls); | |||
assert(TYPE(path) == T_STRING); | |||
throw Ice::UnknownUserException{__FILE__, __LINE__, RSTRING_PTR(path)}; | |||
throw Ice::UnknownUserException{__FILE__, __LINE__, string(RSTRING_PTR(path), RSTRING_LEN(path))}; |
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.
string is fine here. I would use {}
.
Fix #2342