Support for cleanup actions on arguments performed when callback returns
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
CFFI |
Triaged
|
Wishlist
|
Unassigned |
Bug Description
To be reviewed and documented.
On Sun, Jul 26, 2009 at 10:06 PM, Kalyanov Dmitry <email address hidden> wrote:
> I am trying to create a binding for gobject library with CFFI.
>
> CFFI works extremely well, however I have a use case that is not covered by
> CFFI.
>
> Basically, I want to define foreign types that should "clean up" after
> themselves when they are used as types for callback arguments.
>
> I have following use cases for this:
> 1) I want to have a structure created when callback is entered and have its
> contents copied to foreign structure when callback returns.
>
> 2) I want to have wrappers that contain a pointer to foreign structure.
> However, I want to ensure that operations on wrapper signal errors when
> callback returns (because pointer points to a stack-allocated structure). This
> is needed to ensure that no operations are done on invalid pointer.
>
> The attached patch provides suggested change: foreign types may specify that
> additional actions should be performed when the callback returns. This is
> achieved by adding new generic function CLEANUP-
> CALLBACK. Additional generic function HAS-CALLBACK-
> macroexpansion time as an optimization to remove unnecessary calls to CLEANUP-
> TRANSLATED-
>
> Attached is a test case that demonstrates the usage and checks for correctness
> of behavior.
>
> If there are obstacles for adding this patch, I would be happy to work on
> them.