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

25 Коммитов

Автор SHA1 Сообщение Дата
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 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
Sutou Kouhei ae18220f99
[ruby/fiddle] Add support for variadic arguments
GitHub: fix GH-39

Reported by kojix2. Thanks!!!

https://github.com/ruby/fiddle/commit/6c4cb904dc
2020-06-27 23:54:08 +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
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
Hiroshi SHIBATA dc44ab2913 Revert "[ruby/fiddle] Fix a failing test (#13)"
This reverts commit 5ebb0d50f6.
2019-10-24 20:58:32 +09:00
Hiroshi SHIBATA de5ee47c3d Revert "[ruby/fiddle] test: use env Hash"
This reverts commit 4d844cbaed.
2019-10-24 20:58:32 +09:00
Sutou Kouhei 4d844cbaed [ruby/fiddle] test: use env Hash
https://github.com/ruby/fiddle/commit/a01a962342
2019-10-24 19:34:29 +09:00
Kenta Murata 5ebb0d50f6 [ruby/fiddle] Fix a failing test (#13)
* Fix a failing test

This commit fixes the following failure:

```
  1) Failure:
Fiddle::TestImport#test_no_message_with_debug [/Users/mrkn/src/github.com/ruby/fiddle/test/fiddle/test_import.rb:152]:

1. [2/2] Assertion for "stderr"
   | <[]> expected but was
   | <["Exception `NameError' at /Users/mrkn/.rbenv/versions/2.5.1/lib/ruby/2.5.0/fiddle/import.rb:157 - uninitialized constant Fiddle::Function::STDCALL"]>.
```

* Stop using Bundler.with_clean_env

* Clear existing Ruby environment variables on test_no_message_with_debug

https://github.com/ruby/fiddle/commit/13133ddec8
2019-10-24 19:34:22 +09:00
nobu 5a5c9a706c fiddle/test_import.rb: fix warnings by rubygems
[Bug #14686]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-19 23:46:55 +00: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
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
ko1 3fe69a0da4 Use mutable strings for mutation tests.
* test/fiddle/test_func.rb (test_string): this test break String buffer
  by `strcpy` ("000" -> "123"). However, the string literal "000" with
  `frozen_string_literal: true` returns a string object from frozen
  string pool. So that after this test "000" from fstring pool becomes
  "123" (modified string). 'test/date/' uses "000" (as fstring) and tests
  are fails (we could check with `make test-all TESTS='fiddle date'`).

* test/fiddle/test_function.rb: ditto.

* test/fiddle/test_import.rb: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-12 23:15:34 +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
hsbt 24873d1a05 Use Test::Unit::TestCase instead of MiniTest::Unit::TestCase. Because
tests of fiddle already used customized assertions of ruby core.

  * test/fiddle/helper.rb: Use Test::Unit::TestCase for base class of
    testcase.
  * test/fiddle/test_*.rb: Use assert_raise instead of assert_raises.
    Remove needless includes for Test::Unit::Assertions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-13 09:46:16 +00:00
usa 836794f206 Removed the obstacle to running test-all with VC14.
* test/fiddle/test_import.rb (LIBC.fprintf): VC14's `fprintf` is very distinct
  name, then, just ignore this test.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-14 17:53:20 +00:00
naruse 3e92b635fb Add frozen_string_literal: false for all files
When you change this to true, you may need to add more tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16 05:07:31 +00:00
nobu 0445b5f6c6 test/fiddle: revert r52384 partially
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-30 07:17:08 +00:00
nobu 068f312a7c use assert_raise
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-30 04:37:13 +00:00
hsbt 842e0b05ea * test/fiddle/test_import.rb (Fiddle::TestImport#test_sizeof):
added test for long long [fix GH-716]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-17 02:33:41 +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
ktsj 1dafd4ebf1 * test/fiddle/test_c_struct_entry.rb,
test/fiddle/test_c_union_entity.rb,
  test/fiddle/test_cparser.rb, test/fiddle/test_func.rb,
  test/fiddle/test_handle.rb, test/fiddle/test_import.rb,
  test/fiddle/test_pointer.rb: don't run test if the system
  don't support fiddle.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-25 14:29:02 +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
tenderlove 0713f89944 * ext/fiddle/fiddle.c: adding alignment constants for compatibility
with DL.
* ext/fiddle/fiddle.h: ditto
* ext/fiddle/lib/fiddle/cparser.rb: importing the C parser for DL
  backwards compatibility.
* ext/fiddle/lib/fiddle/import.rb: importing the import DSL for DL
  backwards compatibility.
* ext/fiddle/lib/fiddle/pack.rb: importing structure pack for DL
  backwards compatibility.
* ext/fiddle/lib/fiddle/value.rb: ditto
* ext/fiddle/lib/fiddle/struct.rb: importing struct DSL for DL backwards
  compatibility.
* test/dl/test_c_struct_entry.rb: importing tests
* test/dl/test_c_union_entity.rb: ditto
* test/dl/test_cparser.rb: ditto
* test/dl/test_import.rb: ditto
* test/fiddle/test_c_struct_entry.rb: ditto
* test/fiddle/test_c_union_entity.rb: ditto
* test/fiddle/test_cparser.rb: ditto
* test/fiddle/test_import.rb: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 00:02:49 +00:00