Fix function array argument calling convention#10
Open
davispuh wants to merge 1 commit intoMVV90:mainfrom
Open
Fix function array argument calling convention#10davispuh wants to merge 1 commit intoMVV90:mainfrom
davispuh wants to merge 1 commit intoMVV90:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adjusts generated Ruby FFI signatures so C array parameters (e.g., const double m[16]) are emitted as pointer types in function/callback signatures, avoiding invalid FFI array type resolution errors.
Changes:
- Add an optional
usecaseparameter toruby_ffi_typeacross type classes to allow context-sensitive type emission. - Emit
:pointerforArrayTypewhen used as a function argument, while retaining array literals for struct/union layouts. - Update function/callback signature generation to call
ruby_ffi_type(:function_argument)for parameters.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/ffi_generator/generators/from_c_generator/unknown_type.rb | Updates ruby_ffi_type signature to accept a context parameter. |
| lib/ffi_generator/generators/from_c_generator/struct_or_union.rb | Updates ruby_ffi_type signature to accept a context parameter. |
| lib/ffi_generator/generators/from_c_generator/string_type.rb | Updates ruby_ffi_type signature to accept a context parameter. |
| lib/ffi_generator/generators/from_c_generator/primitive_type.rb | Updates ruby_ffi_type signature to accept a context parameter. |
| lib/ffi_generator/generators/from_c_generator/pointer_type.rb | Updates ruby_ffi_type signature to accept a context parameter. |
| lib/ffi_generator/generators/from_c_generator/function_or_callback.rb | Passes :function_argument context when generating parameter FFI signatures. |
| lib/ffi_generator/generators/from_c_generator/enum.rb | Updates ruby_ffi_type signature to accept a context parameter. |
| lib/ffi_generator/generators/from_c_generator/by_value_type.rb | Updates ruby_ffi_type signature to accept a context parameter. |
| lib/ffi_generator/generators/from_c_generator/array_type.rb | Emits :pointer for function-argument arrays; keeps array literals elsewhere. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| def ruby_ffi_type | ||
| def ruby_ffi_type(usecase = nil) | ||
| "#{@inner_type.ruby_ffi_type}.by_value" |
There was a problem hiding this comment.
ByValueType accepts the new usecase argument but doesn’t forward it to @inner_type.ruby_ffi_type. To keep behavior consistent (and avoid future context-specific type mismatches), pass usecase through when calling the inner type.
Suggested change
| "#{@inner_type.ruby_ffi_type}.by_value" | |
| "#{@inner_type.ruby_ffi_type(usecase)}.by_value" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
C language allows function definitions to be like:
But currently such definitions create invalid FFI type:
This PR fixes this by correctly defining it as pointer type.
So now with this PR and with #9
rake testcompletes successfully.