summaryrefslogtreecommitdiff
path: root/lib/ffi
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ffi')
-rw-r--r--lib/ffi/function.rb10
-rw-r--r--lib/ffi/library.rb11
-rw-r--r--lib/ffi/variadic.rb5
3 files changed, 26 insertions, 0 deletions
diff --git a/lib/ffi/function.rb b/lib/ffi/function.rb
index 6fff6ae..b4469be 100644
--- a/lib/ffi/function.rb
+++ b/lib/ffi/function.rb
@@ -32,10 +32,20 @@ module FFI
class Function
# Only MRI allows function type queries
if private_method_defined?(:type)
+ # Retrieve the return type of the function
+ #
+ # This method returns FFI type returned by the function.
+ #
+ # @return [FFI::Type]
def return_type
type.return_type
end
+ # Retrieve Array of parameter types
+ #
+ # This method returns an Array of FFI types accepted as function parameters.
+ #
+ # @return [Array<FFI::Type>]
def param_types
type.param_types
end
diff --git a/lib/ffi/library.rb b/lib/ffi/library.rb
index 8af457d..9394902 100644
--- a/lib/ffi/library.rb
+++ b/lib/ffi/library.rb
@@ -542,10 +542,21 @@ module FFI
end || FFI.find_type(t)
end
+ # Retrieve all attached functions and their function signature
+ #
+ # This method returns a Hash of method names of attached functions connected by #attach_function and the corresponding function type.
+ # The function type responds to #return_type and #param_types which return the FFI types of the function signature.
+ #
+ # @return [Hash< Symbol => [FFI::Function, FFI::VariadicInvoker] >]
def attached_functions
@ffi_functions || {}
end
+ # Retrieve all attached variables and their type
+ #
+ # This method returns a Hash of variable names and the corresponding type or variables connected by #attach_variable .
+ #
+ # @return [Hash< Symbol => ffi_type >]
def attached_variables
(
(@ffi_gsvars || {}).map do |name, gvar|
diff --git a/lib/ffi/variadic.rb b/lib/ffi/variadic.rb
index 246b52f..389c53c 100644
--- a/lib/ffi/variadic.rb
+++ b/lib/ffi/variadic.rb
@@ -67,6 +67,11 @@ module FFI
invoker
end
+ # Retrieve Array of parameter types
+ #
+ # This method returns an Array of FFI types accepted as function parameters.
+ #
+ # @return [Array<FFI::Type>]
def param_types
[*@fixed, Type::Builtin::VARARGS]
end