Skip to content

Commit

Permalink
- Fixed examples for 1.9 compatibility.
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//src/RubyInline/dev/": change = 6417]
  • Loading branch information
zenspider committed Jun 30, 2011
1 parent 787ab68 commit d6a5acd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions example2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ class MyTest
builder.add_compile_flags %q(-x c++)
builder.add_link_flags %q(-lstdc++)

builder.include "<iostream>"

builder.c "
// stupid c++ comment
#include <iostream>
/* stupid c comment */
static
void
hello(int i) {
Expand Down
12 changes: 6 additions & 6 deletions tutorial/example2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ class Array
inline do |builder|
builder.c_raw "
static VALUE average(int argc, VALUE *argv, VALUE self) {
double result;
double result = 0;
long i, len;
VALUE *arr = RARRAY(self)->ptr;
len = RARRAY(self)->len;
VALUE *arr = RARRAY_PTR(self);
len = RARRAY_LEN(self);
for(i=0; i<len; i++) {
result += NUM2DBL(arr[i]);
}
return rb_float_new(result/(double)len);
}
"
Expand Down Expand Up @@ -70,7 +70,7 @@ class Array

# & time ruby ./example2.rb 5 100000
# .....
#
#
# real 0m1.403s
# user 0m1.120s
# sys 0m0.070s
Expand Down

0 comments on commit d6a5acd

Please sign in to comment.