Skip to content

bool struct member parsing not working  #168

@wallacerunner

Description

@wallacerunner

This script

require 'fiddle/import'

module Test
  extend Fiddle::Importer

  test_struct = struct [
    'int int_member',
    'bool boolean_member'
  ]
end

fails with this error:

PS D:\code\ruby\sdl_test> ruby .\struct_test.rb
C:/Users/Dee/scoop/apps/ruby/3.3.6-2/lib/ruby/3.3.0/fiddle/cparser.rb:261:in `parse_ctype': unknown type: bool (Fiddle::DLError)
        from C:/Users/Dee/scoop/apps/ruby/3.3.6-2/lib/ruby/3.3.0/fiddle/cparser.rb:71:in `block in parse_struct_signature'
        from C:/Users/Dee/scoop/apps/ruby/3.3.6-2/lib/ruby/3.3.0/fiddle/cparser.rb:43:in `each'
        from C:/Users/Dee/scoop/apps/ruby/3.3.6-2/lib/ruby/3.3.0/fiddle/cparser.rb:43:in `parse_struct_signature'
        from C:/Users/Dee/scoop/apps/ruby/3.3.6-2/lib/ruby/3.3.0/fiddle/import.rb:223:in `struct'
        from ./struct_test.rb:6:in `<module:Test>'
        from ./struct_test.rb:3:in `<main>'

Looks like parse_struct_signature passes the whole bool boolean_member string to parse_ctype, where it fails to be parsed because case expression tries to match on "bool" (i.e. a plain string) instead of a regex, something like /\Abool(?:\s+\w+)?\z/:

when "bool"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions