ruby / fiddle

A libffi wrapper for Ruby.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No bool type

eregon opened this issue · comments

/home/eregon/.rubies/ruby-3.2.2/lib/ruby/3.2.0/fiddle/cparser.rb:247:in `parse_ctype': unknown type: bool (Fiddle::DLError)
	from /home/eregon/.rubies/ruby-3.2.2/lib/ruby/3.2.0/fiddle/cparser.rb:117:in `parse_signature'
	from /home/eregon/.rubies/ruby-3.2.2/lib/ruby/3.2.0/fiddle/import.rb:168:in `extern'

for extern "bool foo(void *buffer)" with extend Fiddle::Importer.

Maybe a workaround is to use typealias, but not sure what would be the correct type then.

Good catch.
I've implemented it.

Thanks!
Ideally extern "bool foo(void *buffer)" would return Ruby true/false, not 1/0 (which are both truthy in Ruby).
Do you think Fiddle could handle that?

Ah, then we should not implement bool as an alias.

@kou Should we revert bc6c66b maybe? Because if bool is then implemented properly to use Ruby true/false instead of 1/0 then it would be incompatible when that changes.

Is it for Ruby 3.3.0?
If I can implement bool <-> Ruby's true/false soon, we don't need to revert the commit, right?

Implemented.

Thanks!
Yeah, I just wanted to avoid the half-done support for boolean to get in a Fiddle release, or if it did for as short as possible.