Skip to content

function: keep resolved ffi_type for arguments and return value - #216

Open
kou wants to merge 1 commit into
ruby:masterfrom
kou:function-ffi-type
Open

kou wants to merge 1 commit into
ruby:masterfrom
kou:function-ffi-type

Conversation

@kou

@kou kou commented Oct 12, 2026

Copy link
Copy Markdown
Member

This is a preparation for supporting structs passed by value (#114).

Fiddle::Function resolves each argument type and the return type from an int to an ffi_type * when it prepares the CIF. An int can only represent built-in types, so a struct type can't be passed to ffi_prep_cif() this way.

#initialize resolves the types once and keeps them in the new argument_ffi_types and return_ffi_type members. #call copies the fixed argument types from argument_ffi_types and resolves only the variadic argument types.

This doesn't change behavior. The CIF is still prepared lazily on the first #call, and cif.arg_types is still allocated and owned by the CIF as before.

This is a preparation for supporting structs passed by value (ruby#114).

`Fiddle::Function` resolves each argument type and the return type
from an `int` to an `ffi_type *` when it prepares the CIF. An `int` can
only represent built-in types, so a struct type can't be passed to
`ffi_prep_cif()` this way.

`#initialize` resolves the types once and keeps them in the new
`argument_ffi_types` and `return_ffi_type` members. `#call` copies the
fixed argument types from `argument_ffi_types` and resolves only the
variadic argument types.

This doesn't change behavior. The CIF is still prepared lazily on the
first `#call`, and `cif.arg_types` is still allocated and owned by the
CIF as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant