Commit graph

247 commits

Author SHA1 Message Date
Sutou Kouhei
79717f81f8 [ruby/fiddle] windows: link to ws2_32 for WSAGetLastError()
e9955d74ae
2021-05-18 12:48:40 +09:00
Sutou Kouhei
71d4a493b8 [ruby/fiddle] windows: add Fiddle.win32_last_socket_error{,=}
GitHub: fix GH-72

Users can't use WSAGetLastError() with Ruby 3.0 or later because
rb_funcall() resets the last socket error internally.

Users can get the last socket error by Fiddle.win32_last_socket_error.

Reported by Kentaro Hayashi. Thanks!!!

76158db00a
2021-05-18 12:48:40 +09:00
Sutou Kouhei
ab5212b3c9 [ruby/fiddle] Add support for "const" in type
GitHub: fix #68

Reported by kojix2. Thanks!!!

d7322c234a
2021-05-18 12:48:40 +09:00
Sutou Kouhei
4d1bb460f6 [ruby/fiddle] Add --enable-debug-build option to extconf.rb
e0498e60ea
2021-05-18 12:48:40 +09:00
Sutou Kouhei
791e8eec66 [ruby/fiddle] win32types: sort
35dec6c5a5
2021-05-18 12:48:40 +09:00
Sutou Kouhei
8758b07b1e [ruby/fiddle] Fix more Win32Types definitions
https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types

805c1a595a
2021-05-18 12:48:40 +09:00
Orgad Shaneh
25e56fe374 [ruby/fiddle] Fix Win32Types for Windows 64-bit (#63)
https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types

28ee5b1608
2021-05-18 12:48:40 +09:00
Sutou Kouhei
8d63b1dc75 [ruby/fiddle] Bump version
0cbd370fd6
2021-05-18 12:48:40 +09:00
Sutou Kouhei
881b2dc898 [ruby/fiddle] closure: add support for const char *
GitHub: fix GH-62

Reported by Cody Krieger. Thanks!!!

284b820f2d
2021-05-18 12:48:40 +09:00
Sutou Kouhei
b2de5999d8 [ruby/fiddle] closure: accept symbol as type
dc2da6633e
2021-05-18 12:48:40 +09:00
Sutou Kouhei
212d836cd7 [ruby/fiddle] Remove wrong comment
831522e768
2021-05-18 12:48:40 +09:00
Kenta Murata
7bd3d6d23e [ruby/fiddle] Bump version
63e5f98412
2021-05-18 12:48:40 +09:00
卜部昌平
6413dc27dc dependency updates 2021-04-13 14:30:21 +09:00
Aaron Patterson
d45466dc5b
Oops! Add another test and fix to_proc implementation 2021-02-26 10:06:56 -08:00
Aaron Patterson
0590e9b677
Fiddle::Function responds to to_proc
This lets us cast a Fiddle::Function to a block, allowing is to write
things like:

```ruby
f = Fiddle::Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP)
define_method :strcpy, &f
```
2021-02-26 09:57:13 -08:00
Kenta Murata
94015200b6
[fiddle] Update to 1.0.6 2020-12-23 23:40:04 +09:00
Kenta Murata
74652e640a
[memory_view][fiddle] Rename len to byte_size in rb_memory_view_t 2020-12-23 09:24:53 +09:00
Kenta Murata
05014dcb88
[memory_view][fiddle] Use bool for boolean return value 2020-12-23 09:05:07 +09:00
Sutou Kouhei
32849dc1bb fiddle: Update to 1.0.5 2020-12-23 05:49:52 +09:00
Alan Wu
a5fd651575 Reword docs for Fiddle::Function#call [ci skip]
I'm using `<code>` instead of `+` since `+` only works when it encloses
a single word.
2020-12-14 18:26:32 -05:00
Kenta Murata
9b0c36b390
Import fiddle-1.0.4 (#3860)
I don't use tool/sync_default_gem.rb because the last sync was incomplete.

Co-authored-by: Hiroshi SHIBATA <hsbt@ruby-lang.org>
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
Co-authored-by: sinisterchipmunk <sinisterchipmunk@gmail.com>
Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2020-12-11 09:41:12 +09:00
Sutou Kouhei
0915a02068 Update Fiddle's dependencies 2020-11-18 09:05:13 +09:00
Sutou Kouhei
fcd680fbf0 [ruby/fiddle] Remove needless return
50e02f9445
2020-11-18 09:05:13 +09:00
Sutou Kouhei
aa22b6658a [ruby/fiddle] Bump version
74b65cb858
2020-11-18 09:05:13 +09:00
Sutou Kouhei
ceccc16589 [ruby/fiddle] Remove needless workaround
It's fixed in upstream.
https://github.com/MSP-Greg/ruby-loco/issues/4

2ae0ff4934
2020-11-18 09:05:13 +09:00
Sutou Kouhei
3b385c33b8 [ruby/fiddle] Add workaround for ruby head for mingw
bb227c206d
2020-11-18 09:05:13 +09:00
Sutou Kouhei
821cfa74cb [ruby/fiddle] Use msys2_mingw_dependencies
fee175a8ff
2020-11-18 09:05:13 +09:00
Sutou Kouhei
e27701291a [ruby/fiddle] Use ruby_xcalloc() instead of ruby_xmalloc() and memset()
6d24fb5438
2020-11-18 09:05:13 +09:00
Sutou Kouhei
1867088d90 [ruby/fiddle] Remove needless rescue
GitHub: fix GH-15

Reported by Eneroth3. Thanks!!!

f3d70b81ec
2020-11-18 09:05:13 +09:00
Sutou Kouhei
aff5eaced4 [ruby/fiddle] Add workaround for RubyInstaller for Windows
See comment for details.

0c76f03dc4
2020-11-18 09:05:13 +09:00
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.

ac52d00223
2020-11-18 09:05:13 +09:00
Sutou Kouhei
e2dfc0c26b [ruby/fiddle] Add support for specifying types by name as String or Symbol
For example, :voidp equals to Fiddle::TYPE_VOID_P.

3b4de54899
2020-11-18 09:05:13 +09:00
Sutou Kouhei
ae7b53546c [ruby/fiddle] Add TYPE_CONST_STRING and SIZEOF_CONST_STRING for "const char *"
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.

0ffcaa39e5
2020-11-18 09:05:13 +09:00
卜部昌平
490010084e sed -i '/rmodule.h/d' 2020-08-27 16:42:06 +09:00
卜部昌平
756403d775 sed -i '/r_cast.h/d' 2020-08-27 15:03:36 +09:00
卜部昌平
0da2a3f1fc sed -i '\,2/extern.h,d' 2020-08-27 14:07:49 +09:00
Hiroshi SHIBATA
8fb02b7a97
Update the license for the default gems to dual licenses 2020-08-18 20:26:39 +09:00
Nobuyoshi Nakada
48fb6299c6
[ruby/fiddle] support for very old libffi
Define `Fiddle::TYPE_VARIADIC` only when `ffi_prep_cif_var` is
available, otherwise skip the test for it.
2020-06-28 10:40:31 +09:00
Nobuyoshi Nakada
c405a8d37a
[ruby/fiddle] try bundled libffi by default
If no installed libffi found, use bundled libffi unless explicitly
`--disable-bundled-libffi` option is given.
2020-06-28 01:03:21 +09:00
Sutou Kouhei
f2bcdc7283
[ruby/fiddle] Support MSWIN (#43)
f16e7ff6e0
2020-06-27 23:54:09 +09:00
Sutou Kouhei
6429b6d973
[ruby/fiddle] Add missing include
4ca61efcd7
2020-06-27 23:54:08 +09:00
Sutou Kouhei
ae18220f99
[ruby/fiddle] Add support for variadic arguments
GitHub: fix GH-39

Reported by kojix2. Thanks!!!

6c4cb904dc
2020-06-27 23:54:08 +09:00
Sutou Kouhei
9f740acaf9
[ruby/fiddle] Use meaningful variable name
2cac24b7c8
2020-06-27 23:54:08 +09:00
Sutou Kouhei
50fbd00e76
[ruby/fiddle] Use "do { } while (0)" to ensure requiring ";"
2155ae5979
2020-06-27 23:54:08 +09:00
Nobuyoshi Nakada
4949df498a
[ruby/fiddle] Fixed typos
a09e66adf4
6cab9b45d6
ab72b19bed
2020-06-26 17:05:27 +09:00
Nobuyoshi Nakada
6dbc3a2871
autoconf may not be available 2020-05-27 23:46:55 +09:00
Nobuyoshi Nakada
135c6a4b99
fiddle: need to update configure after updating config tools 2020-05-27 00:30:59 +09:00
Nobuyoshi Nakada
5917fe2303
_GNU_SOURCE is needed for mkostemp on Cygwin 2020-05-26 19:17:47 +09:00
Yusuke Endoh
f27e0d90c8 ext/fiddle/fiddle.gemspec: avoid require lib/fiddle/version.rb
It loads `ext/fiddle/lib/fiddle/version.rb`, which causes constant
redefinition warning:

20200523T153003Z.log.html.gz
```
[ 6317/20193] TestDefaultGems#test_validate_gemspec/home/chkbuild/chkbuild/tmp/build/20200523T153003Z/ruby/ext/fiddle/lib/fiddle/version.rb:2: warning: already initialized constant Fiddle::VERSION
/home/chkbuild/chkbuild/tmp/build/20200523T153003Z/ruby/.ext/common/fiddle/version.rb:2: warning: previous definition of VERSION was here
 = 0.16 s
```

This changeset read the version by manual parsing hack which is also
used in stringio and zlib.
2020-05-24 04:01:20 +09:00
Chris Seaton
3015a7aae7 [ruby/fiddle] Improve documentation on how to correctly free memory and free memory in tests (#33)
e59cfd708a
2020-05-23 14:34:07 +09:00