rufus-lua 1.1.2 → 1.1.3
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/CHANGELOG.txt +5 -0
- data/CREDITS.txt +1 -0
- data/LICENSE.txt +1 -1
- data/README.md +9 -5
- data/lib/rufus/lua.rb +1 -1
- data/lib/rufus/lua/error.rb +1 -1
- data/lib/rufus/lua/lib.rb +1 -1
- data/lib/rufus/lua/objects.rb +1 -1
- data/lib/rufus/lua/state.rb +2 -2
- data/lib/rufus/lua/utils.rb +1 -1
- data/lib/rufus/lua/version.rb +2 -2
- data/rufus-lua.gemspec +1 -2
- metadata +10 -45
- data/Rakefile +0 -82
- data/spec/coroutines_spec.rb +0 -136
- data/spec/error_handler_spec.rb +0 -222
- data/spec/eval_spec.rb +0 -165
- data/spec/functions_spec.rb +0 -119
- data/spec/gc_spec.rb +0 -41
- data/spec/lib_spec.rb +0 -32
- data/spec/rfunctions_spec.rb +0 -295
- data/spec/spec.rb +0 -9
- data/spec/spec_base.rb +0 -10
- data/spec/state_spec.rb +0 -106
- data/spec/string_spec.rb +0 -60
- data/spec/tables_spec.rb +0 -165
- data/spec/utils_spec.rb +0 -45
- data/test/bm0.rb +0 -41
- data/test/bm_fiber.rb +0 -78
- data/test/bm_gc_stop.rb +0 -43
- data/test/gc0.rb +0 -19
- data/test/t.rb +0 -19
data/CHANGELOG.txt
CHANGED
data/CREDITS.txt
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
Copyright (c) 2009-
|
2
|
+
Copyright (c) 2009-2016, John Mettraux, Alain Hoang.
|
3
3
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
# rufus-lua
|
3
3
|
|
4
|
-
[](http://badge.fury.io/rb/rufus-lua)
|
5
5
|
|
6
6
|
Lua embedded in Ruby, via Ruby FFI.
|
7
7
|
|
@@ -40,7 +40,7 @@ On Debian GNU/Linux, I do
|
|
40
40
|
sudo apt-get install liblua5.1-0
|
41
41
|
```
|
42
42
|
|
43
|
-
If your system's package manager doesn't have some version (5.1.x) of Lua around, jump to [compiling liblua.dylib](#compiling-libluadylib) below.
|
43
|
+
If your system's package manager doesn't have some version (5.1.x) of Lua around, jump to [compiling liblua.dylib](#compiling-libluadylib-osx) below or look at the [LuaBinaries solution](#lua-binaries-gnulinux) for GNU/Linux.
|
44
44
|
|
45
45
|
Rufus-lua will look for library in a [list of know places](https://github.com/jmettraux/rufus-lua/blob/9ddf26cde9f4a73115032504ad7f7eb688849b73/lib/rufus/lua/lib.rb#L38-L50).
|
46
46
|
|
@@ -56,7 +56,7 @@ export LUA_LIB=~/mystuff/lualib.5.1.4.so
|
|
56
56
|
ruby myluacode.rb
|
57
57
|
```
|
58
58
|
|
59
|
-
|
59
|
+
On Windows try using [rufus-lua-win](https://github.com/ukoloff/rufus-lua-win) gem.
|
60
60
|
|
61
61
|
## using rufus-lua
|
62
62
|
|
@@ -250,7 +250,7 @@ end
|
|
250
250
|
```
|
251
251
|
|
252
252
|
|
253
|
-
## compiling liblua.dylib
|
253
|
+
## compiling liblua.dylib (OSX)
|
254
254
|
|
255
255
|
original instructions by Adrian Perez at:
|
256
256
|
|
@@ -278,7 +278,7 @@ liblua.dylib: $(CORE_O) $(LIB_O)
|
|
278
278
|
Here's how to build the library file and deploy it:
|
279
279
|
```
|
280
280
|
make
|
281
|
-
make macosx
|
281
|
+
make macosx
|
282
282
|
make -C src liblua.dylib
|
283
283
|
sudo cp src/liblua.dylib /usr/local/lib/
|
284
284
|
|
@@ -294,6 +294,10 @@ sudo cp src/liblua.dylib /usr/local/lib/liblua.5.1.4.dylib
|
|
294
294
|
#sudo cp src/liblua.dylib /usr/local/lib/
|
295
295
|
```
|
296
296
|
|
297
|
+
## lua binaries (GNU/Linux)
|
298
|
+
|
299
|
+
Hat tip to [Micka33](https://github.com/Micka33) for pointing to [LuaBinaries](http://luabinaries.sourceforge.net/download.html) in [issue #34](https://github.com/jmettraux/rufus-lua/issues/34)
|
300
|
+
|
297
301
|
|
298
302
|
## tested with
|
299
303
|
|
data/lib/rufus/lua.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2009-
|
2
|
+
# Copyright (c) 2009-2016, John Mettraux, Alain Hoang.
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/rufus/lua/error.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2009-
|
2
|
+
# Copyright (c) 2009-2016, John Mettraux, Alain Hoang.
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/rufus/lua/lib.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2009-
|
2
|
+
# Copyright (c) 2009-2016, John Mettraux, Alain Hoang.
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/rufus/lua/objects.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2009-
|
2
|
+
# Copyright (c) 2009-2016, John Mettraux, Alain Hoang.
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/rufus/lua/state.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2009-
|
2
|
+
# Copyright (c) 2009-2016, John Mettraux, Alain Hoang.
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -91,7 +91,7 @@ module Rufus::Lua
|
|
91
91
|
bottom = stack_top
|
92
92
|
chunk = filename ? "#{filename}:#{lineno}" : 'line'
|
93
93
|
|
94
|
-
err = Lib.luaL_loadbuffer(@pointer, s, s.
|
94
|
+
err = Lib.luaL_loadbuffer(@pointer, s, s.bytesize, chunk)
|
95
95
|
fail_if_error('eval:compile', err, bndng, filename, lineno)
|
96
96
|
|
97
97
|
pcall(bottom, 0, bndng, filename, lineno) # arg_count is set to 0
|
data/lib/rufus/lua/utils.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2009-
|
2
|
+
# Copyright (c) 2009-2016, John Mettraux, Alain Hoang.
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
data/lib/rufus/lua/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2009-
|
2
|
+
# Copyright (c) 2009-2016, John Mettraux, Alain Hoang.
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -26,7 +26,7 @@
|
|
26
26
|
module Rufus
|
27
27
|
module Lua
|
28
28
|
|
29
|
-
VERSION = '1.1.
|
29
|
+
VERSION = '1.1.3'
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
data/rufus-lua.gemspec
CHANGED
@@ -22,13 +22,12 @@ ruby-ffi based bridge from Ruby to Lua
|
|
22
22
|
#s.files = `git ls-files`.split("\n")
|
23
23
|
s.files = Dir[
|
24
24
|
'Rakefile',
|
25
|
-
'lib/**/*.rb', 'spec/**/*.rb', 'test/**/*.rb',
|
25
|
+
'lib/**/*.rb', #'spec/**/*.rb', 'test/**/*.rb',
|
26
26
|
'*.gemspec', '*.txt', '*.rdoc', '*.md'
|
27
27
|
]
|
28
28
|
|
29
29
|
s.add_dependency 'ffi', '~> 1.9'
|
30
30
|
|
31
|
-
s.add_development_dependency 'rake'
|
32
31
|
s.add_development_dependency 'rspec', '>= 2.13.0'
|
33
32
|
|
34
33
|
s.require_path = 'lib'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rufus-lua
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2016-08-21 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: ffi
|
@@ -29,22 +29,6 @@ dependencies:
|
|
29
29
|
- - ~>
|
30
30
|
- !ruby/object:Gem::Version
|
31
31
|
version: '1.9'
|
32
|
-
- !ruby/object:Gem::Dependency
|
33
|
-
name: rake
|
34
|
-
requirement: !ruby/object:Gem::Requirement
|
35
|
-
none: false
|
36
|
-
requirements:
|
37
|
-
- - ! '>='
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '0'
|
40
|
-
type: :development
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
|
-
requirements:
|
45
|
-
- - ! '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
32
|
- !ruby/object:Gem::Dependency
|
49
33
|
name: rspec
|
50
34
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,38 +52,19 @@ executables: []
|
|
68
52
|
extensions: []
|
69
53
|
extra_rdoc_files: []
|
70
54
|
files:
|
71
|
-
- Rakefile
|
72
|
-
- lib/rufus-lua.rb
|
73
|
-
- lib/rufus/lua.rb
|
74
55
|
- lib/rufus/lua/error.rb
|
75
|
-
- lib/rufus/lua/state.rb
|
76
56
|
- lib/rufus/lua/lib.rb
|
77
|
-
- lib/rufus/lua/version.rb
|
78
|
-
- lib/rufus/lua/utils.rb
|
79
57
|
- lib/rufus/lua/objects.rb
|
80
|
-
-
|
81
|
-
-
|
82
|
-
-
|
83
|
-
-
|
84
|
-
-
|
85
|
-
- spec/eval_spec.rb
|
86
|
-
- spec/state_spec.rb
|
87
|
-
- spec/spec_base.rb
|
88
|
-
- spec/error_handler_spec.rb
|
89
|
-
- spec/string_spec.rb
|
90
|
-
- spec/gc_spec.rb
|
91
|
-
- spec/lib_spec.rb
|
92
|
-
- spec/spec.rb
|
93
|
-
- test/bm0.rb
|
94
|
-
- test/t.rb
|
95
|
-
- test/gc0.rb
|
96
|
-
- test/bm_gc_stop.rb
|
97
|
-
- test/bm_fiber.rb
|
58
|
+
- lib/rufus/lua/state.rb
|
59
|
+
- lib/rufus/lua/utils.rb
|
60
|
+
- lib/rufus/lua/version.rb
|
61
|
+
- lib/rufus/lua.rb
|
62
|
+
- lib/rufus-lua.rb
|
98
63
|
- rufus-lua.gemspec
|
99
64
|
- CHANGELOG.txt
|
100
|
-
- TODO.txt
|
101
|
-
- LICENSE.txt
|
102
65
|
- CREDITS.txt
|
66
|
+
- LICENSE.txt
|
67
|
+
- TODO.txt
|
103
68
|
- README.md
|
104
69
|
homepage: https://github.com/jmettraux/rufus-lua
|
105
70
|
licenses:
|
@@ -122,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
87
|
version: '0'
|
123
88
|
requirements: []
|
124
89
|
rubyforge_project: rufus
|
125
|
-
rubygems_version: 1.8.23
|
90
|
+
rubygems_version: 1.8.23.2
|
126
91
|
signing_key:
|
127
92
|
specification_version: 3
|
128
93
|
summary: ruby-ffi based bridge from Ruby to Lua
|
data/Rakefile
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
|
2
|
-
$:.unshift('.') # 1.9.2
|
3
|
-
|
4
|
-
require 'rake'
|
5
|
-
require 'rake/clean'
|
6
|
-
require 'rspec/core/rake_task'
|
7
|
-
|
8
|
-
|
9
|
-
#
|
10
|
-
# clean
|
11
|
-
|
12
|
-
CLEAN.include('pkg', 'rdoc')
|
13
|
-
|
14
|
-
|
15
|
-
#
|
16
|
-
# test / spec
|
17
|
-
|
18
|
-
RSpec::Core::RakeTask.new
|
19
|
-
|
20
|
-
task :test => :spec
|
21
|
-
task :default => :spec
|
22
|
-
|
23
|
-
|
24
|
-
#
|
25
|
-
# gem
|
26
|
-
|
27
|
-
GEMSPEC_FILE = Dir['*.gemspec'].first
|
28
|
-
GEMSPEC = eval(File.read(GEMSPEC_FILE))
|
29
|
-
GEMSPEC.validate
|
30
|
-
|
31
|
-
|
32
|
-
desc %{
|
33
|
-
builds the gem and places it in pkg/
|
34
|
-
}
|
35
|
-
task :build do
|
36
|
-
|
37
|
-
sh "gem build #{GEMSPEC_FILE}"
|
38
|
-
sh "mkdir pkg" rescue nil
|
39
|
-
sh "mv #{GEMSPEC.name}-#{GEMSPEC.version}.gem pkg/"
|
40
|
-
end
|
41
|
-
|
42
|
-
desc %{
|
43
|
-
builds the gem and pushes it to rubygems.org
|
44
|
-
}
|
45
|
-
task :push => :build do
|
46
|
-
|
47
|
-
sh "gem push pkg/#{GEMSPEC.name}-#{GEMSPEC.version}.gem"
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
##
|
52
|
-
## rdoc
|
53
|
-
##
|
54
|
-
## make sure to have rdoc 2.5.x to run that
|
55
|
-
#
|
56
|
-
#Rake::RDocTask.new do |rd|
|
57
|
-
#
|
58
|
-
# rd.main = 'README.txt'
|
59
|
-
# rd.rdoc_dir = "rdoc/#{GEMSPEC.name}"
|
60
|
-
#
|
61
|
-
# rd.rdoc_files.include('README.mdown', 'CHANGELOG.txt', 'lib/**/*.rb')
|
62
|
-
#
|
63
|
-
# rd.title = "#{GEMSPEC.name} #{GEMSPEC.version}"
|
64
|
-
#end
|
65
|
-
#
|
66
|
-
#
|
67
|
-
##
|
68
|
-
## upload_rdoc
|
69
|
-
#
|
70
|
-
#desc %{
|
71
|
-
# upload the rdoc to rubyforge
|
72
|
-
#}
|
73
|
-
#task :upload_rdoc => [ :clean, :rdoc ] do
|
74
|
-
#
|
75
|
-
# account = 'jmettraux@rubyforge.org'
|
76
|
-
# webdir = '/var/www/gforge-projects/rufus'
|
77
|
-
#
|
78
|
-
# sh "rsync -azv -e ssh rdoc/#{GEMSPEC.name} #{account}:#{webdir}/"
|
79
|
-
#end
|
80
|
-
#
|
81
|
-
# keep that in the fridge for now
|
82
|
-
|
data/spec/coroutines_spec.rb
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Specifying rufus-lua
|
4
|
-
#
|
5
|
-
# Sat Mar 14 23:51:42 JST 2009
|
6
|
-
#
|
7
|
-
|
8
|
-
require 'spec_base'
|
9
|
-
|
10
|
-
|
11
|
-
describe Rufus::Lua::State do
|
12
|
-
|
13
|
-
describe 'a Lua coroutine' do
|
14
|
-
|
15
|
-
before do
|
16
|
-
@s = Rufus::Lua::State.new
|
17
|
-
end
|
18
|
-
after do
|
19
|
-
@s.close
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'can be returned to Ruby' do
|
23
|
-
|
24
|
-
expect(@s.eval(
|
25
|
-
'return coroutine.create(function (x) end)'
|
26
|
-
).class).to eq(Rufus::Lua::Coroutine)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'has a status visible from Ruby' do
|
30
|
-
|
31
|
-
co = @s.eval(
|
32
|
-
'return coroutine.create(function (x) end)'
|
33
|
-
)
|
34
|
-
expect(co.status).to eq('suspended')
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'can be resumed from Ruby' do
|
38
|
-
|
39
|
-
@s.eval(%{
|
40
|
-
co = coroutine.create(function (x)
|
41
|
-
while true do
|
42
|
-
coroutine.yield(x)
|
43
|
-
end
|
44
|
-
end)
|
45
|
-
})
|
46
|
-
expect(@s['co'].resume(7)).to eq [ true, 7.0 ]
|
47
|
-
expect(@s['co'].resume()).to eq [ true, 7.0 ]
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'can be resumed from Ruby (and is not averse to \0 bytes)' do
|
51
|
-
|
52
|
-
@s.eval(%{
|
53
|
-
co = coroutine.create(function (x)
|
54
|
-
while true do
|
55
|
-
coroutine.yield(x)
|
56
|
-
end
|
57
|
-
end)
|
58
|
-
})
|
59
|
-
s = [ 0, 64, 0, 0, 65, 0 ].pack('c*')
|
60
|
-
expect(@s['co'].resume(s)).to eq [ true, s ]
|
61
|
-
expect(@s['co'].resume()).to eq [ true, s ]
|
62
|
-
end
|
63
|
-
|
64
|
-
# compressed version of the spec proposed by Nathanael Jones
|
65
|
-
# in https://github.com/nathanaeljones/rufus-lua/commit/179184aS
|
66
|
-
#
|
67
|
-
# for https://github.com/jmettraux/rufus-lua/issues/19
|
68
|
-
#
|
69
|
-
it 'yields the right value' do
|
70
|
-
|
71
|
-
@s.function :host_function do
|
72
|
-
'success'
|
73
|
-
end
|
74
|
-
r = @s.eval(%{
|
75
|
-
function routine()
|
76
|
-
coroutine.yield(host_function())
|
77
|
-
end
|
78
|
-
co = coroutine.create(routine)
|
79
|
-
a, b = coroutine.resume(co)
|
80
|
-
return { a, b }
|
81
|
-
}).to_ruby
|
82
|
-
|
83
|
-
expect(r).to eq([ true, 'success' ])
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'executes a ruby function within a coroutine' do
|
87
|
-
|
88
|
-
run_count = 0
|
89
|
-
|
90
|
-
@s.function :host_function do
|
91
|
-
run_count += 1
|
92
|
-
end
|
93
|
-
r = @s.eval(%{
|
94
|
-
function routine()
|
95
|
-
host_function()
|
96
|
-
coroutine.yield()
|
97
|
-
host_function()
|
98
|
-
coroutine.yield()
|
99
|
-
end
|
100
|
-
co = coroutine.create(routine)
|
101
|
-
a, b = coroutine.resume(co)
|
102
|
-
a, b = coroutine.resume(co)
|
103
|
-
return { a, b }
|
104
|
-
}).to_ruby
|
105
|
-
|
106
|
-
expect(r).to eq([ true])
|
107
|
-
expect(run_count).to eq(2)
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'executes a ruby function (with arguments) within a coroutine' do
|
111
|
-
|
112
|
-
run_count = 0
|
113
|
-
last_arguments = nil
|
114
|
-
|
115
|
-
@s.function :host_function, { :to_ruby => true } do |*args|
|
116
|
-
run_count += 1
|
117
|
-
last_arguments = args
|
118
|
-
0
|
119
|
-
end
|
120
|
-
r = @s.eval(%{
|
121
|
-
function routine()
|
122
|
-
host_function("hi")
|
123
|
-
coroutine.yield()
|
124
|
-
end
|
125
|
-
co = coroutine.create(routine)
|
126
|
-
a, b = coroutine.resume(co)
|
127
|
-
return { a, b }
|
128
|
-
}).to_ruby
|
129
|
-
|
130
|
-
expect(r).to eq([ true ])
|
131
|
-
expect(run_count).to eq(1)
|
132
|
-
expect(last_arguments).to eq([ "hi" ])
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|