summaryrefslogtreecommitdiffstats
path: root/lib/efl/eina_list.rb
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-05-12 11:32:03 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-05-12 11:32:03 +0200
commitc4c02d3bdd9cecf03667f2e6d152300eb7678e48 (patch)
tree21e978145545a2cf75d3040493861904a5b19e53 /lib/efl/eina_list.rb
parentc18b9432eeabad028cd252d6a983c5abf06d9ac2 (diff)
downloadffi-efl-c4c02d3bdd9cecf03667f2e6d152300eb7678e48.zip
ffi-efl-c4c02d3bdd9cecf03667f2e6d152300eb7678e48.tar.gz
add REinaList#from_a
Diffstat (limited to 'lib/efl/eina_list.rb')
-rw-r--r--lib/efl/eina_list.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/efl/eina_list.rb b/lib/efl/eina_list.rb
index 15c1707..ba2bde3 100644
--- a/lib/efl/eina_list.rb
+++ b/lib/efl/eina_list.rb
@@ -40,6 +40,13 @@ module Efl
Native.eina_list_free @ptr
@ptr = nil
end
+ def self.from_a ary, ptrt
+ REinaList.new ary.inject(FFI::Pointer::NULL) { |p,e|
+ ptr = FFI::MemoryPointer.new ptrt
+ ptr.send 'write_'+ptrt.to_s, e
+ Native.eina_list_append p, ptr
+ }
+ end
def each
return if not block_given?
p = @ptr
@@ -49,8 +56,8 @@ module Efl
p = l[:next]
end
end
- def to_a
- inject([]) { |s,e| s<<e }
+ def to_a ptrt=nil
+ return inject([]) { |s,e| s<<e } if ptrt.nil?
end
alias :to_ary :to_a
# for fun and tests