ruby/fiddle

No bool type

eregon opened this issue · 7 comments

eregon commented
/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.

kou commented

Good catch.
I've implemented it.

eregon commented

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?

kou commented

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

eregon commented

@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.

kou commented

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?

kou commented

Implemented.

eregon commented

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.