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
|
# frozen_string_literal: true
module GObjectIntrospection
# Wraps a GIStructInfo struct.
# Represents a struct.
class IStructInfo < IRegisteredTypeInfo
def n_fields
Lib.g_struct_info_get_n_fields self
end
def field(index)
IFieldInfo.wrap Lib.g_struct_info_get_field(self, index)
end
##
build_array_method :fields
build_finder_method :find_field
def get_n_methods
Lib.g_struct_info_get_n_methods self
end
def get_method(index)
@method_cache ||= []
@method_cache[index] ||= IFunctionInfo.wrap Lib.g_struct_info_get_method(self, index)
end
##
build_array_method :get_methods
# There is a function g_struct_info_find_method but it causes a core dump.
build_finder_method :find_method, :get_n_methods, :get_method
def size
Lib.g_struct_info_get_size self
end
def empty?
size == 0
end
def alignment
Lib.g_struct_info_get_alignment self
end
def gtype_struct?
Lib.g_struct_info_is_gtype_struct self
end
end
end
|