Skip to content

Update documentation #119

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

Merged
merged 1 commit into from
Dec 27, 2022
Merged

Update documentation #119

merged 1 commit into from
Dec 27, 2022

Conversation

tenderlove
Copy link
Member

The documentation for Fiddle.dlwrap and Fiddle.dlunwrap were not very accurate and pretty confusing. This commit updates the documentation so it's easier to understand what the methods do.

The documentation for `Fiddle.dlwrap` and `Fiddle.dlunwrap` were not
very accurate and pretty confusing.  This commit updates the
documentation so it's easier to understand what the methods do.
@tenderlove tenderlove merged commit 7bd615d into master Dec 27, 2022
@tenderlove tenderlove deleted the docs branch December 27, 2022 19:19
Comment on lines +65 to +70
* >> x = Object.new
* => #<Object:0x0000000107c7d870>
* >> Fiddle.dlwrap(x)
* => 4425504880
* >> Fiddle.dlunwrap(_)
* => #<Object:0x0000000107c7d870>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we prefer examples syntax that is correct Ruby to be copy-pasted in some file and tried (also RDoc's syntax highlight wouldn't work otherwise, so I'd suggest...

Suggested change
* >> x = Object.new
* => #<Object:0x0000000107c7d870>
* >> Fiddle.dlwrap(x)
* => 4425504880
* >> Fiddle.dlunwrap(_)
* => #<Object:0x0000000107c7d870>
* x = Object.new
* # => #<Object:0x0000000107c7d870>
* addr = Fiddle.dlwrap(x)
* # => 4425504880
* Fiddle.dlunwrap(addr)
* # => #<Object:0x0000000107c7d870>

Comment on lines +65 to +70
* >> x = Object.new
* => #<Object:0x0000000107c7d870>
* >> Fiddle.dlwrap(x)
* => 4425504880
* >> Fiddle.dlunwrap(_)
* => #<Object:0x0000000107c7d870>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we prefer examples syntax that is correct Ruby to be copy-pasted in some file and tried (also RDoc's syntax highlight wouldn't work otherwise), so I'd suggest...

Suggested change
* >> x = Object.new
* => #<Object:0x0000000107c7d870>
* >> Fiddle.dlwrap(x)
* => 4425504880
* >> Fiddle.dlunwrap(_)
* => #<Object:0x0000000107c7d870>
* x = Object.new
* # => #<Object:0x0000000107c7d870>
* addr = Fiddle.dlwrap(x)
* # => 4425504880
* Fiddle.dlunwrap(addr)
* # => #<Object:0x0000000107c7d870>

Comment on lines +85 to +88
* >> x = Object.new
* => #<Object:0x0000000107c7d870>
* >> Fiddle.dlwrap(x)
* => 4425504880
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* >> x = Object.new
* => #<Object:0x0000000107c7d870>
* >> Fiddle.dlwrap(x)
* => 4425504880
* x = Object.new
* # => #<Object:0x0000000107c7d870>
* Fiddle.dlwrap(x)
* # => 4425504880

Comment on lines +95 to +96
* >> Fiddle.dlwrap(123)
* => 247
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* >> Fiddle.dlwrap(123)
* => 247
* Fiddle.dlwrap(123)
* # => 247

* => 4425504880
*
* In the case +val+ is not a heap allocated object, this method will return
* the tagged pointer value.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't say that "tagged pointer value" says anything to me in the context (and the example doesn't make it much clearer), but that's might be because of my ignorance :)

@tenderlove
Copy link
Member Author

@zverok oops, thanks. I'll update the comments with your suggestions.

I think explaining tagged pointers is probably outside the scope of Fiddle documentation. I expect developers that are messing around with pointers to Ruby objects need to know a bit about Ruby internals, but I wanted to at least call out that not all Ruby objects passed to dlwrap will return a memory address.

matzbot pushed a commit to ruby/ruby that referenced this pull request Jan 27, 2023
(ruby/fiddle#119)

The documentation for `Fiddle.dlwrap` and `Fiddle.dlunwrap` were not
very accurate and pretty confusing. This commit updates the
documentation so it's easier to understand what the methods do.
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.

2 participants