Re: absract_surface -> cairo_surface_t* vs void*

Uli Schlachter <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
Am 11.12.2015 um 13:34 schrieb Enrico Weigelt, metux IT consult:
> Hi folks,
> 
> 
> I've seen many places where an (abstract) surface structure is passed
> as void* pointer, which is then directly typecaste'd to the actual
> structure.
> 
> Should we change it to use cairo_surface_t* intead and then use
> container_of() for the typecast instead ?
> 
> By the way: I'd also propose an additional sanity check:
> 
> * put in an magic value (more precisely: an array of magics - for
>   deeper inheritance)

What deeper inheritance? Can surface inherit from each other at all?

>   into cairo_surface_t, so we can check individual
>   instances for correct class
> * add some macros for the typecasting and type check
> * make the whole thing (compile-time) optional

Don't the existing ->type and ->backend values serve this goal? I guess we could
add some macros for this, but ->backend == my_backend is quite obvious, I think.

Uli
-- 
"Are you preparing for another war, Plutarch?" I ask.
"Oh, not now. Now we're in that sweet period where everyone agrees that our
recent horrors should never be repeated," he says. "But collective thinking is
usually short-lived. We're fickle, stupid beings with poor memories and a great
gift for self-destruction.
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.