<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/test/fiddle/test_import.rb, branch v3_3_11</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>[ruby/fiddle] test: suppress a warning</title>
<updated>2022-10-07T06:18:51+00:00</updated>
<author>
<name>Sutou Kouhei</name>
<email>kou@clear-code.com</email>
</author>
<published>2022-09-14T03:51:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=191b91f47a1557b7178072e2a607105d5449e2ef'/>
<id>191b91f47a1557b7178072e2a607105d5449e2ef</id>
<content type='text'>
    test/fiddle/test_import.rb:138: warning:
    ambiguous first argument; put parentheses or a space even after `-' operator

https://github.com/ruby/fiddle/commit/060eef76ad
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
    test/fiddle/test_import.rb:138: warning:
    ambiguous first argument; put parentheses or a space even after `-' operator

https://github.com/ruby/fiddle/commit/060eef76ad
</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='https://git.ruby-lang.org/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='https://git.ruby-lang.org/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] test: ensure GC-ing closures</title>
<updated>2022-10-07T06:18:49+00:00</updated>
<author>
<name>Sutou Kouhei</name>
<email>kou@clear-code.com</email>
</author>
<published>2022-09-09T14:59:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=6d01b66764b6dd3fc61c297bd1ec973f8ea686aa'/>
<id>6d01b66764b6dd3fc61c297bd1ec973f8ea686aa</id>
<content type='text'>
GitHub: fix GH-102

We can't use Fiddle::Closure before we fork the process. If we do it,
the process may be crashed with SELinux.

See https://github.com/ruby/fiddle/issues/102#issuecomment-1241763091
for details.

Reported by Vít Ondruch. Thanks!!!

https://github.com/ruby/fiddle/commit/1343ac7a95
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
GitHub: fix GH-102

We can't use Fiddle::Closure before we fork the process. If we do it,
the process may be crashed with SELinux.

See https://github.com/ruby/fiddle/issues/102#issuecomment-1241763091
for details.

Reported by Vít Ondruch. Thanks!!!

https://github.com/ruby/fiddle/commit/1343ac7a95
</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='https://git.ruby-lang.org/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] 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='https://git.ruby-lang.org/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>
<entry>
<title>[ruby/fiddle] Add support for variadic arguments</title>
<updated>2020-06-27T14:54:08+00:00</updated>
<author>
<name>Sutou Kouhei</name>
<email>kou@clear-code.com</email>
</author>
<published>2020-06-26T22:25:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ae18220f9904c70304bd1672eecadbb3618fc7e5'/>
<id>ae18220f9904c70304bd1672eecadbb3618fc7e5</id>
<content type='text'>
GitHub: fix GH-39

Reported by kojix2. Thanks!!!

https://github.com/ruby/fiddle/commit/6c4cb904dc
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
GitHub: fix GH-39

Reported by kojix2. Thanks!!!

https://github.com/ruby/fiddle/commit/6c4cb904dc
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/fiddle] Improve documentation on how to correctly free memory and free memory in tests (#33)</title>
<updated>2020-05-23T05:34:07+00:00</updated>
<author>
<name>Chris Seaton</name>
<email>chris@chrisseaton.com</email>
</author>
<published>2020-05-18T23:12:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=3015a7aae7ddc9b63149df34b1f12366e07a9563'/>
<id>3015a7aae7ddc9b63149df34b1f12366e07a9563</id>
<content type='text'>
https://github.com/ruby/fiddle/commit/e59cfd708a
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/fiddle/commit/e59cfd708a
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/fiddle] Fix assignment to array within struct (#26)</title>
<updated>2020-05-23T05:29:16+00:00</updated>
<author>
<name>sinisterchipmunk</name>
<email>sinisterchipmunk@gmail.com</email>
</author>
<published>2020-01-23T01:37:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=77cc13943cd9ec908d75133d7ac0b89c9ab57deb'/>
<id>77cc13943cd9ec908d75133d7ac0b89c9ab57deb</id>
<content type='text'>
* Allow access to a struct's underlying memory with `struct[offset, length]`.

https://github.com/ruby/fiddle/commit/24083690a6
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Allow access to a struct's underlying memory with `struct[offset, length]`.

https://github.com/ruby/fiddle/commit/24083690a6
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/fiddle] Make array access override compatible with base class (#25)</title>
<updated>2020-05-23T05:29:16+00:00</updated>
<author>
<name>sinisterchipmunk</name>
<email>sinisterchipmunk@gmail.com</email>
</author>
<published>2020-01-22T07:55:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4a835621ced099316850a16f2a13534dea62a0b8'/>
<id>4a835621ced099316850a16f2a13534dea62a0b8</id>
<content type='text'>
* Allow access to a struct's underlying memory with `struct[offset, length]`.

* Make accessing a struct's underlying memory more convenient.

* refactor memory access unit tests for improved clarity


https://github.com/ruby/fiddle/commit/c082c81bb5
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Allow access to a struct's underlying memory with `struct[offset, length]`.

* Make accessing a struct's underlying memory more convenient.

* refactor memory access unit tests for improved clarity


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