Skip to content

Instantly share code, notes, and snippets.

View methodmissing's full-sized avatar

Lourens Naudé methodmissing

View GitHub Profile
methodmissing:hwia lourens$ sudo gem install hwia-1.0.0.gem
Building native extensions. This could take a while...
Successfully installed hwia-1.0.0
1 gem installed
Installing ri documentation for hwia-1.0.0...
Installing RDoc documentation for hwia-1.0.0...
macbook-pros-computer:hwia lourens$ irb
>> require 'rubygems'
=> true
>> require 'hwia'
checking for rb_thread_blocking_region()... no
checking for rb_trap_immediate in ruby.h,rubysig.h... yes
creating Makefile
make
gcc -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.5.1 -I. -DHAVE_RB_TRAP_IMMEDIATE -DRUBY18 -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -O2 -pipe -fno-common -c hwia.c
cc -dynamic -bundle -undefined suppress -flat_namespace -o hwia.bundle hwia.o -L. -L/opt/local/lib -L. -ldl -lobjc
/opt/local/bin/ruby -I"ext/hwia" "/Users/lourens/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/test_hwia.rb"
Loaded suite /Users/lourens/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.................F..........
methodmissing:callback lourens$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9.5.1]
methodmissing:callback lourens$ rake bench
(in /Users/lourens/projects/callback)
/opt/local/bin/ruby extconf.rb
creating Makefile
make
gcc -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.5.1 -I/opt/local/lib/ruby/1.8/i686-darwin9.5.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -O2 -pipe -fno-common -c callback.c
cc -dynamic -bundle -undefined suppress -flat_namespace -o callback.bundle callback.o -L. -L/opt/local/lib -L. -ldl -lobjc
/opt/local/bin/ruby bench/bench.rb
static VALUE rb_f_callback( int argc, VALUE *argv )
{
return rb_callback_initialize( argc, argv, rb_callback_new() );
}
static VALUE
rb_obj_callback( VALUE obj, VALUE mid)
{
VALUE args[2];
args[0] = obj;
static VALUE rb_callback_initialize( int argc, VALUE *argv, VALUE cb )
{
VALUE object;
VALUE method;
ID meth;
RCallback* cbs = GetCallbackStruct(cb);
if (rb_block_given_p()) {
if (argc == 1) rb_raise(rb_eArgError, "wrong number of arguments");
cbs->object = rb_block_proc();
Callback( 'bai', :gsub )
Callback{ 'hai' }
'hai'.callback(:gsub)
static VALUE
callback_alloc( VALUE klass )
{
VALUE cb;
RCallback* cbs;
cb = Data_Make_Struct(klass, RCallback, mark_callback, free_callback, cbs);
cbs->object = Qnil;
cbs->method = 0;
return cb;
static void mark_callback(RCallback* cb)
{
rb_gc_mark(cb->object);
}
static void free_callback(RCallback* cb)
{
xfree(cb);
}
typedef struct {
VALUE object;
ID method;
} RCallback;
#define GetCallbackStruct(obj) (Check_Type(obj, T_DATA), (RCallback*)DATA_PTR(obj))
typedef struct {
VALUE object;
ID method;
} RCallback;