FFI::ClangSourceFFIClangTypesFunction

class Function

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

Definitions

def variadic?

Check if this function is variadic.

Signature

returns Boolean

True if the function accepts a variable number of arguments.

Implementation

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

def args_size

Get the number of arguments this function takes.

Signature

returns Integer

The number of arguments.

Implementation

def args_size
	Lib.get_num_arg_types(@type)
end

def arg_type(i)

Get the type of a specific argument.

Signature

parameter i Integer

The zero-based argument index.

returns Type

The type of the argument at the specified index.

Implementation

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

def arg_types

Iterate over all argument types or get an enumerator.

Signature

yields {|type| ...}

Yields each argument type if a block is given.

parameter type Type

An argument type.

returns Enumerator, self

An enumerator if no block is given, self otherwise.

Implementation

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

def result_type

Get the return type of this function.

Signature

returns Type

The function's return type.

Implementation

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

def calling_conv

Get the calling convention of this function.

Signature

returns Symbol

The calling convention (e.g., :calling_conv_c, :calling_conv_x86_stdcall).

Implementation

def calling_conv
	Lib.get_fuction_type_calling_conv(@type)
end

def exception_specification

Get the exception specification type for this function.

Signature

returns Symbol

The exception specification type (e.g., :exception_spec_none, :exception_spec_basic_noexcept).

Implementation

def exception_specification
	Lib.get_exception_specification_type(@type)
end