/usr/lib/ruby/vendor_ruby/gir_ffi/boxed_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 | require 'gir_ffi/class_base'
module GirFFI
# Base class for generated classes representing boxed types.
class BoxedBase < ClassBase
extend FFI::DataConverter
def self.native_type
FFI::Type::Struct.new(self::Struct)
end
def self.to_ffi_type
self
end
# NOTE: Needed for JRuby's FFI
def self.to_native(value, _context)
value.struct
end
def self.get_value_from_pointer(pointer, offset)
pointer + offset
end
def self.copy_value_to_pointer(value, pointer, offset = 0)
size = self::Struct.size
bytes = if value
value.to_ptr.read_bytes(size)
else
"\x00" * size
end
pointer.put_bytes offset, bytes, 0, size
end
def initialize
@struct = self.class::Struct.new
end
end
end
|