Module: GirFFI::EnumLikeBase
Overview
Base module for enums and flags.
Instance Method Summary
collapse
#gtype
Methods included from TypeBase
#gir_ffi_builder, #gir_info
Instance Method Details
#copy_value_to_pointer(value, pointer) ⇒ Object
22
23
24
|
# File 'lib/gir_ffi/enum_like_base.rb', line 22
def copy_value_to_pointer(value, pointer)
pointer.put_int32 0, to_native(value, nil)
end
|
#from(arg) ⇒ Object
14
15
16
|
# File 'lib/gir_ffi/enum_like_base.rb', line 14
def from(arg)
self[arg]
end
|
#get_value_from_pointer(pointer, offset) ⇒ Object
26
27
28
|
# File 'lib/gir_ffi/enum_like_base.rb', line 26
def get_value_from_pointer(pointer, offset)
from_native pointer.get_int32(offset), nil
end
|
#setup_and_call(method, arguments, &block) ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'lib/gir_ffi/enum_like_base.rb', line 30
def setup_and_call(method, arguments, &block)
result = setup_method method.to_s
unless result
raise "Unable to set up method #{method} in #{self}"
end
send method, *arguments, &block
end
|
#setup_method(name) ⇒ Object
44
45
46
|
# File 'lib/gir_ffi/enum_like_base.rb', line 44
def setup_method(name)
gir_ffi_builder.setup_method name
end
|
#size ⇒ Object
18
19
20
|
# File 'lib/gir_ffi/enum_like_base.rb', line 18
def size
native_type.size
end
|
#to_ffi_type ⇒ Object
40
41
42
|
# File 'lib/gir_ffi/enum_like_base.rb', line 40
def to_ffi_type
self
end
|
#wrap(arg) ⇒ Object
10
11
12
|
# File 'lib/gir_ffi/enum_like_base.rb', line 10
def wrap(arg)
self[arg]
end
|