summaryrefslogtreecommitdiff
path: root/ext/fiddle
AgeCommit message (Collapse)Author
2025-02-05Migrate fiddle as bundled gemsHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/12616
2025-02-03[ruby/fiddle] Fix Fiddle.last_error on FFI backend and improve testBenoit Daloze
to work for all (https://github.com/ruby/fiddle/pull/173) https://github.com/ruby/fiddle/commit/ef2382a7ef
2025-02-03[ruby/fiddle] Define Fiddle.last_error family and Fiddle.dlopenNobuyoshi Nakada
statically (https://github.com/ruby/fiddle/pull/172) `RUBY_ENGINE` and `Fiddle::WINDOWS` should not change in a process, no need to be checked inside the methods. Also, `win32_last_error` and `win32_last_socket_error` are equal to `last_error` on JRuby. https://github.com/ruby/fiddle/commit/50ac00ed53
2025-01-14[ruby/fiddle] add regex for bool parsing & test struct w/ boolDmitrii
parsing (https://github.com/ruby/fiddle/pull/169) GitHub: fix https://github.com/ruby/fiddle/pull/168 Struct parsing invokes "parse_ctype" on the whole member signature, which fails if member type is "bool" due to plain string matching for it. This change updates "bool" type matching to a regexp, so TYPE_BOOL is correctly parsed for a whole signature like "bool toggle" as well as just "bool". --------- https://github.com/ruby/fiddle/commit/71607446d4 Co-authored-by: Sutou Kouhei <kou@cozmixng.org> Notes: Merged: https://github.com/ruby/ruby/pull/12568
2024-12-26Bump up fiddle 1.1.7.dev and stringio 3.1.3.devHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/12469
2024-12-16Lock released version of fiddle-1.1.6Hiroshi SHIBATA
2024-12-16[ruby/fiddle] ffi_backend: convert numeric function args to pointersDani Smith
(https://github.com/ruby/fiddle/pull/162) This allows for passing integers as pointer arguments to functions when using the FFI backend. This is a workaround until we can get JRuby's FFI implementation to allow for it directly (see also https://github.com/jruby/jruby/pull/8423) --------- https://github.com/ruby/fiddle/commit/e2f0952e9b Co-authored-by: Benoit Daloze <eregontp@gmail.com>
2024-12-11[ruby/fiddle] dlopen: add support for INPUT(-lXXX)Sutou Kouhei
GitHub: fix https://github.com/ruby/fiddle/pull/166 Arch Linux's libncurses.so uses this style. https://github.com/ruby/fiddle/commit/77d3dc934f
2024-12-11[ruby/fiddle] Implement `Fiddle::Pointer.read` and `.write` on theLars Kanis
FFI backend (https://github.com/ruby/fiddle/pull/165) https://github.com/ruby/fiddle/commit/0bd963d3b8
2024-12-04Do not depend on the evaluation order of C argumentsYusuke Endoh
The evaluation order of C arguments is unspecified. `RSTRING_LEN(str)` would fails if the conversion to a String by `StringValuePtr` is not done yet. Coverity Scan found this issue. Notes: Merged: https://github.com/ruby/ruby/pull/12209
2024-11-11Bump versionSutou Kouhei
2024-11-11[ruby/fiddle] Accept Symbol as Function name againSutou Kouhei
GitHub: fix https://github.com/ruby/fiddle/pull/159 It's used by FFI test. So Symbol may be used by other use cases. https://github.com/ruby/fiddle/pull/139 introduced the "Function name is String" limitation. This commit removed the limitation. Reported by Mamoru TASAKA. Thanks!!! https://github.com/ruby/fiddle/commit/cea30fe5f9
2024-10-26Bump versionSutou Kouhei
2024-10-26[ruby/fiddle] Don't use mkmf to generate dummy MakefileSutou Kouhei
(https://github.com/ruby/fiddle/pull/155) GitHub: fix https://github.com/ruby/fiddle/pull/153 mkmf requires fileutils. JRuby doesn't like it. https://github.com/ruby/fiddle/commit/df4bd21fc3
2024-10-26[ruby/fiddle] Suppress -Wundef warningsNobuyoshi Nakada
(https://github.com/ruby/fiddle/pull/157) The GCC warning puts undefined macro names in double quotes while clang puts them in single quotes. https://github.com/ruby/fiddle/commit/7dcb40bccb
2024-10-26[ruby/fiddle] Fix Fiddle::Handle.new for a missing library in theBenoit Daloze
FFI backend (https://github.com/ruby/fiddle/pull/156) * From https://github.com/ruby/reline/issues/766#issuecomment-2422135968 https://github.com/ruby/fiddle/commit/eea9fd0cc4
2024-10-16Bump versionSutou Kouhei
2024-10-16Use JRuby implementation for TruffleRuby (#149)Sutou Kouhei
Fix GH-145 Rename `lib/fiddle/jruby.rb` to `lib/fiddle/ffi_backend.rb` as a generic ffi gem API based implementation. JRuby and TruffleRuby use `lib/fiddle/ffi_backend.rb`. --------- Co-authored-by: Benoit Daloze <eregontp@gmail.com>
2024-10-16[ruby/fiddle] Ractor supportNobuyoshi Nakada
(https://github.com/ruby/fiddle/pull/139) https://github.com/ruby/fiddle/commit/91d0ea9849 Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2024-10-10[ruby/fiddle] Cast via `VALUE` function pointer between objectNobuyoshi Nakada
pointer (https://github.com/ruby/fiddle/pull/150) With gcc 13 and -pedantic: ``` ../../../src/ext/fiddle/function.c: In function ‘function_call’: ../../../src/ext/fiddle/function.c:374:15: error: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic] 374 | args.fn = (void(*)(void))NUM2PTR(cfunc); | ^ ../../../src/ext/fiddle/pointer.c: In function ‘rb_fiddle_ptr_inspect’: ../../../src/ext/fiddle/pointer.c:573:84: error: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic] 573 | RB_OBJ_CLASSNAME(self), (void *)data, data->ptr, data->size, (void *)data->free); | ^ ``` https://github.com/ruby/fiddle/commit/6421e317a1
2024-10-10Import JRuby implementation (#147)Sutou Kouhei
Fix GH-104 lib/fiddle/jruby.rb is based on https://github.com/jruby/jruby/blob/master/lib/ruby/stdlib/fiddle/jruby.rb . Here are changes for it: * Move `Fiddle::TYPE_*` to `Fiddle::Types::*` * Add `Fiddle::Types::VARIADIC` * Add `Fiddle::Types::CONST_STRING` * Add `Fiddle::Types::BOOL` * Add `Fiddle::Types::INT8_T` * Add `Fiddle::Types::UINT8_T` * Add `Fiddle::Types::INT16_T` * Add `Fiddle::Types::UINT16_T` * Add `Fiddle::Types::INT32_T` * Add `Fiddle::Types::UINT32_T` * Add `Fiddle::Types::INT64_T` * Add `Fiddle::Types::UINT64_T` * Add more `Fiddle::ALIGN_*` for the above new `Fiddle::Types::*` * Add more `Fiddle::SIZEOF_*` for the above new `Fiddle::Types::*` * Add support for specifying type as not only `Fiddle::Types::*` but also `Symbol` like `:int` * Add support for variable size arguments in `Fiddle::Function` * Add `Fiddle::Closure#free` * Add `Fiddle::Closure#freed?` * Add `Fiddle::Error` as base the error class * Add `Fiddle::Pointer#call_free` and stop using `FFI::AutoPointer` in `Fiddle::Pointer` * Add support for `Fiddle::Pointer.malloc {}` `Fiddle::Pointer` * Add support for `Fiddle::Pointer#free=` * Add `Fiddle::Pointer#freed?` * Use binary string not C string for `Fiddle::Pointer#[]` * Add `Fiddle::Handle.sym_defined?` * Add `Fiddle::Handle#sym_defined?` * Add `Fiddle::Handle::DEFAULT` * Add `Fiddle::ClearedReferenceError` * Add no-op `Fiddle::Pinned` Some features are still "not implemented". So there are some "omit"s for JRuby in tests. Notes: Merged: https://github.com/ruby/ruby/pull/11860
2024-08-31Added pre-release suffix for development version of default gemsHiroshi SHIBATA
https://github.com/ruby/stringio/issues/81
2024-08-23[ruby/fiddle] Removed libffi patchs for old RubyHiroshi SHIBATA
(https://github.com/ruby/fiddle/pull/143) Pick https://github.com/ruby/ruby/commit/92865d8760e22dc5035a67e636fab3fbd7a77a26 from `ruby/ruby` repo. --------- https://github.com/ruby/fiddle/commit/aad5a3bc79 Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2024-07-31Remove files to build libffi in mswinNobuyoshi Nakada
These files were to build libffi from the bundled source, but are no longer used since we stopped bundling the libffi sources in commit e4f5296f065110fa83eb450d3a861253e76e534f. The gemspec file is unchanged because fiddle gem itself still supports ruby 2.5. Notes: Merged: https://github.com/ruby/ruby/pull/11285
2024-06-20[ruby/fiddle] Remove Vim commandsAaron Patterson
(https://github.com/ruby/fiddle/pull/140) Some of these commands just don't work (for example `sws` is not a Vim setting). I think we should just remove these. https://github.com/ruby/fiddle/commit/c3dbf7ba9a
2024-04-27ruby tool/update-deps --fix卜部昌平
2024-02-08[ruby/fiddle] Set changelog_uri gem metadataMasato Nakamura
(https://github.com/ruby/fiddle/pull/138) See https://guides.rubygems.org/specification-reference/#metadata for changelog_uri metadata. https://github.com/ruby/fiddle/commit/0bd8e96adc
2023-12-25[ruby/fiddle] Bump versionSutou Kouhei
https://github.com/ruby/fiddle/commit/fd4bb4ea8a
2023-11-08[ruby/fiddle] Remove garbageSutou Kouhei
https://github.com/ruby/fiddle/commit/bbcb66e16e
2023-11-08[ruby/fiddle] Include stdbool.h explicitly for old RubySutou Kouhei
https://github.com/ruby/fiddle/commit/74a05fb358
2023-11-08[ruby/fiddle] Use Ruby's true/false for C boolSutou Kouhei
GitHub: fix https://github.com/ruby/fiddle/pull/130 Reported by Benoit Daloze. Thanks!!! https://github.com/ruby/fiddle/commit/2640e0148e
2023-09-17[ruby/fiddle] Suppress -Wundef warnings on arm64 macOS and WindowsNobuyoshi Nakada
(https://github.com/ruby/fiddle/pull/134) ``` In file included from ../../../../ext/fiddle/fiddle.h:46: /opt/local/include/ffi.h:477:5: warning: 'FFI_GO_CLOSURES' is not defined, evaluates to 0 [-Wundef] ^ ``` c.f. https://github.com/libffi/libffi/pull/796 https://github.com/ruby/fiddle/commit/d4feb57098
2023-08-25use configure-detected sanity of _Alignof卜部昌平
This is actually already checked in (Ruby's) configure. Notes: Merged: https://github.com/ruby/ruby/pull/8274
2023-08-02[ruby/fiddle] Include stdbool.h explicitlySutou Kouhei
https://github.com/ruby/fiddle/commit/c313a74632
2023-08-02[ruby/fiddle] Include stdbool.h explicitlySutou Kouhei
https://github.com/ruby/fiddle/commit/69ff680bf6
2023-08-02[ruby/fiddle] Add support for boolSutou Kouhei
GitHub: fix https://github.com/ruby/fiddle/pull/130 Reported by Benoit Daloze. Thanks!!! https://github.com/ruby/fiddle/commit/bc6c66bbb9
2023-08-02[ruby/fiddle] Use ifdefSutou Kouhei
https://github.com/ruby/fiddle/commit/6cdf53726d
2023-06-28[ruby/fiddle] Mark Closure, Function and Handle as write barrierJean byroot Boussier
protected (https://github.com/ruby/fiddle/pull/129) They don't have a mark function, so they don't need any change. https://github.com/ruby/fiddle/commit/9bbc732aef Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2023-06-28[ruby/fiddle] Implement write barriers for Fiddle::PointerJean byroot Boussier
(https://github.com/ruby/fiddle/pull/127) Save from having to mark them on every minor. https://github.com/ruby/fiddle/commit/153c09c99f Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2023-06-28[ruby/fiddle] Fix a typoSutou Kouhei
https://github.com/ruby/fiddle/commit/4c0c5da1a5
2023-06-28[ruby/fiddle] Add support for converting "C" (one character string) to charSutou Kouhei
GitHub: fix https://github.com/ruby/fiddle/pull/96 I wanted to add a test for this but I couldn't find a function that has a "char" argument in libc... Reported by kojix2. Thanks!!! https://github.com/ruby/fiddle/commit/2c863ef8ba
2023-06-28[ruby/fiddle] Add support for more "short" variantsSutou Kouhei
https://github.com/ruby/fiddle/commit/2b22bb9d74
2023-06-28[ruby/fiddle] Add support for "long" variantsSutou Kouhei
GitHub: fix https://github.com/ruby/fiddle/pull/100 Reported by David M. Lary. Thanks!!! https://github.com/ruby/fiddle/commit/516333dd78
2023-06-28[ruby/fiddle] Add a helper method for reading/writing memoryAaron Patterson
(https://github.com/ruby/fiddle/pull/123) This commit adds two new methods, `Fiddle::Pointer.read` and `Fiddle::Pointer.write`. Both methods take an address, and will read or write bytes at that address respectively. For example we can read from an address without making a Pointer object: ```ruby Fiddle::Pointer.read(address, 5) # read 5 bytes ``` We can also write to an address without allocating a Pointer object: ```ruby Fiddle::Pointer.write(address, "bytes") # write 5 bytes ``` This allows us to read / write memory at arbitrary addresses without instantiating a new `Fiddle::Pointer` object. Examples where this API would be useful [1](https://github.com/tenderlove/tenderjit/blob/f03481d28bff4d248746e596929b0841de65f181/lib/tenderjit/fiddle_hacks.rb#L26-L28) [2](https://github.com/tenderlove/ruby/blob/77c8daa2d40dd58eeb3785ce17dea2ee38f308d1/lib/ruby_vm/rjit/c_pointer.rb#L193) [3](https://github.com/tenderlove/ruby/blob/77c8daa2d40dd58eeb3785ce17dea2ee38f308d1/lib/ruby_vm/rjit/c_pointer.rb#L284) I also added a writer method for the same reasons as the reader. --------- https://github.com/ruby/fiddle/commit/04238cefed Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2023-02-28Update the depend filesMatt Valentine-House
Notes: Merged: https://github.com/ruby/ruby/pull/7310
2023-02-27Remove intern/gc.h from Make depsMatt Valentine-House
Notes: Merged: https://github.com/ruby/ruby/pull/7330
2023-02-27Prefer to use File.foreach instead of IO.foreachHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/7387
2023-02-27Prefer to use File.binwrite instead of IO.binwriteHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/7387
2023-02-27Prefer to use File.binread instead of IO.binreadHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/7387
2023-02-08Extract include/ruby/internal/attr/packed_struct.hNobuyoshi Nakada
Split `PACKED_STRUCT` and `PACKED_STRUCT_UNALIGNED` macros into the macros bellow: * `RBIMPL_ATTR_PACKED_STRUCT_BEGIN` * `RBIMPL_ATTR_PACKED_STRUCT_END` * `RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN` * `RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END` Notes: Merged: https://github.com/ruby/ruby/pull/7268