Граф коммитов

60 Коммитов

Автор SHA1 Сообщение Дата
Aaron Patterson 0f1e8f38c9 [ruby/fiddle] Improve "offsetof" calculations (https://github.com/ruby/fiddle/pull/90)
I need to get the offset of members inside sub structures.  This patch
adds sub-structure offset support for structs.

https://github.com/ruby/fiddle/commit/cf78eddbb6
2021-08-24 16:18:22 +09:00
Aaron Patterson 5c0d8c6369
[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 <kou@cozmixng.org>

https://github.com/ruby/fiddle/commit/4e3b60c5b6

Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
2021-07-13 19:37:46 +09:00
Sutou Kouhei a2c9e1b58a
[ruby/fiddle] Bump version
https://github.com/ruby/fiddle/commit/049138b4b8
2021-07-13 19:37:46 +09:00
Sutou Kouhei c0f9191ab6
[ruby/fiddle] Bump version
https://github.com/ruby/fiddle/commit/3784cfeec4
2021-07-13 19:37:44 +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!!!

https://github.com/ruby/fiddle/commit/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!!!

https://github.com/ruby/fiddle/commit/d7322c234a
2021-05-18 12:48:40 +09:00
Sutou Kouhei 791e8eec66 [ruby/fiddle] win32types: sort
https://github.com/ruby/fiddle/commit/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

https://github.com/ruby/fiddle/commit/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

https://github.com/ruby/fiddle/commit/28ee5b1608
2021-05-18 12:48:40 +09:00
Sutou Kouhei 8d63b1dc75 [ruby/fiddle] Bump version
https://github.com/ruby/fiddle/commit/0cbd370fd6
2021-05-18 12:48:40 +09:00
Kenta Murata 7bd3d6d23e [ruby/fiddle] Bump version
https://github.com/ruby/fiddle/commit/63e5f98412
2021-05-18 12:48:40 +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
Sutou Kouhei 32849dc1bb fiddle: Update to 1.0.5 2020-12-23 05:49:52 +09: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 aa22b6658a [ruby/fiddle] Bump version
https://github.com/ruby/fiddle/commit/74b65cb858
2020-11-18 09:05:13 +09:00
Sutou Kouhei 1867088d90 [ruby/fiddle] Remove needless rescue
GitHub: fix GH-15

Reported by Eneroth3. Thanks!!!

https://github.com/ruby/fiddle/commit/f3d70b81ec
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.

https://github.com/ruby/fiddle/commit/0ffcaa39e5
2020-11-18 09:05:13 +09:00
Chris Seaton 3015a7aae7 [ruby/fiddle] Improve documentation on how to correctly free memory and free memory in tests (#33)
https://github.com/ruby/fiddle/commit/e59cfd708a
2020-05-23 14:34:07 +09:00
Sutou Kouhei 24b615e82e [ruby/fiddle] Export Fiddle::VERSION
https://github.com/ruby/fiddle/commit/1b93a2d9db
2020-05-23 14:29:16 +09:00
Sutou Kouhei d5c0018a9a [ruby/fiddle] Fix a typo
https://github.com/ruby/fiddle/commit/445ca6b501
2020-05-23 14:29:16 +09:00
Sutou Kouhei a0dcdd64c5 [ruby/fiddle] Bump version
https://github.com/ruby/fiddle/commit/f8fb7c4823
2020-05-23 14:29:16 +09:00
Sutou Kouhei 13f64333ea [ruby/fiddle] Add Fiddle::VERSION
https://github.com/ruby/fiddle/commit/9dcf64c096
2020-05-23 14:29:16 +09:00
sinisterchipmunk 77cc13943c [ruby/fiddle] Fix assignment to array within struct (#26)
* Allow access to a struct's underlying memory with `struct[offset, length]`.

https://github.com/ruby/fiddle/commit/24083690a6
2020-05-23 14:29:16 +09:00
sinisterchipmunk 4a835621ce [ruby/fiddle] Make array access override compatible with base class (#25)
* 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
2020-05-23 14:29:16 +09:00
nobu eb02a846a4 fiddle/import.rb: suppress warning
* ext/fiddle/lib/fiddle/import.rb: suppress exception report when
  $DEBUG is enabled.  [ruby-core:86536] [Bug #14686]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-19 23:35:39 +00:00
normal 604a96d9de ext/fiddle/lib/fiddle/pack.rb: pack "void *" properly on 32-bit
Fixes: r62450 (commit 1aaeeb326e)
       ("long long is a C99ism")

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-18 00:38:35 +00:00
shyouhei 1aaeeb326e long long is a C99ism
so SIZEOF_LONG_LONG is not always available.
We have to check its defined?-ness before using.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-17 09:51:23 +00:00
hsbt 7d2e5fb979 Added explicitly require to example code.
https://github.com/ruby/ruby/pull/1666

  Patch by @guilherme [fix GH-1666]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 14:55:22 +00:00
hsbt 7f24b0aabd Merge fiddle-1.0.0.beta2 from upstream.
* ext/fiddle/closure.c: use directly declaration for standalone gem
    without internal.h.
  * Specify frozen string literal is true.
  * Update gemspec configuration for release version.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-12 11:52:23 +00:00
nobu bf6a8134f8 fiddle/import.rb: suppress warnings
* ext/fiddle/lib/fiddle/import.rb (type_alias, handler): suppress
  "not initialized instance variable" warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-11 04:28:16 +00:00
naruse c4fdfabcc8 handle ext/ as r53141
g -L frozen_string_literal ext/**/*.rb|xargs ruby -Ka -e'ARGV.each{|fn|puts
fn;open(fn,"r+"){|f|s=f.read.sub(/\A(#!.*\n)?(#.*coding.*\n)?/,"\\&#
frozen_string_literal: false\n");f.rewind;f.write s}}'

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16 05:31:54 +00:00
nobu 544651a2fb cparser.rb: limit word number
* ext/fiddle/lib/fiddle/cparser.rb (parse_ctype): limit split word
  number as the rest are not used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-03 09:53:30 +00:00
hsbt 1ba6e8868c * ext/fiddle/lib/fiddle/cparser.rb: r49110 brake Fiddle::Import with
type_alias
* test/fiddle/test_cparser.rb: added type_alias test for parse_ctype
  and parse_struct_signature.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-03 09:23:43 +00:00
svn f661c0be44 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-03 00:54:40 +00:00
hsbt 3afd0f9a91 * ext/fiddle/lib/fiddle/cparser.rb: Support for Fiddle::CParser
to handle rich signatures including parameter names and function
  pointer types. Patch by @theryan [fix GH-590]
* test/fiddle/test_cparser.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-03 00:54:37 +00:00
nobu 065b6d2b7c fiddle/import.rb: fix typo
* ext/fiddle/lib/fiddle/import.rb (Fiddle::Importer#sizeof): fix typo,
  SIZEOF_LONG_LON.  [Fix GH-714]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-15 00:43:14 +00:00
charliesome 75f4731f90 * benchmark/bm_so_meteor_contest.rb: [DOC] Fix a few typos
* ext/fiddle/lib/fiddle/import.rb: ditto
* ext/psych/lib/psych.rb: ditto
* ext/psych/lib/psych/nodes/sequence.rb: ditto
* ext/tk/lib/multi-tk.rb: ditto
* ext/tk/lib/tcltk.rb: ditto

Closes GH-490

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-28 08:25:28 +00:00
zzak 6bb201d6d1 * ext/fiddle/*: [DOC] More doc on dlopen and RTLD_DEFAULT from r42186
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-26 05:06:57 +00:00
zzak 5cbfd7509c * ext/fiddle/lib/fiddle.rb: [DOC] Document Fiddle.dlopen(nil)
* ext/fiddle/handle.c: [DOC] Document Fiddle::Handle.new(nil)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-26 04:11:27 +00:00
kou 8346f7b2ad * ext/fiddle/lib/fiddle/struct.rb (Fiddle::CStructEntity#set_ctypes):
CPtr -> Pointer.
* test/fiddle/test_c_struct_entry.rb
  (Fiddle::TestCStructEntity#test_aref_pointer):
  Added the test for the above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-21 14:16:02 +00:00
kou e852838cee * ext/fiddle/lib/fiddle/struct.rb (Fiddle::CStructEntity#set_ctypes):
CPtr -> Pointer.
* test/fiddle/test_c_struct_entry.rb
  (Fiddle::TestCStructEntity#test_aref_pointer_array):
  Added the test for the above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-21 14:12:57 +00:00
kou 3fed8bc9a5 * ext/fiddle/lib/fiddle/import.rb (Fiddle::Importer#sizeof):
CPtr -> Pointer.
* test/fiddle/test_import.rb (Fiddle::TestImport#test_sizeof):
  Added the test for the above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-21 13:44:44 +00:00
ngoto 3e6a624a83 * ext/fiddle/function.c (Fiddle::Function.new): new keyword argument :name to set the name attribute.
* ext/fiddle/lib/fiddle/import.rb (import_function, bind_function): set function name by using the :name keyword argument.
  Re-fixes r38243. [ruby-core:50566]
* test/fiddle/test_function.rb (test_name): test for the :name keyword argument and Fiddle::Function#name.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-11 10:41:00 +00:00
ngoto 0bc733d9e3 * ext/fiddle/lib/fiddle/function.rb (Fiddle::Function#name): new
attribute needed to switch Win32::Registry from DL to Fiddle.

* ext/fiddle/lib/fiddle/import.rb (import_function, bind_function):
  set function name to the returned Fiddle::Function object.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-06 16:21:43 +00:00
ngoto 382217c8b6 * ext/fiddle/lib/fiddle/import.rb (CALL_TYPE_TO_ABI): exclude private constant from RDoc
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-06 14:27:38 +00:00
ngoto b6b8960018 * ext/fiddle/lib/fiddle/types.rb: copied from ext/dl/lib/dl/types.rb
and modified for Fiddle, needed for migration from DL to Fiddle.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-04 09:08:12 +00:00
ngoto 7b103012dc * ext/fiddle/lib/fiddle/import.rb (import_function, bind_function):
should respect call_type for migration from DL to Fiddle.
  [Bug #7484] [ruby-core:50405]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-04 09:00:23 +00:00
nobu e553663cbd value.rb: adjust indent
* ext/fiddle/lib/fiddle/value.rb (Fiddle::ValueUtil#wrap_arg): adjust
  indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 01:35:13 +00:00