summaryrefslogtreecommitdiff
path: root/ext/fiddle/lib
AgeCommit message (Collapse)Author
2023-12-25[ruby/fiddle] Bump versionSutou Kouhei
https://github.com/ruby/fiddle/commit/fd4bb4ea8a
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-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-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
2022-12-26[ruby/fiddle] Prefer String#unpack1 in Fiddle::ValueUtilMau Magnaguagno
(https://github.com/ruby/fiddle/pull/118) String#unpack1 is available since Ruby 2.4, and support for older than Ruby 2.5 was dropped by #85. Also simplified a common return statement. Notes: Merged: https://github.com/ruby/ruby/pull/7025
2022-12-26[ruby/fiddle] Bump versionSutou Kouhei
https://github.com/ruby/fiddle/commit/3033266902 Notes: Merged: https://github.com/ruby/ruby/pull/7025
2022-10-18[ruby/fiddle] Add support for linker script on LinuxSutou Kouhei
GitHub: fix https://github.com/ruby/fiddle/pull/107 Reported by nicholas a. evans. Thanks!!! https://github.com/ruby/fiddle/commit/49ea1490df Notes: Merged: https://github.com/ruby/ruby/pull/6576
2022-10-18[ruby/fiddle] Bump versionSutou Kouhei
Notes: Merged: https://github.com/ruby/ruby/pull/6576
2022-10-07[ruby/fiddle] Add Fiddle::Closure.create and Fiddle::Closure.freeSutou Kouhei
GitHub: fix GH-102 It's for freeing a closure explicitly. 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/a0ccc6bb1b
2022-10-07[ruby/fiddle] Move "type" constants to `Fiddle::Types` ↵Aaron Patterson
(https://github.com/ruby/fiddle/pull/112) 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, &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, &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 <kou@clear-code.com>
2022-10-07[ruby/fiddle] Add constants for unsigned values ↵Aaron Patterson
(https://github.com/ruby/fiddle/pull/111) 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 <kou@clear-code.com>
2022-09-11[ruby/fiddle] Fix PACK_MAP for unsigned types ↵Takashi Kokubun
(https://github.com/ruby/fiddle/pull/110) https://github.com/ruby/fiddle/commit/4a71246645ccff001292c9d80b855b2ef5bf06c1
2021-08-24[ruby/fiddle] Improve "offsetof" calculations ↵Aaron Patterson
(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-07-13[ruby/fiddle] Add "offsetof" to Struct classes ↵Aaron Patterson
(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[ruby/fiddle] Bump versionSutou Kouhei
https://github.com/ruby/fiddle/commit/049138b4b8
2021-07-13[ruby/fiddle] Bump versionSutou Kouhei
https://github.com/ruby/fiddle/commit/3784cfeec4
2021-05-18[ruby/fiddle] windows: add Fiddle.win32_last_socket_error{,=}Sutou Kouhei
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 Notes: Merged: https://github.com/ruby/ruby/pull/4506
2021-05-18[ruby/fiddle] Add support for "const" in typeSutou Kouhei
GitHub: fix #68 Reported by kojix2. Thanks!!! https://github.com/ruby/fiddle/commit/d7322c234a Notes: Merged: https://github.com/ruby/ruby/pull/4506
2021-05-18[ruby/fiddle] win32types: sortSutou Kouhei
https://github.com/ruby/fiddle/commit/35dec6c5a5 Notes: Merged: https://github.com/ruby/ruby/pull/4506
2021-05-18[ruby/fiddle] Fix more Win32Types definitionsSutou Kouhei
https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types https://github.com/ruby/fiddle/commit/805c1a595a Notes: Merged: https://github.com/ruby/ruby/pull/4506
2021-05-18[ruby/fiddle] Fix Win32Types for Windows 64-bit (#63)Orgad Shaneh
https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types https://github.com/ruby/fiddle/commit/28ee5b1608 Notes: Merged: https://github.com/ruby/ruby/pull/4506
2021-05-18[ruby/fiddle] Bump versionSutou Kouhei
https://github.com/ruby/fiddle/commit/0cbd370fd6 Notes: Merged: https://github.com/ruby/ruby/pull/4506
2021-05-18[ruby/fiddle] Bump versionKenta Murata
https://github.com/ruby/fiddle/commit/63e5f98412 Notes: Merged: https://github.com/ruby/ruby/pull/4506
2021-02-26Oops! Add another test and fix to_proc implementationAaron Patterson
2021-02-26Fiddle::Function responds to to_procAaron Patterson
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 ```
2020-12-23[fiddle] Update to 1.0.6Kenta Murata
2020-12-23fiddle: Update to 1.0.5Sutou Kouhei
Notes: Merged: https://github.com/ruby/ruby/pull/3970
2020-12-11Import fiddle-1.0.4 (#3860)Kenta Murata
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> Notes: Merged-By: mrkn <mrkn@ruby-lang.org>
2020-11-18[ruby/fiddle] Bump versionSutou Kouhei
https://github.com/ruby/fiddle/commit/74b65cb858 Notes: Merged: https://github.com/ruby/ruby/pull/3780
2020-11-18[ruby/fiddle] Remove needless rescueSutou Kouhei
GitHub: fix GH-15 Reported by Eneroth3. Thanks!!! https://github.com/ruby/fiddle/commit/f3d70b81ec Notes: Merged: https://github.com/ruby/ruby/pull/3780
2020-11-18[ruby/fiddle] Add TYPE_CONST_STRING and SIZEOF_CONST_STRING for "const char *"Sutou Kouhei
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 Notes: Merged: https://github.com/ruby/ruby/pull/3780
2020-05-23[ruby/fiddle] Improve documentation on how to correctly free memory and free ↵Chris Seaton
memory in tests (#33) https://github.com/ruby/fiddle/commit/e59cfd708a
2020-05-23[ruby/fiddle] Export Fiddle::VERSIONSutou Kouhei
https://github.com/ruby/fiddle/commit/1b93a2d9db Notes: Merged: https://github.com/ruby/ruby/pull/3068
2020-05-23[ruby/fiddle] Fix a typoSutou Kouhei
https://github.com/ruby/fiddle/commit/445ca6b501 Notes: Merged: https://github.com/ruby/ruby/pull/3068
2020-05-23[ruby/fiddle] Bump versionSutou Kouhei
https://github.com/ruby/fiddle/commit/f8fb7c4823 Notes: Merged: https://github.com/ruby/ruby/pull/3068
2020-05-23[ruby/fiddle] Add Fiddle::VERSIONSutou Kouhei
https://github.com/ruby/fiddle/commit/9dcf64c096 Notes: Merged: https://github.com/ruby/ruby/pull/3068
2020-05-23[ruby/fiddle] Fix assignment to array within struct (#26)sinisterchipmunk
* Allow access to a struct's underlying memory with `struct[offset, length]`. https://github.com/ruby/fiddle/commit/24083690a6 Notes: Merged: https://github.com/ruby/ruby/pull/3068
2020-05-23[ruby/fiddle] Make array access override compatible with base class (#25)sinisterchipmunk
* 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 Notes: Merged: https://github.com/ruby/ruby/pull/3068
2018-04-19fiddle/import.rb: suppress warningnobu
* 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-02-18ext/fiddle/lib/fiddle/pack.rb: pack "void *" properly on 32-bitnormal
Fixes: r62450 (commit 1aaeeb326e754c5c5db83fbf35f780f729a9dfed) ("long long is a C99ism") git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-17long long is a C99ismshyouhei
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
2017-10-21Added explicitly require to example code.hsbt
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-09-12Merge fiddle-1.0.0.beta2 from upstream.hsbt
* 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
2016-04-11fiddle/import.rb: suppress warningsnobu
* 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
2015-12-16handle ext/ as r53141naruse
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-01-03cparser.rb: limit word numbernobu
* 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* ext/fiddle/lib/fiddle/cparser.rb: r49110 brake Fiddle::Import withhsbt
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* remove trailing spaces.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-03* ext/fiddle/lib/fiddle/cparser.rb: Support for Fiddle::CParserhsbt
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