Support for cleanup actions on arguments performed when callback returns

Bug #622274 reported by Luís Oliveira
10
This bug affects 2 people
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-TRANSLATED-OBJECT-FOR-
> CALLBACK. Additional generic function HAS-CALLBACK-CLEANUP is called at
> macroexpansion time as an optimization to remove unnecessary calls to CLEANUP-
> TRANSLATED-OBJECT-FOR-CALLBACK.
>
> 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.

Tags: callbacks
Revision history for this message
Luís Oliveira (luismbo) wrote :
Revision history for this message
Luís Oliveira (luismbo) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.