summaryrefslogtreecommitdiffstats
path: root/lib/efl/eina_hash.rb
diff options
context:
space:
mode:
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?