Tamar 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +21 -3
- data/Rakefile +3 -0
- data/Tamar.gemspec +27 -2
- data/VERSION +1 -1
- data/src/build/extconf.rb +2 -0
- data/src/rubyluabridge/.hg_archival.txt +2 -0
- data/src/rubyluabridge/.project +91 -0
- data/src/rubyluabridge/LICENSE +31 -0
- data/src/rubyluabridge/LUA_IN_RUBY +146 -0
- data/src/rubyluabridge/README +129 -0
- data/src/rubyluabridge/RUBY_IN_LUA +25 -0
- data/src/rubyluabridge/Rakefile +88 -0
- data/src/rubyluabridge/build/extconf_osx.sh +2 -0
- data/src/rubyluabridge/build/extconf_ubuntu.sh +2 -0
- data/src/rubyluabridge/debian/changelog +34 -0
- data/src/rubyluabridge/debian/compat +1 -0
- data/src/rubyluabridge/debian/control +29 -0
- data/src/rubyluabridge/debian/copyright +34 -0
- data/src/rubyluabridge/debian/libluabridge-ruby1.8.doc-base +11 -0
- data/src/rubyluabridge/debian/libluabridge-ruby1.8.docs +2 -0
- data/src/rubyluabridge/debian/libluabridge-ruby1.8.install +1 -0
- data/src/rubyluabridge/debian/rules +65 -0
- data/src/rubyluabridge/debian/watch +2 -0
- data/src/rubyluabridge/doc/jamis.rb +591 -0
- data/src/rubyluabridge/extconf.rb +48 -0
- data/src/rubyluabridge/rubyluabridge.cc +1623 -0
- data/src/rubyluabridge/rubyluabridge.h +81 -0
- data/src/rubyluabridge/tests/lua_in_ruby_test.rb +508 -0
- metadata +28 -4
data/HISTORY
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
RELEASE HISTORY
|
2
2
|
|
3
|
+
v0.7.3 / 2011-05-23
|
4
|
+
|
5
|
+
Regenerate gemspec for version 0.7.3 (David Love david@homeunix.org.uk)
|
6
|
+
|
7
|
+
Changes:
|
8
|
+
|
9
|
+
* 3 General Enhancements
|
10
|
+
|
11
|
+
* Version bump to 0.7.3
|
12
|
+
* Update HISTORY file
|
13
|
+
* Regenerate gemspec for version 0.7.2
|
14
|
+
|
15
|
+
* 1 Patch Enhancements
|
16
|
+
|
17
|
+
* Include LuaDist in the gem
|
18
|
+
|
19
|
+
|
3
20
|
v0.7.2 / 2011-05-23
|
4
21
|
|
5
22
|
Regenerate gemspec for version 0.7.2 (David Love david@homeunix.org.uk)
|
@@ -59,11 +76,12 @@ Current Development (David Love)
|
|
59
76
|
|
60
77
|
Changes:
|
61
78
|
|
62
|
-
*
|
79
|
+
* 2 Patch Enhancements
|
63
80
|
|
64
|
-
*
|
81
|
+
* Copy build script from RubyLuaBridge
|
82
|
+
* Added sources for RubyLuaBridge 0.7.0
|
65
83
|
|
66
84
|
* 1 General Enhancements
|
67
85
|
|
68
|
-
* Regenerate gemspec for version 0.7.
|
86
|
+
* Regenerate gemspec for version 0.7.3
|
69
87
|
|
data/Rakefile
CHANGED
data/Tamar.gemspec
CHANGED
@@ -5,13 +5,14 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{Tamar}
|
8
|
-
s.version = "0.7.
|
8
|
+
s.version = "0.7.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Evan Wies, David Love"]
|
12
12
|
s.date = %q{2011-05-23}
|
13
13
|
s.description = %q{See: http://rubyluabridge.rubyforge.org}
|
14
14
|
s.email = %q{david@homeunix.org.uk}
|
15
|
+
s.extensions = ["src/build/extconf.rb"]
|
15
16
|
s.extra_rdoc_files = [
|
16
17
|
"LICENSE.txt",
|
17
18
|
"README.rdoc"
|
@@ -28,6 +29,7 @@ Gem::Specification.new do |s|
|
|
28
29
|
"Rakefile",
|
29
30
|
"Tamar.gemspec",
|
30
31
|
"VERSION",
|
32
|
+
"src/build/extconf.rb",
|
31
33
|
"src/luadist/CMakeLists.txt",
|
32
34
|
"src/luadist/COPYRIGHT",
|
33
35
|
"src/luadist/README",
|
@@ -52,7 +54,30 @@ Gem::Specification.new do |s|
|
|
52
54
|
"src/luadist/doc/modules/dist.package.html",
|
53
55
|
"src/luadist/doc/modules/dist.persist.html",
|
54
56
|
"src/luadist/doc/modules/dist.sys.html",
|
55
|
-
"src/luadist/luadist"
|
57
|
+
"src/luadist/luadist",
|
58
|
+
"src/rubyluabridge/.hg_archival.txt",
|
59
|
+
"src/rubyluabridge/.project",
|
60
|
+
"src/rubyluabridge/LICENSE",
|
61
|
+
"src/rubyluabridge/LUA_IN_RUBY",
|
62
|
+
"src/rubyluabridge/README",
|
63
|
+
"src/rubyluabridge/RUBY_IN_LUA",
|
64
|
+
"src/rubyluabridge/Rakefile",
|
65
|
+
"src/rubyluabridge/build/extconf_osx.sh",
|
66
|
+
"src/rubyluabridge/build/extconf_ubuntu.sh",
|
67
|
+
"src/rubyluabridge/debian/changelog",
|
68
|
+
"src/rubyluabridge/debian/compat",
|
69
|
+
"src/rubyluabridge/debian/control",
|
70
|
+
"src/rubyluabridge/debian/copyright",
|
71
|
+
"src/rubyluabridge/debian/libluabridge-ruby1.8.doc-base",
|
72
|
+
"src/rubyluabridge/debian/libluabridge-ruby1.8.docs",
|
73
|
+
"src/rubyluabridge/debian/libluabridge-ruby1.8.install",
|
74
|
+
"src/rubyluabridge/debian/rules",
|
75
|
+
"src/rubyluabridge/debian/watch",
|
76
|
+
"src/rubyluabridge/doc/jamis.rb",
|
77
|
+
"src/rubyluabridge/extconf.rb",
|
78
|
+
"src/rubyluabridge/rubyluabridge.cc",
|
79
|
+
"src/rubyluabridge/rubyluabridge.h",
|
80
|
+
"src/rubyluabridge/tests/lua_in_ruby_test.rb"
|
56
81
|
]
|
57
82
|
s.homepage = %q{http://rubyluabridge.rubyforge.org}
|
58
83
|
s.licenses = ["BSD"]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.4
|
@@ -0,0 +1,91 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<projectDescription>
|
3
|
+
<name>RubyLuaBridge</name>
|
4
|
+
<comment></comment>
|
5
|
+
<projects>
|
6
|
+
</projects>
|
7
|
+
<buildSpec>
|
8
|
+
<buildCommand>
|
9
|
+
<name>org.eclipse.cdt.make.core.makeBuilder</name>
|
10
|
+
<triggers>clean,full,incremental,</triggers>
|
11
|
+
<arguments>
|
12
|
+
<dictionary>
|
13
|
+
<key>org.eclipse.cdt.make.core.build.arguments</key>
|
14
|
+
<value></value>
|
15
|
+
</dictionary>
|
16
|
+
<dictionary>
|
17
|
+
<key>org.eclipse.cdt.core.errorOutputParser</key>
|
18
|
+
<value>org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser;</value>
|
19
|
+
</dictionary>
|
20
|
+
<dictionary>
|
21
|
+
<key>org.eclipse.cdt.make.core.environment</key>
|
22
|
+
<value></value>
|
23
|
+
</dictionary>
|
24
|
+
<dictionary>
|
25
|
+
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
26
|
+
<value>false</value>
|
27
|
+
</dictionary>
|
28
|
+
<dictionary>
|
29
|
+
<key>org.eclipse.cdt.make.core.build.target.inc</key>
|
30
|
+
<value>all</value>
|
31
|
+
</dictionary>
|
32
|
+
<dictionary>
|
33
|
+
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
34
|
+
<value>true</value>
|
35
|
+
</dictionary>
|
36
|
+
<dictionary>
|
37
|
+
<key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key>
|
38
|
+
<value>true</value>
|
39
|
+
</dictionary>
|
40
|
+
<dictionary>
|
41
|
+
<key>org.eclipse.cdt.make.core.build.location</key>
|
42
|
+
<value></value>
|
43
|
+
</dictionary>
|
44
|
+
<dictionary>
|
45
|
+
<key>org.eclipse.cdt.make.core.build.command</key>
|
46
|
+
<value>make</value>
|
47
|
+
</dictionary>
|
48
|
+
<dictionary>
|
49
|
+
<key>org.eclipse.cdt.make.core.build.target.clean</key>
|
50
|
+
<value>clean</value>
|
51
|
+
</dictionary>
|
52
|
+
<dictionary>
|
53
|
+
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
54
|
+
<value>true</value>
|
55
|
+
</dictionary>
|
56
|
+
<dictionary>
|
57
|
+
<key>org.eclipse.cdt.make.core.append_environment</key>
|
58
|
+
<value>true</value>
|
59
|
+
</dictionary>
|
60
|
+
<dictionary>
|
61
|
+
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
62
|
+
<value>true</value>
|
63
|
+
</dictionary>
|
64
|
+
<dictionary>
|
65
|
+
<key>org.eclipse.cdt.make.core.build.target.auto</key>
|
66
|
+
<value>all</value>
|
67
|
+
</dictionary>
|
68
|
+
<dictionary>
|
69
|
+
<key>org.eclipse.cdt.make.core.stopOnError</key>
|
70
|
+
<value>false</value>
|
71
|
+
</dictionary>
|
72
|
+
</arguments>
|
73
|
+
</buildCommand>
|
74
|
+
<buildCommand>
|
75
|
+
<name>org.eclipse.dltk.core.scriptbuilder</name>
|
76
|
+
<arguments>
|
77
|
+
</arguments>
|
78
|
+
</buildCommand>
|
79
|
+
<buildCommand>
|
80
|
+
<name>org.eclipse.cdt.make.core.ScannerConfigBuilder</name>
|
81
|
+
<arguments>
|
82
|
+
</arguments>
|
83
|
+
</buildCommand>
|
84
|
+
</buildSpec>
|
85
|
+
<natures>
|
86
|
+
<nature>org.eclipse.dltk.ruby.core.nature</nature>
|
87
|
+
<nature>org.eclipse.cdt.core.cnature</nature>
|
88
|
+
<nature>org.eclipse.cdt.make.core.makeNature</nature>
|
89
|
+
<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>
|
90
|
+
</natures>
|
91
|
+
</projectDescription>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
RubyLuaBridge
|
2
|
+
|
3
|
+
Licensed under the BSD License:
|
4
|
+
|
5
|
+
Copyright (c) 2007, Evan Wies
|
6
|
+
All rights reserved.
|
7
|
+
|
8
|
+
Redistribution and use in source and binary forms, with or without
|
9
|
+
modification, are permitted provided that the following conditions are met:
|
10
|
+
|
11
|
+
* Redistributions of source code must retain the above copyright
|
12
|
+
notice, this list of conditions and the following disclaimer.
|
13
|
+
|
14
|
+
* Redistributions in binary form must reproduce the above copyright
|
15
|
+
notice, this list of conditions and the following disclaimer in the
|
16
|
+
documentation and/or other materials provided with the distribution.
|
17
|
+
|
18
|
+
* Neither the name of the neomantra nor the names of its contributors may
|
19
|
+
be used to endorse or promote products derived from this software without
|
20
|
+
specific prior written permission.
|
21
|
+
|
22
|
+
THIS SOFTWARE IS PROVIDED BY Evan Wies ``AS IS'' AND ANY
|
23
|
+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
24
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
25
|
+
DISCLAIMED. IN NO EVENT SHALL Evan Wies BE LIABLE FOR ANY
|
26
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
27
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
28
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
29
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
30
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
31
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -0,0 +1,146 @@
|
|
1
|
+
= Using Lua in Ruby
|
2
|
+
|
3
|
+
Ruby is different in Lua in that there is a single Ruby VM, whereas there can be
|
4
|
+
many Lua states. A Lua virtual machine is wrapped in an instance of the Lua::State class.
|
5
|
+
You can have multiple Lua::States.
|
6
|
+
|
7
|
+
First, you need to require the RubyLuaBridge library and create a Lua::State. With this
|
8
|
+
instance, you can run Lua code, load Lua libraries, and access Lua objects.
|
9
|
+
|
10
|
+
require 'rubyluabridge'
|
11
|
+
l = Lua::State.new # we're gonna do a lot with this guy
|
12
|
+
|
13
|
+
Once you have a Lua::State, you can run Lua code using the Lua::State.eval. This method will
|
14
|
+
return whatever value is returned by the passed code. It will also raise an exception on errors.
|
15
|
+
|
16
|
+
l.eval "print('hello world')" # => nil
|
17
|
+
l.eval "function give_me_one() return 1 end" # => nil
|
18
|
+
l.eval("return give_me_one()") # => 1
|
19
|
+
|
20
|
+
Since Lua can return multiple values, Lua::State.eval_mult will return all values in an Array.
|
21
|
+
|
22
|
+
require 'pp'
|
23
|
+
pp l.eval_mult("return") # => []
|
24
|
+
pp l.eval_mult("return 1") # => [1.0]
|
25
|
+
pp l.eval_mult("return 1, 2, 3") # => [1.0, 2.0, 3.0]
|
26
|
+
|
27
|
+
Due to the dynamic natures of Ruby and Lua, you can easily query and set Lua values in a natural way.
|
28
|
+
You can use square brackets <tt>[key]</tt>, which is necessary if your key is not a string. Otherwise, string
|
29
|
+
keys can also be accessed by invoking it like a method (see example below).
|
30
|
+
Querying from the Lua::State will access the Lua global table.
|
31
|
+
|
32
|
+
l.eval <<LUA_END
|
33
|
+
n = 5 -- see how Ruby long strings
|
34
|
+
s = "hello" -- make it easy to embed Lua code?
|
35
|
+
a = { 1, 2, 3, 4 }
|
36
|
+
h = { a='x', b='y', }
|
37
|
+
LUA_END
|
38
|
+
l.n # => 5
|
39
|
+
l.s # => "hello"
|
40
|
+
l.a # => Lua::Table
|
41
|
+
l.a[1] # => 1
|
42
|
+
l.h # => Lua::Table
|
43
|
+
l.h['a'] # => "x"
|
44
|
+
l.h.a # => "x"
|
45
|
+
|
46
|
+
Similarly, you can use this style to set Lua variables. To make a new table, invoke _new_table_at_
|
47
|
+
on the object, specifying where you want it. Setting a Ruby Arrays or Hashes to a Lua variable will
|
48
|
+
create and assign a new table with a shallow copy of the Ruby container.
|
49
|
+
|
50
|
+
l.n = 5 # n = 5
|
51
|
+
l.new_table_at 't' # t = {}
|
52
|
+
l.t.u = 4 # t.u = 4
|
53
|
+
l.t['u'] = 4 # t.u = 4
|
54
|
+
l.a = [1,2] # t.a = { 1, 2 }
|
55
|
+
l.h = { 'a' => 'b' } # t.h = { a = 'b' }
|
56
|
+
|
57
|
+
When RubyLuaBridge has to marshal a table to Ruby, it return a Lua::Table. The Lua::Table implements
|
58
|
+
various iterators that take Ruby Blocks. There are two ways of looking at a Lua table.
|
59
|
+
The first is as a hash, where it has keys of any type mapping to values of any type. The second is as an array,
|
60
|
+
where it has integer keys from 1 to N, where N is the size of the array. The <tt>each_i*</tt> methods iterate
|
61
|
+
the table as an array, whereas the <tt>each_*</tt> methods (without the i) iterate the table as a hash. In
|
62
|
+
each case you can iterate of the keys, the values, or the pair [key, value]. Lua::Table#each is aliased to
|
63
|
+
Lua::Table#each_pair and Lua::Table#each_index is aliased to Lua::Table#each_ikey.
|
64
|
+
|
65
|
+
l.eval( "array = { 100, 200, 300, 400 }" )
|
66
|
+
l.array.each_ikey { |k| print "#{k} " } # 1 2 3 4
|
67
|
+
l.array.each_ivalue { |v| print "#{v} " } # 100.0 200.0 300.0 400.0
|
68
|
+
l.array.each_ipair { |k,v| print "#{k},#{v} " } # 1,100.0 2,200.0 3,300.0 4,400.0
|
69
|
+
|
70
|
+
l.eval( "hsh = { a = 100, b = 200, [1] = 300, [5] = 400 }" )
|
71
|
+
l.hsh.each_key { |k| print "#{k} " } # a 1.0 5.0 b
|
72
|
+
l.hsh.each_value { |v| print "#{v} " } # 100.0 300.0 400.0 200.0
|
73
|
+
l.hsh.each_pair { |k,v| print "#{k},#{v} " } # a,100.0 1.0,300.0 5.0,400.0 b,200.0
|
74
|
+
l.hsh.each_ikey { |k| print "#{k} " } # 1
|
75
|
+
l.hsh.each_ivalue { |v| print "#{v} " } # 300.0
|
76
|
+
l.hsh.each_ipair { |k,v| print "#{k},#{v} " } # 1,300.0
|
77
|
+
|
78
|
+
You can also extract a Ruby Hash or Array that is a shallow-copy of the table.
|
79
|
+
|
80
|
+
l.eval "a = {1,2} ; h = { a=3, b=4 }"
|
81
|
+
l.a.to_array # => [1, 2]
|
82
|
+
l.a.to_hash # => { 1 => 1, 2 => 2 }
|
83
|
+
l.h.to_array # => []
|
84
|
+
l.a.to_hash # => { 'a' => 3, 'b' => 4 }
|
85
|
+
|
86
|
+
Note that by default, all the Lua standard libraries are loaded into the Lua::State. You can
|
87
|
+
control this by passing :loadlibs option to Lua::State.new, or invoking Lua::State.__loadlibs:
|
88
|
+
|
89
|
+
l = Lua::State.new( :loadlibs => :none )
|
90
|
+
l = Lua::State.new( :loadlibs => [:base, :io, :debug] )
|
91
|
+
l.__loadlibs( :package )
|
92
|
+
l.__loadlibs( [:string, :math] )
|
93
|
+
|
94
|
+
|
95
|
+
<b>Note that Ruby Array's start with index 0, whereas Lua array's start with index 1.</b>
|
96
|
+
|
97
|
+
<b>Note for advanced Lua users:</b> all of these accesses use the Lua object's metamethods.
|
98
|
+
|
99
|
+
RubyLuaBridge has a comprehensive test suite (LuaInRuby_Test). Examine it to see various simple uses of
|
100
|
+
this library.
|
101
|
+
|
102
|
+
== Language Mismatchs
|
103
|
+
|
104
|
+
There are two sticky issues when trying to express ideas with RubyLuaBridge.
|
105
|
+
|
106
|
+
Lua uses a colon <tt>:</tt> syntax to define Lua's "methods", functions that have an implicit extra
|
107
|
+
parameter self. Ruby methods always have this self parameter implicitly. RubyLuaBridge's will only
|
108
|
+
pass the self parameter to a Lua function invocation if you end the method name with bang <tt>!</tt>.
|
109
|
+
The bang was chosen because it vaguely resembles a colon <tt>: !</tt>. Note that in Lua, the colon
|
110
|
+
is before the method name, but in RubyLuaBridge, the bang is after (but attached to) the method name.
|
111
|
+
|
112
|
+
Another issue is that it there is an ambiguity whether an index is meant to be a property or a function call.
|
113
|
+
This happens when there are no arguments, since Ruby's parentheses are optional. RubyLuaBridge always returns
|
114
|
+
the object when there are no arguments, unless it's name is suffixed with an underscore <tt>_</tt>. With the
|
115
|
+
underscore, RubyLuaBridge will invoke the object like a function. The underscore can be used with multiple
|
116
|
+
arguments as well. Awkwardly, it will do this parameter-less behavior even when paretheses are present,
|
117
|
+
so don't do that!
|
118
|
+
|
119
|
+
The one exception to the no argument behavior is if the object is a Lua function, in which case it is
|
120
|
+
dispatched. To get a reference to a function, rather than invoking it, use [].
|
121
|
+
|
122
|
+
Examples of this notation, with their semantics shown in the more explicit Lua code:
|
123
|
+
|
124
|
+
l.eval <<END_OF_LUA
|
125
|
+
obj = {
|
126
|
+
foo = function (...)
|
127
|
+
end,
|
128
|
+
bar = "a"
|
129
|
+
}
|
130
|
+
END_OF_LUA
|
131
|
+
|
132
|
+
l.obj.foo # return obj.foo()
|
133
|
+
l.obj.foo() # return obj.foo()
|
134
|
+
l.obj.foo_ # return obj.foo()
|
135
|
+
l.obj.foo 2 # return obj.foo(2)
|
136
|
+
l.obj.foo_ 2 # return obj.foo(2)
|
137
|
+
l.obj.foo! # return obj:foo(obj)
|
138
|
+
l.obj.foo! 2 # return obj:foo(obj, 2)
|
139
|
+
l.obj['foo'] # return obj.foo
|
140
|
+
|
141
|
+
l.obj.bar # return obj.bar
|
142
|
+
l.obj.bar() # return obj.bar -- yuck!
|
143
|
+
l.obj.bar_ # error("object not callable")
|
144
|
+
l.obj.bar! # error("object not callable")
|
145
|
+
l.obj.bar(2) # error("object not callable")
|
146
|
+
l.obj['bar'] # return obj.bar
|
@@ -0,0 +1,129 @@
|
|
1
|
+
= RubyLuaBridge - a seamless bridge between Ruby and Lua
|
2
|
+
|
3
|
+
RubyLuaBridge lets you access Lua from Ruby. Eventually, support for accessing Ruby from Lua will be added.
|
4
|
+
This documentation assumes basic knowledge of Ruby[http://www.ruby-lang.org] and Lua[http://www.lua.org].
|
5
|
+
|
6
|
+
Relevant web pages:
|
7
|
+
* {RubyLuaBridge Homepage}[http://rubyluabridge.rubyforge.org/]
|
8
|
+
* {RubyForge Project}[http://rubyforge.org/projects/rubyluabridge/]
|
9
|
+
|
10
|
+
== Installation
|
11
|
+
|
12
|
+
RubyLuaBridge is a C extension that uses the actual Lua C library. It currently targets Lua 5.1 and Ruby 1.8. You must run:
|
13
|
+
|
14
|
+
% ruby extconf.rb --with-lua-include=/path/to/lua/include --with-lualib=lualibname
|
15
|
+
% make
|
16
|
+
% sudo make install
|
17
|
+
|
18
|
+
There are extconf helpers for various platforms. Run these instead of the 'ruby extconf.rb'. Included are:
|
19
|
+
* build/extconf_osx.sh
|
20
|
+
* build/extconf_ubuntu.sh
|
21
|
+
|
22
|
+
== Basic Usage
|
23
|
+
|
24
|
+
Read about using {Lua in Ruby}[link:files/LUA_IN_RUBY.html].
|
25
|
+
|
26
|
+
NOT IMPLEMENTED YET, SUGGESTIONS ARE WELCOME. Read about using {Ruby in Lua}[link:files/RUBY_IN_LUA.html].
|
27
|
+
|
28
|
+
|
29
|
+
== Design Philosophy
|
30
|
+
|
31
|
+
* simplest marshalling possible
|
32
|
+
* simplest API possible
|
33
|
+
* do more complicated things in Lua itself, rather than exposing them!
|
34
|
+
For example, the coroutine library is not explicitly exposed because
|
35
|
+
it can be handled all through eval and indexing: <tt>l.coroutine.create(f)</tt>
|
36
|
+
|
37
|
+
|
38
|
+
== Ruby to Lua Type Mapping
|
39
|
+
|
40
|
+
*Ruby*:: *Lua*
|
41
|
+
nil:: nil
|
42
|
+
None:: nil
|
43
|
+
True:: true
|
44
|
+
False:: false
|
45
|
+
Fixnum:: number
|
46
|
+
Bignum:: number
|
47
|
+
Float:: number
|
48
|
+
String:: string
|
49
|
+
Symbol:: string
|
50
|
+
Hash:: new Lua::Table clone
|
51
|
+
Array:: new Lua::Table clone
|
52
|
+
everything else:: lightuserdata
|
53
|
+
|
54
|
+
|
55
|
+
== Lua to Ruby Type Mapping
|
56
|
+
|
57
|
+
*Lua*:: *Ruby*
|
58
|
+
none:: nil
|
59
|
+
nil:: nil
|
60
|
+
true:: True
|
61
|
+
false:: False
|
62
|
+
number:: Float
|
63
|
+
string:: String
|
64
|
+
table:: Lua::Table
|
65
|
+
lightuserdata:: Lua::RefObject
|
66
|
+
function:: Lua::RefObject
|
67
|
+
userdata:: Lua::RefObject
|
68
|
+
thread:: Lua::RefObject
|
69
|
+
|
70
|
+
|
71
|
+
== TODO
|
72
|
+
|
73
|
+
* package as gem
|
74
|
+
* stack trace in error callback
|
75
|
+
* how to get some external lua_State there?
|
76
|
+
* how to deal with .clone and .dup?
|
77
|
+
* accessing Ruby from Lua
|
78
|
+
|
79
|
+
== Credits
|
80
|
+
|
81
|
+
The following persons have contributed to RubyLuaBridge:
|
82
|
+
* Evan Wies (evan a neomantra d net)
|
83
|
+
|
84
|
+
RubyLuaBridge is inspired by, but not derived from:
|
85
|
+
* Lunatic Python [http://labix.org/lunatic-python]
|
86
|
+
* ruby-lua [http://raa.ruby-lang.org/project/ruby-lua]
|
87
|
+
|
88
|
+
|
89
|
+
== License
|
90
|
+
|
91
|
+
Licensed under the BSD License. It is free software, and may be
|
92
|
+
redistributed under the terms specified in the accompanying LICENSE file, as follows:
|
93
|
+
|
94
|
+
Copyright (c) 2007, Evan Wies. All rights reserved.
|
95
|
+
|
96
|
+
Redistribution and use in source and binary forms, with or without
|
97
|
+
modification, are permitted provided that the following conditions are met:
|
98
|
+
|
99
|
+
* Redistributions of source code must retain the above copyright
|
100
|
+
notice, this list of conditions and the following disclaimer.
|
101
|
+
|
102
|
+
* Redistributions in binary form must reproduce the above copyright
|
103
|
+
notice, this list of conditions and the following disclaimer in the
|
104
|
+
documentation and/or other materials provided with the distribution.
|
105
|
+
|
106
|
+
* Neither the name of the neomantra nor the names of its contributors may
|
107
|
+
be used to endorse or promote products derived from this software without
|
108
|
+
specific prior written permission.
|
109
|
+
|
110
|
+
THIS SOFTWARE IS PROVIDED BY Evan Wies ``AS IS'' AND ANY
|
111
|
+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
112
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
113
|
+
DISCLAIMED. IN NO EVENT SHALL Evan Wies BE LIABLE FOR ANY
|
114
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
115
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
116
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
117
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
118
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
119
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
120
|
+
|
121
|
+
|
122
|
+
== Support
|
123
|
+
|
124
|
+
* {RubyLuaBridge Homepage}[http://rubyluabridge.rubyforge.org/]
|
125
|
+
* {RubyForge Project}[http://rubyforge.org/projects/rubyluabridge/]
|
126
|
+
|
127
|
+
Download the latest sources from there. Please use the mailing list and issue tracking features as well.
|
128
|
+
|
129
|
+
I am particularly interested in problems you may have on various systems. I have only tested it in Ubuntu Dapper and MacOSX.
|
@@ -0,0 +1,25 @@
|
|
1
|
+
== Using Ruby in Lua
|
2
|
+
|
3
|
+
==NONE OF THIS IS IMPLEMENTED
|
4
|
+
|
5
|
+
==IF YOU HAVE SUGGESTIONS, TELL ME!
|
6
|
+
|
7
|
+
Ruby is different in Lua in that there is a single Ruby VM, whereas there can be
|
8
|
+
many Lua states. This is represented in Lua as an object in the global table named 'ruby'.
|
9
|
+
|
10
|
+
The first thing you need to require the RubyLuaBridge library. With this object, you can
|
11
|
+
run Ruby code, load Ruby libraries, and access Ruby objects.
|
12
|
+
|
13
|
+
require 'rubyluabridge'
|
14
|
+
print(ruby) # => userdata: 0x219083
|
15
|
+
|
16
|
+
With this +ruby+ object, you can get and set variables and invoke functions.
|
17
|
+
|
18
|
+
ruby.NilClass --
|
19
|
+
ruby.a = 5 --
|
20
|
+
ruby.print --
|
21
|
+
|
22
|
+
ruby.eval("print 'hello world'" # => nil
|
23
|
+
ruby.eval("1") # => 1
|
24
|
+
ruby.eval("'test'") # => "test"
|
25
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'rake/rdoctask'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/clean'
|
5
|
+
require 'rubygems'
|
6
|
+
|
7
|
+
#require 'rubyluabridge'
|
8
|
+
|
9
|
+
# Specifies the default task to execute. This is often the "test" task
|
10
|
+
# and we'll change things around as soon as we have some tests.
|
11
|
+
task :default => [:rdoc]
|
12
|
+
|
13
|
+
# The directory to generate +rdoc+ in.
|
14
|
+
RDOC_DIR = "doc/html"
|
15
|
+
|
16
|
+
# This global variable contains files that will be erased by the `clean` task.
|
17
|
+
# The `clean` task itself is automatically generated by requiring `rake/clean`.
|
18
|
+
CLEAN << RDOC_DIR
|
19
|
+
|
20
|
+
|
21
|
+
# This is the task that generates the +rdoc+ documentation from the
|
22
|
+
# source files. Instantiating Rake::RDocTask automatically generates a
|
23
|
+
# task called `rdoc`.
|
24
|
+
Rake::RDocTask.new("rdoc") do |rdoc|
|
25
|
+
|
26
|
+
rdoc.main = "README"
|
27
|
+
rdoc.rdoc_files.include(
|
28
|
+
"README", "LICENSE", "RUBY_IN_LUA", "LUA_IN_RUBY",
|
29
|
+
"rubyluabridge.cc", "tests/*.rb" )
|
30
|
+
rdoc.rdoc_dir = RDOC_DIR
|
31
|
+
|
32
|
+
rdoc.title = "RubyLuaBridge: A seamless bridge between Ruby and Lua."
|
33
|
+
|
34
|
+
rdoc.options = ["--line-numbers", "--inline-source"]
|
35
|
+
rdoc.template = 'doc/jamis.rb'
|
36
|
+
|
37
|
+
# Check:
|
38
|
+
# `rdoc --help` for more rdoc options
|
39
|
+
# the {rdoc documenation home}[http://www.ruby-doc.org/stdlib/libdoc/rdoc/rdoc/index.html]
|
40
|
+
# or the documentation for the +Rake::RDocTask+ task[http://rake.rubyforge.org/classes/Rake/RDocTask.html]
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
# The GemPackageTask facilitates getting all your files collected
|
45
|
+
# together into gem archives. You can also use it to generate tarball
|
46
|
+
# and zip archives.
|
47
|
+
PROJECT_NAME = "rubyluabridge"
|
48
|
+
PKG_VERSION = "0.5.0" #Lua::BRIDGE_VERSION
|
49
|
+
PKG_FILES = FileList['lib/**/*.rb', 'bin/**/*', 'examples/**/*', '[A-Z]*', 'test/**/*'].to_a
|
50
|
+
|
51
|
+
spec = Gem::Specification.new do |s|
|
52
|
+
s.platform = Gem::Platform::RUBY
|
53
|
+
s.summary = "RubyLuaBridge: A seamless bridge between Ruby and Lua."
|
54
|
+
s.name = PROJECT_NAME
|
55
|
+
s.version = PKG_VERSION
|
56
|
+
s.files = PKG_FILES
|
57
|
+
s.requirements << "none"
|
58
|
+
s.require_path = ''
|
59
|
+
s.description = <<END_DESC
|
60
|
+
RubyLuaBridge lets you access Lua from Ruby. Eventually, support for accessing Ruby from Lua will be added.
|
61
|
+
END_DESC
|
62
|
+
end
|
63
|
+
|
64
|
+
# Adding a new GemPackageTask adds a task named `package`, which generates
|
65
|
+
# packages as gems, tarball and zip archives.
|
66
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
67
|
+
pkg.need_zip = true
|
68
|
+
pkg.need_tar_gz = true
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
# This task will run the unit tests provided in files called
|
73
|
+
# 'tests/test*.rb'. The task itself can be run with a call to "rake test"
|
74
|
+
Rake::TestTask.new do |t|
|
75
|
+
#t.libs << "test"
|
76
|
+
#t.libs << "lib"
|
77
|
+
t.test_files = FileList['tests/*.rb']
|
78
|
+
t.verbose = true
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
desc "Install the jamis RDoc template"
|
83
|
+
task :install_jamis_template do
|
84
|
+
require 'rbconfig'
|
85
|
+
dest_dir = File.join(Config::CONFIG['rubylibdir'], "rdoc/generators/template/html")
|
86
|
+
fail "Unabled to write to #{dest_dir}" unless File.writable?(dest_dir)
|
87
|
+
install "doc/jamis.rb", dest_dir, :verbose => true
|
88
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
rubyluabridge (0.7.0-1) unstable; urgency=low
|
2
|
+
|
3
|
+
* Update to upstream 0.7
|
4
|
+
* Fixes longstanding garbage collection bugs.
|
5
|
+
|
6
|
+
-- Evan Wies <neomantra@gmail.com> Thu, 13 May 2010 02:13:04 -0500
|
7
|
+
|
8
|
+
rubyluabridge (0.6.0-4) unstable; urgency=low
|
9
|
+
|
10
|
+
* Update package section to ruby to comply with new archive layout.
|
11
|
+
* Bump standards version to 3.8.3 (no changes)
|
12
|
+
|
13
|
+
-- Roberto C. Sanchez <roberto@connexer.com> Thu, 27 Aug 2009 20:38:01 -0400
|
14
|
+
|
15
|
+
rubyluabridge (0.6.0-3) unstable; urgency=medium
|
16
|
+
|
17
|
+
* Quit installing the shared library into /usr/lib/ruby/1.8/i486-linux
|
18
|
+
on non-x86 platforms
|
19
|
+
|
20
|
+
-- Roberto C. Sanchez <roberto@connexer.com> Sat, 11 Oct 2008 10:24:54 -0400
|
21
|
+
|
22
|
+
rubyluabridge (0.6.0-2) unstable; urgency=high
|
23
|
+
|
24
|
+
* Bump Standards-Version to 3.8.0 (no changes).
|
25
|
+
* Change Build-Depends: libgems-ruby1.8 to rubygems1.8 (Closes: #490316)
|
26
|
+
- Fixes FTBFS, set urgency to high
|
27
|
+
|
28
|
+
-- Roberto C. Sanchez <roberto@connexer.com> Thu, 17 Jul 2008 21:32:25 -0400
|
29
|
+
|
30
|
+
rubyluabridge (0.6.0-1) unstable; urgency=low
|
31
|
+
|
32
|
+
* Initial release (Closes: #462033)
|
33
|
+
|
34
|
+
-- Roberto C. Sanchez <roberto@connexer.com> Thu, 14 Feb 2008 21:36:41 -0500
|
@@ -0,0 +1 @@
|
|
1
|
+
5
|