jl4rb 0.2.2 → 0.2.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cee2b9429514424e01c99dcec41acf6066b5c399937723649159f411e714abfb
4
- data.tar.gz: 623f3df43750d4f369cd9b221f4d68df83e6d87739d98b48136479e532ecece1
3
+ metadata.gz: b8b8aade7e2cc0fc2991e6352b94f47a56c7683f818373036afe32b83bb52e28
4
+ data.tar.gz: 781b45f9522acb27f4422e7f6f1cc6879dda966b7f5fee0cd505d21891fd0e2a
5
5
  SHA512:
6
- metadata.gz: a440ce035beee6f21b263870cc3292fcc7ac54dd36778c743cdd30086d6952b1aae36e91bc1380734e63186bd90a81c6509115206292ca0111f79ed4a6d00215
7
- data.tar.gz: cc61b73afa390b9b189f0454b73de020c9614c7bdd382c01ea6d218f1ddca10f47b5b1c3a41b09789847d41978476ca7be515e526c408e0041b98c9180c57c64
6
+ metadata.gz: daabc722567025b44d986a6f033b1de3ccd31dc16059b889b987eb6fa272d752a6b258eccbb5ce484110e06c2692522c7a7a6c68950da7590eed0bc49dd349e2
7
+ data.tar.gz: a4e322987a2d7f31c9bbb29353aecd0d5acdcda4ceaf11c7170b2aee892f3ec8e39d0265d93ffe345bd047d7c4cc754d3125cdfe43d71b880e401f8bf524314f
data/ext/jl4rb/extconf.rb CHANGED
@@ -15,19 +15,21 @@ end
15
15
  def jl4rb_makefile(incs,libs)
16
16
 
17
17
  jl_share=`julia -e 'print(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia"))'`
18
- $CFLAGS =`julia #{jl_share}/julia-config.jl --cflags`.strip
18
+ $CFLAGS =`julia #{jl_share}/julia-config.jl --cflags`.strip + " -fdeclspec"
19
19
  $LDFLAGS =`julia #{jl_share}/julia-config.jl --ldflags`.strip
20
- $libs =`julia #{jl_share}/julia-config.jl --ldlibs`.strip
20
+ $LIBS = `julia #{jl_share}/julia-config.jl --ldlibs`.strip
21
21
 
22
+ puts [$CFLAGS, $LDFLAGS, $LIBS]
22
23
 
23
24
  header = nil
24
25
 
25
- rb4r_name="jl4rb"
26
- $objs = [rb4r_name+".o"]
26
+ jl4r_name="jl4rb"
27
+ $objs = [jl4r_name+".o"]
27
28
 
28
- dir_config("R4rb")
29
- p ( {:CFLAGS => $CFLAGS, :LDFLAGS => $LDFLAGS, :libs => $libs })
30
- create_makefile(rb4r_name)
29
+ dir_config("jl4rb")
30
+ #
31
+ p ( {:CFLAGS => $CFLAGS, :LDFLAGS => $LDFLAGS, :LIBS => $LIBS })
32
+ create_makefile(jl4r_name)
31
33
  end
32
-
34
+ #p [$prefix_include,$prefix_lib]
33
35
  jl4rb_makefile($prefix_include,$prefix_lib)
data/ext/jl4rb/jl4rb.c CHANGED
@@ -4,7 +4,6 @@
4
4
 
5
5
  **********************************************************************/
6
6
 
7
- #include "julia.h"
8
7
  #include <stdio.h>
9
8
  #include <string.h>
10
9
  #include <math.h>
@@ -17,23 +16,28 @@
17
16
  //#endif
18
17
 
19
18
  //-| next macros already exist in ruby and are undefined here
20
- //#undef T_FLOAT
21
19
  #undef NORETURN
22
20
  #include "ruby.h"
23
21
  #include "ruby/version.h"
22
+ #undef T_FLOAT
23
+ #undef NOINLINE
24
+ #include "julia.h"
24
25
 
25
26
  #define length(a) jl_array_size(a,0)
26
27
 
27
28
  /************* INIT *********************/
28
29
 
29
30
 
30
- VALUE Julia_init()
31
+ VALUE Julia_init(VALUE obj)
31
32
  {
32
- jl_init();
33
+ //jl_init();
34
+ printf("%s %s\n", jl_get_libdir(), jl_get_default_sysimg_path());
35
+ jl_init(); //_with_image("/Applications/Julia-1.6.app/Contents/Resources/julia/bin", "../lib/sys.dylib");
36
+ printf("ok\n");
33
37
  return Qtrue;
34
38
  }
35
39
 
36
- VALUE Julia_exit(VALUE exitcode) {
40
+ VALUE Julia_exit(VALUE obj, VALUE exitcode) {
37
41
  jl_atexit_hook(exitcode);
38
42
  return Qtrue;
39
43
  }
@@ -278,7 +282,7 @@ VALUE util_jl_value_to_VALUE(jl_value_t *ans)
278
282
  //-| Todo: when not a vector, avoid transform to vector first.
279
283
  jl_value_t* util_VALUE_to_jl_value(VALUE arr)
280
284
  {
281
- jl_value_t *ans,*elt;
285
+ jl_value_t *ans,*elt,*array_type;
282
286
  VALUE res,class,tmp;
283
287
  int i,n=0,vect=1;
284
288
 
@@ -293,39 +297,43 @@ jl_value_t* util_VALUE_to_jl_value(VALUE arr)
293
297
  }
294
298
 
295
299
  class=rb_class_of(rb_ary_entry(arr,0));
296
- ans=jl_alloc_cell_1d(n);
300
+
297
301
  if(class==rb_cFloat) {
298
302
  //-| This is maybe faster and can be developped in julia-api as jl_vector_float64(n) for example.
299
- //ans=jl_alloc_array_1d(jl_float64_type,n);
303
+ array_type=jl_apply_array_type((jl_value_t*)jl_float64_type, 1);
304
+ ans=(jl_value_t*)jl_alloc_array_1d(array_type,n);
300
305
  for(i=0;i<n;i++) {
301
306
  elt=jl_box_float64(NUM2DBL(rb_ary_entry(arr,i)));
302
- jl_arrayset(ans,elt,i);
307
+ jl_arrayset((jl_array_t*)ans,elt,i);
303
308
  }
304
309
  #if RUBY_API_VERSION_CODE >= 20400
305
310
  } else if(class==rb_cInteger) {
306
311
  #else
307
312
  } else if(class==rb_cFixnum || class==rb_cBignum) {
308
313
  #endif
309
- //ans=jl_alloc_array_1d(jl_long_type,n);
314
+ array_type=jl_apply_array_type((jl_value_t*)jl_long_type, 1);
315
+ ans=(jl_value_t*)jl_alloc_array_1d(array_type,n);
310
316
  for(i=0;i<n;i++) {
311
317
  elt=jl_box_long(NUM2INT(rb_ary_entry(arr,i)));
312
- jl_arrayset(ans,elt,i);
318
+ jl_arrayset((jl_array_t*)ans,elt,i);
313
319
  }
314
320
  } else if(class==rb_cTrueClass || class==rb_cFalseClass) {
315
- //ans=jl_alloc_array_1d(jl_bool_type,n);
321
+ array_type=jl_apply_array_type((jl_value_t*)jl_bool_type, 1);
322
+ ans=(jl_value_t*)jl_alloc_array_1d(array_type,n);
316
323
  for(i=0;i<n;i++) {
317
324
  elt=jl_box_bool(rb_class_of(rb_ary_entry(arr,i))==rb_cFalseClass ? 0 : 1);
318
- jl_arrayset(ans,elt,i);
325
+ jl_arrayset((jl_array_t*)ans,elt,i);
319
326
  }
320
327
  } else if(class==rb_cString) {
321
- //ans=jl_alloc_array_1d(jl_utf8_string_type,n);
328
+ array_type=jl_apply_array_type((jl_value_t*)jl_string_type, 1);
329
+ ans=(jl_value_t*)jl_alloc_array_1d(array_type,n);
322
330
  for(i=0;i<n;i++) {
323
331
  tmp=rb_ary_entry(arr,i);
324
332
  elt=jl_cstr_to_string(StringValuePtr(tmp));
325
- jl_arrayset(ans,elt,i);
333
+ jl_arrayset((jl_array_t*)ans,elt,i);
326
334
  }
327
335
  } else ans=NULL;
328
- if(!vect && ans) ans=jl_arrayref(ans,0);
336
+ if(!vect && ans) ans=jl_arrayref((jl_array_t*)ans,0);
329
337
  return ans;
330
338
  }
331
339
 
@@ -502,7 +510,7 @@ Init_jl4rb()
502
510
  mJulia = rb_define_module("Julia");
503
511
 
504
512
  rb_define_module_function(mJulia, "initJL", Julia_init, 0);
505
-
513
+
506
514
  rb_define_module_function(mJulia, "exitJL", Julia_exit, 1);
507
515
 
508
516
  rb_define_module_function(mJulia, "evalLine", Julia_eval, 2);
data/jl4rb.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rubygems/package_task'
3
3
 
4
4
  PKG_NAME='jl4rb'
5
- PKG_VERSION='0.2.2'
5
+ PKG_VERSION='0.2.5'
6
6
  PKG_FILES=FileList[
7
7
  'Rakefile','jl4rb.gemspec',
8
8
  'ext/jl4rb/*.c',
data/lib/jl4rb.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'jl4rb.bundle' if File.exists? File.join(File.dirname(__FILE__),'jl4rb.bundle')
2
2
  require 'jl4rb.so' if File.exists? File.join(File.dirname(__FILE__),'jl4rb.so')
3
3
 
4
+ p [:dl, "jl4rb.DLL loaded" ]
4
5
  # loading ruby files
5
6
  require 'jl4rb/jl2rb_init'
6
7
  require 'jl4rb/jl2rb_eval'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jl4rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - CQLS
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-23 00:00:00.000000000 Z
11
+ date: 2022-03-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'R is embedded in ruby with some communication support .
14
14
 
@@ -35,7 +35,7 @@ licenses:
35
35
  - MIT
36
36
  - GPL-2.0
37
37
  metadata: {}
38
- post_install_message:
38
+ post_install_message:
39
39
  rdoc_options: []
40
40
  require_paths:
41
41
  - lib
@@ -52,8 +52,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
52
  version: '0'
53
53
  requirements:
54
54
  - none
55
- rubygems_version: 3.0.6
56
- signing_key:
55
+ rubygems_version: 3.3.7
56
+ signing_key:
57
57
  specification_version: 4
58
58
  summary: Julia for ruby
59
59
  test_files: []