/usr/lib/ruby/vendor_ruby/gir_ffi/builders/enum_builder.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 | require 'gir_ffi/builders/registered_type_builder'
require 'gir_ffi/enum_base'
module GirFFI
module Builders
# Implements the creation of an enum or flags type. The type will be
# attached to the appropriate namespace module, and will be defined
# as an enum for FFI.
class EnumBuilder < RegisteredTypeBuilder
private
def enum_sym
@classname.to_sym
end
def value_spec
info.values.map do|vinfo|
val = GirFFI::ArgHelper.cast_uint32_to_int32(vinfo.value)
[vinfo.name.to_sym, val]
end.flatten
end
def setup_class
setup_ffi_type
klass.extend superclass
setup_constants
stub_methods
setup_inspect
end
def klass
@klass ||= get_or_define_module namespace_module, @classname
end
def setup_ffi_type
optionally_define_constant klass, :Enum do
lib.enum(enum_sym, value_spec)
end
end
def setup_inspect
klass.instance_eval <<-EOS
def self.inspect
"#{@namespace}::#{@classname}"
end
EOS
end
def already_set_up
klass.respond_to? :gtype
end
def superclass
EnumBase
end
end
end
end
|