Slide 34
Slide 34 text
Copyright
©
2015
Oracle
and/or
its
affiliates.
All
rights
reserved.
34
1 typedef VALUE void*;
2 typedef ID void*;
3
4 // Define a C function as a Ruby method
5 void rb_define_method
6 (VALUE class, const char* name,
7 VALUE(*func)(), int argc);
8
9 // Store an array element into a Ruby array
10 void rb_ary_store
11 (VALUE ary, long idx, VALUE val);
12
13 // Get the Ruby internal representation of an
14 // identifier
15 ID rb_intern(const char* name);
16
17 // Get instance variables of a Ruby object
18 VALUE rb_iv_get(VALUE object,
19 const char* iv_name)
20
21 // Invoke a Ruby method from C
22 VALUE rb_funcall(VALUE receiver ID method_id,
23 int argc, ...);
24
25 // Convert a Ruby Fixnum to C long
26 long FIX2INT(VALUE value);
Well designed API?
è Internal functions of CRuby