[DRE-commits] [ruby-gsl] 01/01: Port to Ruby 2.1 (Closes: #744805)

Antonio Terceiro terceiro at moszumanska.debian.org
Thu Apr 17 13:59:43 UTC 2014


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to branch master
in repository ruby-gsl.

commit b2ab94f0fd09320f36da4ff7ad81f85ed3926562
Author: Antonio Terceiro <terceiro at debian.org>
Date:   Thu Apr 17 10:45:36 2014 -0300

    Port to Ruby 2.1 (Closes: #744805)
    
    This patch is incomplete. See discussion on
    https://github.com/david-macmahon/rb-gsl/issues/7
---
 debian/changelog                     |   7 ++
 debian/patches/port-to-ruby2.1.patch | 202 +++++++++++++++++++++++++++++++++++
 debian/patches/series                |   1 +
 3 files changed, 210 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 9819397..3020324 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+ruby-gsl (1.15.3+dfsg-2) UNRELEASED; urgency=medium
+
+  * Team upload.
+  * Port to Ruby 2.1 (Closes: #744805)
+
+ -- Antonio Terceiro <terceiro at debian.org>  Thu, 17 Apr 2014 10:43:52 -0300
+
 ruby-gsl (1.15.3+dfsg-1) unstable; urgency=medium
 
   * Imported Upstream version 1.15.3
diff --git a/debian/patches/port-to-ruby2.1.patch b/debian/patches/port-to-ruby2.1.patch
new file mode 100644
index 0000000..c85d3aa
--- /dev/null
+++ b/debian/patches/port-to-ruby2.1.patch
@@ -0,0 +1,202 @@
+--- a/ext/linalg.c
++++ b/ext/linalg.c
+@@ -14,6 +14,7 @@
+ #include "rb_gsl_array.h"
+ #include "rb_gsl_common.h"
+ #include "rb_gsl_linalg.h"
++#include "porting.h"
+ 
+ static VALUE cgsl_matrix_LU;
+ static VALUE cgsl_matrix_QR;
+@@ -71,7 +72,7 @@ static VALUE rb_gsl_linalg_LU_decomposit
+   Data_Get_Struct(omatrix, gsl_matrix, mtmp);
+   if (flag == LINALG_DECOMP_BANG) {
+     m = mtmp;
+-    RBASIC(omatrix)->klass = cgsl_matrix_LU;
++    rb_obj_reveal(omatrix, cgsl_matrix_LU);
+     objm = omatrix;
+   } else {
+     m = make_matrix_clone(mtmp);
+@@ -692,7 +693,7 @@ static VALUE rb_gsl_linalg_QR_LQ_decompo
+     fdecomp = &gsl_linalg_QR_decomp;
+     m = mtmp;
+     mdecomp = omatrix;
+-    RBASIC(mdecomp)->klass = cgsl_matrix_QR;
++    rb_obj_reveal(mdecomp, cgsl_matrix_QR);
+     break;
+ #ifdef GSL_1_6_LATER
+   case LINALG_LQ_DECOMP:
+@@ -704,7 +705,7 @@ static VALUE rb_gsl_linalg_QR_LQ_decompo
+     fdecomp = &gsl_linalg_LQ_decomp;
+     m = mtmp;
+     mdecomp = omatrix;
+-    RBASIC(mdecomp)->klass = cgsl_matrix_LQ;
++    rb_obj_reveal(mdecomp, cgsl_matrix_LQ);
+     break;
+ #endif
+   default:
+@@ -731,7 +732,7 @@ static VALUE rb_gsl_linalg_QR_LQ_decompo
+       vtau = Data_Wrap_Struct(cgsl_vector_tau, 0, gsl_vector_free, tau);
+       return rb_ary_new3(2, mdecomp, vtau);
+     } else {
+-      RBASIC(argv[itmp])->klass = cgsl_vector_tau;
++      rb_obj_reveal(argv[itmp], cgsl_vector_tau);
+       return mdecomp;
+     }
+     break;
+@@ -740,7 +741,7 @@ static VALUE rb_gsl_linalg_QR_LQ_decompo
+    if (argc == itmp) {
+       return Data_Wrap_Struct(cgsl_vector_tau, 0, gsl_vector_free, tau);
+     } else {
+-      RBASIC(argv[itmp])->klass = cgsl_vector_tau;
++      rb_obj_reveal(argv[itmp], cgsl_vector_tau);
+       return INT2FIX(status);
+     }
+     break;
+@@ -1628,14 +1629,14 @@ static VALUE rb_gsl_linalg_QRLQPT_decomp
+   norm = gsl_vector_alloc(size0);
+   switch (flag) {
+   case LINALG_QRPT:
+-    RBASIC(vA)->klass = cgsl_matrix_QRPT;
++    rb_obj_reveal(vA, cgsl_matrix_QRPT);
+     vtau = Data_Wrap_Struct(cgsl_vector_tau, 0, gsl_vector_free, tau);
+     vp = Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p);
+     gsl_linalg_QRPT_decomp(A, tau, p, &signum, norm);
+     break;
+ #ifdef GSL_1_6_LATER
+   case LINALG_PTLQ:
+-    RBASIC(vA)->klass = cgsl_matrix_PTLQ;
++    rb_obj_reveal(vA, cgsl_matrix_PTLQ);
+     vtau = Data_Wrap_Struct(cgsl_vector_tau, 0, gsl_vector_free, tau);
+     vp = Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p);
+     gsl_linalg_PTLQ_decomp(A, tau, p, &signum, norm);
+--- a/ext/linalg_complex.c
++++ b/ext/linalg_complex.c
+@@ -14,6 +14,7 @@
+ #include "rb_gsl_array.h"
+ #include "rb_gsl_common.h"
+ #include "rb_gsl_linalg.h"
++#include "porting.h"
+ 
+ EXTERN VALUE mgsl_linalg;
+ EXTERN VALUE cgsl_complex;
+@@ -51,8 +52,8 @@ VALUE rb_gsl_linalg_complex_LU_decomp(in
+   case 0:
+     p = gsl_permutation_alloc(size);
+     gsl_linalg_complex_LU_decomp(m, p, &signum);
+-    if (itmp == 1) RBASIC(argv[0])->klass = cgsl_matrix_complex_LU;
+-    else RBASIC(obj)->klass = cgsl_matrix_complex_LU;
++    if (itmp == 1) rb_obj_reveal(argv[0], cgsl_matrix_complex_LU);
++    else rb_obj_reveal(obj, cgsl_matrix_complex_LU);
+     obj2 = Data_Wrap_Struct(cgsl_permutation, 0, gsl_permutation_free, p);
+     return rb_ary_new3(2, obj2, INT2FIX(signum));
+     break;
+@@ -60,8 +61,8 @@ VALUE rb_gsl_linalg_complex_LU_decomp(in
+     CHECK_PERMUTATION(argv[itmp]);
+     Data_Get_Struct(argv[itmp], gsl_permutation, p);
+     gsl_linalg_complex_LU_decomp(m, p, &signum);
+-    if (itmp == 1) RBASIC(argv[0])->klass = cgsl_matrix_complex_LU;
+-    else RBASIC(obj)->klass = cgsl_matrix_complex_LU;
++    if (itmp == 1) rb_obj_reveal(argv[0], cgsl_matrix_complex_LU);
++    else rb_obj_reveal(obj, cgsl_matrix_complex_LU);
+     return INT2FIX(signum);
+     break;
+   default:
+--- a/ext/ool.c
++++ b/ext/ool.c
+@@ -2,6 +2,7 @@
+ #include "rb_gsl.h"
+ #include "rb_gsl_array.h"
+ #include <ool/ool_conmin.h>
++#include "porting.h"
+ 
+ static VALUE cool_conmin_function;
+ static VALUE cool_conmin_constraint;
+@@ -770,7 +771,7 @@ static VALUE rb_ool_conmin_pgrad_paramet
+ 	VALUE ary;
+ 	ool_conmin_parameters_default(ool_conmin_minimizer_pgrad, (void*) &P);
+ 	ary = create_parameters_ary_pgrad(&P);
+-	RBASIC(ary)->klass = cool_conmin_pgrad_parameters;
++	rb_obj_reveal(ary, cool_conmin_pgrad_parameters);
+ 	return ary;
+ }
+ 
+@@ -780,7 +781,7 @@ static VALUE rb_ool_conmin_spg_parameter
+ 	VALUE ary;
+ 	ool_conmin_parameters_default(ool_conmin_minimizer_spg, (void*) &P);
+ 	ary = create_parameters_ary_spg(&P);	
+-	RBASIC(ary)->klass = cool_conmin_spg_parameters;	
++	rb_obj_reveal(ary, cool_conmin_spg_parameters);	
+ 	return ary;	
+ }
+ 
+@@ -790,7 +791,7 @@ static VALUE rb_ool_conmin_gencan_parame
+ 	VALUE ary;
+ 	ool_conmin_parameters_default(ool_conmin_minimizer_gencan, (void*) &P);
+ 	ary = create_parameters_ary_gencan(&P);		
+-	RBASIC(ary)->klass = cool_conmin_gencan_parameters;	
++	rb_obj_reveal(ary, cool_conmin_gencan_parameters);	
+ 	return ary;
+ }
+ 
+--- /dev/null
++++ b/ext/porting.h
+@@ -0,0 +1,5 @@
++#include <ruby/version.h>
++
++#if RUBY_API_VERSION_CODE < 20100
++  #define rb_obj_reveal(o,k) RBASIC(o)->klass = k
++#endif
+--- a/ext/vector_complex.c
++++ b/ext/vector_complex.c
+@@ -11,6 +11,7 @@
+ #include "rb_gsl_config.h"
+ #include "rb_gsl_array.h"
+ #include "rb_gsl_complex.h"
++#include "porting.h"
+ 
+ EXTERN VALUE cgsl_complex;
+ static VALUE rb_gsl_vector_complex_inner_product(int argc, VALUE *argv, VALUE obj);
+@@ -939,9 +940,9 @@ static VALUE rb_gsl_vector_complex_trans
+ static VALUE rb_gsl_vector_complex_trans2(VALUE obj)
+ {
+   if (CLASS_OF(obj) == cgsl_vector_complex) 
+-    RBASIC(obj)->klass = cgsl_vector_complex_col;
++    rb_obj_reveal(obj, cgsl_vector_complex_col);
+   else if (CLASS_OF(obj) == cgsl_vector_complex_col) 
+-    RBASIC(obj)->klass = cgsl_vector_complex;
++    rb_obj_reveal(obj, cgsl_vector_complex);
+   else {
+     rb_raise(rb_eRuntimeError, "method trans! for %s is forbidden",
+ 	     rb_class2name(CLASS_OF(obj)));
+--- a/ext/vector_source.c
++++ b/ext/vector_source.c
+@@ -36,6 +36,8 @@
+ #define VEC_VIEW_P VECTOR_INT_VIEW_P
+ #endif
+ 
++#include "porting.h"
++
+ void FUNCTION(get_range,beg_en_n)(VALUE range, BASE *beg, BASE *en, size_t *n, int *step);
+ 
+ void get_range_beg_en_n_for_size(VALUE range,
+@@ -673,15 +675,15 @@ static VALUE FUNCTION(rb_gsl_vector,tran
+ static VALUE FUNCTION(rb_gsl_vector,trans_bang)(VALUE obj)
+ {
+ #ifdef BASE_DOUBLE
+-  if (CLASS_OF(obj) == cgsl_vector) RBASIC(obj)->klass = cgsl_vector_col;
+-  else if (CLASS_OF(obj) == cgsl_vector_col) RBASIC(obj)->klass = cgsl_vector;
++  if (CLASS_OF(obj) == cgsl_vector) rb_obj_reveal(obj, cgsl_vector_col);
++  else if (CLASS_OF(obj) == cgsl_vector_col) rb_obj_reveal(obj, cgsl_vector);
+   else {
+     rb_raise(rb_eRuntimeError, "method trans! for %s is not permitted.",
+ 	     rb_class2name(CLASS_OF(obj)));
+   }	
+ #elif defined(BASE_INT)
+-  if (CLASS_OF(obj) == cgsl_vector_int) RBASIC(obj)->klass = cgsl_vector_int_col;
+-  else if (CLASS_OF(obj) == cgsl_vector_int_col) RBASIC(obj)->klass = cgsl_vector_int;
++  if (CLASS_OF(obj) == cgsl_vector_int) rb_obj_reveal(obj, cgsl_vector_int_col);
++  else if (CLASS_OF(obj) == cgsl_vector_int_col) rb_obj_reveal(obj, cgsl_vector_int);
+   else {
+     rb_raise(rb_eRuntimeError, "method trans! for %s is not permitted.",
+ 	     rb_class2name(CLASS_OF(obj)));
diff --git a/debian/patches/series b/debian/patches/series
index 7f8222f..0eb8d70 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -7,3 +7,4 @@
 20131016_fix_test_typo.patch
 20131016_test_output_less_verbose.patch
 20131016_deactivate_failing_tests.patch
+port-to-ruby2.1.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-gsl.git



More information about the Pkg-ruby-extras-commits mailing list