lib/cplus2ruby/cpp_code_generator.rb
#
# Generates a C++ method that forwards the call to the Ruby method
# of the same name.
#
Generates a C++ method that forwards the call to the Ruby method
of the same name.
Generates a C ++ method that forwards the call to the Ruby method of the same name .
def gen_stub_method(klassname, name, options)
    raise "Stub method with body is invalid!" if options[:body]
    args = options[:arguments].dup
    unless args_convertable?(args)
      raise "ERROR: Cannot convert stub method #{klassname}::#{name}"
    end
    returns = args.delete(:returns) || "void"
    out = ""
    out << "{\n"
    out << "VALUE __res__ = " if returns != 'void'
    call_args = ["@__obj__", %{rb_intern("#{name}")}, args.size] + 
      args.map {|n, k| @model.typing.convert(k, n, :c2ruby) }
    out << %{rb_funcall(#{call_args.join(', ')});}
    if returns != 'void' 
      out << @model.typing.convert(returns, '__res__', :ruby2c_checktype)
      retval = @model.typing.convert(returns, '__res__', :ruby2c) 
      out << "return #{retval};\n"
    end
    out << "}\n"
    return out
  end
def gen_stub_method ( klassname , name , options ) raise "Stub method with body is invalid!" if options [ :body ] args = options [ :arguments ] . dup unless args_convertable? ( args ) raise "ERROR: Cannot convert stub method #{klassname}::#{name}" end returns = args . delete ( :returns ) || "void" out = "" out << "{\n" out << "VALUE __res__ = " if returns != 'void' call_args = [ "@__obj__" , %{rb_intern("#{name}")} , args . size ] + args . map { | n , k | @model . typing . convert ( k , n , :c2ruby ) } out << %{rb_funcall(#{call_args.join(', ')});} if returns != 'void' out << @model . typing . convert ( returns , '__res__' , :ruby2c_checktype ) retval = @model . typing . convert ( returns , '__res__' , :ruby2c ) out << "return #{retval};\n" end out << "}\n" return out end
Generates a C++ method that forwards the call to the Ruby method
of the same name.
Generates a C ++ method that forwards the call to the Ruby method of the same name .
# TODO: move rb_intern out # check return type
klassname
<not_specific>
name
<not_specific>
options
<not_specific>