transparent-lua 0.2 → 0.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.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MGMyY2IzNDkyY2I1NTVlYzU2YTlkMjdjM2UyM2U4ZjZmM2YyMTAyMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjIwMzJjYjI1ZDBhMzQwNTJiNWY2ZWYwOGMzZjdhMjI1M2JjYzIzNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDAzMTgwMjA5ZWZmYTMwMjUxNTU3ZmM5YzRkNjg5YmZkMzU3ZWNhZjBkN2U4
|
10
|
+
NGRkOGZmMDZlNWU4NTM5YTQ4ZTg5Y2NiMmZhMTk2ODJkNGE2NzUzZDgzMjQ1
|
11
|
+
MWNmOTc0Mjg1MWM4NTcwN2UyM2MxOTBiM2RmYTJkYjdhYTIwNTU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Y2M2ZDBiNDdkMTllN2I2OGFhZDgxNTMzNGE1MWY4YzhjNzUxZDhjOWExNjJi
|
14
|
+
NmExY2VkZjJjYzUwZmRkNGY2Y2UzODM5ZTI3YmZiZDFjNTFmZGYwMTZjNzI2
|
15
|
+
MzA3NGVkYzMwNmE0NTYyYWYyMWFkZmVhODNkODU4M2Q3ODQ0MDc=
|
@@ -8,7 +8,7 @@ Feature: Sandbox exposition
|
|
8
8
|
Then it should return "OK"
|
9
9
|
|
10
10
|
Scenario Outline: Exposing member class methods to the lua script
|
11
|
-
Given
|
11
|
+
Given a sandbox with an empty member class
|
12
12
|
And the following method definition as part of the member class: def <method_signature>; <method_body>; end;
|
13
13
|
And the following line as Lua script: return(<method_call>);
|
14
14
|
When I execute the script
|
@@ -73,4 +73,14 @@ Feature: Sandbox exposition
|
|
73
73
|
When I execute the script
|
74
74
|
Then the result of @sandbox.struct.values should include('Hi')
|
75
75
|
|
76
|
+
Scenario: Passing instances to methods as arguments
|
77
|
+
Given a sandbox with an empty member class
|
78
|
+
And the following code executed in the sandbox: def ret(param); param.inspect; end
|
79
|
+
And the following Lua script:
|
80
|
+
"""
|
81
|
+
return(ret(member_class));
|
82
|
+
"""
|
83
|
+
When I execute the script
|
84
|
+
Then it should return "#<Sandbox Member Class>"
|
85
|
+
|
76
86
|
|
data/lib/transparent_lua.rb
CHANGED
@@ -57,7 +57,7 @@ class TransparentLua
|
|
57
57
|
'__index' => index_table(object),
|
58
58
|
'__newindex' => newindex_table(object),
|
59
59
|
}
|
60
|
-
|
60
|
+
delegation_table(object, metatable)
|
61
61
|
end
|
62
62
|
|
63
63
|
def newindex_table(object)
|
@@ -93,16 +93,25 @@ class TransparentLua
|
|
93
93
|
|
94
94
|
# @param [Method] method
|
95
95
|
def method_table(method)
|
96
|
-
|
96
|
+
delegation_table(
|
97
97
|
'__call' => ->(t, *args) do
|
98
|
-
|
98
|
+
converted_args = args.collect do |arg|
|
99
|
+
case arg
|
100
|
+
when Lua::Table
|
101
|
+
ObjectSpace._id2ref(Integer(arg.__rb_object_id))
|
102
|
+
else
|
103
|
+
arg
|
104
|
+
end
|
105
|
+
end
|
106
|
+
getter_table(method.call(*converted_args))
|
99
107
|
end
|
100
108
|
)
|
101
109
|
end
|
102
110
|
|
103
|
-
def
|
104
|
-
tab
|
105
|
-
tab.
|
111
|
+
def delegation_table(object = nil, hash)
|
112
|
+
tab = Lua::Table.new(@state)
|
113
|
+
tab.__rb_object_id = -> { object.__id__ } if object
|
114
|
+
tab.__metatable = hash
|
106
115
|
tab
|
107
116
|
end
|
108
117
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transparent-lua
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Haase
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rlua
|