Skip to content
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

Merged
merged 3 commits into from
Jun 28, 2024
Merged

Fix RSTRING_PTR usage in Ruby #2375

merged 3 commits into from
Jun 28, 2024

Conversation

pepone
Copy link
Member

@pepone pepone commented Jun 28, 2024

Fix #2342

@pepone pepone requested a review from bernardnormier June 28, 2024 13:17
@@ -79,39 +79,4 @@ extern "C"

#define CAST_METHOD(X) reinterpret_cast<ICE_RUBY_ENTRY_POINT>(X)

//
Copy link
Member Author

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.

@@ -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));
Copy link
Member

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} << ....

@@ -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))};
Copy link
Member

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 {}.

@pepone pepone merged commit 69a5907 into zeroc-ice:main Jun 28, 2024
16 checks passed
InsertCreativityHere pushed a commit to InsertCreativityHere/compiler-comparison that referenced this pull request Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect RSTRING_PTR usage in Ruby mapping
2 participants