hugopl/gi-crystal

Error compiling harf_buzz - can't use variable name 'extents' inside assignment to variable 'extents'

nobodywasishere opened this issue · 3 comments

Trying to compile rtfm:

  margret@nobody-t14:~/dev/crystal/rtfm main@c360719 (dirty)
  [0] $ make

shards install
Resolving dependencies
Fetching https://github.com/hugopl/fzy.git
Fetching https://github.com/geopjr/libadwaita.cr.git
Fetching https://github.com/crystal-lang/crystal-sqlite3.git
Fetching https://github.com/hugopl/gtk4.cr.git
Fetching https://github.com/hugopl/gi-crystal.git
Fetching https://github.com/hugopl/pango.cr.git
Fetching https://github.com/hugopl/harfbuzz.cr.git
Fetching https://github.com/hugopl/gio.cr.git
Fetching https://github.com/crystal-lang/crystal-db.git
Installing fzy (0.5.5)
Installing gi-crystal (0.16.0 at 9ebef99)
Postinstall of gi-crystal: shards build
Installing harfbuzz (0.1.0)
Installing gio (0.1.0)
Installing pango (0.2.0)
Installing gtk4 (0.14.0 at 83c6921)
Installing libadwaita (1.0.0 at 23ce21d)
Installing db (0.12.0)
Installing sqlite3 (0.20.0)
./bin/gi-crystal
info - Starting at 2023-07-16 22:30:21 -04:00, project dir: /home/margret/dev/crystal/rtfm
info - Gi-Crystal version 0.16.0, built with Crystal 1.8.2.
info - Generating bindings at /home/margret/dev/crystal/rtfm/lib/gi-crystal/src/auto
info - Using binding config at /home/margret/dev/crystal/rtfm/lib/pango/src/bindings/pango/binding.yml
info - Using binding config at /home/margret/dev/crystal/rtfm/lib/gio/src/bindings/gio/binding.yml
info - Using binding config at /home/margret/dev/crystal/rtfm/lib/harfbuzz/src/bindings/harfbuzz/binding.yml
info - Using binding config at /home/margret/dev/crystal/rtfm/lib/gtk4/src/bindings/gtk/binding.yml
info - Using binding config at /home/margret/dev/crystal/rtfm/lib/gtk4/src/bindings/gdk/binding.yml
info - Using binding config at /home/margret/dev/crystal/rtfm/lib/gtk4/src/bindings/gsk/binding.yml
info - Using binding config at /home/margret/dev/crystal/rtfm/lib/gi-crystal/src/bindings/g_lib/binding.yml
info - Using binding config at /home/margret/dev/crystal/rtfm/lib/gi-crystal/src/bindings/g_object/binding.yml
info - Using binding config at /home/margret/dev/crystal/rtfm/lib/libadwaita/src/bindings/binding.yml
info - Using binding config at /home/margret/dev/crystal/rtfm/src/bindings/webkit2/binding.yml
info - Pango - No binding config found for cairo-1.0.
info - HarfBuzz - No binding config found for freetype2-2.0.
warn - HarfBuzz - Interface constant not supported.
warn - g_cancellable_connect - Callback without user_data!
warn - Gio::ActionEntry padding field - Unknown conversion to crystal for fixed size array.
warn - Gio::DBusInterfaceVTable padding field - Unknown conversion to crystal for fixed size array.
warn - Gio::DBusSubtreeVTable padding field - Unknown conversion to crystal for fixed size array.
warn - Boxed not working for enums
info - gtk_image_new_from_pixbuf - No binding config found for GdkPixbuf-2.0.
info - gtk_snapshot_append_cairo - No binding config found for Graphene-1.0.
warn - Gtk::BuildableParser padding field - Unknown conversion to crystal for fixed size array.
warn - gsk_border_node_get_widths - Unknown conversion to crystal for fixed size array.
info - Gdk - No binding config found for PangoCairo-1.0.
warn - Gdk - SeatCapabilities::All (0xf) doesn't have all possible bits set (0x1f).
warn - Gdk::TimeCoord axes field - Unknown conversion to crystal for fixed size array.
info - GdkPixbuf - No binding config found for GModule-2.0.
warn - gdk_pixbuf_get_options - Unknown conversion to crystal for GHash
info - WebKit - No binding config found for Soup-3.0.
info - WebKit - No binding config found for JavaScriptCore-6.0.
warn - soup_form_decode - Unknown conversion to crystal for GHash
warn - soup_form_decode_multipart - Unknown conversion to crystal for GHash
warn - soup_header_parse_param_list - Unknown conversion to crystal for GHash
warn - soup_header_parse_param_list_strict - Unknown conversion to crystal for GHash
warn - soup_header_parse_semi_param_list - Unknown conversion to crystal for GHash
warn - soup_header_parse_semi_param_list_strict - Unknown conversion to crystal for GHash
warn - soup_server_add_early_handler - Unknown conversion to crystal for GHash
warn - soup_server_add_handler - Unknown conversion to crystal for GHash
warn - Generator::VFuncGen - Unknown conversion to crystal for GHash
warn - jsc_class_add_property - Callback without user_data!
warn - jsc_value_object_define_property_accessor - Callback without user_data!
syntax error in './harf_buzz-0.0/harf_buzz.cr:7056:14': can't use variable name 'extents' inside assignment to variable 'extents'
fatal - Error formating generated files at '/home/margret/dev/crystal/rtfm/lib/gi-crystal/src/auto'.
make: *** [Makefile:8: rtfm] Error 1

Lines in question (gi-crystal/src/auto/harf_buzz-0.0/harf_buzz.cr):

def self.ot_layout_get_font_extents(font : HarfBuzz::FontT,direction : HarfBuzz::DirectionT,script_tag : UInt32,language_tag : UInt32,) : HarfBuzz::FontExtentsT
  # hb_ot_layout_get_font_extents: (None)
# @font: 
# @direction: 
# @script_tag: 
# @language_tag: 
# @extents: (out) (nullable) (caller-allocates) 
# Returns: (transfer none) 

  
  # Generator::NullableArrayPlan
extents = if extents.nil?
Void.null
else
extents.to_unsafe
end
# Generator::CallerAllocatesPlan
extents=HarfBuzz::FontExtentsT.new
  # C call
  _retval = LibHarfBuzz.hb_ot_layout_get_font_extents(font, direction, script_tag, language_tag, extents)


  
  # Return value handling
  
  extents

end

Crystal version:

$ crystal --version

Crystal 1.8.2 (2023-05-11)

LLVM: 15.0.7
Default target: x86_64-pc-linux-gnu
hugopl commented

Hi, this is a duplicate of #53

It was "fixed" in harfbuzz bindings v0.2.0, by fixed I mean... I just ignored the function.

Harfbuzz is very hard to create automatic bindings based on gobject introspection due to bad annotation and probably a not so binding friendly API design, so as I don't use harfbuzz API direclty nether know anybody interested on using it directly from Crystal code... I just ignore these functions to keep things compiling and follow with my life :-P

hugopl commented

BTW rtfm dependencies were updated and there's a new release that should work.

Thank you!