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 ); \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue