summaryrefslogtreecommitdiffstats
path: root/lib/efl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/efl')
-rw-r--r--lib/efl/ecore_evas.rb3
-rw-r--r--lib/efl/eina_hash.rb18
-rw-r--r--lib/efl/eina_list.rb9
-rw-r--r--lib/efl/evas.rb6
4 files changed, 23 insertions, 13 deletions
diff --git a/lib/efl/ecore_evas.rb b/lib/efl/ecore_evas.rb
index 6a592dc..6dadd3f 100644
--- a/lib/efl/ecore_evas.rb
+++ b/lib/efl/ecore_evas.rb
@@ -27,7 +27,8 @@ module Efl
)
yield self if block_given?
end
- def free
+ def free p=nil
+ return Efl::EcoreEvas.ecore_evas_free p unless p.nil?
Efl::EcoreEvas.ecore_evas_free @ptr
@ptr=nil
end
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?
diff --git a/lib/efl/eina_list.rb b/lib/efl/eina_list.rb
index 42395b2..3d3ce83 100644
--- a/lib/efl/eina_list.rb
+++ b/lib/efl/eina_list.rb
@@ -37,7 +37,7 @@ module Efl
when NilClass
FFI::Pointer::NULL
when self.class
- o.ptr
+ o.to_ptr
when Array
o.inject(FFI::Pointer::NULL) { |p,e| Efl::EinaList.eina_list_append p, e }
else
@@ -45,9 +45,10 @@ module Efl
end
)
end
- def free
- return if @ptr==FFI::Pointer::NULL
- @ptr = Efl::EinaList.eina_list_free @ptr
+ def free p=nil
+ return Efl::EinaList.eina_list_free p unless p.nil?
+ Efl::EinaList.eina_list_free @ptr
+ @ptr = nil
end
def each
p = @ptr
diff --git a/lib/efl/evas.rb b/lib/efl/evas.rb
index d6f476b..56657d3 100644
--- a/lib/efl/evas.rb
+++ b/lib/efl/evas.rb
@@ -63,7 +63,8 @@ module Efl
)
yield self if block_given?
end
- def free
+ def free p=nil
+ return Efl::Evas.evas_free p unless p.nil?
Efl::Evas.evas_free @ptr
@ptr=nil
end
@@ -120,7 +121,8 @@ module Efl
)
yield self if block_given?
end
- def free
+ def free p=nil
+ return Efl::Evas.evas_object_del p unless p.nil?
Efl::Evas.evas_object_del @ptr
@ptr=nil
end