lib/rupy/conversion.rb in rupy-0.4.1 vs lib/rupy/conversion.rb in rupy-0.4.2
- old
+ new
@@ -170,25 +170,25 @@
rb_hash
end
def self.rtopFunction(rObj)
proc = FFI::Function.new(:pointer, [:pointer, :pointer]) do |p_self, p_args|
- PyObject.new(rObj.call(*ptorTuple(p_args))).pointer
+ retval = rObj.call(*ptorTuple(p_args))
+ pObject = retval.is_a?(RubyPyProxy) ? retval.pObject : PyObject.new(retval)
+
+ # make sure the refcount is >1 when pObject is destroyed
+ pObject.xIncref
+ pObject.pointer
end
defn = Python::PyMethodDef.new
defn[:ml_name] = FFI::MemoryPointer.from_string("Rupy::Proc::%s" % rObj.object_id)
defn[:ml_meth] = proc
defn[:ml_flags] = Python::METH_VARARGS
defn[:ml_doc] = nil
return Python.PyCFunction_New(defn, nil)
end
-
- def self.rtopGenerator(rObj)
-
- end
-
#Converts a pointer to a Python object into a native ruby type, if
#possible. Otherwise raises an error.
#@param [FFI::Pointer] pObj a pointer to a Python object
#@return a native ruby object.