fiddle 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17a63516f0bbb623b730ccaa32e98df18c1b3c447b99027b82125ab788363175
4
- data.tar.gz: 6b834175e32765e9a13edfb4f32390b48d8914d5bbe8e0b50b215f409b4ee192
3
+ metadata.gz: 96a73d1da87f69ec3f4aae33ed5a80ac8c920eb69fd93d91fb2d68c6ad0189af
4
+ data.tar.gz: 50a145cd8275945f292bd8a82184d5955d64ef75a1ed44601daffc6716196dac
5
5
  SHA512:
6
- metadata.gz: 0c0bf76f5288d9241daa1ec0f2dae597a33a428afb893d7cf274cfd6c247c99eb93280f4fe1883b2fbabeb844cae9e272df2209feaba69cd781b689f772fb3f6
7
- data.tar.gz: '038a55b29aafc16824c2d0498be0e22851c0f5e97956ee961220cd606dcb55a6615cdaca8ec0481e1fb6e9a4d28ec544ac86e78cf640c0e0cb551e65266b0a7d'
6
+ metadata.gz: 2d1dda953aab9d5cb9fef0e0f437accfdf9c2cc891cc7319a2d53726d6e71570248a0a5b2308a18d75b7737e6667e798e404d0b5bdab2ad50d88106a061c74a6
7
+ data.tar.gz: d4da3f220dfcbae91f58fd958de75746918a8bf20b1bedc342d99bfbeb3885d124bfece0c7c21523478b0d0c3f961a30b0a5103c65b8263dc37b03ddbc5db47a
data/Rakefile CHANGED
@@ -17,8 +17,13 @@ namespace :version do
17
17
  end
18
18
  end
19
19
 
20
- require 'rake/extensiontask'
21
- Rake::ExtensionTask.new("fiddle")
22
- Rake::ExtensionTask.new("-test-/memory_view")
20
+ if RUBY_ENGINE == "ruby"
21
+ require 'rake/extensiontask'
22
+ Rake::ExtensionTask.new("fiddle")
23
+ Rake::ExtensionTask.new("-test-/memory_view")
24
+ task test: :compile
25
+ else
26
+ task :compile
27
+ end
23
28
 
24
- task :default => [:compile, :test]
29
+ task default: :test
data/ext/fiddle/closure.c CHANGED
@@ -61,7 +61,7 @@ const rb_data_type_t closure_data_type = {
61
61
  .dfree = dealloc,
62
62
  .dsize = closure_memsize
63
63
  },
64
- .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
64
+ .flags = FIDDLE_DEFAULT_TYPED_DATA_FLAGS,
65
65
  };
66
66
 
67
67
  struct callback_args {
@@ -300,6 +300,7 @@ initialize_body(VALUE user_data)
300
300
  cl->argv[i] = rb_fiddle_int_to_ffi_type(NUM2INT(arg));
301
301
  }
302
302
  cl->argv[argc] = NULL;
303
+ OBJ_FREEZE_RAW(normalized_args);
303
304
 
304
305
  ret = rb_fiddle_type_ensure(ret);
305
306
  rb_iv_set(data->self, "@ctype", ret);
@@ -455,4 +456,3 @@ Init_fiddle_closure(void)
455
456
  */
456
457
  rb_define_method(cFiddleClosure, "freed?", closure_freed_p, 0);
457
458
  }
458
- /* vim: set noet sw=4 sts=4 */
@@ -379,5 +379,3 @@ generic_to_value(VALUE rettype, fiddle_generic retval)
379
379
  {
380
380
  return rb_fiddle_generic_to_value(rettype, retval);
381
381
  }
382
-
383
- /* vim: set noet sw=4 sts=4 */
@@ -1,6 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
  require 'mkmf'
3
3
 
4
+ unless RUBY_ENGINE == "ruby"
5
+ File.write('Makefile', dummy_makefile("").join)
6
+ return
7
+ end
8
+
4
9
  # :stopdoc:
5
10
 
6
11
  def gcc?
@@ -218,6 +223,8 @@ if libffi
218
223
  $LOCAL_LIBS.prepend("#{libffi.a} ").strip! # to exts.mk
219
224
  $INCFLAGS.gsub!(/-I#{libffi.dir}/, '-I$(LIBFFI_DIR)')
220
225
  end
226
+
227
+ have_func("rb_str_to_interned_str")
221
228
  create_makefile 'fiddle' do |conf|
222
229
  if !libffi
223
230
  next conf << "LIBFFI_CLEAN = none\n"
data/ext/fiddle/fiddle.c CHANGED
@@ -709,4 +709,3 @@ Init_fiddle(void)
709
709
  Init_fiddle_memory_view();
710
710
  #endif
711
711
  }
712
- /* vim: set noet sws=4 sw=4: */
data/ext/fiddle/fiddle.h CHANGED
@@ -236,5 +236,14 @@ VALUE rb_fiddle_new_function(VALUE address, VALUE arg_types, VALUE ret_type);
236
236
  typedef void (*rb_fiddle_freefunc_t)(void*);
237
237
  VALUE rb_fiddle_ptr_new_wrap(void *ptr, long size, rb_fiddle_freefunc_t func, VALUE wrap0, VALUE wrap1);
238
238
 
239
+ enum {
240
+ FIDDLE_DEFAULT_TYPED_DATA_FLAGS = (
241
+ RUBY_TYPED_FREE_IMMEDIATELY |
242
+ RUBY_TYPED_WB_PROTECTED |
243
+ #ifdef RUBY_TYPED_FROZEN_SHAREABLE
244
+ RUBY_TYPED_FROZEN_SHAREABLE |
245
+ #endif
246
+ 0)
247
+ };
248
+
239
249
  #endif
240
- /* vim: set noet sws=4 sw=4: */
@@ -59,7 +59,7 @@ const rb_data_type_t function_data_type = {
59
59
  .dfree = deallocate,
60
60
  .dsize = function_memsize
61
61
  },
62
- .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
62
+ .flags = FIDDLE_DEFAULT_TYPED_DATA_FLAGS,
63
63
  };
64
64
 
65
65
  static VALUE
@@ -153,6 +153,9 @@ initialize(int argc, VALUE argv[], VALUE self)
153
153
  rb_get_kwargs(kwargs, kw, 0, kw_max_, args);
154
154
  if (args[kw_name] != Qundef) {
155
155
  name = args[kw_name];
156
+ #ifdef HAVE_RB_STR_TO_INTERNED_STR
157
+ name = rb_str_to_interned_str(name);
158
+ #endif
156
159
  }
157
160
  if (args[kw_need_gvl] != Qundef) {
158
161
  need_gvl = args[kw_need_gvl];
@@ -371,7 +374,7 @@ function_call(int argc, VALUE argv[], VALUE self)
371
374
  args.values[i_call] = (void *)&generic_args[i_call];
372
375
  }
373
376
  args.values[i_call] = NULL;
374
- args.fn = (void(*)(void))NUM2PTR(cfunc);
377
+ args.fn = (void(*)(void))(VALUE)NUM2PTR(cfunc);
375
378
 
376
379
  if (RTEST(need_gvl)) {
377
380
  ffi_call(args.cif, args.fn, &(args.retval), args.values);
@@ -493,4 +496,3 @@ Init_fiddle_function(void)
493
496
  */
494
497
  rb_define_method(cFiddleFunction, "initialize", initialize, -1);
495
498
  }
496
- /* vim: set noet sws=4 sw=4: */
data/ext/fiddle/handle.c CHANGED
@@ -56,7 +56,8 @@ static const rb_data_type_t fiddle_handle_data_type = {
56
56
  .dfree = fiddle_handle_free,
57
57
  .dsize = fiddle_handle_memsize
58
58
  },
59
- .flags = RUBY_TYPED_WB_PROTECTED,
59
+ .flags = FIDDLE_DEFAULT_TYPED_DATA_FLAGS & ~RUBY_TYPED_FREE_IMMEDIATELY,
60
+ /* keeping while its symbols are referred. */
60
61
  };
61
62
 
62
63
  /*
@@ -587,5 +588,3 @@ Init_fiddle_handle(void)
587
588
  rb_define_method(rb_cHandle, "enable_close", rb_fiddle_handle_enable_close, 0);
588
589
  rb_define_method(rb_cHandle, "close_enabled?", rb_fiddle_handle_close_enabled_p, 0);
589
590
  }
590
-
591
- /* vim: set noet sws=4 sw=4: */
@@ -64,8 +64,13 @@ fiddle_memview_memsize(const void *ptr)
64
64
  }
65
65
 
66
66
  static const rb_data_type_t fiddle_memview_data_type = {
67
- "fiddle/memory_view",
68
- {fiddle_memview_mark, fiddle_memview_free, fiddle_memview_memsize,},
67
+ .wrap_struct_name = "fiddle/memory_view",
68
+ .function = {
69
+ .dmark = fiddle_memview_mark,
70
+ .dfree = fiddle_memview_free,
71
+ .dsize = fiddle_memview_memsize,
72
+ },
73
+ .flags = FIDDLE_DEFAULT_TYPED_DATA_FLAGS,
69
74
  };
70
75
 
71
76
  static VALUE
data/ext/fiddle/pinned.c CHANGED
@@ -24,9 +24,13 @@ pinned_memsize(const void *ptr)
24
24
  }
25
25
 
26
26
  static const rb_data_type_t pinned_data_type = {
27
- "fiddle/pinned",
28
- {pinned_mark, xfree, pinned_memsize, },
29
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
27
+ .wrap_struct_name = "fiddle/pinned",
28
+ .function = {
29
+ .dmark = pinned_mark,
30
+ .dfree = RUBY_TYPED_DEFAULT_FREE,
31
+ .dsize = pinned_memsize,
32
+ },
33
+ .flags = FIDDLE_DEFAULT_TYPED_DATA_FLAGS,
30
34
  };
31
35
 
32
36
  static VALUE
data/ext/fiddle/pointer.c CHANGED
@@ -94,7 +94,7 @@ static const rb_data_type_t fiddle_ptr_data_type = {
94
94
  .dfree = fiddle_ptr_free,
95
95
  .dsize = fiddle_ptr_memsize,
96
96
  },
97
- .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
97
+ .flags = FIDDLE_DEFAULT_TYPED_DATA_FLAGS,
98
98
  };
99
99
 
100
100
  #ifdef HAVE_RUBY_MEMORY_VIEW_H
@@ -570,7 +570,7 @@ rb_fiddle_ptr_inspect(VALUE self)
570
570
 
571
571
  TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
572
572
  return rb_sprintf("#<%"PRIsVALUE":%p ptr=%p size=%ld free=%p>",
573
- RB_OBJ_CLASSNAME(self), (void *)data, data->ptr, data->size, (void *)data->free);
573
+ RB_OBJ_CLASSNAME(self), (void *)data, data->ptr, data->size, (void *)(VALUE)data->free);
574
574
  }
575
575
 
576
576
  /*
data/fiddle.gemspec CHANGED
@@ -34,14 +34,11 @@ Gem::Specification.new do |spec|
34
34
  "ext/fiddle/memory_view.c",
35
35
  "ext/fiddle/pinned.c",
36
36
  "ext/fiddle/pointer.c",
37
- "ext/fiddle/win32/fficonfig.h",
38
- "ext/fiddle/win32/libffi-3.2.1-mswin.patch",
39
- "ext/fiddle/win32/libffi-config.rb",
40
- "ext/fiddle/win32/libffi.mk.tmpl",
41
37
  "fiddle.gemspec",
42
38
  "lib/fiddle.rb",
43
39
  "lib/fiddle/closure.rb",
44
40
  "lib/fiddle/cparser.rb",
41
+ "lib/fiddle/ffi_backend.rb",
45
42
  "lib/fiddle/function.rb",
46
43
  "lib/fiddle/import.rb",
47
44
  "lib/fiddle/pack.rb",
@@ -56,4 +53,5 @@ Gem::Specification.new do |spec|
56
53
  spec.required_ruby_version = ">= 2.5.0"
57
54
 
58
55
  spec.metadata["msys2_mingw_dependencies"] = "libffi"
56
+ spec.metadata["changelog_uri"] = "https://github.com/ruby/fiddle/releases"
59
57
  end