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:
William S Fulton 2013-04-05 23:41:59 +01:00
commit 5d529d5a76
5 changed files with 34 additions and 9 deletions

View file

@ -34,6 +34,12 @@ def _set(container)
EOF
end
def b_lessthan_a(b, a)
res = b < a
# print b, "<", a, "=", res
return res
end
def _map(container)
swig_assert_each_line(<<EOF, binding)
cont = #{container}.new
@ -43,7 +49,7 @@ def _map(container)
cont['w'] = 2
cont.to_a == [['w',2],['x',8],['y',1],['z',9]]
cont = #{container}.new(proc { |a,b| b < a } )
cont = #{container}.new(proc { |a,b| b_lessthan_a(b, a) } )
cont['z'] = 9
cont['y'] = 1
cont['x'] = 8