Class: FFI::Clang::Types::Function

Inherits:
Type
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ffi/clang/types/function.rb

Overview

Represents a function type. This includes functions with and without prototypes.

Instance Attribute Summary

Attributes inherited from Type

#translation_unit, #type

Instance Method Summary collapse

Methods inherited from Type

#==, #address_space, #alignof, #canonical, #const_qualified?, #copy_assignable?, #copyable?, create, #declaration, #fqn_elaborated, #fqn_impl, #fqn_pointer, #fqn_record, #fqn_template_args, #fully_qualified_name, #initialize, #intrinsic_type, #kind, #kind_spelling, #modified_type, #non_reference_type, #nullability, #num_template_arguments, #parse_template_args_from_spelling, #pod?, #pretty_printed, #ref_qualifier, #reference?, #restrict_qualified?, #sizeof, #spelling, #template_argument_type, #to_s, #transparent_tag_typedef?, #typedef_name, #unqualified_type, #value_type, #visit_base_classes, #visit_fields, #visit_methods, #volatile_qualified?

Constructor Details

This class inherits a constructor from FFI::Clang::Types::Type

Instance Method Details

#arg_type(i) ⇒ Object

Get the type of a specific argument.



30
31
32
# File 'lib/ffi/clang/types/function.rb', line 30

def arg_type(i)
	Type.create Lib.get_arg_type(@type, i), @translation_unit
end

#arg_typesObject

Iterate over all argument types or get an enumerator.



38
39
40
41
42
43
44
45
46
# File 'lib/ffi/clang/types/function.rb', line 38

def arg_types
	return to_enum(:arg_types) unless block_given?
	
	self.args_size.times do |i|
		yield self.arg_type(i)
	end
	
	self
end

#args_sizeObject

Get the number of arguments this function takes.



23
24
25
# File 'lib/ffi/clang/types/function.rb', line 23

def args_size
	Lib.get_num_arg_types(@type)
end

#calling_convObject

Get the calling convention of this function.



56
57
58
# File 'lib/ffi/clang/types/function.rb', line 56

def calling_conv
	Lib.get_fuction_type_calling_conv(@type)
end

#exception_specificationObject

Get the exception specification type for this function.



62
63
64
# File 'lib/ffi/clang/types/function.rb', line 62

def exception_specification
	Lib.get_exception_specification_type(@type)
end

#result_typeObject

Get the return type of this function.



50
51
52
# File 'lib/ffi/clang/types/function.rb', line 50

def result_type
	Type.create Lib.get_result_type(@type), @translation_unit
end

#variadic?Boolean

Check if this function is variadic.

Returns:

  • (Boolean)


17
18
19
# File 'lib/ffi/clang/types/function.rb', line 17

def variadic?
	Lib.is_function_type_variadic(@type) != 0
end