Bug #7514

DL::Function and DL::Importer#bind_function ignores abi and name when Fiddle is available

Added by Naohisa Goto over 1 year ago. Updated over 1 year ago.

[ruby-core:50562]
Status:Closed
Priority:Normal
Assignee:Naohisa Goto
Category:ext
Target version:2.0.0
ruby -v:- Backport:

Description

Like Bug #7484, when Fiddle is available, Fiddle's DL wrapper for DL::Function ignores :stdcall ABI. In addition, when creating callback closure, DL::Function wrapped by Fiddle does not set name, and DL::Function#name raises NoMethodError.

Associated revisions

Revision 38202
Added by Naohisa Goto over 1 year ago

  • ext/dl/lib/dl/func.rb (DL::Function#initialize, DL::Function#bind): ABI should be set by using CFunc#calltype even when Fiddle is used. When Fiddle is used and a block is given, name shoud not be ignored. [Bug #7514]
  • ext/dl/lib/dl/import.rb (DL::Importer#bind_function): should respect abi and name when Fiddle is used.
  • test/dl/testfunc.rb (testnamewithblock): test for "name" method with giving a block.

History

#1 Updated by Naohisa Goto over 1 year ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r38202.
Naohisa, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • ext/dl/lib/dl/func.rb (DL::Function#initialize, DL::Function#bind): ABI should be set by using CFunc#calltype even when Fiddle is used. When Fiddle is used and a block is given, name shoud not be ignored. [Bug #7514]
  • ext/dl/lib/dl/import.rb (DL::Importer#bind_function): should respect abi and name when Fiddle is used.
  • test/dl/testfunc.rb (testnamewithblock): test for "name" method with giving a block.

#2 Updated by Usaku NAKAMURA over 1 year ago

  • Category set to ext
  • Status changed from Closed to Assigned
  • Assignee set to Naohisa Goto
  • Target version set to 2.0.0

Hmm, when using DL::Function, the patch solves the problem.

But, when we try to shift to Fiddle from DL, since Fiddle::Function
does not still have name.
So we can not shift simply.
I think that better solution of this problem is not deceiving DL::Function,
but adding name to Fiddle::Function perfectly.

Goto-san, Aaron, how do you think about this?

In addition, I am actually afflicted by this shift problem now, and this
problem is serious for me.

#3 Updated by Naohisa Goto over 1 year ago

In the commit r38243, Fiddle::Function#name is added, and Fiddle::Importer#importfunction and bindfunction set the name. The name attribute would be used by Fiddle version of Win32::Registry.

#4 Updated by Naohisa Goto over 1 year ago

  • Status changed from Assigned to Closed

In r38322, Fiddle::Function#initialize can get name by using :name keyword argument. For example,
Fiddle::Function.new(ptr, [], Fiddle::TYPE_VOID, name: "example")

Also available in: Atom PDF