[ruby/fiddle] Accept Symbol as Function name again
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
This commit is contained in:
parent
5eaa4c76c6
commit
a23c6db5c5
@ -154,7 +154,9 @@ initialize(int argc, VALUE argv[], VALUE self)
|
|||||||
if (args[kw_name] != Qundef) {
|
if (args[kw_name] != Qundef) {
|
||||||
name = args[kw_name];
|
name = args[kw_name];
|
||||||
#ifdef HAVE_RB_STR_TO_INTERNED_STR
|
#ifdef HAVE_RB_STR_TO_INTERNED_STR
|
||||||
name = rb_str_to_interned_str(name);
|
if (RB_TYPE_P(name, RUBY_T_STRING)) {
|
||||||
|
name = rb_str_to_interned_str(name);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (args[kw_need_gvl] != Qundef) {
|
if (args[kw_need_gvl] != Qundef) {
|
||||||
|
@ -37,6 +37,11 @@ module Fiddle
|
|||||||
assert_equal 'sin', func.name
|
assert_equal 'sin', func.name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_name_symbol
|
||||||
|
func = Function.new(@libm['sin'], [TYPE_DOUBLE], TYPE_DOUBLE, name: :sin)
|
||||||
|
assert_equal :sin, func.name
|
||||||
|
end
|
||||||
|
|
||||||
def test_need_gvl?
|
def test_need_gvl?
|
||||||
if RUBY_ENGINE == "jruby"
|
if RUBY_ENGINE == "jruby"
|
||||||
omit("rb_str_dup() doesn't exist in JRuby")
|
omit("rb_str_dup() doesn't exist in JRuby")
|
||||||
@ -261,7 +266,25 @@ module Fiddle
|
|||||||
|
|
||||||
def test_ractor_shareable
|
def test_ractor_shareable
|
||||||
omit("Need Ractor") unless defined?(Ractor)
|
omit("Need Ractor") unless defined?(Ractor)
|
||||||
assert_ractor_shareable(Function.new(@libm['sin'], [TYPE_DOUBLE], TYPE_DOUBLE))
|
assert_ractor_shareable(Function.new(@libm["sin"],
|
||||||
|
[TYPE_DOUBLE],
|
||||||
|
TYPE_DOUBLE))
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_ractor_shareable_name
|
||||||
|
omit("Need Ractor") unless defined?(Ractor)
|
||||||
|
assert_ractor_shareable(Function.new(@libm["sin"],
|
||||||
|
[TYPE_DOUBLE],
|
||||||
|
TYPE_DOUBLE,
|
||||||
|
name: "sin"))
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_ractor_shareable_name_symbol
|
||||||
|
omit("Need Ractor") unless defined?(Ractor)
|
||||||
|
assert_ractor_shareable(Function.new(@libm["sin"],
|
||||||
|
[TYPE_DOUBLE],
|
||||||
|
TYPE_DOUBLE,
|
||||||
|
name: :sin))
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
Loading…
x
Reference in New Issue
Block a user