remogatto-ffi-generator 0.1.0
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/.gitignore +4 -0
- data/History.txt +10 -0
- data/README.rdoc +89 -0
- data/Rakefile +36 -0
- data/bin/ffi-gen +7 -0
- data/examples/Rakefile +4 -0
- data/examples/interfaces/libc.i +26 -0
- data/examples/interfaces/wiiuse.i +672 -0
- data/lib/ffi-generator.rb +49 -0
- data/lib/generator/application.rb +69 -0
- data/lib/generator/generator.rb +304 -0
- data/lib/generator/generatortask.rb +45 -0
- data/spec/ffi-generator_spec.rb +7 -0
- data/spec/generator/generator_spec.rb +237 -0
- data/spec/generator/swig/constants.i +3 -0
- data/spec/generator/swig/enums.i +5 -0
- data/spec/generator/swig/functions.i +22 -0
- data/spec/generator/swig/structs.i +25 -0
- data/spec/generator/swig/testlib.i +47 -0
- data/spec/generator/swig/typedefs.i +5 -0
- data/spec/generator/swig/types.i +51 -0
- data/spec/generator/swig/unions.i +6 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +27 -0
- data/tasks/ann.rake +80 -0
- data/tasks/bones.rake +20 -0
- data/tasks/gem.rake +201 -0
- data/tasks/git.rake +40 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +34 -0
- data/tasks/rdoc.rake +50 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +300 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- metadata +124 -0
data/.gitignore
ADDED
data/History.txt
ADDED
data/README.rdoc
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
ffi-generator
|
|
2
|
+
by Andrea Fazzi
|
|
3
|
+
http://github.com/remogatto/ffi-generator/tree/master
|
|
4
|
+
|
|
5
|
+
== DESCRIPTION:
|
|
6
|
+
|
|
7
|
+
ffi-generator is a ruby-ffi wrapper code generator based on SWIG
|
|
8
|
+
interfaces.
|
|
9
|
+
|
|
10
|
+
ffi-generator is able to traverse a XML parse tree file generated by
|
|
11
|
+
SWIG and to produce a ruby file with ruby-ffi wrapper code inside.
|
|
12
|
+
|
|
13
|
+
ffi-generator is shipped with a command line tool (ffi-gen) and a rake
|
|
14
|
+
task that automates the code generation process.
|
|
15
|
+
|
|
16
|
+
ffi-generator XML capabilities are provided by nokogiri.
|
|
17
|
+
|
|
18
|
+
== FEATURES/PROBLEMS:
|
|
19
|
+
|
|
20
|
+
* support for
|
|
21
|
+
* all C native types
|
|
22
|
+
* #define constants
|
|
23
|
+
* typedefs
|
|
24
|
+
* struct, union, array and enum types
|
|
25
|
+
* naive indentation of the generated code
|
|
26
|
+
|
|
27
|
+
== SYNOPSIS:
|
|
28
|
+
|
|
29
|
+
From command line:
|
|
30
|
+
|
|
31
|
+
ffi-gen mylib.xml mylib.rb
|
|
32
|
+
|
|
33
|
+
From a Rakefile:
|
|
34
|
+
|
|
35
|
+
require 'ffi-generator'
|
|
36
|
+
FFI::Generator::Task.new :input_fn => 'my_interface_dir/*.i' output_dir => 'my_output_dir'
|
|
37
|
+
|
|
38
|
+
== REQUIREMENTS:
|
|
39
|
+
|
|
40
|
+
* rake >= 0.8.3
|
|
41
|
+
* nokogiri >= 1.1.1
|
|
42
|
+
|
|
43
|
+
== INSTALL:
|
|
44
|
+
|
|
45
|
+
git clone git://github.com/remogatto/ffi-generator.git
|
|
46
|
+
|
|
47
|
+
== EXAMPLES:
|
|
48
|
+
|
|
49
|
+
See the examples in examples/ folder.
|
|
50
|
+
|
|
51
|
+
libc.i is an interface file containing some excerpt of libc functions.
|
|
52
|
+
|
|
53
|
+
wiiuse.i is a enough complex example of a C header file interface. It
|
|
54
|
+
reproduces the content of wiiuse.h, the header file of the wiiuse
|
|
55
|
+
library. wiiuse is a C library that handles the connection with
|
|
56
|
+
Nintendo Wiimote devices. The interface file is almost a mere
|
|
57
|
+
copy/paste from the original header file.
|
|
58
|
+
|
|
59
|
+
== QUICK START:
|
|
60
|
+
|
|
61
|
+
git clone git://github.com/remogatto/ffi-generator.git
|
|
62
|
+
sudo apt-get install swig
|
|
63
|
+
sudo gem install nokogiri rake
|
|
64
|
+
cd ffi-generator/examples && rake ffi:generate
|
|
65
|
+
|
|
66
|
+
== LICENSE:
|
|
67
|
+
|
|
68
|
+
(The MIT License)
|
|
69
|
+
|
|
70
|
+
Copyright (c) 2008 Andrea Fazzi
|
|
71
|
+
|
|
72
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
73
|
+
a copy of this software and associated documentation files (the
|
|
74
|
+
'Software'), to deal in the Software without restriction, including
|
|
75
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
76
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
77
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
78
|
+
the following conditions:
|
|
79
|
+
|
|
80
|
+
The above copyright notice and this permission notice shall be
|
|
81
|
+
included in all copies or substantial portions of the Software.
|
|
82
|
+
|
|
83
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
84
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
85
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
86
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
87
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
88
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
89
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Look in the tasks/setup.rb file for the various options that can be
|
|
2
|
+
# configured in this Rakefile. The .rake files in the tasks directory
|
|
3
|
+
# are where the options are used.
|
|
4
|
+
|
|
5
|
+
begin
|
|
6
|
+
require 'bones'
|
|
7
|
+
Bones.setup
|
|
8
|
+
rescue LoadError
|
|
9
|
+
begin
|
|
10
|
+
load 'tasks/setup.rb'
|
|
11
|
+
rescue LoadError
|
|
12
|
+
raise RuntimeError, '### please install the "bones" gem ###'
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
ensure_in_path 'lib'
|
|
17
|
+
require 'ffi-generator'
|
|
18
|
+
|
|
19
|
+
task :default => 'spec:run'
|
|
20
|
+
|
|
21
|
+
PROJ.name = 'ffi-generator'
|
|
22
|
+
PROJ.authors = 'Andrea Fazzi'
|
|
23
|
+
PROJ.email = 'andrea.fazzi@alcacoop.it'
|
|
24
|
+
PROJ.url = 'http://github.com/remogatto/dokkit-core/tree/master'
|
|
25
|
+
PROJ.version = FFI::Generator::VERSION
|
|
26
|
+
PROJ.rubyforge.name = 'ffi-generator'
|
|
27
|
+
|
|
28
|
+
depend_on 'rake'
|
|
29
|
+
depend_on 'nokogiri'
|
|
30
|
+
|
|
31
|
+
PROJ.readme_file = 'README.rdoc'
|
|
32
|
+
|
|
33
|
+
PROJ.ruby_opts = []
|
|
34
|
+
PROJ.spec.opts << '--color'
|
|
35
|
+
|
|
36
|
+
# EOF
|
data/bin/ffi-gen
ADDED
data/examples/Rakefile
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
%module libc
|
|
2
|
+
|
|
3
|
+
%{
|
|
4
|
+
require 'rubygems'
|
|
5
|
+
require 'ffi'
|
|
6
|
+
|
|
7
|
+
module LibC
|
|
8
|
+
extend FFI::Library
|
|
9
|
+
%}
|
|
10
|
+
|
|
11
|
+
typedef unsigned int size_t;
|
|
12
|
+
|
|
13
|
+
struct timeval {
|
|
14
|
+
unsigned long tv_sec;
|
|
15
|
+
unsigned long tv_usec;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
size_t strlen (const char *s);
|
|
19
|
+
char * strcat (char *restrict to, const char *restrict from);
|
|
20
|
+
int strcmp (const char *s1, const char *s2);
|
|
21
|
+
|
|
22
|
+
int gettimeofday (struct timeval *tp, struct timezone *tzp);
|
|
23
|
+
|
|
24
|
+
%{
|
|
25
|
+
end
|
|
26
|
+
%}
|