Module: GirFFI::EnumLikeBase
Overview
Base module for enums and flags.
Instance Method Summary
collapse
#setup_method, #setup_method!
#gtype
Methods included from TypeBase
#gir_ffi_builder, #gir_info
Instance Method Details
#copy_value_to_pointer(value, pointer, offset = 0) ⇒ Object
25
26
27
|
# File 'lib/gir_ffi/enum_like_base.rb', line 25
def copy_value_to_pointer(value, pointer, offset = 0)
pointer.put_int32 offset, to_native(value, nil)
end
|
#get_value_from_pointer(pointer, offset) ⇒ Object
29
30
31
|
# File 'lib/gir_ffi/enum_like_base.rb', line 29
def get_value_from_pointer(pointer, offset)
from_native pointer.get_int32(offset), nil
end
|
#setup_and_call(method, arguments, &block) ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/gir_ffi/enum_like_base.rb', line 33
def setup_and_call(method, arguments, &block)
result = setup_method method.to_s
raise "Unable to set up method #{method} in #{self}" unless result
send method, *arguments, &block
end
|
#size ⇒ Object
21
22
23
|
# File 'lib/gir_ffi/enum_like_base.rb', line 21
def size
native_type.size
end
|
#to_callback_ffi_type ⇒ Object
45
46
47
|
# File 'lib/gir_ffi/enum_like_base.rb', line 45
def to_callback_ffi_type
:int32
end
|
#to_ffi_type ⇒ Object
41
42
43
|
# File 'lib/gir_ffi/enum_like_base.rb', line 41
def to_ffi_type
self
end
|
#to_int(arg) ⇒ Object
17
18
19
|
# File 'lib/gir_ffi/enum_like_base.rb', line 17
def to_int(arg)
to_native arg, nil
end
|
#wrap(arg) ⇒ Object
13
14
15
|
# File 'lib/gir_ffi/enum_like_base.rb', line 13
def wrap(arg)
from_native arg, nil
end
|