Everything you pass to ruby and obtain from ruby is in a form of pointers (except for fixed numbers and some literals). So, an array passed to a c extension would be in a form of a pointer. Here is how you would process it:
static VALUE process_array(VALUE self, VALUE v_array) {
// Ensure the data passed is an array
Check_Type(v_array, T_ARRAY);
// Process the array
unsigned int array_size = (unsigned int)RARRAY_LEN(v_array);
for (unsigned int i = 0; i < array_size; ++i) {
VALUE v_internal_array = rb_ary_entry(v_array, i);
// Ensure the internal value is an array
Check_Type(v_internal_array, T_ARRAY);
// Process the internal array
unsigned int internal_array_size = (unsigned int)RARRAY_LEN(v_internal_array);
for (unsigned int j = 0; j < internal_array_size; ++j) {
VALUE v_res = rb_ary_entry(v_array, i);
int res = NUM2INT(v_res);
// Do something
}
}
// Return something (nil in this case)
return Qnil;
}
If you want to process an array of Geom::Point3d/Geom::Vector3d objects, you have to access them by their x, y, z interns:
static VALUE process_array_of_points(VALUE self, VALUE v_array) {
// Ensure the data passed is an array
Check_Type(v_array, T_ARRAY);
// Process the array
unsigned int array_size = (unsigned int)RARRAY_LEN(v_array);
for (unsigned int i = 0; i < array_size; ++i) {
VALUE v_point = rb_ary_entry(v_array, i);
double x = rb_num2dbl(rb_funcall(v_point, rb_intern("x"), 0));
double y = rb_num2dbl(rb_funcall(v_point, rb_intern("y"), 0));
double z = rb_num2dbl(rb_funcall(v_point, rb_intern("z"), 0));
// Do something
}
// Return something (nil in this case)
return Qnil;
}
Accessing even an Array object with x,y,z interns will work too, because SketchUp adds these functions to an Array class. So, this second function will work with an array of array, array of Point3d objects, and array of Vector3d objects.
And then of course, you will have to link them with Ruby in the initiator function:
void Init_some_lib() {
VALUE mDacastror = rb_define_module("Dacastror");
rb_define_module_function(mDacastror, "process_array", VALUEFUNC(process_array), 1);
rb_define_module_function(mDacastror, "process_array_of_points", VALUEFUNC(process_array_of_points), 1);
}
Note: I did not check this code for typos, so it's up to you to fix it (if there are any).
Here are a few links to Ruby c++ extension guides:
http://clalance.blogspot.com/2011/01/writing-ruby-extensions-in-c-part-9.html
https://silverhammermba.github.io/emberb/c/
If you search the web, there are plenty of more links on that.