Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small bug (I think) in examples/ directory, at the file called draw_text.rb #39

Closed
rubyFeedback opened this issue Oct 30, 2021 · 2 comments

Comments

@rubyFeedback
Copy link
Collaborator

rubyFeedback commented Oct 30, 2021

Heya kojix2,

I noticed you extended the examples, so I went on to test things. :D

Unfortunately it fails to me as superuser:

ruby draw_text.rb 

The error I get is:

/root/.gem/gems/libui-0.0.12/lib/libui/ffi.rb:22:in `call': no implicit conversion of String into Integer (TypeError)
        from /root/.gem/gems/libui-0.0.12/lib/libui/ffi.rb:22:in `uiOpenTypeFeaturesAdd'
        from /root/.gem/gems/libui-0.0.12/lib/libui/libui_base.rb:39:in `public_send'
        from /root/.gem/gems/libui-0.0.12/lib/libui/libui_base.rb:39:in `block (2 levels) in <module:LibUIBase>'
        from draw_text.rb:66:in `make_attribute_string'
        from draw_text.rb:132:in `<main>'

I am not entirely sure where the error is (I find it not so easy to discover ffi-related errors in general) but I wanted to mention this nonetheless. Please disregard this message if it works for you (I use libui gem 0.0.12, but I used the git clone of the repository here, so not sure if that has anything to do with it or not; I mention it just in case). Thanks for reading!

@kojix2
Copy link
Owner

kojix2 commented Oct 31, 2021

Hi!

Thank you for your report.
I've checked and this has been fixed in the main branch.

git clone https://github.com/kojix2/LibUI
cd LibUI
rake vendor:all_x64
bundle install
bundle exec ruby example/draw_text.rb

Related to: ruby/fiddle#96

In C, there is a difference between the char type and the string type. In Fiddle, char is uint8.
So when you pass a char to a function, you need to make it unit8. This is the same as the Crystal language. See the note on the following page.

https://crystal-lang.org/reference/syntax_and_semantics/c_bindings/fun.html#types-in-c-bindings

However, this specification is not always helpful, so I reported it to Fiddle. So it may be changed in the future.

@kojix2
Copy link
Owner

kojix2 commented Nov 23, 2021

I have released v0.0.13 which includes this fix.

@kojix2 kojix2 closed this as completed Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants