rsruby 0.5.1 → 0.5.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,9 @@
1
+ = 0.5.1.1 2009-02-05
2
+
3
+ * quick hack for ruby 1.9.1
4
+ * test still fails around Complex
5
+ * fix RSRuby.shutdown
6
+
1
7
  = 0.5.1 2008-11-11
2
8
 
3
9
  * removed #include of Rdevices.h so installation is possible with R 2.8.0 packages
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift("./lib")
4
4
  $LOAD_PATH.unshift("./ext")
5
5
 
6
6
  gem_name = RUBY_PLATFORM !~ /mswin32$/ ? "rsruby" : "rsrubywin"
7
- hoe = Hoe.new(gem_name,'0.5.1') do |p|
7
+ hoe = Hoe.new(gem_name,'0.5.1.1') do |p|
8
8
 
9
9
  p.author = "Alex Gutteridge, Ben J Woodcroft"
10
10
  p.email = "ag357@cam.ac.uk, b.woodcroft@pgrad.unimelb.edu.au"
@@ -89,7 +89,7 @@ SEXP ruby_to_R(VALUE obj)
89
89
  else if (!NIL_P(rb_check_string_type(obj)))
90
90
  {
91
91
  PROTECT(robj = NEW_STRING(1));
92
- SET_STRING_ELT(robj, 0, COPY_TO_USER_STRING(RSTRING(obj)->ptr));
92
+ SET_STRING_ELT(robj, 0, COPY_TO_USER_STRING(RSTRING_PTR(obj)));
93
93
  }
94
94
  else if (!NIL_P(rb_check_array_type(obj)))
95
95
  {
@@ -103,7 +103,7 @@ SEXP ruby_to_R(VALUE obj)
103
103
  {
104
104
  str = rb_funcall(obj,rb_intern("inspect"),0);
105
105
  str = rb_funcall(str,rb_intern("slice"),2,INT2NUM(0),INT2NUM(60));
106
- sprintf(buf,"Unsupported object '%s' passed to R.\n",RSTRING(str)->ptr);
106
+ sprintf(buf,"Unsupported object '%s' passed to R.\n",RSTRING_PTR(str));
107
107
  rb_raise(rb_eArgError,buf);
108
108
  PROTECT(robj = NULL); /* Protected to avoid stack inbalance */
109
109
  }
@@ -141,13 +141,13 @@ SEXP array_to_R(VALUE obj)
141
141
  //Probably unnessecary but just in case
142
142
  obj = rb_check_array_type(obj);
143
143
 
144
- if (RARRAY(obj)->len == 0)
144
+ if (RARRAY_LEN(obj) == 0)
145
145
  return R_NilValue;
146
146
 
147
- PROTECT(robj = NEW_LIST(RARRAY(obj)->len));
147
+ PROTECT(robj = NEW_LIST(RARRAY_LEN(obj)));
148
148
 
149
149
  state = -1;
150
- for (i=0; i<RARRAY(obj)->len; i++) {
150
+ for (i=0; i<RARRAY_LEN(obj); i++) {
151
151
 
152
152
  it = rb_ary_entry(obj, i);
153
153
 
@@ -199,12 +199,6 @@ hash_to_R(VALUE obj)
199
199
  VALUE keys, values;
200
200
  SEXP robj, names;
201
201
 
202
- //TODO - Baffling. Not sure what's wrong with these functions?
203
- //rb_hash_keys(proc_table);
204
- //rb_hash_values(proc_table);
205
- //rb_hash_size(proc_table);
206
- //compiles, but complains they are undefined symbols when run...
207
-
208
202
  if (FIX2INT(rb_funcall(obj,rb_intern("size"),0)) == 0)
209
203
  return R_NilValue;
210
204
 
@@ -296,7 +290,7 @@ to_ruby_basic(SEXP robj, VALUE *obj)
296
290
 
297
291
  status = to_ruby_vector(robj, &tmp, BASIC_CONVERSION);
298
292
 
299
- if(status==1 && TYPE(tmp) == T_ARRAY && RARRAY(tmp)->len == 1)
293
+ if(status==1 && TYPE(tmp) == T_ARRAY && RARRAY_LEN(tmp) == 1)
300
294
  {
301
295
  *obj = rb_ary_entry(tmp, 0);
302
296
  }
@@ -377,10 +371,8 @@ to_ruby_vector(SEXP robj, VALUE *obj, int mode)
377
371
  case CPLXSXP:
378
372
  complexes = COMPLEX(robj);
379
373
 
380
- params[0] = rb_float_new(complexes[i].r);
381
- params[1] = rb_float_new(complexes[i].i);
382
-
383
- if (!(it = rb_class_new_instance(2, params, rb_const_get(rb_cObject, rb_intern("Complex")))))
374
+ if (!(it = rb_complex_new(rb_float_new(complexes[i].r),
375
+ rb_float_new(complexes[i].i))))
384
376
 
385
377
  return -1;
386
378
  break;
@@ -600,7 +592,7 @@ VALUE to_ruby_hash(VALUE obj, SEXP names)
600
592
  VALUE it, hash;
601
593
  char *name;
602
594
 
603
- if ((len = RARRAY(obj)->len) < 0)
595
+ if ((len = RARRAY_LEN(obj)) < 0)
604
596
  return Qnil;
605
597
 
606
598
  hash = rb_hash_new();
data/ext/robj.c CHANGED
@@ -49,7 +49,7 @@ VALUE RObj_lcall(VALUE self, VALUE args){
49
49
  args = rb_check_array_type(args);
50
50
 
51
51
  // A SEXP with the function to call and the arguments
52
- PROTECT(exp = allocVector(LANGSXP, (RARRAY(args)->len)+1));
52
+ PROTECT(exp = allocVector(LANGSXP, RARRAY_LEN(args)+1));
53
53
  e = exp;
54
54
 
55
55
  Data_Get_Struct(self, struct SEXPREC, r_obj);
@@ -97,7 +97,7 @@ VALUE RObj_init_lcall(VALUE self, VALUE args){
97
97
  args = rb_check_array_type(args);
98
98
 
99
99
  // A SEXP with the function to call and the arguments
100
- PROTECT(exp = allocVector(LANGSXP, (RARRAY(args)->len)+1));
100
+ PROTECT(exp = allocVector(LANGSXP, RARRAY_LEN(args)+1));
101
101
  e = exp;
102
102
 
103
103
  Data_Get_Struct(self, struct SEXPREC, r_obj);
@@ -137,10 +137,10 @@ make_argl(VALUE args, SEXP *e)
137
137
  //Ensure we have an array
138
138
  args = rb_check_array_type(args);
139
139
 
140
- for (i=0; i<RARRAY(args)->len; i++) {
140
+ for (i=0; i<RARRAY_LEN(args); i++) {
141
141
  pair = rb_ary_entry(args, i);
142
142
  pair = rb_check_array_type(pair);
143
- if(RARRAY(pair)->len != 2)
143
+ if(RARRAY_LEN(pair) != 2)
144
144
  rb_raise(rb_eArgError,"Misformed argument in lcall\n");
145
145
 
146
146
  /* Name must be a string. If it is empty string '' then no name*/
@@ -158,9 +158,9 @@ make_argl(VALUE args, SEXP *e)
158
158
  SETCAR(*e, rvalue);
159
159
 
160
160
  /* Add name (if present) */
161
- if (RSTRING(name)->len > 0)
161
+ if (RSTRING_LEN(name) > 0)
162
162
  {
163
- SET_TAG(*e, Rf_install(RSTRING(name)->ptr));
163
+ SET_TAG(*e, Rf_install(RSTRING_PTR(name)));
164
164
  }
165
165
 
166
166
  /* Move index to new end of call */
@@ -177,11 +177,11 @@ VALUE RObj_to_ruby(VALUE self, VALUE args){
177
177
 
178
178
  args = rb_check_array_type(args);
179
179
 
180
- if (RARRAY(args)->len > 1){
180
+ if (RARRAY_LEN(args) > 1){
181
181
  rb_raise(rb_eArgError,"Too many arguments in to_ruby\n");
182
182
  }
183
183
 
184
- if (RARRAY(args)->len == 0){
184
+ if (RARRAY_LEN(args) == 0){
185
185
  conv = NUM2INT(rb_iv_get(RSRUBY,"@default_mode"));
186
186
  } else {
187
187
  conv = NUM2INT(rb_ary_entry(args,0));
@@ -76,7 +76,7 @@ VALUE get_fun(VALUE self, VALUE name){
76
76
 
77
77
  str = StringValue(name);
78
78
 
79
- cstr_name = RSTRING(str)->ptr;
79
+ cstr_name = RSTRING_PTR(str);
80
80
 
81
81
  robj = (SEXP)get_fun_from_name(cstr_name);
82
82
  if (!robj)
@@ -101,7 +101,7 @@ void r_finalize(void)
101
101
  R_dot_Last();
102
102
  R_RunExitFinalizers();
103
103
  CleanEd();
104
- KillAllDevices();
104
+ Rf_KillAllDevices();
105
105
 
106
106
  if((tmpdir = getenv("R_SESSION_TMPDIR"))) {
107
107
  snprintf((char *)buf, 1024, "rm -rf %s", tmpdir);
@@ -40,11 +40,11 @@ class TestModes < Test::Unit::TestCase
40
40
  RSRuby.set_default_mode(RSRuby::VECTOR_CONVERSION)
41
41
  assert_equal(sequence.to_ruby, [1,2,3])
42
42
 
43
- @r.class_table['htest'] = lambda{5}
43
+ @r.class_table['htest'] = lambda{|x| 5}
44
44
  RSRuby.set_default_mode(RSRuby::CLASS_CONVERSION)
45
45
  assert_equal(t_test.to_ruby, 5)
46
46
 
47
- @r.proc_table[lambda{true}] = lambda{return 6}
47
+ @r.proc_table[lambda{|x| true}] = lambda{|x| return 6}
48
48
  RSRuby.set_default_mode(RSRuby::PROC_CONVERSION)
49
49
  assert_equal(t_test.to_ruby, 6)
50
50
  end
@@ -77,7 +77,7 @@ class TestModes < Test::Unit::TestCase
77
77
  assert_equal(@r.array(1,3).class, @r.array.class)
78
78
 
79
79
  assert_equal(@r.seq(1,3), [1,2,3])
80
- @r.class_table['htest'] = lambda{5}
80
+ @r.class_table['htest'] = lambda{|x| 5}
81
81
  assert_equal(@r.t_test([1,2,3]), 5)
82
82
  end
83
83
 
@@ -149,7 +149,7 @@ class TestModes < Test::Unit::TestCase
149
149
 
150
150
  def test_class_table
151
151
 
152
- @r.class_table['htest'] = lambda{'htest'}
152
+ @r.class_table['htest'] = lambda{|x| 'htest'}
153
153
  @r.class_table['data.frame'] = lambda{|x|
154
154
  if @r['[['].call(x,1).length > 2
155
155
  return 5
@@ -170,9 +170,9 @@ class TestModes < Test::Unit::TestCase
170
170
  f = @r.class__(@r.c(4),'foo')
171
171
  g = @r.class__(@r.c(4), ['bar','foo'])
172
172
 
173
- @r.class_table['foo'] = lambda{'foo'}
174
- @r.class_table['bar'] = lambda{'bar'}
175
- @r.class_table[['bar','foo']] = lambda{5}
173
+ @r.class_table['foo'] = lambda{|x| 'foo'}
174
+ @r.class_table['bar'] = lambda{|x| 'bar'}
175
+ @r.class_table[['bar','foo']] = lambda{|x| 5}
176
176
 
177
177
  RSRuby.set_default_mode(RSRuby::CLASS_CONVERSION)
178
178
  assert_equal(f.to_ruby, 'foo')
@@ -115,7 +115,7 @@ class TestToR < Test::Unit::TestCase
115
115
  def test_instances_not_convertible
116
116
  foo = Foo.new
117
117
  assert_raises(ArgumentError){@r.c(foo)}
118
- end
118
+ end
119
119
 
120
120
  def test_as_r_method
121
121
  @r.c.autoconvert(RSRuby::BASIC_CONVERSION)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Gutteridge, Ben J Woodcroft
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-26 00:00:00 +00:00
12
+ date: 2009-02-11 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies: []
15
15