Skip to content

parse_ctype() fails for "int long len" #100

@dmlary

Description

@dmlary

parse_ctype() does not handle int long len correctly; errors with unknown type: int

[22] pry(#<Fiddle::CastXMLImporter::Importer>)> parse_struct_signature(["char id", "int long size"])
Fiddle::DLError: unknown type: int
from /Users/dmlary/.rbenv/versions/3.0.2/lib/ruby/3.0.0/fiddle/cparser.rb:245:in `parse_ctype'
[24] pry(#<Fiddle::CastXMLImporter::Importer>)> parse_ctype("int long size")
Fiddle::DLError: unknown type: int
from /Users/dmlary/.rbenv/versions/3.0.2/lib/ruby/3.0.0/fiddle/cparser.rb:245:in `parse_ctype'
[25] pry(#<Fiddle::CastXMLImporter::Importer>)> parse_ctype("int long")
=> 4

I am aware that I can switch the field definition to long, but these types are being pulled out of CastXML, and I'd prefer to fix the bug in Fiddle instead of implementing a bunch of type remapping.

old

parse_struct_signature() is passing the complete struct member definition to parse_ctype(). This includes both the ctype and the member name. This causes a problem when handling structs that contain compound members such as: int long length in their definition.

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