From c4c02d3bdd9cecf03667f2e6d152300eb7678e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 12 May 2011 11:32:03 +0200 Subject: add REinaList#from_a --- lib/efl/eina_list.rb | 11 +++++++++-- spec/eina_list_spec.rb | 11 ++++++++++- 2 files changed, 19 insertions(+), 3 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<