diff options
author | Aaron Patterson <[email protected]> | 2021-06-30 17:35:04 -0700 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2021-07-13 19:37:46 +0900 |
commit | 5c0d8c6369f92915bf99924f58f0763abe4f493e (patch) | |
tree | 1b26c487b766527a3e5d3c4fcba89ab961952b94 /ext/fiddle/memory_view.c | |
parent | a2c9e1b58a9bc1da0533171236da43fcb556ead7 (diff) |
[ruby/fiddle] Add "offsetof" to Struct classes (https://github.com/ruby/fiddle/pull/83)
* Add "offsetof" to Struct classes
I need to get the offset of a member inside a struct without allocating
the struct. This patch adds an "offsetof" class method to structs that
are generated.
The usage is like this:
```ruby
MyStruct = struct [
"int64_t i",
"char c",
]
MyStruct.offsetof("i") # => 0
MyStruct.offsetof("c") # => 8
```
* Update test/fiddle/test_c_struct_builder.rb
Co-authored-by: Sutou Kouhei <[email protected]>
https://github.com/ruby/fiddle/commit/4e3b60c5b6
Co-authored-by: Sutou Kouhei <[email protected]>
Diffstat (limited to 'ext/fiddle/memory_view.c')
0 files changed, 0 insertions, 0 deletions