/usr/lib/ruby/vendor_ruby/gir_ffi/enum_base.rb is in ruby-gir-ffi 0.9.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | require 'gir_ffi/registered_type_base'
module GirFFI
# Base module for enums.
module EnumBase
include FFI::DataConverter
include RegisteredTypeBase
def native_type
self::Enum.native_type
end
def to_native(*args)
self::Enum.to_native(*args)
end
def from_native(*args)
self::Enum.from_native(*args)
end
def [](arg)
self::Enum[arg]
end
def wrap(arg)
self[arg]
end
def from(arg)
self[arg]
end
def copy_value_to_pointer(value, pointer)
pointer.put_int32 0, to_native(value, nil)
end
def get_value_from_pointer(pointer, offset)
from_native pointer.get_int32(offset), nil
end
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
def to_ffi_type
self
end
def setup_method(name)
gir_ffi_builder.setup_method name
end
end
end
|