Re: Introducing "toggle references"
- From: Tim Janik <timj gtk org>
- To: Owen Taylor <otaylor redhat com>
- Cc: Gtk+ Developers <gtk-devel-list gnome org>
- Subject: Re: Introducing "toggle references"
- Date: Tue, 26 Apr 2005 01:17:29 +0200 (CEST)
On Mon, 25 Apr 2005, Owen Taylor wrote:
Here's a patch implementing the proposed API (with the GDataset
flags hack). A test case is included.
As always, if the patch is approved, I'll move the docs to the tmpl
files to match the rest of libgobject.
without looking into the issue of toggle references per se, skimming
over the patch i do have two immediate comments on the datalist part:
1) you do:
GData *tmp = G_DATALIST_GET_POINTER (data);
modify (&tmp); // invokes user callbacks
G_DATALIST_SET_POINTER (data, tmp);
this breaks reentrancy for datalists, getters/setters/clearance
all have to work correctly in recursive call scenarios.
so you actually need to move the GET/SET-POINTER logic down into
the modify() functions of your patch.
2)
+++ glib/gdataset.h 25 Apr 2005 22:57:13 -0000
@@ -39,6 +39,15 @@ typedef void (*GDataForeachFu
/* Keyed Data List
*/
+#define G_DATALIST_FLAGS_MASK 0x3
+
+#define G_DATALIST_GET_FLAGS(datalist) \
+ ((gulong)*(datalist) & G_DATALIST_FLAGS_MASK)
+#define G_DATALIST_SET_FLAGS(datalist, flags) G_STMT_START { \
+ *datalist = (GData *)((flags) | \
+ ((gulong)*(datalist) & ~(gulong)G_DATALIST_FLAGS_MASK)); \
+} G_STMT_END
+
not being able to predict future datalist modifications, flag uses,
notification requirements or alignment schemes, the GET_FLAGS and
SET_FLAGS macros should actually be turned into real functions on
the datalist.
i see no problem with leaving G_DATALIST_FLAGS_MASK as a macro, since
ensuring future modifications to it will only grow the number should
be easy to maintain and keeps backwards compatibility.
Regards,
Owen
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]