ruby/test/fiddle
Aaron Patterson 307388ea19 [ruby/fiddle] Add a "pinning" reference (#44)
* Add a "pinning" reference

A `Fiddle::Pinned` objects will prevent the objects they point to from
moving.  This is useful in the case where you need to pass a reference
to a C extension that keeps the address in a global and needs the
address to be stable.

For example:

```ruby
class Foo
  A = "hi" # this is an embedded string

  some_c_function A # A might move!
end
```

If `A` moves, then the underlying string buffer may also move.
`Fiddle::Pinned` will prevent the object from moving:

```ruby
class Foo
  A = "hi" # this is an embedded string

  A_pinner = Fiddle::Pinned.new(A) # :nodoc:

  some_c_function A # A can't move because of `Fiddle::Pinned`
end
```

This is a similar strategy to what Graal uses:

  https://www.graalvm.org/sdk/javadoc/org/graalvm/nativeimage/PinnedObject.html#getObject--

* rename global to match exception name

* Introduce generic Fiddle::Error and rearrange error classes

Fiddle::Error is the generic exception base class for Fiddle exceptions.
This commit introduces the class and rearranges Fiddle exceptions to
inherit from it.

https://github.com/ruby/fiddle/commit/ac52d00223
2020-11-18 09:05:13 +09:00
..
helper.rb Workaroud for macOS Big Sur(11.0) 2020-09-08 20:39:23 +09:00
test_c_struct_entry.rb [ruby/fiddle] Improve documentation on how to correctly free memory and free memory in tests (#33) 2020-05-23 14:34:07 +09:00
test_c_union_entity.rb [ruby/fiddle] Improve documentation on how to correctly free memory and free memory in tests (#33) 2020-05-23 14:34:07 +09:00
test_closure.rb
test_cparser.rb
test_fiddle.rb
test_func.rb [ruby/fiddle] Add support for specifying types by name as String or Symbol 2020-11-18 09:05:13 +09:00
test_function.rb Apply timeout-scale to test_nogvl_poll. 2020-07-30 18:28:41 +09:00
test_handle.rb More fixes for $SAFE/taint post merging 2019-11-18 01:00:25 +02:00
test_import.rb [ruby/fiddle] Add TYPE_CONST_STRING and SIZEOF_CONST_STRING for "const char *" 2020-11-18 09:05:13 +09:00
test_pinned.rb [ruby/fiddle] Add a "pinning" reference (#44) 2020-11-18 09:05:13 +09:00
test_pointer.rb [ruby/fiddle] Improve documentation on how to correctly free memory and free memory in tests (#33) 2020-05-23 14:34:07 +09:00