Subject: [ruby-ffi] Re: :varargs sometimes works, sometimes don't |
From: Quintus |
Date: 4/28/10 10:53 AM |
To: ruby-ffi |
Looks like a bug to me.
I opened an issue on GitHub: http://github.com/ffi/ffi/issues/issue/44
As a workaround, moving the attaching of g_object_set to before the enums makes the example run fine.
Works for me, too. Thank you! Marvin On 27 Apr., 22:42, Matijs van Zuijlen <mat...@matijs.net> wrote:
Hi Marvin, On 04/27/2010 07:19 PM, Quintus wrote:/opt/rubies/ruby-1.9.1-p378/lib/ruby/gems/1.9.1/gems/ffi-0.6.3/lib/ffi/ types.rb:46:in `find_type': Unable to resolve type 'string' (TypeError) from /opt/rubies/ruby-1.9.1-p378/lib/ruby/gems/1.9.1/gems/ffi-0.6.3/ lib/ffi/variadic.rb:47:in `call' from (eval):3:in `g_object_set' from gtkbox.rb:66:in `show' from gtkbox.rb:76:in `<main>' -------------------------------------------------------------- the second fails with a quite strange error message: --------------------------------------------------------------
What's the matter? As far as I know, :string as a regular type in FFI.Looking at the ffi code, the fact that you create two new types in the second example completely overrules the default type map when resolving varargs types. Looks like a bug to me.And here's the (non-working) second: ------------------------------------------------------------- [...]
enum :type, [ :gtk_message_info, :gtk_message_warning, :gtk_message_question, :gtk_message_error, :gtk_message_other ]
enum :buttons, [:gtk_buttons_none, :gtk_button_ok, :gtk_buttons_close, :gtk_buttons_cancel, :gtk_buttons_yes_no, :gtk_buttons_ok_cancel ]At this point, @ffi_typedefs contains :type and :buttons, and only varargs of those types will be recognized. As a workaround, moving the attaching of g_object_set to before the enums makes the example run fine. -- Matijs