From: Michael Neumann Date: 2007-09-22T18:34:25+09:00 Subject: Re: CplusRuby - Gluing C and Ruby Konrad Meyer schrieb: > Quoth Konrad Meyer: > Okay, so I have added the following to DEFAULT_OPTIONS: > > :int => { > :default => '0', > :ctype => 'int %s', > :ruby2c => '(int)NUM2INT(%s)', > :c2ruby => 'INT2NUM(%s)'}, > > :char_p => { > :default => '""', > :ctype => 'char *%s', > :ruby2c => 'StringValuePtr(%s)', > :c2ruby => 'rb_str_new2(%s)'} > > My code is like this: > > #---------------------start > > require 'cplusruby' > > class BankAccount < CplusRuby > property :balance, :int > property :name, :char_p > > method_c :withdraw, %{int dollars}, %{ > if (dollars <= selfc->balance){ > selfc->balance -= dollars; > return true; > } > } > > def initialize > end > end > > CplusRuby.evaluate("foo.c", "-Os", "") > > n = BankAccount.new > puts n.balance > puts n.name I've applied your patch. Plus, generating C code is now possible. The example above should now just work. Alternatively "foo.cc" :) Regards, Michael