Re: [gtk-list] Interpreter requests



On Thu, 4 Jun 1998, Kenneth Albanowski wrote:

>  4. Add a bit more .defs information describing whether the contents of a
> structure are important, the pointer to a structure, or both. (Or firmly
> define boxed & struct in these terms). Consider that only the contents of
> a GdkEvent matter, while the location of a GdkColormap is important,
> despite not being reference counted. (I still don't know what to do with
> colormaps, btw. :-)

To clarify this a bit (for me as much as the reader), look at GdkColor
objects: in the gtk.defs file, these are defined as a boxed type, with the
"increment reference" command being gdk_color_copy(ptr) and the "decrement
reference" command being gdk_color_free(ptr).

The problem with this is that the model is wrong: GdkColor objects are
always passed around by value. The exact location of the structure is
irrelevant. Reference counting is not needed as the objects do not need to
be shared, copying the contents is in all cases necessary and sufficient. 
The only places these objects are used with pointers (as far as I can
tell) is for arrays. It's conceivable such a structure might be passed by
pointer to a signal handler, but again this would be to allow
modifications, or as an optimization, not as a reference counted object.

The immediate fix is to say, instead of a define-boxed, something like
this: 

   (define-struct GdkColor
	(members 
		(pixel	ulong)
		(red	ushort)
		(green	ushort)
		(blue	ushort)
	)
   )

The key difference between a define-boxed and define-struct is that the
pointer of a define-boxed object is the key value. In a define-struct
object, the _contents_ are the important part, and the exact location of
the object is irrelevant, and does not need to be retained.

I'm still not sure what to do with the GtkNotebookPage and similar
"helper" structures.

-- 
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]