rupy 0.4.1 → 0.4.2
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/Rakefile +21 -21
- data/lib/rupy/conversion.rb +6 -6
- data/lib/rupy/pygenerator.rb +9 -6
- data/lib/rupy/version.rb +1 -1
- metadata +3 -3
data/Rakefile
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rspec/rake/spectask'
|
3
|
-
require 'yard'
|
4
|
-
|
5
|
-
desc "Run all examples"
|
6
|
-
Spec::Rake::SpecTask.new('spec') do |t|
|
7
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
8
|
-
end
|
9
|
-
|
10
|
-
desc "Run all examples with RCov"
|
11
|
-
Spec::Rake::SpecTask.new('spec:rcov') do |t|
|
12
|
-
t.spec_files = FileList['spec/**/*.rb']
|
13
|
-
t.rcov = true
|
14
|
-
t.rcov_opts = ['--exclude', 'spec']
|
15
|
-
end
|
16
|
-
|
17
|
-
YARD::Rake::YardocTask.new do |t|
|
18
|
-
t.options = [ '--markup','markdown', '--title', 'RubyPython Documentation' ]
|
19
|
-
end
|
20
|
-
|
21
|
-
Dir['tasks/**/*.rake'].each { |rake| load rake }
|
1
|
+
require 'rake'
|
2
|
+
require 'rspec/rake/spectask'
|
3
|
+
require 'yard'
|
4
|
+
|
5
|
+
desc "Run all examples"
|
6
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
7
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Run all examples with RCov"
|
11
|
+
Spec::Rake::SpecTask.new('spec:rcov') do |t|
|
12
|
+
t.spec_files = FileList['spec/**/*.rb']
|
13
|
+
t.rcov = true
|
14
|
+
t.rcov_opts = ['--exclude', 'spec']
|
15
|
+
end
|
16
|
+
|
17
|
+
YARD::Rake::YardocTask.new do |t|
|
18
|
+
t.options = [ '--markup','markdown', '--title', 'RubyPython Documentation' ]
|
19
|
+
end
|
20
|
+
|
21
|
+
Dir['tasks/**/*.rake'].each { |rake| load rake }
|
data/lib/rupy/conversion.rb
CHANGED
@@ -172,7 +172,12 @@ module Rupy
|
|
172
172
|
|
173
173
|
def self.rtopFunction(rObj)
|
174
174
|
proc = FFI::Function.new(:pointer, [:pointer, :pointer]) do |p_self, p_args|
|
175
|
-
|
175
|
+
retval = rObj.call(*ptorTuple(p_args))
|
176
|
+
pObject = retval.is_a?(RubyPyProxy) ? retval.pObject : PyObject.new(retval)
|
177
|
+
|
178
|
+
# make sure the refcount is >1 when pObject is destroyed
|
179
|
+
pObject.xIncref
|
180
|
+
pObject.pointer
|
176
181
|
end
|
177
182
|
|
178
183
|
defn = Python::PyMethodDef.new
|
@@ -184,11 +189,6 @@ module Rupy
|
|
184
189
|
return Python.PyCFunction_New(defn, nil)
|
185
190
|
end
|
186
191
|
|
187
|
-
def self.rtopGenerator(rObj)
|
188
|
-
|
189
|
-
end
|
190
|
-
|
191
|
-
|
192
192
|
#Converts a pointer to a Python object into a native ruby type, if
|
193
193
|
#possible. Otherwise raises an error.
|
194
194
|
#@param [FFI::Pointer] pObj a pointer to a Python object
|
data/lib/rupy/pygenerator.rb
CHANGED
@@ -38,13 +38,16 @@ def rupy_generator(callback):
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def generator
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
return lambda do |*args|
|
42
|
+
fib = Fiber.new do
|
43
|
+
yield *args
|
44
|
+
Python.PyErr_SetNone(Python.PyExc_StopIteration)
|
45
|
+
FFI::Pointer::NULL
|
46
|
+
end
|
47
|
+
generator_type.__call__(lambda do
|
48
|
+
fib.resume
|
49
|
+
end)
|
45
50
|
end
|
46
|
-
|
47
|
-
return lambda { generator_type.__call__(lambda { fib.resume }).pObject.pointer }
|
48
51
|
end
|
49
52
|
|
50
53
|
def yield(*args)
|
data/lib/rupy/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 2
|
9
|
+
version: 0.4.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Steeve Morin
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-11 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|