Class: FFIDB::Struct
Instance Method Summary
collapse
Methods included from Symbolic
#<=>, #enum?, #function?, #kind, #kind_weight, #to_yaml, #typedef?, #union?
Constructor Details
#initialize(name, fields = {}, comment = nil) ⇒ Struct
Returns a new instance of Struct.
13
14
15
|
# File 'lib/ffidb/struct.rb', line 13
def initialize(name, fields = {}, = nil)
super(name.to_sym, fields || {}, &.to_s)
end
|
Instance Method Details
#opaque? ⇒ Boolean
23
|
# File 'lib/ffidb/struct.rb', line 23
def opaque?() !self.fields || self.fields.empty? end
|
#struct? ⇒ Boolean
19
|
# File 'lib/ffidb/struct.rb', line 19
def struct?() return true end
|
#to_h ⇒ Hash<Symbol, Type>
33
34
35
36
37
38
39
|
# File 'lib/ffidb/struct.rb', line 33
def to_h
{
name: self.name.to_s,
comment: self.,
fields: self.opaque? ? nil : self.fields&.transform_values { |t| t.to_s },
}.delete_if { |k, v| v.nil? }
end
|
#to_s ⇒ String
27
28
29
|
# File 'lib/ffidb/struct.rb', line 27
def to_s
"struct #{self.name}"
end
|