[前][次][番号順一覧][スレッド一覧]

ruby-changes:46515

From: nagachika <ko1@a...>
Date: Wed, 10 May 2017 00:30:24 +0900 (JST)
Subject: [ruby-changes:46515] nagachika:r58636 (ruby_2_4): merge revision(s) 58359: [Backport #13439]

nagachika	2017-05-10 00:30:19 +0900 (Wed, 10 May 2017)

  New Revision: 58636

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58636

  Log:
    merge revision(s) 58359: [Backport #13439]
    
    fix RSTRUCT_LEN macro in public C API
    
    rb_struct_size returns an Integer VALUE, so it must be converted
    to a `long` for compatibility with previous Ruby C API versions.
    
    * ext/-test-/struct/len.c: new
    * test/-ext-/struct/test_len.rb: new
    * include/ruby/ruby.h (RSTRUCT_LEN): use NUM2LONG
      [ruby-core:80692] [Bug #13439]

  Added files:
    branches/ruby_2_4/ext/-test-/struct/len.c
    branches/ruby_2_4/test/-ext-/struct/test_len.rb
  Modified directories:
    branches/ruby_2_4/
  Modified files:
    branches/ruby_2_4/include/ruby/ruby.h
    branches/ruby_2_4/version.h
Index: ruby_2_4/ext/-test-/struct/len.c
===================================================================
--- ruby_2_4/ext/-test-/struct/len.c	(nonexistent)
+++ ruby_2_4/ext/-test-/struct/len.c	(revision 58636)
@@ -0,0 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/-test-/struct/len.c#L1
+#include "ruby.h"
+
+static VALUE
+bug_struct_len(VALUE obj)
+{
+    return LONG2NUM(RSTRUCT_LEN(obj));
+}
+
+void
+Init_len(VALUE klass)
+{
+    rb_define_method(klass, "rstruct_len", bug_struct_len, 0);
+}
Index: ruby_2_4/version.h
===================================================================
--- ruby_2_4/version.h	(revision 58635)
+++ ruby_2_4/version.h	(revision 58636)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1
 #define RUBY_VERSION "2.4.2"
 #define RUBY_RELEASE_DATE "2017-05-10"
-#define RUBY_PATCHLEVEL 129
+#define RUBY_PATCHLEVEL 130
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 5
Index: ruby_2_4/test/-ext-/struct/test_len.rb
===================================================================
--- ruby_2_4/test/-ext-/struct/test_len.rb	(nonexistent)
+++ ruby_2_4/test/-ext-/struct/test_len.rb	(revision 58636)
@@ -0,0 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/-ext-/struct/test_len.rb#L1
+# frozen_string_literal: false
+require 'test/unit'
+require "-test-/struct"
+
+class Bug::Struct::Test_Len < Test::Unit::TestCase
+  def test_rstruct_len
+    klass = Bug::Struct.new(:a, :b, :c)
+    assert_equal 3, klass.new.rstruct_len
+  end
+end
Index: ruby_2_4/include/ruby/ruby.h
===================================================================
--- ruby_2_4/include/ruby/ruby.h	(revision 58635)
+++ ruby_2_4/include/ruby/ruby.h	(revision 58636)
@@ -1190,7 +1190,7 @@ void *rb_check_typeddata(VALUE, const rb https://github.com/ruby/ruby/blob/trunk/ruby_2_4/include/ruby/ruby.h#L1190
 #define TypedData_Get_Struct(obj,type,data_type,sval) \
     ((sval) = (type*)rb_check_typeddata((obj), (data_type)))
 
-#define RSTRUCT_LEN(st)         rb_struct_size(st)
+#define RSTRUCT_LEN(st)         NUM2LONG(rb_struct_size(st))
 #define RSTRUCT_PTR(st)         rb_struct_ptr(st)
 #define RSTRUCT_SET(st, idx, v) rb_struct_aset(st, INT2NUM(idx), (v))
 #define RSTRUCT_GET(st, idx)    rb_struct_aref(st, INT2NUM(idx))
Index: ruby_2_4
===================================================================
--- ruby_2_4	(revision 58635)
+++ ruby_2_4	(revision 58636)

Property changes on: ruby_2_4
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /trunk:r58359

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]