Class: FFIDB::Function

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

Instance Method Summary collapse

Methods included from Symbolic

#<=>, #enum?, #kind, #kind_weight, #struct?, #typedef?, #union?

Instance Method Details

#arityInteger

Returns:

  • (Integer)


46
# File 'lib/ffidb/function.rb', line 46

def arity() self.parameters.size end

#binary?Boolean

Returns:

  • (Boolean)


38
# File 'lib/ffidb/function.rb', line 38

def binary?() self.arity.equal?(2) end

#function?Boolean

Returns:

  • (Boolean)


18
# File 'lib/ffidb/function.rb', line 18

def function?() return true end

#nonpublic?Boolean

Returns:

  • (Boolean)


26
# File 'lib/ffidb/function.rb', line 26

def nonpublic?() !(self.public?) end

#nullary?Boolean

Returns:

  • (Boolean)


30
# File 'lib/ffidb/function.rb', line 30

def nullary?() self.arity.zero? end

#public?Boolean

Returns:

  • (Boolean)


22
# File 'lib/ffidb/function.rb', line 22

def public?() self.name[0] != '_' end

#ternary?Boolean

Returns:

  • (Boolean)


42
# File 'lib/ffidb/function.rb', line 42

def ternary?() self.arity.equal?(3) end

#to_hHash<Symbol, Object>

Returns:

  • (Hash<Symbol, Object>)


50
51
52
53
54
55
56
57
58
# File 'lib/ffidb/function.rb', line 50

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

#to_yamlString

Returns:

  • (String)


62
63
64
65
66
67
68
# File 'lib/ffidb/function.rb', line 62

def to_yaml
  h = self.to_h
  h.delete(:parameters) if h[:parameters].empty?
  h.transform_keys!(&:to_s)
  h.transform_values! { |v| v.is_a?(Hash) ? v.transform_keys!(&:to_s) : v }
  YAML.dump(h).gsub!("---\n", "--- !#{self.kind}\n")
end

#unary?Boolean

Returns:

  • (Boolean)


34
# File 'lib/ffidb/function.rb', line 34

def unary?() self.arity.equal?(1) end