summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/efl/eina_list.rb16
-rw-r--r--spec/eina_list_spec.rb14
2 files changed, 5 insertions, 25 deletions
diff --git a/lib/efl/eina_list.rb b/lib/efl/eina_list.rb
index 3d3ce83..3e014ad 100644
--- a/lib/efl/eina_list.rb
+++ b/lib/efl/eina_list.rb
@@ -3,17 +3,6 @@
#
require 'efl/ffi/eina_list'
#
-class Array
- def self.from_eina_list o
- if o.is_a? Efl::EinaList::REinaList
- o.to_ary
- elsif o.is_a? FFI::Pointer
- Efl::EinaList::REinaList.new(o).to_ary
- else
- raise ArgumentError.new "wrong argument #{o.class.name}"
- end
- end
-end
module Efl
module EinaList
#
@@ -36,8 +25,6 @@ module Efl
o
when NilClass
FFI::Pointer::NULL
- when self.class
- o.to_ptr
when Array
o.inject(FFI::Pointer::NULL) { |p,e| Efl::EinaList.eina_list_append p, e }
else
@@ -45,8 +32,7 @@ module Efl
end
)
end
- def free p=nil
- return Efl::EinaList.eina_list_free p unless p.nil?
+ def free
Efl::EinaList.eina_list_free @ptr
@ptr = nil
end
diff --git a/spec/eina_list_spec.rb b/spec/eina_list_spec.rb
index 66e65c8..96ac7bd 100644
--- a/spec/eina_list_spec.rb
+++ b/spec/eina_list_spec.rb
@@ -32,19 +32,13 @@ describe Efl::EinaList do
end
#
it "should be able to convert into ruby Array from NULL pointer" do
- ary = Array.from_eina_list ::FFI::Pointer::NULL
+ ary = REinaList.new(FFI::Pointer::NULL).to_ary
ary.empty?.should be_true
ary.is_a?(Array).should be_true
end
#
it "should be able to convert into ruby Array from empty REinaList" do
- ary = Array.from_eina_list REinaList.new
- ary.empty?.should be_true
- ary.is_a?(Array).should be_true
- end
- #
- it "should be able to convert into ruby Array from empty REinaList pointer" do
- ary = Array.from_eina_list REinaList.new.to_ptr
+ ary = REinaList.new.to_ary
ary.empty?.should be_true
ary.is_a?(Array).should be_true
end
@@ -59,7 +53,7 @@ describe Efl::EinaList do
l.prepend d2
l << d4
l.unshift d1
- ary = Array.from_eina_list l
+ ary = l.to_ary
ary.length.should == 4
0.upto 3 do |i|
ary[i].read_string.should == "D#{i}"
@@ -77,7 +71,7 @@ describe Efl::EinaList do
l.prepend d2
l << d4
l.unshift d1
- ary = Array.from_eina_list l.to_ptr
+ ary = l.to_ary
ary.length.should == 4
0.upto 3 do |i|
ary[i].read_string.should == "D#{i}"