narray_ffi 0.1

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.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014, Brice Videau <brice.videau@imag.fr>
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,43 @@
1
+ require 'mkmf'
2
+ require 'rbconfig'
3
+
4
+ if RUBY_VERSION < "1.9" then
5
+ conf = Config::CONFIG
6
+ else
7
+ conf = RbConfig::CONFIG
8
+ end
9
+
10
+ dir_config("narray", conf["archdir"])
11
+ unless have_header("narray.h")
12
+ begin
13
+ require "rubygems"
14
+ if spec = Gem::Specification.find_all_by_name("narray").last
15
+ spec.require_paths.each { |path|
16
+ $CPPFLAGS = "-I" << spec.full_gem_path << "/" << path << " " << $CPPFLAGS
17
+ }
18
+ end
19
+ rescue LoadError
20
+ end
21
+ unless have_header("narray.h")
22
+ abort "missing narray.h" unless have_header("narray.h")
23
+ end
24
+ end
25
+
26
+ dir_config("ffi", conf["archdir"])
27
+ unless have_header("Pointer.h")
28
+ begin
29
+ require "rubygems"
30
+ if spec = Gem::Specification.find_all_by_name("ffi").last
31
+ spec.require_paths.each { |path|
32
+ $CPPFLAGS = "-I" << spec.full_gem_path << "/" << path << " " << $CPPFLAGS
33
+ }
34
+ end
35
+ rescue LoadError
36
+ end
37
+ unless have_header("Pointer.h")
38
+ abort "missing ffi Pointer.h" unless have_header("Pointer.h")
39
+ end
40
+ end
41
+
42
+
43
+ create_makefile("narray_ffi_c")
@@ -0,0 +1,21 @@
1
+ #include "ruby.h"
2
+ #include "narray.h"
3
+ #include "Pointer.h"
4
+
5
+ VALUE na_to_pointer(VALUE self) {
6
+ struct NARRAY *ary;
7
+ void * ptr;
8
+
9
+ GetNArray(self,ary);
10
+ ptr = ary->ptr;
11
+ return rbffi_Pointer_NewInstance(ptr);
12
+ }
13
+
14
+ void Init_narray_ffi_c() {
15
+ ID id;
16
+ VALUE klass;
17
+ id = rb_intern("NArray");
18
+ klass = rb_const_get(rb_cObject, id);
19
+ rb_define_method(klass, "to_ptr", na_to_pointer, 0);
20
+ }
21
+
data/lib/narray_ffi.rb ADDED
@@ -0,0 +1,3 @@
1
+ require "narray"
2
+ require "ffi"
3
+ require "narray_ffi_c.so"
@@ -0,0 +1,18 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'narray_ffi'
3
+ s.version = "0.1"
4
+ s.author = "Brice Videau"
5
+ s.email = "brice.videau@imag.fr"
6
+ s.homepage = "https://forge.imag.fr/projects/opencl-ruby/"
7
+ s.summary = "Ruby narray_ffi"
8
+ s.description = "Ruby narray_ffi interface"
9
+ s.files = %w( narray_ffi.gemspec LICENSE lib/narray_ffi.rb ext/narray_ffi_c/narray_ffi.c ext/narray_ffi_c/extconf.rb) + Dir.glob("{ext,lib}/**/*").reject { |f| f =~ /(lib\/[12]\.[089]|\.so$|\.bundle$)/ }
10
+ s.extensions << 'ext/narray_ffi_c/extconf.rb'
11
+ s.has_rdoc = false
12
+ s.license = 'BSD'
13
+ s.required_ruby_version = '>= 1.8.7'
14
+ # s.add_development_dependency 'rake'
15
+ # s.add_development_dependency 'rake-compiler', '>=0.6.0'
16
+ s.add_dependency 'narray', '>=0.6.0.8'
17
+ s.add_dependency 'ffi', '>=1.9.3'
18
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: narray_ffi
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Brice Videau
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-03-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: narray
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.6.0.8
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.6.0.8
30
+ - !ruby/object:Gem::Dependency
31
+ name: ffi
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 1.9.3
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.9.3
46
+ description: Ruby narray_ffi interface
47
+ email: brice.videau@imag.fr
48
+ executables: []
49
+ extensions:
50
+ - ext/narray_ffi_c/extconf.rb
51
+ extra_rdoc_files: []
52
+ files:
53
+ - narray_ffi.gemspec
54
+ - LICENSE
55
+ - lib/narray_ffi.rb
56
+ - ext/narray_ffi_c/narray_ffi.c
57
+ - ext/narray_ffi_c/extconf.rb
58
+ homepage: https://forge.imag.fr/projects/opencl-ruby/
59
+ licenses:
60
+ - BSD
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: 1.8.7
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 1.8.23
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: Ruby narray_ffi
83
+ test_files: []