rufus-lua 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,210 +0,0 @@
1
-
2
- = rufus-lua
3
-
4
- Lua embedded in Ruby, via Ruby FFI
5
-
6
-
7
- == Lua
8
-
9
- http://www.lua.org/about.html says :
10
-
11
- """
12
- Lua is a powerful, fast, lightweight, embeddable scripting language.
13
-
14
- Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.
15
- """
16
-
17
- http://www.lua.org/
18
-
19
-
20
- == other Ruby and Lua bridges / connectors
21
-
22
-
23
- http://rubyluabridge.rubyforge.org/
24
- http://raa.ruby-lang.org/project/ruby-lua
25
-
26
-
27
- == using rufus-lua
28
-
29
- If you don't have liblua.dylib on your system, scroll until "compiling liblua.dylib" to learn how to get it.
30
-
31
- sudo gem install rufus-lua
32
-
33
- then
34
-
35
- require 'rubygems'
36
- require 'rufus/lua'
37
-
38
- s = Rufus::Lua::State.new
39
-
40
- puts s.eval("return table.concat({ 'hello', 'from', 'Lua' }, ' ')")
41
- #
42
- # => "Hello from Lua"
43
-
44
- s.close
45
-
46
-
47
- === binding Ruby code as Lua functions
48
-
49
- require 'rubygems'
50
- require 'rufus/lua'
51
-
52
- s = Rufus::Lua::State.new
53
-
54
- s.function 'key_up' do |table|
55
- table.inject({}) do |h, (k, v)|
56
- h[k.to_s.upcase] = v
57
- end
58
- end
59
-
60
- p s.eval(%{
61
- local table = { CoW = 2, pigs = 3, DUCKS = 'none' }
62
- return key_up(table) -- calling Ruby from Lua...
63
- }).to_h
64
- # => { 'COW' => 2.0, 'DUCKS => 'none', 'PIGS' => 3.0 }
65
-
66
- s.close
67
-
68
-
69
- It's OK to bind a function inside of a table (library) :
70
-
71
- require 'rubygems'
72
- require 'rufus/lua'
73
-
74
- s = Rufus::Lua::State.new
75
-
76
- s.eval("rubies = {}")
77
- s.function 'add' do |x, y|
78
- x + y
79
- end
80
-
81
- s.eval("rubies.add(1, 2)")
82
- # => 3.0
83
-
84
- s.close
85
-
86
-
87
- You can omit the table definition (only 1 level allowed here though) :
88
-
89
- require 'rubygems'
90
- require 'rufus/lua'
91
-
92
- s = Rufus::Lua::State.new
93
-
94
- s.function 'rubies.add' do |x, y|
95
- x + y
96
- end
97
-
98
- s.eval("rubies.add(1, 2)")
99
- # => 3.0
100
-
101
- s.close
102
-
103
-
104
-
105
- The specs contain more examples :
106
-
107
- http://github.com/jmettraux/rufus-lua/tree/master/spec/
108
-
109
- rufus-lua's rdoc is at :
110
-
111
- http://rufus.rubyforge.org/rufus-lua/
112
-
113
-
114
- == compiling liblua.dylib
115
-
116
- original instructions by Adrian Perez at :
117
-
118
- http://lua-users.org/lists/lua-l/2006-09/msg00894.html
119
-
120
- get the source at
121
-
122
- http://www.lua.org/ftp/lua-5.1.4.tar.gz
123
-
124
- then
125
-
126
- tar xzvf lua-5.1.4.tar.gz
127
- cd lua-5.1.4
128
-
129
- modify the file src/Makefile as per http://lua-users.org/lists/lua-l/2006-09/msg00894.html
130
-
131
- make
132
- make macosx # or make linux ...
133
- make -C src liblua.dylib
134
- sudo cp src/liblua.dylib /usr/local/lib/
135
-
136
- sudo make macosx install
137
-
138
-
139
- == build dependencies
140
-
141
- The following gems are needed to run the specs
142
-
143
- sudo gem install bacon
144
-
145
-
146
- == tested with
147
-
148
- ruby 1.8.7p72, ruby 1.9.1p0, jruby 1.2.0
149
- jruby 1.1.6 has an issue with errors raised inside of Ruby functions (callbacks)
150
-
151
- ruby-ffi 0.4.0 and 0.5.0
152
-
153
-
154
- == dependencies
155
-
156
- the ruby gem 'ffi'
157
-
158
-
159
- == mailing list
160
-
161
- On the rufus-ruby list :
162
-
163
- http://groups.google.com/group/rufus-ruby
164
-
165
-
166
- == issue tracker
167
-
168
- http://github.com/jmettraux/rufus-lua/issues
169
-
170
-
171
- == irc
172
-
173
- irc.freenode.net #ruote
174
-
175
-
176
- == source
177
-
178
- http://github.com/jmettraux/rufus-lua
179
-
180
- git clone git://github.com/jmettraux/rufus-lua.git
181
-
182
-
183
- == credits
184
-
185
- many thanks to the authors of Ruby FFI, and of Lua
186
-
187
- http://wiki.github.com/ffi/ffi
188
- http://lua.org/
189
-
190
-
191
- == authors
192
-
193
- John Mettraux, jmettraux@gmail.com, http://jmettraux.wordpress.com
194
- Alain Hoang, http://blogs.law.harvard.edu/hoanga/
195
- Scott Persinger, http://github.com/scottpersinger/
196
-
197
-
198
- == the rest of Rufus
199
-
200
- http://rufus.rubyforge.org
201
-
202
-
203
- == license
204
-
205
- MIT
206
-
207
- Lua itself is licensed under the MIT license as well :
208
-
209
- http://www.lua.org/license.html
210
-