rlua 1.0rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/LICENSE.rdoc +167 -0
  2. data/README.rdoc +97 -0
  3. data/ext/extconf.rb +10 -0
  4. data/ext/rlua.c +1239 -0
  5. data/lib/rlua.rb +82 -0
  6. metadata +63 -0
data/lib/rlua.rb ADDED
@@ -0,0 +1,82 @@
1
+ # This file is part of RLua.
2
+ #
3
+ # RLua is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU Lesser General Public License as
5
+ # published by the Free Software Foundation, either version 3 of
6
+ # the License, or (at your option) any later version.
7
+ #
8
+ # RLua is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with RLua. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ require 'rlua.so'
17
+
18
+ module Lua
19
+ class Table
20
+ # Traverses the table using Lua::Table.next function.
21
+ def each(&block)
22
+ key = nil
23
+ loop {
24
+ key, value = *self.class.next(self, key)
25
+ break if key.nil?
26
+ block.call(key, value)
27
+ }
28
+ self
29
+ end
30
+
31
+ # Non-recursively converts table to hash.
32
+ def to_hash
33
+ hash = {}
34
+ each { |k, v| hash[k] = v }
35
+ hash
36
+ end
37
+
38
+ # Converts table to array. Only integer indexes are used.
39
+ def to_ary
40
+ ary = []
41
+ 1.upto(__length) { |i|
42
+ if self[i]
43
+ ary << self[i]
44
+ else
45
+ break
46
+ end
47
+ }
48
+ ary
49
+ end
50
+ alias :to_a :to_ary
51
+
52
+ # Recursively pretty-prints the table properly handling reference loops.
53
+ #
54
+ # +trace+ argument is internal, do not use it.
55
+ def inspect(trace=[])
56
+ if to_hash.empty?
57
+ "L{}"
58
+ elsif trace.include? self
59
+ "L{...}"
60
+ else
61
+ trace << self
62
+ v = []
63
+ each { |key, value|
64
+ s = ""
65
+ if key.class == self.class
66
+ s += key.inspect(trace)
67
+ else
68
+ s += key.inspect
69
+ end
70
+ s += " => "
71
+ if value.class == self.class
72
+ s += value.inspect(trace)
73
+ else
74
+ s += value.inspect
75
+ end
76
+ v << s
77
+ }
78
+ "L{#{v.join ', '}}"
79
+ end
80
+ end
81
+ end
82
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rlua
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0rc1
5
+ platform: ruby
6
+ authors:
7
+ - Peter Zotov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-03-31 00:00:00 +04:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: " Fully functional, almost complete Ruby to Lua binding library that\n features seamless translation of most Lua and Ruby objects and calling\n code of each language from other one.\n"
17
+ email: whitequark@whitequark.ru
18
+ executables: []
19
+
20
+ extensions:
21
+ - ext/extconf.rb
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ - LICENSE.rdoc
25
+ - ext/rlua.c
26
+ files:
27
+ - ext/rlua.c
28
+ - lib/rlua.rb
29
+ - README.rdoc
30
+ - LICENSE.rdoc
31
+ has_rdoc: true
32
+ homepage: http://rlua.rubyforge.org
33
+ licenses: []
34
+
35
+ post_install_message:
36
+ rdoc_options:
37
+ - -S
38
+ - -N
39
+ - --main=README.rdoc
40
+ - --title=RLua Documentation
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">"
52
+ - !ruby/object:Gem::Version
53
+ version: 1.3.1
54
+ version:
55
+ requirements: []
56
+
57
+ rubyforge_project: rlua
58
+ rubygems_version: 1.3.5
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: Ruby to Lua bindings.
62
+ test_files: []
63
+