class FFIDB::Struct

Public Class Methods

new(name, fields = {}, comment = nil) click to toggle source

@param [Symbol, to_sym] name @param [Map<Symbol, Type>] fields @param [String, to_s] comment

Calls superclass method
# File lib/ffidb/struct.rb, line 13
def initialize(name, fields = {}, comment = nil)
  super(name.to_sym, fields || {}, comment&.to_s)
end

Public Instance Methods

opaque?() click to toggle source

@return [Boolean]

# File lib/ffidb/struct.rb, line 23
def opaque?() !self.fields || self.fields.empty? end
struct?() click to toggle source

@return [Boolean]

# File lib/ffidb/struct.rb, line 19
def struct?() return true end
to_h() click to toggle source

@return [Hash<Symbol, Type>]

# File lib/ffidb/struct.rb, line 33
def to_h
  {
    name: self.name.to_s,
    comment: self.comment,
    fields: self.opaque? ? nil : self.fields&.transform_values { |t| t.to_s },
  }.delete_if { |k, v| v.nil? }
end
to_s() click to toggle source

@return [String]

# File lib/ffidb/struct.rb, line 27
def to_s
  "struct #{self.name}"
end