summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Kanis <lars@greiz-reinsdorf.de>2023-04-26 14:50:29 +0200
committerLars Kanis <lars@greiz-reinsdorf.de>2023-04-27 13:47:57 +0200
commit0093113f07d1878d6f70480cdc1bf95c09fb7c2a (patch)
tree1cd14ee99ab73756de95792d41d2697f2609d033
parent4fc6a8c5ec8a9a720330946af9d1103015c62942 (diff)
downloadffi-0093113f07d1878d6f70480cdc1bf95c09fb7c2a.tar.gz
Rename result_type to return_type
The term "return_type" is already used in Truffleruby and sounds better to me. On the other hand the term "result_type" was only used in C-ffi as FunctionInfo#result_type, which is an internal class only.
-rw-r--r--ext/ffi_c/FunctionInfo.c6
-rw-r--r--ext/ffi_c/Variadic.c4
-rw-r--r--lib/ffi/function.rb4
-rw-r--r--spec/ffi/function_type_spec.rb2
-rw-r--r--spec/ffi/library_spec.rb2
-rw-r--r--spec/ffi/variadic_spec.rb2
6 files changed, 10 insertions, 10 deletions
diff --git a/ext/ffi_c/FunctionInfo.c b/ext/ffi_c/FunctionInfo.c
index 197c681..7495215 100644
--- a/ext/ffi_c/FunctionInfo.c
+++ b/ext/ffi_c/FunctionInfo.c
@@ -255,12 +255,12 @@ fntype_initialize(int argc, VALUE* argv, VALUE self)
}
/*
- * call-seq: result_type
+ * call-seq: return_type
* @return [Type]
* Get the return type of the function type
*/
static VALUE
-fntype_result_type(VALUE self)
+fntype_return_type(VALUE self)
{
FunctionType* ft;
@@ -311,7 +311,7 @@ rbffi_FunctionInfo_Init(VALUE moduleFFI)
rb_define_alloc_func(rbffi_FunctionTypeClass, fntype_allocate);
rb_define_method(rbffi_FunctionTypeClass, "initialize", fntype_initialize, -1);
- rb_define_method(rbffi_FunctionTypeClass, "result_type", fntype_result_type, 0);
+ rb_define_method(rbffi_FunctionTypeClass, "return_type", fntype_return_type, 0);
rb_define_method(rbffi_FunctionTypeClass, "param_types", fntype_param_types, 0);
}
diff --git a/ext/ffi_c/Variadic.c b/ext/ffi_c/Variadic.c
index cb5081b..0f321d9 100644
--- a/ext/ffi_c/Variadic.c
+++ b/ext/ffi_c/Variadic.c
@@ -323,7 +323,7 @@ variadic_invoke(VALUE self, VALUE parameterTypes, VALUE parameterValues)
}
static VALUE
-variadic_result_type(VALUE self)
+variadic_return_type(VALUE self)
{
VariadicInvoker* invoker;
@@ -341,6 +341,6 @@ rbffi_Variadic_Init(VALUE moduleFFI)
rb_define_method(classVariadicInvoker, "initialize", variadic_initialize, 4);
rb_define_method(classVariadicInvoker, "invoke", variadic_invoke, 2);
- rb_define_method(classVariadicInvoker, "result_type", variadic_result_type, 0);
+ rb_define_method(classVariadicInvoker, "return_type", variadic_return_type, 0);
}
diff --git a/lib/ffi/function.rb b/lib/ffi/function.rb
index 5996d96..6fff6ae 100644
--- a/lib/ffi/function.rb
+++ b/lib/ffi/function.rb
@@ -32,8 +32,8 @@ module FFI
class Function
# Only MRI allows function type queries
if private_method_defined?(:type)
- def result_type
- type.result_type
+ def return_type
+ type.return_type
end
def param_types
diff --git a/spec/ffi/function_type_spec.rb b/spec/ffi/function_type_spec.rb
index 54e1c48..2f171d8 100644
--- a/spec/ffi/function_type_spec.rb
+++ b/spec/ffi/function_type_spec.rb
@@ -8,7 +8,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
describe "FFI::FunctionType", skip: RUBY_ENGINE != "ruby" do
it 'is initialized with return type and a list of parameter types' do
function_type = FFI::FunctionType.new(:int, [ :char, :ulong ])
- expect(function_type.result_type).to be == FFI::Type::Builtin::INT
+ expect(function_type.return_type).to be == FFI::Type::Builtin::INT
expect(function_type.param_types).to be == [ FFI::Type::Builtin::CHAR, FFI::Type::Builtin::ULONG ]
end
diff --git a/spec/ffi/library_spec.rb b/spec/ffi/library_spec.rb
index c9542b9..14a8bc1 100644
--- a/spec/ffi/library_spec.rb
+++ b/spec/ffi/library_spec.rb
@@ -204,7 +204,7 @@ describe "Library" do
fun = mod.attached_functions
expect(fun.keys).to eq(["bool_return_true"])
expect(fun["bool_return_true"].param_types).to eq([FFI::Type::STRING])
- expect(fun["bool_return_true"].result_type).to eq(FFI::Type::BOOL)
+ expect(fun["bool_return_true"].return_type).to eq(FFI::Type::BOOL)
end
end
diff --git a/spec/ffi/variadic_spec.rb b/spec/ffi/variadic_spec.rb
index 283878b..917212a 100644
--- a/spec/ffi/variadic_spec.rb
+++ b/spec/ffi/variadic_spec.rb
@@ -40,7 +40,7 @@ describe "Function with variadic arguments" do
it "can reveal its return and parameters" do
fun = LibTest.attached_functions["testBlockingWRva"]
expect(fun.param_types).to eq([FFI::Type::POINTER, FFI::Type::CHAR, FFI::Type::VARARGS])
- expect(fun.result_type).to eq(FFI::Type::INT8)
+ expect(fun.return_type).to eq(FFI::Type::INT8)
end
it 'can wrap a blocking function with varargs' do