No bool type
eregon opened this issue · comments
Benoit Daloze 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.
Sutou Kouhei commented
Good catch.
I've implemented it.
Benoit Daloze 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?
Sutou Kouhei commented
Ah, then we should not implement bool
as an alias.
Benoit Daloze commented
Sutou Kouhei 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?
Sutou Kouhei commented
Implemented.
Benoit Daloze 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.