Class: FFIDB::Typedef

Inherits:
Object
  • Object
show all
Includes:
Symbolic
Defined in:
lib/ffidb/typedef.rb

Instance Method Summary collapse

Methods included from Symbolic

#<=>, #enum?, #function?, #kind, #kind_weight, #struct?, #to_yaml, #union?

Constructor Details

#initialize(name, type, comment = nil) ⇒ Typedef

Returns a new instance of Typedef.

Parameters:

  • name (Symbol, #to_sym)
  • type (Type)
  • comment (String, #to_s) (defaults to: nil)


14
15
16
# File 'lib/ffidb/typedef.rb', line 14

def initialize(name, type, comment = nil)
  super(name.to_sym, Type.for(type), comment&.to_s)
end

Instance Method Details

#to_hHash<Symbol, Type>

Returns:

  • (Hash<Symbol, Type>)


30
31
32
33
34
35
36
# File 'lib/ffidb/typedef.rb', line 30

def to_h
  {
    name: self.name.to_s,
    type: self.type.to_s,
    comment: self.comment,
  }.delete_if { |k, v| v.nil? }
end

#to_sString

Returns:

  • (String)


24
25
26
# File 'lib/ffidb/typedef.rb', line 24

def to_s
  "typedef #{self.type} #{self.name}"
end

#typedef?Boolean

Returns:

  • (Boolean)


20
# File 'lib/ffidb/typedef.rb', line 20

def typedef?() return true end