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

Error with ./gsk-4.0/path_point.cr #58

Open
xenanthropy opened this issue Oct 22, 2023 · 10 comments
Open

Error with ./gsk-4.0/path_point.cr #58

xenanthropy opened this issue Oct 22, 2023 · 10 comments
Labels
bug Something isn't working

Comments

@xenanthropy
Copy link

xenanthropy commented Oct 22, 2023

Edit: I realize this is most likely an issue with gi-crystal, but I'll leave the issue here as it also affects this repo as well

after cloning the repo and running shards install, running ./bin/gi-crystal gives the following output:

info - Starting at 2023-10-21 23:09:45 -05:00, project dir: /home/conner/git-projects/gtk4.cr
info - Gi-Crystal version 0.19.0, built with Crystal 1.9.2.
info - Generating bindings at /home/conner/git-projects/gtk4.cr/lib/gi-crystal/src/auto
info - Using binding config at /home/conner/git-projects/gtk4.cr/src/bindings/gdk/binding.yml
info - Using binding config at /home/conner/git-projects/gtk4.cr/src/bindings/gsk/binding.yml
info - Using binding config at /home/conner/git-projects/gtk4.cr/src/bindings/gtk/binding.yml
info - Using binding config at /home/conner/git-projects/gtk4.cr/lib/gi-crystal/src/bindings/g_lib
/binding.yml
info - Using binding config at /home/conner/git-projects/gtk4.cr/lib/gi-crystal/src/bindings/g_obj
ect/binding.yml
info - Using binding config at /home/conner/git-projects/gtk4.cr/lib/harfbuzz/src/bindings/harfbuz
z/binding.yml
info - Using binding config at /home/conner/git-projects/gtk4.cr/lib/gio/src/bindings/gio/binding.
yml
info - Using binding config at /home/conner/git-projects/gtk4.cr/lib/pango/src/bindings/pango/bind
ing.yml
info - Gdk - No binding config found for cairo-1.0.
info - Gdk - No binding config found for PangoCairo-1.0.
info - Gdk - No binding config found for GdkPixbuf-2.0.
warn - Gdk::TimeCoord axes field - Unknown conversion to crystal for fixed size array.
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.
info - GdkPixbuf - No binding config found for GModule-2.0.
warn - gdk_pixbuf_get_options - Unknown conversion to crystal for GHash
info - Gsk - No binding config found for Graphene-1.0.
warn - gsk_border_node_get_widths - Unknown conversion to crystal for fixed size array.
warn - Boxed not working for enums
warn - Gtk::BuildableParser padding field - Unknown conversion to crystal for fixed size array.
syntax error in './gsk-4.0/path_point.cr:122:13': can't use variable name 'center' inside assignme
nt to variable 'center'
fatal - Error formating generated files at '/home/conner/git-projects/gtk4.cr/lib/gi-crystal/src/a
uto'.

Most notable being the actual error:
`syntax error in './gsk-4.0/path_point.cr:122:13': can't use variable name 'center' inside assignment to variable 'center'
fatal - Error formating generated files at '/home/conner/git-projects/gtk4.cr/lib/gi-crystal/src/auto'.`

I'm not sure if I have improper versions of programs or what, I can provide extra information as needed!

crystal: 1.9.2
gtk+4: 4.13.0
gobject-introspection: 1.72.0

@hugopl hugopl added the bug Something isn't working label Oct 23, 2023
@hugopl
Copy link
Owner

hugopl commented Oct 23, 2023

GTK4 on ArchLinux still on 4.12, I'll wait 4.13 land there to fix this, so I don't need to compile gtk4 myself or install gtk4 4.13 from test repository.

BTW I good thing to do when reporting these kind of bugs is to paste the code for the generated function that had problems... maybe I should create some issue template on github, anyway, thanks for reporting!

@xenanthropy
Copy link
Author

xenanthropy commented Oct 23, 2023

GTK4 on ArchLinux still on 4.12, I'll wait 4.13 land there to fix this, so I don't need to compile gtk4 myself or install gtk4 4.13 from test repository.

BTW I good thing to do when reporting these kind of bugs is to paste the code for the generated function that had problems... maybe I should create some issue template on github, anyway, thanks for reporting!

Ah sorry, I wasn't fully aware that the code was generated! I'll do that now - this is the issue in question:

# Generator::NullableArrayPlan
center = if center.nil?
Void.null
else
center.to_unsafe
end

center = if center.nil? being the problem line

@hugopl
Copy link
Owner

hugopl commented Oct 23, 2023

Better copy the whole method declaration with annotation comments, etc. Usually it's possible to identify what's wrong with just that. Then I can try to reproduce the issue in the lib used on gi-crystal tests.

GskPath is a new API from GSK, so I don't have it here in my system yet. The weird thins is that the docs says "since 4.14", however you seems to have it on 4.13.

@xenanthropy
Copy link
Author

Ah, of course, here is the entire method:

def curvature(path : Gsk::Path,direction : Gsk::PathDirection,) : Graphene::Point
  # gsk_path_point_get_curvature: (Method)
# @path: 
# @direction: 
# @center: (out) (nullable) (caller-allocates) 
# Returns: (transfer none) 

  
  # Generator::NullableArrayPlan
center = if center.nil?
Void.null
else
center.to_unsafe
end
# Generator::CallerAllocatesPlan
center=Graphene::Point.new
  # C call
  _retval = LibGsk.gsk_path_point_get_curvature(to_unsafe, path, direction, center)


  
  # Return value handling
  center

end

i'll go ahead and attach the whole file as well, in case any extra details are needed from it!
path_point.txt

@hugopl
Copy link
Owner

hugopl commented Oct 23, 2023

Hmmm... it's a well known problem related to how to handle these out/nullable/optimal parameters in bindings.

BTW, if you don't need this method you can unblock yourself by changing GSK binding.yml file to:

namespace: Gsk
version: "4.0"
require_after:
- gi_crystal.cr
- render_node.cr

types:
  RenderNode:
    ignore_methods:
    - ref
    - unref
  PathPoint:
    ignore_methods:
    - get_curvature

@xenanthropy
Copy link
Author

Hmmm... it's a well known problem related to how to handle these out/nullable/optimal parameters in bindings.

BTW, if you don't need this method you can unblock yourself by changing GSK binding.yml file to:

namespace: Gsk
version: "4.0"
require_after:
- gi_crystal.cr
- render_node.cr

types:
  RenderNode:
    ignore_methods:
    - ref
    - unref
  PathPoint:
    ignore_methods:
    - get_curvature

Yeah I don't think i'm needing that method so thanks, that got me past it and thankfully no other methods had issues! Shall I close this or do you want me to leave it open as a reminder to look into when your GTK gets updated?

@hugopl
Copy link
Owner

hugopl commented Oct 24, 2023

No, keep it open, the bug still exists. Even the fix need to be made on gi-crystal, IMO is ok the bug to be filed here since it's a bug in GSK bindings that are provided by this repository.

@hugopl
Copy link
Owner

hugopl commented Dec 11, 2023

I just pushed these changes while this isn't proper fixed in gi-crystal. They will be available in next release.

@kojix2
Copy link

kojix2 commented Apr 11, 2024

I am using macOS and am getting the same error.

@kojix2
Copy link

kojix2 commented Apr 11, 2024

No, no, forget it.
I updated shard.lock and all is well.
Have a nice day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants