narray_ffi 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 +4 -4
- data/ext/narray_ffi_c/narray_ffi.c +30 -5
- data/lib/narray_ffi.rb +0 -11
- data/narray_ffi.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 510a401c952751ea163855b174e72a2f871c25d4
|
4
|
+
data.tar.gz: 9e81c0380bc8e31ec91a82c5f72b4df4344b0516
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ef3e44b7ad2999b1cee2146a63d4f34828d27e588d2952bfdff3120e62d17588e7d11dad16801f6c2de80a2db8f96ce5dcef71d759200bba7b0e8083f512282
|
7
|
+
data.tar.gz: 85840bd05ac8574a205185d5a4f2582161b8135df5870d0e6a7a33dfbb0c1fb7c871a7dbf5c852da9a721951f334b6b27f6a02f4c63a927de192f11e4eaa66c2
|
@@ -14,6 +14,31 @@ static VALUE
|
|
14
14
|
return ret;
|
15
15
|
}
|
16
16
|
|
17
|
+
static VALUE
|
18
|
+
na_to_ptr(VALUE self)
|
19
|
+
{
|
20
|
+
struct NARRAY *ary;
|
21
|
+
VALUE mod;
|
22
|
+
VALUE klass;
|
23
|
+
VALUE ret;
|
24
|
+
VALUE address;
|
25
|
+
long length;
|
26
|
+
|
27
|
+
GetNArray(self,ary);
|
28
|
+
mod = rb_const_get(rb_cObject, rb_intern("FFI"));
|
29
|
+
klass = rb_const_get(mod, rb_intern("Pointer"));
|
30
|
+
if ( ary->ref != Qnil ) {
|
31
|
+
if ( rb_funcall(ary->ref, rb_intern("kind_of?"), 1, klass) == Qtrue ) {
|
32
|
+
return ary->ref;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
length = na_sizeof[ary->type] * ary->total;
|
37
|
+
ret = rb_funcall(klass, rb_intern("new"), 1, na_address(self));
|
38
|
+
ret = rb_funcall(ret, rb_intern("slice"), 2, LONG2NUM(0), LONG2NUM(length));
|
39
|
+
return ret;
|
40
|
+
}
|
41
|
+
|
17
42
|
static struct NARRAY*
|
18
43
|
na_alloc_struct_empty(int type, int rank, int *shape)
|
19
44
|
{
|
@@ -153,11 +178,9 @@ static VALUE
|
|
153
178
|
rb_raise(rb_eArgError, "Argument is required");
|
154
179
|
}
|
155
180
|
mod = rb_const_get(rb_cObject, rb_intern("FFI"));
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
return na_pointer_to_na(argc-1,argv+1,argv[0]);
|
160
|
-
}
|
181
|
+
klass_p = rb_const_get(mod, rb_intern("Pointer"));
|
182
|
+
if ( rb_funcall(argv[0], rb_intern("kind_of?"), 1, klass_p) == Qtrue ){
|
183
|
+
return na_pointer_to_na(argc-1,argv+1,argv[0]);
|
161
184
|
}
|
162
185
|
rb_funcall2(klass, rb_intern("to_na_old"), argc, argv);
|
163
186
|
}
|
@@ -168,6 +191,8 @@ void Init_narray_ffi_c() {
|
|
168
191
|
id = rb_intern("NArray");
|
169
192
|
klass = rb_const_get(rb_cObject, id);
|
170
193
|
rb_define_private_method(klass, "address", na_address, 0);
|
194
|
+
rb_define_method(klass, "to_ptr", na_to_ptr, 0);
|
195
|
+
rb_define_alias(rb_singleton_class(klass), "to_na_old", "to_na");
|
171
196
|
rb_define_singleton_method(klass, "to_na", na_s_to_na_pointer, -1);
|
172
197
|
rb_define_singleton_method(klass, "to_narray", na_s_to_na_pointer, -1);
|
173
198
|
}
|
data/lib/narray_ffi.rb
CHANGED
data/narray_ffi.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: narray_ffi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brice Videau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: narray
|