ffi 1.1.6.pre2-x86-mingw32 → 1.2.0.pre2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ffi might be problematic. Click here for more details.

Files changed (50) hide show
  1. data/COPYING +674 -0
  2. data/COPYING.LESSER +165 -0
  3. data/README.md +104 -0
  4. data/Rakefile +36 -43
  5. data/ext/ffi_c/LongDouble.c +4 -0
  6. data/ext/ffi_c/LongDouble.c.orig +65 -0
  7. data/ext/ffi_c/MethodHandle.c +1 -1
  8. data/ext/ffi_c/Types.h +1 -0
  9. data/ext/ffi_c/Variadic.c +4 -0
  10. data/ext/ffi_c/extconf.rb +1 -0
  11. data/ext/ffi_c/libffi.bsd.mk +1 -1
  12. data/ext/ffi_c/libffi.darwin.mk +6 -4
  13. data/ext/ffi_c/libffi.mk +1 -1
  14. data/lib/1.8/ffi_c.so +0 -0
  15. data/lib/1.9/ffi_c.so +0 -0
  16. data/lib/ffi/autopointer.rb +9 -8
  17. data/lib/ffi/enum.rb +2 -1
  18. data/libtest/Benchmark.c +66 -0
  19. data/libtest/BoolTest.c +45 -0
  20. data/libtest/BufferTest.c +45 -0
  21. data/libtest/ClosureTest.c +204 -0
  22. data/libtest/EnumTest.c +48 -0
  23. data/libtest/FunctionTest.c +72 -0
  24. data/libtest/GNUmakefile +149 -0
  25. data/libtest/GlobalVariable.c +76 -0
  26. data/libtest/LastErrorTest.c +35 -0
  27. data/libtest/NumberTest.c +146 -0
  28. data/libtest/PointerTest.c +77 -0
  29. data/libtest/ReferenceTest.c +37 -0
  30. data/libtest/StringTest.c +48 -0
  31. data/libtest/StructTest.c +254 -0
  32. data/libtest/UnionTest.c +57 -0
  33. data/libtest/VariadicTest.c +76 -0
  34. data/spec/ffi/enum_spec.rb +4 -0
  35. data/spec/ffi/pointer_spec.rb +17 -0
  36. metadata +85 -40
  37. data/README.rdoc +0 -102
  38. data/tasks/ann.rake +0 -80
  39. data/tasks/extension.rake +0 -32
  40. data/tasks/gem.rake +0 -199
  41. data/tasks/git.rake +0 -41
  42. data/tasks/notes.rake +0 -27
  43. data/tasks/post_load.rake +0 -34
  44. data/tasks/rdoc.rake +0 -50
  45. data/tasks/rubyforge.rake +0 -55
  46. data/tasks/setup.rb +0 -301
  47. data/tasks/spec.rake +0 -54
  48. data/tasks/svn.rake +0 -47
  49. data/tasks/test.rake +0 -40
  50. data/tasks/yard.rake +0 -11
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -0,0 +1,104 @@
1
+ # ruby-ffi http://wiki.github.com/ffi/ffi
2
+
3
+ ## Description
4
+
5
+ Ruby-FFI is a ruby extension for programmatically loading dynamic
6
+ libraries, binding functions within them, and calling those functions
7
+ from Ruby code. Moreover, a Ruby-FFI extension works without changes
8
+ on Ruby and JRuby. Discover why should you write your next extension
9
+ using Ruby-FFI [here](http://wiki.github.com/ffi/ffi/why-use-ffi).
10
+
11
+ ## Features/problems
12
+
13
+ * Intuitive DSL
14
+ * Supports all C native types
15
+ * C structs (also nested), enums and global variables
16
+ * Callbacks from C to ruby
17
+ * Automatic garbage collection of native memory
18
+
19
+ ## Synopsis
20
+
21
+ ```ruby
22
+ require 'ffi'
23
+
24
+ module MyLib
25
+ extend FFI::Library
26
+ ffi_lib 'c'
27
+ attach_function :puts, [ :string ], :int
28
+ end
29
+
30
+ MyLib.puts 'Hello, World using libc!'
31
+ ```
32
+
33
+ For less minimalistic and more sane examples you may look at:
34
+
35
+ * the samples/ folder
36
+ * the examples on the [wiki](http://wiki.github.com/ffi/ffi)
37
+ * the projects using FFI listed on this page (http://wiki.github.com/ffi/ffi/projects-using-ffi)
38
+
39
+ ## Requirements
40
+
41
+ * You need a sane building environment in order to compile the extension.
42
+
43
+ ## Installation
44
+
45
+ From rubygems:
46
+
47
+ [sudo] gem install ffi
48
+
49
+ or from the git repository on github:
50
+
51
+ git clone git://github.com/ffi/ffi.git
52
+ cd ffi
53
+ rake gem:install
54
+
55
+ ## License
56
+
57
+ See LICENSE file.
58
+
59
+ ## Credits
60
+
61
+ The following people have submitted code, bug reports, or otherwide contributed to the success of this project:
62
+
63
+ * Alban Peignier <alban.peignier@free.fr>
64
+ * Aman Gupta <aman@tmm1.net>
65
+ * Andrea Fazzi <andrea.fazzi@alcacoop.it>
66
+ * Andreas Niederl <rico32@gmx.net>
67
+ * Andrew Cholakian <andrew@andrewvc.com>
68
+ * Antonio Terceiro <terceiro@softwarelivre.org>
69
+ * Brian Candler <B.Candler@pobox.com>
70
+ * Brian D. Burns <burns180@gmail.com>
71
+ * Bryan Kearney <bkearney@redhat.com>
72
+ * Charlie Savage <cfis@zerista.com>
73
+ * Chikanaga Tomoyuki <nagachika00@gmail.com>
74
+ * Hongli Lai <hongli@phusion.nl>
75
+ * Ian MacLeod <ian@nevir.net>
76
+ * Jake Douglas <jake@shiftedlabs.com>
77
+ * Jean-Dominique Morani <jdmorani@mac.com>
78
+ * Jeremy Hinegardner <jeremy@hinegardner.org>
79
+ * Jesús García Sáez <blaxter@gmail.com>
80
+ * Joe Khoobyar <joe@ankhcraft.com>
81
+ * Jurij Smakov <jurij@wooyd.org>
82
+ * KISHIMOTO, Makoto <ksmakoto@dd.iij4u.or.jp>
83
+ * Kim Burgestrand <kim@burgestrand.se>
84
+ * Lars Kanis <kanis@comcard.de>
85
+ * Luc Heinrich <luc@honk-honk.com>
86
+ * Luis Lavena <luislavena@gmail.com>
87
+ * Matijs van Zuijlen <matijs@matijs.net>
88
+ * Matthew King <automatthew@gmail.com>
89
+ * Mike Dalessio <mike.dalessio@gmail.com>
90
+ * NARUSE, Yui <naruse@airemix.jp>
91
+ * Park Heesob <phasis@gmail.com>
92
+ * Shin Yee <shinyee@speedgocomputing.com>
93
+ * Stephen Bannasch <stephen.bannasch@gmail.com>
94
+ * Suraj N. Kurapati <sunaku@gmail.com>
95
+ * Sylvain Daubert <sylvain.daubert@laposte.net>
96
+ * Victor Costan
97
+ * beoran@gmail.com
98
+ * ctide <christide@christide.com>
99
+ * emboss <Martin.Bosslet@googlemail.com>
100
+ * hobophobe <unusualtears@gmail.com>
101
+ * meh <meh@paranoici.org>
102
+ * postmodern <postmodern.mod3@gmail.com>
103
+ * wycats@gmail.com <wycats@gmail.com>
104
+ * Wayne Meissner <wmeissner@gmail.com>
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'rubygems'
2
+ require 'rubygems/package_task'
2
3
  require 'rbconfig'
3
4
 
4
5
  USE_RAKE_COMPILER = (RUBY_PLATFORM =~ /java/) ? false : true
@@ -11,7 +12,6 @@ require 'date'
11
12
  require 'fileutils'
12
13
  require 'rbconfig'
13
14
 
14
- load 'tasks/setup.rb'
15
15
 
16
16
  LIBEXT = case RbConfig::CONFIG['host_os'].downcase
17
17
  when /darwin/
@@ -64,7 +64,7 @@ OS = case RbConfig::CONFIG['host_os'].downcase
64
64
  RbConfig::CONFIG['host_os'].downcase
65
65
  end
66
66
 
67
- CC=ENV['CC'] || RbConfig::CONFIG['CC'] || "gcc"
67
+ CC = ENV['CC'] || RbConfig::CONFIG['CC'] || "gcc"
68
68
 
69
69
  GMAKE = system('which gmake >/dev/null') && 'gmake' || 'make'
70
70
 
@@ -72,47 +72,13 @@ LIBTEST = "build/libtest.#{LIBEXT}"
72
72
  BUILD_DIR = "build"
73
73
  BUILD_EXT_DIR = File.join(BUILD_DIR, "#{RbConfig::CONFIG['arch']}", 'ffi_c', RUBY_VERSION)
74
74
 
75
- # Project general information
76
- PROJ.name = 'ffi'
77
- PROJ.authors = 'Wayne Meissner'
78
- PROJ.email = 'wmeissner@gmail.com'
79
- PROJ.url = 'http://wiki.github.com/ffi/ffi'
80
- PROJ.version = '1.1.6.pre2'
81
- PROJ.rubyforge.name = 'ffi'
82
- PROJ.readme_file = 'README.rdoc'
75
+ gem_spec = Gem::Specification.load('ffi.gemspec')
83
76
 
84
- # Annoucement
85
- PROJ.ann.paragraphs << 'FEATURES' << 'SYNOPSIS' << 'REQUIREMENTS' << 'DOWNLOAD/INSTALL' << 'CREDITS' << 'LICENSE'
86
-
87
- PROJ.ann.email[:from] = 'andrea.fazzi@alcacoop.it'
88
- PROJ.ann.email[:to] = ['ruby-ffi@googlegroups.com']
89
- PROJ.ann.email[:server] = 'smtp.gmail.com'
90
-
91
- # Gem specifications
92
- PROJ.gem.need_tar = false
93
- PROJ.gem.files = %w(History.txt LICENSE README.rdoc Rakefile) + Dir.glob("{ext,gen,lib,spec,tasks}/**/*")
94
- PROJ.gem.platform = Gem::Platform::RUBY
95
- #PROJ.gem.required_ruby_version = ">= 1.9.2"
96
-
97
- # Override Mr. Bones autogenerated extensions and force ours in
98
- PROJ.gem.extras['extensions'] = %w(ext/ffi_c/extconf.rb)
99
- #PROJ.gem.extras['required_ruby_version'] = ">= 1.9.2"
100
-
101
- # RDoc
102
- PROJ.rdoc.exclude << '^ext\/'
103
- PROJ.rdoc.opts << '-x' << 'ext'
104
-
105
- # Ruby
106
- PROJ.ruby_opts = []
107
- PROJ.ruby_opts << '-I' << BUILD_EXT_DIR unless RUBY_PLATFORM == "java"
108
-
109
- # RSpec
110
- PROJ.spec.files.exclude /rbx/
111
- PROJ.spec.opts << '--color' << '-fs'
112
-
113
- # Dependencies
114
-
115
- #depend_on 'rake', '>=0.8.7'
77
+ Gem::PackageTask.new(gem_spec) do |pkg|
78
+ pkg.need_zip = true
79
+ pkg.need_tar = true
80
+ pkg.package_dir = 'pkg'
81
+ end
116
82
 
117
83
  TEST_DEPS = [ LIBTEST ]
118
84
  if RUBY_PLATFORM == "java"
@@ -144,6 +110,11 @@ task :package => 'gem:package'
144
110
  desc "Install the gem locally"
145
111
  task :install => 'gem:install'
146
112
 
113
+ namespace :gem do
114
+ task :install => :gem do
115
+ ruby %{ -S gem install pkg/ffi-#{gem_spec.version}.gem }
116
+ end
117
+ end
147
118
 
148
119
  desc "Clean all built files"
149
120
  task :distclean => :clobber do
@@ -158,7 +129,7 @@ end
158
129
 
159
130
 
160
131
  desc "Build the native test lib"
161
- task "build/libtest.#{LIBEXT}" do
132
+ file "build/libtest.#{LIBEXT}" => FileList['libtest/**/*.[ch]'] do
162
133
  sh %{#{GMAKE} -f libtest/GNUmakefile CPU=#{CPU} OS=#{OS} }
163
134
  end
164
135
 
@@ -194,3 +165,25 @@ task :default => :specs
194
165
  task 'gem:win32' do
195
166
  sh("rake cross native gem RUBY_CC_VERSION='1.8.7:1.9.3'") || raise("win32 build failed!")
196
167
  end
168
+
169
+
170
+ if USE_RAKE_COMPILER
171
+ Rake::ExtensionTask.new('ffi_c', gem_spec) do |ext|
172
+ ext.name = 'ffi_c' # indicate the name of the extension.
173
+ # ext.lib_dir = BUILD_DIR # put binaries into this folder.
174
+ ext.tmp_dir = BUILD_DIR # temporary folder used during compilation.
175
+ ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
176
+ ext.cross_platform = 'i386-mingw32' # forces the Windows platform instead of the default one
177
+ end
178
+ end
179
+
180
+ begin
181
+ require 'yard'
182
+
183
+ namespace :doc do
184
+ YARD::Rake::YardocTask.new do |yard|
185
+ end
186
+ end
187
+ rescue LoadError
188
+ warn "[warn] YARD unavailable"
189
+ end
@@ -3,6 +3,10 @@
3
3
  #include <stdarg.h>
4
4
  #include <float.h>
5
5
 
6
+ #if defined (__CYGWIN__) || defined(__INTERIX)
7
+ # define strtold(str, endptr) ((long double) strtod((str), (endptr)))
8
+ #endif /* defined (__CYGWIN__) */
9
+
6
10
  static VALUE rb_cBigDecimal = Qnil;
7
11
  static VALUE bigdecimal_load(VALUE unused);
8
12
  static VALUE bigdecimal_failed(VALUE value);
@@ -0,0 +1,65 @@
1
+ #include "LongDouble.h"
2
+ #include <stdio.h>
3
+ #include <stdarg.h>
4
+ #include <float.h>
5
+
6
+ #if defined (__CYGWIN__) || defined(__INTERIX)
7
+
8
+ #define strtold(str, endptr) ((long double)strtod((str),(endptr)))
9
+
10
+ #endif /* defined (__CYGWIN__) */
11
+
12
+ static VALUE rb_cBigDecimal = Qnil;
13
+ static VALUE bigdecimal_load(VALUE unused);
14
+ static VALUE bigdecimal_failed(VALUE value);
15
+
16
+ VALUE
17
+ rbffi_longdouble_new(long double ld)
18
+ {
19
+ if (!RTEST(rb_cBigDecimal)) {
20
+ /* allow fallback if the bigdecimal library is unavailable in future ruby versions */
21
+ rb_cBigDecimal = rb_rescue(bigdecimal_load, Qnil, bigdecimal_failed, rb_cObject);
22
+ }
23
+
24
+ if (RTEST(rb_cBigDecimal) && rb_cBigDecimal != rb_cObject) {
25
+ char buf[128];
26
+ return rb_funcall(rb_cBigDecimal, rb_intern("new"), 1, rb_str_new(buf, sprintf(buf, "%.35Le", ld)));
27
+ }
28
+
29
+ /* Fall through to handling as a float */
30
+ return rb_float_new(ld);
31
+ }
32
+
33
+ long double
34
+ rbffi_num2longdouble(VALUE value)
35
+ {
36
+ if (TYPE(value) == T_FLOAT) {
37
+ return rb_num2dbl(value);
38
+ }
39
+
40
+ if (!RTEST(rb_cBigDecimal) && rb_const_defined(rb_cObject, rb_intern("BigDecimal"))) {
41
+ rb_cBigDecimal = rb_const_get(rb_cObject, rb_intern("BigDecimal"));
42
+ }
43
+
44
+ if (RTEST(rb_cBigDecimal) && rb_cBigDecimal != rb_cObject && RTEST(rb_obj_is_kind_of(value, rb_cBigDecimal))) {
45
+ VALUE s = rb_funcall(value, rb_intern("to_s"), 1, rb_str_new2("E"));
46
+ return strtold(RSTRING_PTR(s), NULL);
47
+ }
48
+
49
+ /* Fall through to handling as a float */
50
+ return rb_num2dbl(value);
51
+ }
52
+
53
+
54
+ static VALUE
55
+ bigdecimal_load(VALUE unused)
56
+ {
57
+ rb_require("bigdecimal");
58
+ return rb_const_get(rb_cObject, rb_intern("BigDecimal"));
59
+ }
60
+
61
+ static VALUE
62
+ bigdecimal_failed(VALUE value)
63
+ {
64
+ return value;
65
+ }