jl4rb 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/jl4rb/jl4rb.c +15 -11
- data/jl4rb.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f7cae52ad265d312103b5315bfd6280f2eba84b7745890046d0b5fcd2ae839f
|
4
|
+
data.tar.gz: 60e322b9e4f36c971156a754750b9b0de176a71556f437e4c2d28fbb30d51108
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa638b61bf3d4cb80caa430299c7add73f039b55e93c8ebd55bb4d00de4dfdf71bda3b3d08e20b971ba71bb7e7d0958bdb4266ed23b171071ef685f6342e6697
|
7
|
+
data.tar.gz: 77cc18725d48204aafcd6fea6b8a0b460c5f8e74eb0de206b2e659bcf4f936b6e1a91e98b5ba87e5cc10bc980a3bc54bd426b976cb6093a03b76b7bb4f4f206f
|
data/ext/jl4rb/jl4rb.c
CHANGED
@@ -278,7 +278,7 @@ VALUE util_jl_value_to_VALUE(jl_value_t *ans)
|
|
278
278
|
//-| Todo: when not a vector, avoid transform to vector first.
|
279
279
|
jl_value_t* util_VALUE_to_jl_value(VALUE arr)
|
280
280
|
{
|
281
|
-
jl_value_t *ans,*elt;
|
281
|
+
jl_value_t *ans,*elt,*array_type;
|
282
282
|
VALUE res,class,tmp;
|
283
283
|
int i,n=0,vect=1;
|
284
284
|
|
@@ -293,39 +293,43 @@ jl_value_t* util_VALUE_to_jl_value(VALUE arr)
|
|
293
293
|
}
|
294
294
|
|
295
295
|
class=rb_class_of(rb_ary_entry(arr,0));
|
296
|
-
|
296
|
+
|
297
297
|
if(class==rb_cFloat) {
|
298
298
|
//-| This is maybe faster and can be developped in julia-api as jl_vector_float64(n) for example.
|
299
|
-
|
299
|
+
array_type=jl_apply_array_type((jl_value_t*)jl_float64_type, 1);
|
300
|
+
ans=(jl_value_t*)jl_alloc_array_1d(array_type,n);
|
300
301
|
for(i=0;i<n;i++) {
|
301
302
|
elt=jl_box_float64(NUM2DBL(rb_ary_entry(arr,i)));
|
302
|
-
jl_arrayset(ans,elt,i);
|
303
|
+
jl_arrayset((jl_array_t*)ans,elt,i);
|
303
304
|
}
|
304
305
|
#if RUBY_API_VERSION_CODE >= 20400
|
305
306
|
} else if(class==rb_cInteger) {
|
306
307
|
#else
|
307
308
|
} else if(class==rb_cFixnum || class==rb_cBignum) {
|
308
309
|
#endif
|
309
|
-
|
310
|
+
array_type=jl_apply_array_type((jl_value_t*)jl_long_type, 1);
|
311
|
+
ans=(jl_value_t*)jl_alloc_array_1d(array_type,n);
|
310
312
|
for(i=0;i<n;i++) {
|
311
313
|
elt=jl_box_long(NUM2INT(rb_ary_entry(arr,i)));
|
312
|
-
jl_arrayset(ans,elt,i);
|
314
|
+
jl_arrayset((jl_array_t*)ans,elt,i);
|
313
315
|
}
|
314
316
|
} else if(class==rb_cTrueClass || class==rb_cFalseClass) {
|
315
|
-
|
317
|
+
array_type=jl_apply_array_type((jl_value_t*)jl_bool_type, 1);
|
318
|
+
ans=(jl_value_t*)jl_alloc_array_1d(array_type,n);
|
316
319
|
for(i=0;i<n;i++) {
|
317
320
|
elt=jl_box_bool(rb_class_of(rb_ary_entry(arr,i))==rb_cFalseClass ? 0 : 1);
|
318
|
-
jl_arrayset(ans,elt,i);
|
321
|
+
jl_arrayset((jl_array_t*)ans,elt,i);
|
319
322
|
}
|
320
323
|
} else if(class==rb_cString) {
|
321
|
-
|
324
|
+
array_type=jl_apply_array_type((jl_value_t*)jl_string_type, 1);
|
325
|
+
ans=(jl_value_t*)jl_alloc_array_1d(array_type,n);
|
322
326
|
for(i=0;i<n;i++) {
|
323
327
|
tmp=rb_ary_entry(arr,i);
|
324
328
|
elt=jl_cstr_to_string(StringValuePtr(tmp));
|
325
|
-
jl_arrayset(ans,elt,i);
|
329
|
+
jl_arrayset((jl_array_t*)ans,elt,i);
|
326
330
|
}
|
327
331
|
} else ans=NULL;
|
328
|
-
if(!vect && ans) ans=jl_arrayref(ans,0);
|
332
|
+
if(!vect && ans) ans=jl_arrayref((jl_array_t*)ans,0);
|
329
333
|
return ans;
|
330
334
|
}
|
331
335
|
|
data/jl4rb.gemspec
CHANGED