Hi,
In message "[ruby-talk:15259] c-api-question."
on 01/05/16, Erik BéČfors <erik / bagfors.nu> writes:
|So. How would I call A in ruby and how would the ruby-api-wrapping
|look?? Would it include Proc objects?
It depends on what and how you want to show to Ruby world.
One possibility is something like:
struct A {
void (*funcA)();
void (*funcB)();
}
VALUE
foo_foo()
{
struct A *a;
VALUE obj = Data_Make_Struct(rb_cFoo, struct A, 0, 0, a);
a->funcA = funcA;
a->funcB = funcB;
return obj;
}
VALUE
foo_call(obj)
VALUE obj;
{
struct A *a;
VALUE obj = Data_Get_Struct(obj, struct A, a);
if (something)
funcA(param);
else
funcB(param);
}
matz.