<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/ruby.git/ext/fiddle/fiddle.c, branch ruby_3_2</title>
<subtitle>github.com: ruby/ruby.git
</subtitle>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/'/>
<entry>
<title>Merge fiddle-1.1.1</title>
<updated>2022-12-09T07:36:22+00:00</updated>
<author>
<name>Hiroshi SHIBATA</name>
<email>hsbt@ruby-lang.org</email>
</author>
<published>2022-12-09T04:43:01+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=286812bcf3f3ece9ed784d943902007ec065bdd9'/>
<id>286812bcf3f3ece9ed784d943902007ec065bdd9</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/fiddle] Move "type" constants to `Fiddle::Types` (https://github.com/ruby/fiddle/pull/112)</title>
<updated>2022-10-07T06:18:50+00:00</updated>
<author>
<name>Aaron Patterson</name>
<email>tenderlove@ruby-lang.org</email>
</author>
<published>2022-09-13T15:26:47+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=755d99e8789b84a7d73d5a30f6b5d582e06f7f45'/>
<id>755d99e8789b84a7d73d5a30f6b5d582e06f7f45</id>
<content type='text'>
This helps to reduce repetition in code. Instead of doing "TYPE_*"
everywhere, you can do `include Fiddle::Types`, and write the type name
directly.

This PR is to help reduce repetition when writing Fiddle code. Right now
we have to type `TYPE_` everywhere, and you also have to include all of
`Fiddle` to access `TYPE_*` constants. With this change, you can just
include `Fiddle::Types` and it will shorten your code and also you only
have to include those constants.

Here is an example before:

```ruby
require "fiddle"

module MMAP
  # All Fiddle constants included
  include Fiddle

  def self.make_function name, args, ret
    ptr = Handle::DEFAULT[name]
    func = Function.new ptr, args, ret, name: name
    define_singleton_method name, &amp;func.to_proc
  end

  make_function "munmap", [TYPE_VOIDP, # addr
                           TYPE_SIZE_T], # len
                           TYPE_INT

  make_function "mmap", [TYPE_VOIDP,
                         TYPE_SIZE_T,
                         TYPE_INT,
                         TYPE_INT,
                         TYPE_INT,
                         TYPE_INT], TYPE_VOIDP

  make_function "mprotect", [TYPE_VOIDP, TYPE_SIZE_T, TYPE_INT], TYPE_INT
end
```

After:

```ruby
require "fiddle"

module MMAP
  # Only type names included
  include Fiddle::Types

  def self.make_function name, args, ret
    ptr = Fiddle::Handle::DEFAULT[name]
    func = Fiddle::Function.new ptr, args, ret, name: name
    define_singleton_method name, &amp;func.to_proc
  end

  make_function "munmap", [VOIDP, # addr
                           SIZE_T], # len
                           INT

  make_function "mmap", [VOIDP, SIZE_T, INT, INT, INT, INT], VOIDP

  make_function "mprotect", [VOIDP, SIZE_T, INT], INT
end
```

We only need to import the type names, and you don't have to type
`TYPE_` over and over. I think this makes Fiddle code easier to read.

https://github.com/ruby/fiddle/commit/49fa7233e5

Co-authored-by: Sutou Kouhei &lt;kou@clear-code.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This helps to reduce repetition in code. Instead of doing "TYPE_*"
everywhere, you can do `include Fiddle::Types`, and write the type name
directly.

This PR is to help reduce repetition when writing Fiddle code. Right now
we have to type `TYPE_` everywhere, and you also have to include all of
`Fiddle` to access `TYPE_*` constants. With this change, you can just
include `Fiddle::Types` and it will shorten your code and also you only
have to include those constants.

Here is an example before:

```ruby
require "fiddle"

module MMAP
  # All Fiddle constants included
  include Fiddle

  def self.make_function name, args, ret
    ptr = Handle::DEFAULT[name]
    func = Function.new ptr, args, ret, name: name
    define_singleton_method name, &amp;func.to_proc
  end

  make_function "munmap", [TYPE_VOIDP, # addr
                           TYPE_SIZE_T], # len
                           TYPE_INT

  make_function "mmap", [TYPE_VOIDP,
                         TYPE_SIZE_T,
                         TYPE_INT,
                         TYPE_INT,
                         TYPE_INT,
                         TYPE_INT], TYPE_VOIDP

  make_function "mprotect", [TYPE_VOIDP, TYPE_SIZE_T, TYPE_INT], TYPE_INT
end
```

After:

```ruby
require "fiddle"

module MMAP
  # Only type names included
  include Fiddle::Types

  def self.make_function name, args, ret
    ptr = Fiddle::Handle::DEFAULT[name]
    func = Fiddle::Function.new ptr, args, ret, name: name
    define_singleton_method name, &amp;func.to_proc
  end

  make_function "munmap", [VOIDP, # addr
                           SIZE_T], # len
                           INT

  make_function "mmap", [VOIDP, SIZE_T, INT, INT, INT, INT], VOIDP

  make_function "mprotect", [VOIDP, SIZE_T, INT], INT
end
```

We only need to import the type names, and you don't have to type
`TYPE_` over and over. I think this makes Fiddle code easier to read.

https://github.com/ruby/fiddle/commit/49fa7233e5

Co-authored-by: Sutou Kouhei &lt;kou@clear-code.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/fiddle] Add constants for unsigned values (https://github.com/ruby/fiddle/pull/111)</title>
<updated>2022-10-07T06:18:49+00:00</updated>
<author>
<name>Aaron Patterson</name>
<email>tenderlove@ruby-lang.org</email>
</author>
<published>2022-09-12T16:53:19+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=48a64984063532f4dedf62e8ac4958a3cf3b556d'/>
<id>48a64984063532f4dedf62e8ac4958a3cf3b556d</id>
<content type='text'>
This commit adds constants for unsigned values. Currently we can use `-`
to mean "unsigned", but I think having a specific name makes Fiddle more
user friendly. This commit continues to support `-`, but introduces
negative constants with "unsigned" names

I think this will help to eliminate [this
code](https://github.com/ruby/ruby/blob/3a56bf0bcc66e14ffe5ec89efc32ecfceed180f4/lib/mjit/c_type.rb#L31-L38)

https://github.com/ruby/fiddle/commit/2bef0f1082

Co-authored-by: Sutou Kouhei &lt;kou@clear-code.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit adds constants for unsigned values. Currently we can use `-`
to mean "unsigned", but I think having a specific name makes Fiddle more
user friendly. This commit continues to support `-`, but introduces
negative constants with "unsigned" names

I think this will help to eliminate [this
code](https://github.com/ruby/ruby/blob/3a56bf0bcc66e14ffe5ec89efc32ecfceed180f4/lib/mjit/c_type.rb#L31-L38)

https://github.com/ruby/fiddle/commit/2bef0f1082

Co-authored-by: Sutou Kouhei &lt;kou@clear-code.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/fiddle] Check HAVE_RUBY_MEMORY_VIEW_H rather than API version (https://github.com/ruby/fiddle/pull/86)</title>
<updated>2021-07-14T09:55:59+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2021-07-14T06:38:55+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=169529a0c0973fa925ad3b36f4427d31e802a37e'/>
<id>169529a0c0973fa925ad3b36f4427d31e802a37e</id>
<content type='text'>
https://github.com/ruby/fiddle/commit/c5abcc3a7e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/fiddle/commit/c5abcc3a7e
</pre>
</div>
</content>
</entry>
<entry>
<title>Import fiddle-1.0.4 (#3860)</title>
<updated>2020-12-11T00:41:12+00:00</updated>
<author>
<name>Kenta Murata</name>
<email>mrkn@users.noreply.github.com</email>
</author>
<published>2020-12-11T00:41:12+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=9b0c36b39032cffff3c62a2b0e1fc38fa429f5ea'/>
<id>9b0c36b39032cffff3c62a2b0e1fc38fa429f5ea</id>
<content type='text'>
I don't use tool/sync_default_gem.rb because the last sync was incomplete.

Co-authored-by: Hiroshi SHIBATA &lt;hsbt@ruby-lang.org&gt;
Co-authored-by: Alan Wu &lt;XrXr@users.noreply.github.com&gt;
Co-authored-by: sinisterchipmunk &lt;sinisterchipmunk@gmail.com&gt;
Co-authored-by: Sutou Kouhei &lt;kou@clear-code.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I don't use tool/sync_default_gem.rb because the last sync was incomplete.

Co-authored-by: Hiroshi SHIBATA &lt;hsbt@ruby-lang.org&gt;
Co-authored-by: Alan Wu &lt;XrXr@users.noreply.github.com&gt;
Co-authored-by: sinisterchipmunk &lt;sinisterchipmunk@gmail.com&gt;
Co-authored-by: Sutou Kouhei &lt;kou@clear-code.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/fiddle] Use ruby_xcalloc() instead of ruby_xmalloc() and memset()</title>
<updated>2020-11-18T00:05:13+00:00</updated>
<author>
<name>Sutou Kouhei</name>
<email>kou@clear-code.com</email>
</author>
<published>2020-11-16T21:04:00+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=e27701291a48ee939e0d4713f122d30d07c95773'/>
<id>e27701291a48ee939e0d4713f122d30d07c95773</id>
<content type='text'>
https://github.com/ruby/fiddle/commit/6d24fb5438
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/fiddle/commit/6d24fb5438
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/fiddle] Add workaround for RubyInstaller for Windows</title>
<updated>2020-11-18T00:05:13+00:00</updated>
<author>
<name>Sutou Kouhei</name>
<email>kou@clear-code.com</email>
</author>
<published>2020-08-15T04:19:23+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=aff5eaced4ca458bebc59b62502c2addc3d7364a'/>
<id>aff5eaced4ca458bebc59b62502c2addc3d7364a</id>
<content type='text'>
See comment for details.

https://github.com/ruby/fiddle/commit/0c76f03dc4
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
See comment for details.

https://github.com/ruby/fiddle/commit/0c76f03dc4
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/fiddle] Add a "pinning" reference (#44)</title>
<updated>2020-11-18T00:05:13+00:00</updated>
<author>
<name>Aaron Patterson</name>
<email>tenderlove@ruby-lang.org</email>
</author>
<published>2020-08-02T21:26:40+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=307388ea19f5c9d1c8c417d1979c40d970b420a2'/>
<id>307388ea19f5c9d1c8c417d1979c40d970b420a2</id>
<content type='text'>
* 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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* 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
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/fiddle] Add support for specifying types by name as String or Symbol</title>
<updated>2020-11-18T00:05:13+00:00</updated>
<author>
<name>Sutou Kouhei</name>
<email>kou@clear-code.com</email>
</author>
<published>2020-07-09T12:39:51+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=e2dfc0c26b1f3d3517002ca2645d1b67847fe518'/>
<id>e2dfc0c26b1f3d3517002ca2645d1b67847fe518</id>
<content type='text'>
For example, :voidp equals to Fiddle::TYPE_VOID_P.

https://github.com/ruby/fiddle/commit/3b4de54899
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
For example, :voidp equals to Fiddle::TYPE_VOID_P.

https://github.com/ruby/fiddle/commit/3b4de54899
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/fiddle] Add TYPE_CONST_STRING and SIZEOF_CONST_STRING for "const char *"</title>
<updated>2020-11-18T00:05:13+00:00</updated>
<author>
<name>Sutou Kouhei</name>
<email>kou@clear-code.com</email>
</author>
<published>2020-07-09T11:19:20+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/ruby.git/commit/?id=ae7b53546ca18b56c23f612b6935e98268a07602'/>
<id>ae7b53546ca18b56c23f612b6935e98268a07602</id>
<content type='text'>
Add rb_fiddle_ prefix to conversion functions.h to keep backward
compatibility but value_to_generic() isn't safe for TYPE_CONST_STRING
and not String src. Use rb_fiddle_value_to_generic() instead.

https://github.com/ruby/fiddle/commit/0ffcaa39e5
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add rb_fiddle_ prefix to conversion functions.h to keep backward
compatibility but value_to_generic() isn't safe for TYPE_CONST_STRING
and not String src. Use rb_fiddle_value_to_generic() instead.

https://github.com/ruby/fiddle/commit/0ffcaa39e5
</pre>
</div>
</content>
</entry>
</feed>
