mvz / gir_ffi

Auto-generate bindings for GObject based libraries at run time using FFI

Home Page:https://github.com/mvz/gir_ffi/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

syntax error, unexpected tIDENTIFIER, expecting ']' after upgrade to 0.6.1

mamciek opened this issue · comments

Ruby: 2.0.0 (p195)

The code presented below causes an error. Before upgrading to 0.6.1 (from 0.5.1) it worked properly:

require 'gir_ffi'

GirFFI.setup :Secret
GirFFI.setup :GLib

schema_attributes = GLib::HashTable.new(:utf8, :gint32)
schema_attributes.insert("nc-workflow-auth-name", Secret::SchemaAttributeType[:string])

Secret::Schema.new("ncworkflow.schema", Secret::SchemaFlags[:none], schema_attributes)

An error is rased when invoking last line above

SyntaxError: (eval):5: syntax error, unexpected tIDENTIFIER, expecting ']'
  _v4 = Secret::Lib.secret_schema_newv _v1, _v2, _v3
                                          ^
(eval):5: syntax error, unexpected '\n', expecting '='
        from /home/maciej/.rvm/gems/ruby-2.0.0-p195@nc-workflow/gems/gir_ffi-0.6.1/lib/gir_ffi/builder/type/with_methods.rb:52:in `class_eval'
        from /home/maciej/.rvm/gems/ruby-2.0.0-p195@nc-workflow/gems/gir_ffi-0.6.1/lib/gir_ffi/builder/type/with_methods.rb:52:in `attach_and_define_method'
        from /home/maciej/.rvm/gems/ruby-2.0.0-p195@nc-workflow/gems/gir_ffi-0.6.1/lib/gir_ffi/builder/type/with_methods.rb:12:in `setup_method'
        from /home/maciej/.rvm/gems/ruby-2.0.0-p195@nc-workflow/gems/gir_ffi-0.6.1/lib/gir_ffi/class_base.rb:48:in `setup_method'
        from /home/maciej/.rvm/gems/ruby-2.0.0-p195@nc-workflow/gems/gir_ffi-0.6.1/lib/gir_ffi/class_base.rb:28:in `block in setup_and_call'
        from /home/maciej/.rvm/gems/ruby-2.0.0-p195@nc-workflow/gems/gir_ffi-0.6.1/lib/gir_ffi/class_base.rb:26:in `each'
        from /home/maciej/.rvm/gems/ruby-2.0.0-p195@nc-workflow/gems/gir_ffi-0.6.1/lib/gir_ffi/class_base.rb:26:in `any?'
        from /home/maciej/.rvm/gems/ruby-2.0.0-p195@nc-workflow/gems/gir_ffi-0.6.1/lib/gir_ffi/class_base.rb:26:in `setup_and_call'
        from (eval):3:in `new'
        from (irb):6

Hi @mamciek, thanks for reporting this. This should be fixed in version 0.6.3. By the way, conversion of enums and hash tables happens automatically, so you can simplify the above code to:

require 'gir_ffi'

GirFFI.setup :Secret

Secret::Schema.new("ncworkflow.schema", :none, "nc-workflow-auth-name" => :string)