Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/ffi_generator/generators/from_c_generator/array_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def ruby_name
"array"
end

def ruby_ffi_type
if @constant_size
def ruby_ffi_type(usecase = nil)
if @constant_size && usecase != :function_argument
"[#{@element_type.ruby_ffi_type}, #{@constant_size}]"
else
":pointer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def ruby_name
@inner_type.ruby_name
end

def ruby_ffi_type
def ruby_ffi_type(usecase = nil)
"#{@inner_type.ruby_ffi_type}.by_value"
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Copilot uses AI. Check for mistakes.
end

Expand Down
2 changes: 1 addition & 1 deletion lib/ffi_generator/generators/from_c_generator/enum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def ruby_name
@ruby_name ||= @name.to_ruby_downcase
end

def ruby_ffi_type
def ruby_ffi_type(usecase = nil)
":#{ruby_name}"
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def write_ruby
writer.puts "@scope class"
end

ffi_signature = "[#{@parameters.map{ |parameter| parameter[:type].ruby_ffi_type }.join(', ')}], #{@return_type.ruby_ffi_type}"
ffi_signature = "[#{@parameters.map{ |parameter| parameter[:type].ruby_ffi_type(:function_argument) }.join(', ')}], #{@return_type.ruby_ffi_type}"

if @is_callback
write_callback(ruby_name, ffi_signature)
Expand Down Expand Up @@ -69,7 +69,7 @@ def ruby_name
@ruby_name ||= @name.to_ruby_downcase
end

def ruby_ffi_type
def ruby_ffi_type(usecase = nil)
":#{ruby_name}"
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def ruby_name
@pointee_name.to_ruby_downcase
end

def ruby_ffi_type
def ruby_ffi_type(usecase = nil)
":pointer"
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def ruby_name
end
end

def ruby_ffi_type
def ruby_ffi_type(usecase = nil)
case @clang_type
when :void then ":void"
when :bool then ":bool"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def ruby_name
"String"
end

def ruby_ffi_type
def ruby_ffi_type(usecase = nil)
":string"
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def ruby_name
@ruby_name ||= @name.to_ruby_classname
end

def ruby_ffi_type
def ruby_ffi_type(usecase = nil)
@written ? ruby_name : ":pointer"
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def ruby_name
"error_unknown"
end

def ruby_ffi_type
def ruby_ffi_type(usecase = nil)
":char"
end

Expand Down
Loading