R4rb 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c91842f538e4ba2118bc1b284774ff00d3c09ce2561faec8c0734ced68d6b4ae
4
- data.tar.gz: 3d7bddd32a1ec1d3dd1bcabce5ad398a3440036aa8744b4a0c4204d601083517
3
+ metadata.gz: 7b3fd5ec7a4bb58571955e8cdf5e486f24b46fc6dde78ef4c45b3ead009896f0
4
+ data.tar.gz: cb8138744d0696efd35ddc54c4a7270592ea140d623b4152c1a85276edc18dd0
5
5
  SHA512:
6
- metadata.gz: 3896a52935a0d5b932e4e458eb07187af2839c0a1edbfab9534d0a9d6adc0e47f5f51e00dbd7ec7a29b16c932abf0968e9bc6876c6835de3e13299eab760fde1
7
- data.tar.gz: dbe537547e1134f8d5c0166fa7bf250749d15d66b98f0170a85cbad660c8aa6fb151f7cb143e3bee41cbb4a220efd1e603890e713a8e2cdbdd5b101f57cbcba4
6
+ metadata.gz: 025c1736d4ed8242f123e63d7748141ee7c718ed9feda2fa08767ddb3b31ec897c6b5c219fb10ba04076eb9bb9697ed979a5c651fb1940740c1b192cc0314451
7
+ data.tar.gz: df29b358f0849391e17cf8dc5c0c534e0e222a046d4e67b7344d8be24f6b119c5c730cd575b164674f7932d2e2fbb1f3f6b304d01fd98678aa2600ae0744de3e
data/R4rb.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rubygems/package_task'
3
3
 
4
4
  pkg_NAME='R4rb'
5
- pkg_VERSION='1.1.0'
5
+ pkg_VERSION='1.1.1'
6
6
  pkg_FILES=FileList[
7
7
  'Rakefile','R4rb.gemspec',
8
8
  'ext/R4rb/*.c',
@@ -0,0 +1,600 @@
1
+ /**********************************************************************
2
+
3
+ R4rb.c
4
+
5
+ **********************************************************************/
6
+ #include <stdio.h>
7
+ #include <string.h>
8
+
9
+ #include "ruby.h"
10
+ #include "ruby/version.h"
11
+ #include <R.h>
12
+ #include <Rinternals.h>
13
+ #include <Rdefines.h>
14
+ #include <Rversion.h>
15
+
16
+
17
+ /* From Parse.h -- must find better solution: */
18
+ #define PARSE_NULL 0
19
+ #define PARSE_OK 1
20
+ #define PARSE_INCOMPLETE 2
21
+ #define PARSE_ERROR 3
22
+ #define PARSE_EOF 4
23
+
24
+
25
+ #define Need_Integer(x) (x) = rb_Integer(x)
26
+ #define Need_Float(x) (x) = rb_Float(x)
27
+ #define Need_Float2(x,y) {\
28
+ Need_Float(x);\
29
+ Need_Float(y);\
30
+ }
31
+ #define Need_Float3(x,y,z) {\
32
+ Need_Float(x);\
33
+ Need_Float(y);\
34
+ Need_Float(z);\
35
+ }
36
+
37
+ #if (R_VERSION < 132352) /* before 2.5 to check!*/
38
+ SEXP R_ParseVector(SEXP, int, int *);
39
+ #define RR_ParseVector(x,y,z) R_ParseVector(x, y, z)
40
+ #else
41
+ SEXP R_ParseVector(SEXP, int, int *,SEXP);
42
+ #define RR_ParseVector(x,y,z) R_ParseVector(x, y, z, R_NilValue)
43
+ #endif
44
+
45
+ /************* INIT *********************/
46
+
47
+ extern Rboolean R_Interactive;
48
+ extern int Rf_initEmbeddedR(int argc, char *argv[]);
49
+
50
+ VALUE R2rb_init(VALUE obj, VALUE args)
51
+ {
52
+ char **argv;//={"REmbed","--save","--slave","--quiet"};
53
+ int i,argc;//=sizeof(argv)/sizeof(argv[0]);
54
+ VALUE tmp;
55
+
56
+ argc=RARRAY_LEN(args) + 1;
57
+ //printf("argc=%d\n",argc);
58
+ argv=malloc(sizeof(char*)*argc);
59
+ argv[0]="REmbed";
60
+ for (i = 1 ; i < argc ; i++) {
61
+ tmp=rb_ary_entry(args,i-1);
62
+ argv[i]=StringValuePtr(tmp);
63
+ //printf("argv[%d]=%s\n",i,argv[i]);
64
+ }
65
+ //printf("argc=%d\n",argc);
66
+ Rf_initEmbeddedR(argc,argv);
67
+ R_Interactive = FALSE;
68
+ return Qtrue;
69
+ }
70
+
71
+ /***************** EVAL **********************/
72
+
73
+ VALUE R2rb_eval(VALUE obj, VALUE cmd, VALUE print)
74
+ {
75
+ char *cmdString;
76
+ int nbCmds;
77
+ VALUE tmp;
78
+ int errorOccurred,status, i;
79
+
80
+ SEXP text, expr, ans=R_NilValue /* -Wall */;
81
+
82
+
83
+ //printf("Avant parsing\n");
84
+
85
+ nbCmds=RARRAY_LEN(cmd);
86
+
87
+ //printf("nbCmds : %d\n",nbCmds);
88
+
89
+ text = PROTECT(allocVector(STRSXP, nbCmds));
90
+ for (i = 0 ; i < nbCmds ; i++) {
91
+ tmp=rb_ary_entry(cmd,i);
92
+ cmdString=StringValuePtr(tmp);
93
+ SET_STRING_ELT(text, i, mkChar(cmdString));
94
+ }
95
+ expr = PROTECT(RR_ParseVector(text, -1, &status));
96
+
97
+ if (status != PARSE_OK) {
98
+ //printf("Parsing error (status=%d) in:\n",status);
99
+ for (i = 0 ; i < nbCmds ; i++) {
100
+ tmp=rb_ary_entry(cmd,i);
101
+ cmdString=StringValuePtr(tmp);
102
+ //printf("%s\n",cmdString);
103
+ }
104
+ UNPROTECT(2);
105
+ return Qfalse;
106
+ }
107
+
108
+ /* Note that expr becomes an EXPRSXP and hence we need the loop
109
+ below (a straight eval(expr, R_GlobalEnv) won't work) */
110
+ {
111
+ for(i = 0 ; i < nbCmds ; i++)
112
+ ans = R_tryEval(VECTOR_ELT(expr, i),NULL, &errorOccurred);
113
+ if(errorOccurred) {
114
+ //fprintf(stderr, "Caught another error calling sqrt()\n");
115
+ fflush(stderr);
116
+ UNPROTECT(2);
117
+ return Qfalse;
118
+ }
119
+
120
+ if (print != Qnil) {
121
+ Rf_PrintValue(ans);
122
+ }
123
+ }
124
+
125
+ UNPROTECT(2);
126
+ return Qtrue;
127
+ }
128
+
129
+ /***************** PARSE **********************/
130
+
131
+ VALUE R2rb_parse(VALUE obj, VALUE cmd,VALUE print)
132
+ {
133
+ char *cmdString;
134
+ int nbCmds;
135
+ VALUE tmp;
136
+ int status,i;
137
+
138
+ SEXP text, expr, ans=R_NilValue /* -Wall */;
139
+
140
+
141
+ //printf("Avant parsing\n");
142
+
143
+ nbCmds=RARRAY_LEN(cmd);
144
+
145
+ //printf("nbCmds : %d\n",nbCmds);
146
+
147
+ text = PROTECT(allocVector(STRSXP, nbCmds));
148
+ for (i = 0 ; i < nbCmds ; i++) {
149
+ tmp=rb_ary_entry(cmd,i);
150
+ cmdString=StringValuePtr(tmp);
151
+ SET_STRING_ELT(text, i, mkChar(cmdString));
152
+ }
153
+ expr = PROTECT(RR_ParseVector(text, -1, &status));
154
+
155
+ if (status != PARSE_OK) {
156
+ if (print != Qnil) printf("Parsing error (status=%d) in:\n",status);
157
+ for (i = 0 ; i < nbCmds ; i++) {
158
+ tmp=rb_ary_entry(cmd,i);
159
+ cmdString=StringValuePtr(tmp);
160
+ if (print != Qnil) printf("%s\n",cmdString);
161
+ }
162
+ //UNPROTECT(2);
163
+ //return Qfalse;
164
+ }
165
+ UNPROTECT(2);
166
+ //return Qtrue;
167
+ return INT2FIX(status);
168
+ }
169
+
170
+
171
+ /*****************************************
172
+
173
+ Interface to get values of RObj from Ruby
174
+ The basic idea : no copy of the R Vector
175
+ just methods to extract value !!!
176
+
177
+ ******************************************/
178
+
179
+ // used internally !!! -> eval only one string line
180
+ SEXP util_eval1string(VALUE cmd)
181
+ {
182
+ char *cmdString;
183
+ int errorOccurred,status, i;
184
+
185
+ SEXP text, expr, ans=R_NilValue /* -Wall */;
186
+
187
+ text = PROTECT(allocVector(STRSXP, 1));
188
+ cmdString=StringValuePtr(cmd);
189
+ //printf("cmd: %s\n",cmdString);
190
+ SET_STRING_ELT(text, 0, mkChar(cmdString));
191
+ expr = PROTECT(RR_ParseVector(text, -1, &status));
192
+ if (status != PARSE_OK) {
193
+ printf("Parsing error in: %s\n",cmdString);
194
+ UNPROTECT(2);
195
+ return R_NilValue;
196
+ }
197
+ /* Note that expr becomes an EXPRSXP and hence we need the loop
198
+ below (a straight eval(expr, R_GlobalEnv) won't work) */
199
+ ans = R_tryEval(VECTOR_ELT(expr, 0),R_GlobalEnv,&errorOccurred);
200
+ //ans = eval(VECTOR_ELT(expr, 0),R_GlobalEnv);
201
+ if(errorOccurred) {
202
+ //fflush(stderr);
203
+ printf("Exec error in: %s\n",cmdString);
204
+ UNPROTECT(2);
205
+ return R_NilValue;
206
+ }
207
+ UNPROTECT(2);
208
+ return ans;
209
+ }
210
+
211
+ int util_isVector(SEXP ans)
212
+ {
213
+ return ((!isNewList(ans)) & isVector(ans));
214
+ }
215
+
216
+ int util_isVariable(VALUE self)
217
+ {
218
+ VALUE tmp;
219
+ tmp=rb_iv_get(self,"@type");
220
+ return strcmp(StringValuePtr(tmp),"var")==0;
221
+ }
222
+
223
+ SEXP util_getVar(VALUE self)
224
+ {
225
+ SEXP ans;
226
+ char *name;
227
+ VALUE tmp;
228
+
229
+ tmp=rb_iv_get(self,"@name");
230
+ name=StringValuePtr(tmp);
231
+ if(util_isVariable(self)) {
232
+ ans = findVar(install(name),R_GlobalEnv); //currently in R_GlobalEnv!!!
233
+ } else {
234
+ //printf("getVar:%s\n",name);
235
+ ans=util_eval1string(rb_iv_get(self,"@name"));
236
+ if(ans==R_NilValue) return ans;
237
+ }
238
+ if(!util_isVector(ans)) return R_NilValue;
239
+ return ans;
240
+ }
241
+
242
+ //with argument!! necessarily an expression and not a variable
243
+ SEXP util_getExpr_with_arg(VALUE self)
244
+ {
245
+ SEXP ans;
246
+ VALUE tmp;
247
+
248
+ //printf("getVar:%s\n",name);
249
+ tmp=rb_str_dup(rb_iv_get(self,"@arg"));
250
+ ans=util_eval1string(rb_str_cat2(rb_str_dup(rb_iv_get(self,"@name")),StringValuePtr(tmp)));
251
+ if(ans==R_NilValue) return ans;
252
+ if(!util_isVector(ans)) return R_NilValue;
253
+ return ans;
254
+ }
255
+
256
+
257
+ VALUE util_SEXP2VALUE(SEXP ans)
258
+ {
259
+ VALUE res;
260
+ int n,i;
261
+ Rcomplex cpl;
262
+ VALUE res2;
263
+
264
+ n=length(ans);
265
+ res = rb_ary_new2(n);
266
+ switch(TYPEOF(ans)) {
267
+ case REALSXP:
268
+ for(i=0;i<n;i++) {
269
+ rb_ary_store(res,i,rb_float_new(REAL(ans)[i]));
270
+ }
271
+ break;
272
+ case INTSXP:
273
+ for(i=0;i<n;i++) {
274
+ rb_ary_store(res,i,INT2FIX(INTEGER(ans)[i]));
275
+ }
276
+ break;
277
+ case LGLSXP:
278
+ for(i=0;i<n;i++) {
279
+ rb_ary_store(res,i,(INTEGER(ans)[i] ? Qtrue : Qfalse));
280
+ }
281
+ break;
282
+ case STRSXP:
283
+ for(i=0;i<n;i++) {
284
+ rb_ary_store(res,i,rb_str_new2(CHAR(STRING_ELT(ans,i))));
285
+ }
286
+ break;
287
+ case CPLXSXP:
288
+ rb_require("complex");
289
+ for(i=0;i<n;i++) {
290
+ cpl=COMPLEX(ans)[i];
291
+ res2 = rb_eval_string("Complex.new(0,0)");
292
+ rb_iv_set(res2,"@real",rb_float_new(cpl.r));
293
+ rb_iv_set(res2,"@image",rb_float_new(cpl.i));
294
+ rb_ary_store(res,i,res2);
295
+ }
296
+ break;
297
+ }
298
+
299
+ return res;
300
+ }
301
+
302
+
303
+ SEXP util_VALUE2SEXP(VALUE arr)
304
+ {
305
+ SEXP ans;
306
+ VALUE res,class,tmp;
307
+ int i,n=0;
308
+
309
+ if(!rb_obj_is_kind_of(arr,rb_cArray)) {
310
+ n=1;
311
+ res = rb_ary_new2(1);
312
+ rb_ary_push(res,arr);
313
+ arr=res;
314
+ } else {
315
+ n=RARRAY_LEN(arr);
316
+ }
317
+
318
+ class=rb_class_of(rb_ary_entry(arr,0));
319
+
320
+ if(class==rb_cFloat) {
321
+ PROTECT(ans=allocVector(REALSXP,n));
322
+ for(i=0;i<n;i++) {
323
+ REAL(ans)[i]=NUM2DBL(rb_ary_entry(arr,i));
324
+ }
325
+ #if RUBY_API_VERSION_CODE >= 20400
326
+ } else if(class==rb_cInteger) {
327
+ #else
328
+ } else if(class==rb_cFixnum || class==rb_cBignum) {
329
+ #endif
330
+ PROTECT(ans=allocVector(INTSXP,n));
331
+ for(i=0;i<n;i++) {
332
+ INTEGER(ans)[i]=NUM2INT(rb_ary_entry(arr,i));
333
+ }
334
+ } else if(class==rb_cTrueClass || class==rb_cFalseClass) {
335
+ PROTECT(ans=allocVector(LGLSXP,n));
336
+ for(i=0;i<n;i++) {
337
+ LOGICAL(ans)[i]=(rb_class_of(rb_ary_entry(arr,i))==rb_cFalseClass ? FALSE : TRUE);
338
+ }
339
+ } else if(class==rb_cString) {
340
+ PROTECT(ans=allocVector(STRSXP,n));
341
+ for(i=0;i<n;i++) {
342
+ tmp=rb_ary_entry(arr,i);
343
+ SET_STRING_ELT(ans,i,mkChar(StringValuePtr(tmp)));
344
+ }
345
+ } else ans=R_NilValue;
346
+
347
+ if(n>0) UNPROTECT(1);
348
+ return ans;
349
+ }
350
+
351
+
352
+
353
+ VALUE RVect_initialize(VALUE self, VALUE name)
354
+ {
355
+ rb_iv_set(self,"@name",name);
356
+ rb_iv_set(self,"@type",rb_str_new2("var"));
357
+ rb_iv_set(self,"@arg",rb_str_new2(""));
358
+ return self;
359
+ }
360
+
361
+ VALUE RVect_isValid(VALUE self)
362
+ {
363
+ SEXP ans;
364
+ char *name;
365
+
366
+ #ifdef cqls
367
+ VALUE tmp;
368
+ tmp=rb_iv_get(self,"@name");
369
+ name = StringValuePtr(tmp);
370
+ ans = findVar(install(name),R_GlobalEnv); //currently in R_GlobalEnv!!!
371
+ #else
372
+ ans = util_getVar(self);
373
+ #endif
374
+ if(!util_isVector(ans)) {
375
+ #ifndef cqls
376
+ VALUE tmp;
377
+ tmp=rb_iv_get(self,"@name");
378
+ name = StringValuePtr(tmp);
379
+ #endif
380
+ rb_warn("%s is not a R vector !!!",name); //TODO name not defined
381
+ return Qfalse;
382
+ }
383
+ return Qtrue;
384
+ }
385
+
386
+ VALUE RVect_length(VALUE self)
387
+ {
388
+ SEXP ans;
389
+ char *name;
390
+ #ifdef cqls
391
+ VALUE tmp;
392
+ tmp=rb_iv_get(self,"@name");
393
+ if(!RVect_isValid(self)) return Qnil;
394
+ name = StringValuePtr(tmp);
395
+ ans = findVar(install(name),R_GlobalEnv); //currently in R_GlobalEnv!!!
396
+ #else
397
+ ans = util_getVar(self);
398
+
399
+ if(ans==R_NilValue) {
400
+ //printf("Sortie de length avec nil\n");
401
+ return Qnil;
402
+ }
403
+ #endif
404
+ return INT2NUM(length(ans));
405
+ }
406
+
407
+ VALUE RVect_get(VALUE self)
408
+ {
409
+ SEXP ans;
410
+ VALUE res;
411
+ char *name;
412
+ int n,i;
413
+ Rcomplex cpl;
414
+ VALUE res2;
415
+
416
+ //#define cqls
417
+ #ifdef cqls
418
+ VALUE tmp;
419
+ if(!RVect_isValid(self)) return Qnil;
420
+ #else
421
+ ans = util_getVar(self);
422
+
423
+ if(ans==R_NilValue) {
424
+ //printf("Sortie de get avec nil\n");
425
+ return Qnil;
426
+ }
427
+ #endif
428
+ #ifdef cqls
429
+ tmp=rb_iv_get(self,"@name");
430
+ name = StringValuePtr(tmp);
431
+ ans = findVar(install(name),R_GlobalEnv);
432
+ #endif
433
+
434
+ res=util_SEXP2VALUE(ans);
435
+ if(length(ans)==1) res=rb_ary_entry(res,0);
436
+ return res;
437
+ }
438
+
439
+ VALUE RVect_get_with_arg(VALUE self)
440
+ {
441
+ SEXP ans;
442
+ VALUE res;
443
+ char *name;
444
+ int n,i;
445
+ Rcomplex cpl;
446
+ VALUE res2;
447
+
448
+ ans = util_getExpr_with_arg(self);
449
+
450
+ if(ans==R_NilValue) {
451
+ //printf("Sortie de get avec nil\n");
452
+ return Qnil;
453
+ }
454
+ res=util_SEXP2VALUE(ans);
455
+
456
+ //printf("RVect_get_with_arg: length(ans)=%d\n",length(ans));
457
+ if (length(ans)==1) res=rb_ary_entry(res,0);
458
+
459
+ return res;
460
+ }
461
+
462
+
463
+
464
+ // faster than self.to_a[index]
465
+ VALUE RVect_aref(VALUE self, VALUE index)
466
+ {
467
+ SEXP ans;
468
+ VALUE res;
469
+ char *name;
470
+ int n,i;
471
+ Rcomplex cpl;
472
+ #ifdef cqls
473
+ VALUE tmp;
474
+ #endif
475
+ i = FIX2INT(index);
476
+
477
+ #ifdef cqls
478
+ if(!RVect_isValid(self)) return Qnil;
479
+ tmp=rb_iv_get(self,"@name");
480
+ name = StringValuePtr(tmp);
481
+ ans = findVar(install(name),R_GlobalEnv); //currently in R_GlobalEnv!!!
482
+ #else
483
+ ans = util_getVar(self);
484
+ #endif
485
+ n=length(ans);
486
+ //printf("i=%d and n=%d\n",i,n);
487
+ if(i<n) {
488
+ switch(TYPEOF(ans)) {
489
+ case REALSXP:
490
+ res=rb_float_new(REAL(ans)[i]);
491
+ break;
492
+ case INTSXP:
493
+ res=INT2FIX(INTEGER(ans)[i]);
494
+ break;
495
+ case LGLSXP:
496
+ res=(INTEGER(ans)[i] ? Qtrue : Qfalse);
497
+ break;
498
+ case STRSXP:
499
+ res=rb_str_new2(CHAR(STRING_ELT(ans,i)));
500
+ break;
501
+ case CPLXSXP:
502
+ rb_require("complex");
503
+ cpl=COMPLEX(ans)[i];
504
+ res = rb_eval_string("Complex.new(0,0)");
505
+ rb_iv_set(res,"@real",rb_float_new(cpl.r));
506
+ rb_iv_set(res,"@image",rb_float_new(cpl.i));
507
+ break;
508
+ }
509
+ } else {
510
+ res = Qnil;
511
+ }
512
+ return res;
513
+ }
514
+
515
+ VALUE RVect_set(VALUE self,VALUE arr)
516
+ {
517
+ SEXP ans;
518
+ char *name;
519
+ VALUE tmp;
520
+
521
+ ans=util_VALUE2SEXP(arr);
522
+
523
+ tmp=rb_iv_get(self,"@name");
524
+ name = StringValuePtr(tmp);
525
+ if(util_isVariable(self)) {
526
+ defineVar(install(name),ans,R_GlobalEnv); //currently in R_GlobalEnv!!!
527
+ } else {
528
+ defineVar(install(".rubyExport"),ans,R_GlobalEnv);
529
+ util_eval1string(rb_str_cat2(rb_str_dup(rb_iv_get(self,"@name")),"<-.rubyExport"));
530
+ }
531
+
532
+ return self;
533
+ }
534
+
535
+ VALUE RVect_assign(VALUE obj, VALUE name,VALUE arr)
536
+ {
537
+ SEXP ans;
538
+ char *tmp;
539
+
540
+ ans=util_VALUE2SEXP(arr);
541
+
542
+ tmp = StringValuePtr(name);
543
+ defineVar(install(tmp),ans,R_GlobalEnv);
544
+
545
+ return Qnil;
546
+ }
547
+
548
+ VALUE RVect_set_with_arg(VALUE self,VALUE arr)
549
+ {
550
+ VALUE tmp;
551
+ defineVar(install(".rubyExport"),util_VALUE2SEXP(arr),R_GlobalEnv);
552
+ tmp=rb_iv_get(self,"@arg");
553
+ util_eval1string(rb_str_cat2(rb_str_cat2(rb_str_dup(rb_iv_get(self,"@name")),StringValuePtr(tmp)),"<-.rubyExport"));
554
+ return self;
555
+ }
556
+
557
+
558
+
559
+ void
560
+ Init_R4rb()
561
+ {
562
+ VALUE mR2rb;
563
+
564
+ mR2rb = rb_define_module("R2rb");
565
+
566
+ rb_define_module_function(mR2rb, "initR", R2rb_init, 1);
567
+
568
+ rb_define_module_function(mR2rb, "evalLines", R2rb_eval, 2);
569
+
570
+ rb_define_module_function(mR2rb, "parseLines", R2rb_parse, 2);
571
+
572
+ VALUE cRVect;
573
+
574
+ cRVect = rb_define_class_under(mR2rb,"RVector",rb_cObject);
575
+
576
+ rb_define_module_function(cRVect, "assign", RVect_assign, 2);
577
+
578
+ rb_define_method(cRVect,"initialize",RVect_initialize,1);
579
+
580
+ rb_define_method(cRVect,"get",RVect_get,0);
581
+ rb_define_alias(cRVect,"to_a","get");
582
+ rb_define_alias(cRVect,"value","get");
583
+
584
+ rb_define_method(cRVect,"set",RVect_set,1);
585
+ rb_define_alias(cRVect,"<","set");
586
+ rb_define_alias(cRVect,"value=","set");
587
+
588
+ //method "arg=" defined in eval.rb!! @arg initialized in method "initialize"
589
+ rb_define_method(cRVect,"get_with_arg",RVect_get_with_arg,0);
590
+ rb_define_alias(cRVect,"value_with_arg","get_with_arg");
591
+ rb_define_method(cRVect,"set_with_arg",RVect_set_with_arg,1);
592
+ rb_define_alias(cRVect,"value_with_arg=","set_with_arg");
593
+
594
+ rb_define_method(cRVect,"valid?",RVect_isValid,0);
595
+ rb_define_method(cRVect,"length",RVect_length,0);
596
+ rb_define_method(cRVect,"[]",RVect_aref,1);
597
+ //[]= iter !!!
598
+ rb_define_attr(cRVect,"name",1,1);
599
+ rb_define_attr(cRVect,"type",1,1);
600
+ }
data/ext/R4rb/extconf.rb CHANGED
@@ -17,17 +17,18 @@ def find_installed_R
17
17
  break if $prefix_lib
18
18
  end
19
19
  elsif RUBY_PLATFORM=~/darwin/
20
- versions="/Library/Frameworks/R.framework/Versions"
21
- if File.directory? versions
22
- $prefix=Dir[versions+"/*/Resources"].select{|e| e.split("/")[-2]!="Current"}
23
- $prefix_include=$prefix.map{|e| e+"/include"}
24
- $prefix_lib=$prefix.map{|e| e+"/lib"}
25
- $versions=$prefix.map{|e| e.split("/")[-2]}
26
- else
20
+
21
+ # versions="/Library/Frameworks/R.framework/Versions"
22
+ # if File.directory? versions
23
+ # $prefix=Dir[versions+"/*/Resources"].select{|e| e.split("/")[-2]!="Current"}
24
+ # $prefix_include=$prefix.map{|e| e+"/include"}
25
+ # $prefix_lib=$prefix.map{|e| e+"/lib"}
26
+ # $versions=$prefix.map{|e| e.split("/")[-2]}
27
+ # else
27
28
  $prefix=`R RHOME`.strip
28
29
  $prefix_include=$prefix+"/include"
29
30
  $prefix_lib=$prefix+"/lib"
30
- end
31
+ # end
31
32
 
32
33
  else
33
34
  stddirs=["/usr/local/lib/R","/usr/lib/R","/usr/share/R","/usr/include/R","/usr/lib64/R"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: R4rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - CQLS
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-15 00:00:00.000000000 Z
11
+ date: 2021-09-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " R is embedded in ruby with some communication support .\n"
14
14
  email: rdrouilh@gmail.com
@@ -20,6 +20,7 @@ files:
20
20
  - R4rb.gemspec
21
21
  - Rakefile
22
22
  - ext/R4rb/MANIFEST
23
+ - ext/R4rb/R4rb.4.1.c
23
24
  - ext/R4rb/R4rb.c
24
25
  - ext/R4rb/extconf.rb
25
26
  - lib/R2rb.rb
@@ -65,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
66
  version: '0'
66
67
  requirements:
67
68
  - none
68
- rubygems_version: 3.2.15
69
+ rubygems_version: 3.2.22
69
70
  signing_key:
70
71
  specification_version: 4
71
72
  summary: R for ruby