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 ADDED
@@ -0,0 +1,4 @@
1
+ pkg/
2
+ generated/
3
+ *.gem
4
+
data/History.txt ADDED
@@ -0,0 +1,10 @@
1
+ == 0.1.0 / 2009-02-16
2
+
3
+ * a bunch of minor fixes
4
+ * fix the gem build process
5
+ * new interface file for the wiiuse example
6
+
7
+ == 0.0.1 / 2009-02-13
8
+
9
+ * 1 major enhancement
10
+ * Birthday!
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
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(
4
+ File.join(File.dirname(__FILE__), %w[.. lib ffi-generator]))
5
+
6
+ FFI::Generator::Application.run
7
+
data/examples/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib ffi-generator]))
2
+
3
+ FFI::Generator::Task.new :input_fn => 'interfaces/*.i', :output_dir => 'generated'
4
+
@@ -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
+ %}