Class: SWIG::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/crequire/swig.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, args = [], ret = :void) ⇒ Function

Returns a new instance of Function.



81
82
83
84
85
# File 'lib/crequire/swig.rb', line 81

def initialize(name, args = [], ret = :void)
  @name = name
  @args = args
  @return = ret
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



79
80
81
# File 'lib/crequire/swig.rb', line 79

def args
  @args
end

#nameObject

Returns the value of attribute name.



79
80
81
# File 'lib/crequire/swig.rb', line 79

def name
  @name
end

#returnObject

Returns the value of attribute return.



79
80
81
# File 'lib/crequire/swig.rb', line 79

def return
  @return
end

Instance Method Details

#to_sObject



87
88
89
90
91
92
93
94
95
96
97
# File 'lib/crequire/swig.rb', line 87

def to_s
  res = "extern #{@return} #{@name}("
  res << @args.each_with_index.map do |arg,i|
    if arg =~ /(INPUT)|(OUTPUT)/
      arg.to_s.gsub(/(INPUT)|(OUTPUT)/, "arg#{i}")
    else
      arg.to_s + " arg#{i}"
    end
  end.join(", ")
  res << ");"
end

#to_swig_sObject



99
100
101
102
103
104
105
106
107
108
109
# File 'lib/crequire/swig.rb', line 99

def to_swig_s
  res = "extern #{@return} #{@name}("
  res << @args.each_with_index.map do |arg,i|
    if arg =~ /(INPUT)|(OUTPUT)/
      arg.to_s
    else
      arg.to_s + " arg#{i}"
    end
  end.join(", ")
  res << ");"
end