summaryrefslogtreecommitdiffstats
path: root/lib/efl/eina_hash.rb
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-05-01 08:49:59 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-05-01 08:49:59 +0200
commitbb7b6c52a50e65fb361ede8f26039b5822b9a0cb (patch)
tree632d6d68b93eb85350af21e05ed5575f7c377f9c /lib/efl/eina_hash.rb
parent51a6645abd257b37f3248ccf26b1007a7ac88208 (diff)
downloadffi-efl-bb7b6c52a50e65fb361ede8f26039b5822b9a0cb.zip
ffi-efl-bb7b6c52a50e65fb361ede8f26039b5822b9a0cb.tar.gz
fix AutoPointer usage, not sure about REinaHash, ...
Diffstat (limited to 'lib/efl/eina_hash.rb')
-rw-r--r--lib/efl/eina_hash.rb18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/efl/eina_hash.rb b/lib/efl/eina_hash.rb
index 4f4f44d..e47e2c1 100644
--- a/lib/efl/eina_hash.rb
+++ b/lib/efl/eina_hash.rb
@@ -25,24 +25,30 @@ module Efl
cstr = ( block_given? ? block : Proc.new { Efl::EinaHash.eina_hash_string_djb2_new FFI::Pointer::NULL } )
@ptr = (
case o
- when FFI::Pointer
- ( o==FFI::Pointer::NULL ? cstr.call : o )
when NilClass
cstr.call
+# FFI::AutoPointer.new cstr.call, method(:free)
when self.class
- o.ptr
+ o.to_ptr
+# when FFI::AutoPointer
+# o
+ when FFI::Pointer
+ ( o==FFI::Pointer::NULL ? cstr.call : o )
+# FFI::AutoPointer.new ( o==FFI::Pointer::NULL ? cstr.call : o ), method(:free)
when Hash
ptr = cstr.call
o.each do |k,v| Efl::EinaHash.eina_hash_add ptr, k, v end
ptr
+# FFI::AutoPointer.new ptr, method(:free)
else
raise ArgumentError.new "wrong argument #{o.class.name}"
end
)
end
- def free
- return if @ptr==FFI::Pointer::NULL
- @ptr = Efl::EinaHash.eina_hash_free @ptr
+ def free p=nil
+ return Efl::EinaHash.eina_hash_free p unless p.nil?
+ Efl::EinaHash.eina_hash_free @ptr
+ @ptr = nil
end
def each data=FFI::Pointer::NULL, &block
return if not block_given?