[cairo] API completeness of reference/user_data pairs

Torsten Schoenfeld kaffeetisch at gmx.de
Mon Jan 29 14:04:17 PST 2007


On Mon, 2007-01-29 at 16:13 -0500, Behdad Esfahbod wrote:

> Is there any reason that the other three don't have user_data?
> How do language bindings deal with this currently?

In Perl, every variable pointing to some cairo object owns a reference
to said object.  That is, whenever the bindings wrap a pointer to some
cairo object and stuff it into a Perl variable, the corresponding
_reference function is called.  When the Perl variable goes out of scope
or is overwritten, the reference is released by calling _destroy.  That
way, leaving bugs aside, it's impossible for Perl variables to point to
freed objects.  So destruction notification is not necessary for this.

The only place where user data is used in the Perl bindings is in the
surface stream bindings.  We use the user data slot and its destruction
notification to know when to free the heap-allocated marshal information
struct that's used to route callbacks to Perl.

-- 
Bye,
-Torsten



More information about the cairo mailing list