ts wrote:
"I" == Iain Dooley <idoo4002@mail.usyd.edu.au> writes:
> but surely i can't call:
> rb_protect(app.exec(),VALUE ?,RESULT ?);
/* Something like this */
static VALUE
call_exec_for_app(QApplication *app)
{
return app->exec();
}
/* ... */
int status;
VALUE res;
/* ... */
res = rb_protect(call_exec_for_app, (VALUE)&app, &status);
if (status) {
/* there is a ruby error */
}
/* ... */
it appears that i can't pass the name of a C function to rb_protect. i've tried these things:
/*** DEFINITION OF MY EXECUTE FUNCTION***/
VALUE executeApplication(void);
VALUE executeApplication()
{
return app->exec();
}
1) passing the C function to rb_protect as follows:
VALUE res = rb_protect(executeApplication, (VALUE)0, &status);
gives the following compile errors:
main.cpp:30: error: invalid conversion from `VALUE (*)()' to `VALUE (*)(VALUE)'
main.cpp:30: error: initializing argument 1 of `VALUE rb_protect(VALUE (*)(VALUE), VALUE, int*)'
2) using rb_define_method to define the method in ruby and then using rb_const_get to get it out and then calling it:
rb_define_method(rb_cObject,"executeApplication",executeApplication,0);
VALUE res;
VALUE func = rb_const_get(rb_cObject,rb_intern("executeApplication"));
res = rb_protect(func, (VALUE)0, &status);
gives the following compile errors:
main.cpp:24: error: invalid conversion from `VALUE (*)()' to `VALUE (*)(...)'
main.cpp:24: error: initializing argument 3 of `void rb_define_method(VALUE, const char*, VALUE (*)(...), int)'
main.cpp:30: error: invalid conversion from `VALUE' to `VALUE (*)(VALUE)'
main.cpp:30: error: initializing argument 1 of `VALUE rb_protect(VALUE (*)(VALUE), VALUE, int*)'
these types really confuse the hell out of me. what is VALUE(*)() ?!?! VALUE everywhere... this is the last tiny little thing that i have to do for the summer of code ends in two days ... just need to protect the calls!
cheers
iain