ffi-clang
ffi-clang copied to clipboard
Undefined method `visit_children' for an instance of FFI::Clang::Cursor (NoMethodError)
How to fix this error? OS: macOS Sonoma 14.6.1 Apple clang version: 15.0.0 (clang-1500.3.9.4) Ruby: 3.3.5 Gems: ffi (1.17.0 arm64-darwin) ffi-clang (0.10.0)
I try to run bro-gen.rb from https://github.com/dkimitsa/robovm-bro-gen
But got this error:
/Users/roman/Downloads/bindings/robovm-bro-gen/bro-gen.rb:2911:in `process': undefined method `visit_children' for an instance of FFI::Clang::Cursor (NoMethodError)
cursor.visit_children do |cursor, _parent|
^^^^^^^^^^^^^^^
from /Users/roman/Downloads/bindings/robovm-bro-gen/bro-gen.rb:3974:in `block in <main>'
from /Users/roman/Downloads/bindings/robovm-bro-gen/bro-gen.rb:3816:in `each'
from /Users/roman/Downloads/bindings/robovm-bro-gen/bro-gen.rb:3816:in `<main>'
@dkimitsa can you help please?
@PromanSEW please open issue in https://github.com/dkimitsa/robovm-bro-gen project. its not related to ffi-clang
meanwhile I can confirm that issues is with ffi-clang (0.10.0)
@PromanSEW i would revert to 0.9.0 for now
@PromanSEW https://github.com/dkimitsa/robovm-bro-gen/issues/4
@dkimitsa I wanted, but your project didn't have "Issues" tab in that time 🤷
@dkimitsa anyway, fun fact, that devs broke the main "Usage" from README...
@PromanSEW bro-gen fixed with https://github.com/dkimitsa/robovm-bro-gen/commit/f8f9c67cecd474e746e5de3f85ecf893ae39b535
Sorry to cause a problem. This was a change I made, which replaces #visit_children with #each (a more idiomatic Ruby idiom). The PR was here:
https://github.com/ioquatix/ffi-clang/pull/80
Forgive me for being out of touch but is there any actionable work here or are we good to close?
The big benefit of switching to #each is that it is idiomatic Ruby and the Cursor class can then include Enumerable.
An actionable item could be be adding code like this for backwards compatibility:
alias visit_children each
However that is not quite the same as the fix in robovm-bro-gen which was:
def visit_children(&block)
each(recurse = false, &block)
end
The difference is setting recurse to false instead of true. So the alias might not work in this case. (FYI I would love it if Enumerable methods like #find, #find_all, etc. could pass extra parameters to #each but from my testing that doesn't work).
hello @ioquatix @cfis ,
thank you for comments, from robovm-bro-gen point of view we are good to go as already adapted to changes.
Why don't we introduce the fix proposed by @dkimitsa
def visit_children(&block)
each(false, &block)
end
I think you can write it like this:
node.visit_children.find(...)
Am I missing something?
Fix released in v0.11.0. Thanks everyone.