Ruby 1.9 fixes.
SF Bug#1292 - Runtime fixes for Proc changes in ruby-1.9 when using STL wrappers that override the default predicate, such as: %template(Map) std::map<swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ, swig::BinaryPredicate<> >; Fixes li_std_functors testcases for Ruby 1.9. Also rb_respond_to return values have changed subtely in 1.9 and return should be treated as a flag instead of checking for Qtrue, see SF Bug #1159. Also fix li_std_map, li_std_set silently failing - rb_protect behaviour seems to have changed when an exception is thrown, so code has been changed to use rb_rescue. A call to 'rb_set_errinfo(Qnil)' could have solved this after the rb_protect call, but it is only available in 1.9+ and Ruby API changes are not easily and transparently detectable.
This commit is contained in:
parent
ee92a26819
commit
5d529d5a76
5 changed files with 34 additions and 9 deletions
|
|
@ -172,6 +172,16 @@ namespace swig {
|
|||
return rb_inspect(_obj);
|
||||
}
|
||||
|
||||
static VALUE swig_rescue_funcall( VALUE )
|
||||
{
|
||||
/*
|
||||
VALUE err = rb_errinfo();
|
||||
VALUE errstr = rb_obj_as_string(err);
|
||||
std::cout << "Error is: '" << RSTRING_PTR(StringValue(errstr)) << "'" << std::endl;
|
||||
*/
|
||||
return Qnil;/* Swallow Ruby exception */
|
||||
}
|
||||
|
||||
static VALUE swig_protect_funcall( VALUE p )
|
||||
{
|
||||
OpArgs* args = (OpArgs*) p;
|
||||
|
|
@ -189,16 +199,15 @@ namespace swig {
|
|||
bool res = false; \
|
||||
VALUE ret = Qnil; \
|
||||
SWIG_RUBY_THREAD_BEGIN_BLOCK; \
|
||||
if ( rb_respond_to( _obj, op_id ) == Qtrue ) \
|
||||
if ( rb_respond_to( _obj, op_id ) ) \
|
||||
{ \
|
||||
int status; \
|
||||
OpArgs args; \
|
||||
args.src = _obj; \
|
||||
args.id = op_id; \
|
||||
args.nargs = 1; \
|
||||
args.target = VALUE(other); \
|
||||
ret = rb_protect( PROTECTFUNC(swig_protect_funcall), \
|
||||
VALUE(&args), &status ); \
|
||||
ret = rb_rescue(RUBY_METHOD_FUNC(swig_protect_funcall), VALUE(&args), \
|
||||
(RUBY_METHOD_FUNC(swig_rescue_funcall)), Qnil); \
|
||||
} \
|
||||
if ( ret == Qnil ) { \
|
||||
VALUE a = rb_funcall( _obj, hash_id, 0 ); \
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ VALUE rb_complex_new(VALUE x, VALUE y) {
|
|||
static int SWIG_Is_Complex( VALUE obj ) {
|
||||
static ID real_id = rb_intern("real");
|
||||
static ID imag_id = rb_intern("imag");
|
||||
return ( (rb_respond_to( obj, real_id ) == Qtrue) &&
|
||||
(rb_respond_to( obj, imag_id ) == Qtrue) );
|
||||
return ( (rb_respond_to( obj, real_id ) ) &&
|
||||
(rb_respond_to( obj, imag_id ) ) );
|
||||
}
|
||||
%#else
|
||||
static int SWIG_Is_Complex( VALUE obj ) {
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ SWIG_Ruby_SetModule(swig_module_info *pointer)
|
|||
SWIGINTERN
|
||||
int SWIG_Ruby_isCallable( VALUE proc )
|
||||
{
|
||||
if ( rb_respond_to( proc, swig_call_id ) == Qtrue )
|
||||
if ( rb_respond_to( proc, swig_call_id ) )
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -424,7 +424,7 @@ int SWIG_Ruby_isCallable( VALUE proc )
|
|||
SWIGINTERN
|
||||
int SWIG_Ruby_arity( VALUE proc, int minimal )
|
||||
{
|
||||
if ( rb_respond_to( proc, swig_arity_id ) == Qtrue )
|
||||
if ( rb_respond_to( proc, swig_arity_id ) )
|
||||
{
|
||||
VALUE num = rb_funcall( proc, swig_arity_id, 0 );
|
||||
int arity = NUM2INT(num);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue