[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dennou-ruby:002882] Re: ruby-1.9.0
- To: dennou-ruby@xxxxxxxxxxx
- Subject: [dennou-ruby:002882] Re: ruby-1.9.0
- From: ÂçÄÍÀ®ÆÁ<otsuka@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 01 Feb 2008 22:46:06 +0900
大塚@京大です。
NArray を ruby 1.9.0 で使うためのパッチですが、
前回作ったものには問題が残っていたので作り直しました。
もしも使っておられる方は更新お願いします。
> NArray を ruby 1.9 で使うためのパッチを作ったので投げます。
> アドホックなものですが、とりあえず使ってみたい方はどうぞ。
--
京都大学大学院理学研究科
気象学研究室 D2
大塚成徳 (Shigenori OTSUKA)
email: otsuka@xxxxxxxxxxxxxxxxxx
diff -Naur narray-0.5.9p2-org/na_array.c narray-0.5.9p2/na_array.c
--- narray-0.5.9p2-org/na_array.c 2005-08-05 13:36:28.000000000 +0900
+++ narray-0.5.9p2/na_array.c 2008-02-01 16:37:11.609375000 +0900
@@ -560,7 +560,7 @@
{
VALUE str=Qnil, tmp;
int max_col = 77;
- int sep_len = RSTRING(sep)->len;
+ int sep_len = RSTRING_LEN(sep);
if (n>0)
(*tostr)(&str,p2);
@@ -571,7 +571,7 @@
if (!NIL_P(sep)) rb_str_concat(str, sep);
- if (RSTRING(str)->len + RSTRING(tmp)->len + rank*4 + sep_len < max_col) {
+ if (RSTRING_LEN(str) + RSTRING_LEN(tmp) + rank*4 + sep_len < max_col) {
rb_str_concat(str, tmp);
} else {
rb_str_cat(str,"...",3);
diff -Naur narray-0.5.9p2-org/na_index.c narray-0.5.9p2/na_index.c
--- narray-0.5.9p2-org/na_index.c 2006-08-09 01:10:11.000000000 +0900
+++ narray-0.5.9p2/na_index.c 2008-02-01 20:51:29.515625000 +0900
@@ -23,7 +23,7 @@
sl->idx = NULL;
/* Beginning */
- vbeg = rb_ivar_get(obj, na_id_beg);
+ vbeg = rb_funcall(obj, na_id_beg, 0);
if (vbeg==Qnil) /* First is nil */
beg = 0;
else
@@ -31,7 +31,7 @@
if (beg<0) beg += size;
/* End */
- vend = rb_ivar_get(obj, na_id_end);
+ vend = rb_funcall(obj, na_id_end, 0);
if (vend==Qnil) { /* Last is nil */
sl->beg = beg;
sl->step = 1;
diff -Naur narray-0.5.9p2-org/narray.c narray-0.5.9p2/narray.c
--- narray-0.5.9p2-org/narray.c 2006-08-09 01:10:11.000000000 +0900
+++ narray-0.5.9p2/narray.c 2008-02-01 16:34:36.953125000 +0900
@@ -10,13 +10,13 @@
*/
#define NARRAY_C
#include <ruby.h>
-#include <version.h>
+//#include <version.h>
#include "narray.h"
#include "narray_local.h"
-#if RUBY_VERSION_CODE < 150
-#define NARRAY_GC
-#endif
+//#if RUBY_VERSION_CODE < 150
+//#define NARRAY_GC
+//#endif
/* global variables within this module */
VALUE cNArray, cNArrayScalar, cComplex;
@@ -170,7 +170,7 @@
while (v) {
if (v == cNArray || RCLASS(v)->m_tbl == RCLASS(cNArray)->m_tbl)
return;
- v = RCLASS(v)->super;
+ v = RCLASS_SUPER(v);
}
rb_raise(rb_eRuntimeError, "need NArray or its subclass");
}
@@ -378,7 +378,7 @@
}
if (TYPE(v)==T_STRING) {
for (i=1; i<NA_NTYPES; i++) {
- if ( !strncmp( RSTRING(v)->ptr, na_typestring[i], RSTRING(v)->len) )
+ if ( !strncmp( RSTRING_PTR(v), na_typestring[i], RSTRING_LEN(v)) )
return i;
}
}
@@ -602,7 +602,7 @@
type = na_get_typecode(argv[0]);
- str_len = RSTRING(str)->len;
+ str_len = RSTRING_LEN(str);
if (argc == 1) {
rank = 1;
@@ -622,7 +622,7 @@
v = na_make_object( type, rank, shape, cNArray );
GetNArray(v,ary);
- memcpy( ary->ptr, RSTRING(str)->ptr, ary->total*na_sizeof[type] );
+ memcpy( ary->ptr, RSTRING_PTR(str), ary->total*na_sizeof[type] );
return v;
}