summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Janik <timj@gtk.org>1998-10-31 18:57:36 +0000
committerTim Janik <timj@src.gnome.org>1998-10-31 18:57:36 +0000
commite8a920f88d5e6f534f20f04681e5cc33dba8239f (patch)
tree88bb87a9ef0a7e5c0fa413e04c9dda41daf8bac3
parenta32e40e2c4b62a41777d63d20a0898de4aa58b91 (diff)
downloadglib-e8a920f88d5e6f534f20f04681e5cc33dba8239f.tar.gz
removed old G_ENUM(), G_FLAGS(), G_NV() and G_SV() macros. added macros
Sat Oct 31 05:08:26 1998 Tim Janik <timj@gtk.org> * glib.h: removed old G_ENUM(), G_FLAGS(), G_NV() and G_SV() macros. added macros G_STRUCT_OFFSET(), G_STRUCT_MEMBER_P() and G_STRUCT_MEMBER() for handling structure fields through their offsets. (struct _GHookList): added a hook_free function member, that can be used to free additional fields in derived hook structures. g_hook_free(): if hook_list->hook_free != NULL, call this function prior to freeing the hook. (this functionality should have been there in the first place, it just got forgotten as an implementation detail).
-rw-r--r--ChangeLog11
-rw-r--r--ChangeLog.pre-2-011
-rw-r--r--ChangeLog.pre-2-1011
-rw-r--r--ChangeLog.pre-2-1211
-rw-r--r--ChangeLog.pre-2-211
-rw-r--r--ChangeLog.pre-2-411
-rw-r--r--ChangeLog.pre-2-611
-rw-r--r--ChangeLog.pre-2-811
-rw-r--r--ghook.c6
-rw-r--r--glib.h26
-rw-r--r--glib/ghook.c6
-rw-r--r--glib/glib.h26
12 files changed, 122 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index 95e9b009a..3a1fa109a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Sat Oct 31 05:08:26 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h: removed old G_ENUM(), G_FLAGS(), G_NV() and G_SV() macros.
+ added macros G_STRUCT_OFFSET(), G_STRUCT_MEMBER_P() and
+ G_STRUCT_MEMBER() for handling structure fields through their offsets.
+ (struct _GHookList): added a hook_free function member, that can be used
+ to free additional fields in derived hook structures.
+ g_hook_free(): if hook_list->hook_free != NULL, call this function prior
+ to freeing the hook. (this functionality should have been there in the
+ first place, it just got forgotten as an implementation detail).
+
Wed Oct 28 00:49:32 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: G_BREAKPOINT for alpha from Robert Wilhelm
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index 95e9b009a..3a1fa109a 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -1,3 +1,14 @@
+Sat Oct 31 05:08:26 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h: removed old G_ENUM(), G_FLAGS(), G_NV() and G_SV() macros.
+ added macros G_STRUCT_OFFSET(), G_STRUCT_MEMBER_P() and
+ G_STRUCT_MEMBER() for handling structure fields through their offsets.
+ (struct _GHookList): added a hook_free function member, that can be used
+ to free additional fields in derived hook structures.
+ g_hook_free(): if hook_list->hook_free != NULL, call this function prior
+ to freeing the hook. (this functionality should have been there in the
+ first place, it just got forgotten as an implementation detail).
+
Wed Oct 28 00:49:32 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: G_BREAKPOINT for alpha from Robert Wilhelm
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 95e9b009a..3a1fa109a 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,14 @@
+Sat Oct 31 05:08:26 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h: removed old G_ENUM(), G_FLAGS(), G_NV() and G_SV() macros.
+ added macros G_STRUCT_OFFSET(), G_STRUCT_MEMBER_P() and
+ G_STRUCT_MEMBER() for handling structure fields through their offsets.
+ (struct _GHookList): added a hook_free function member, that can be used
+ to free additional fields in derived hook structures.
+ g_hook_free(): if hook_list->hook_free != NULL, call this function prior
+ to freeing the hook. (this functionality should have been there in the
+ first place, it just got forgotten as an implementation detail).
+
Wed Oct 28 00:49:32 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: G_BREAKPOINT for alpha from Robert Wilhelm
diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12
index 95e9b009a..3a1fa109a 100644
--- a/ChangeLog.pre-2-12
+++ b/ChangeLog.pre-2-12
@@ -1,3 +1,14 @@
+Sat Oct 31 05:08:26 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h: removed old G_ENUM(), G_FLAGS(), G_NV() and G_SV() macros.
+ added macros G_STRUCT_OFFSET(), G_STRUCT_MEMBER_P() and
+ G_STRUCT_MEMBER() for handling structure fields through their offsets.
+ (struct _GHookList): added a hook_free function member, that can be used
+ to free additional fields in derived hook structures.
+ g_hook_free(): if hook_list->hook_free != NULL, call this function prior
+ to freeing the hook. (this functionality should have been there in the
+ first place, it just got forgotten as an implementation detail).
+
Wed Oct 28 00:49:32 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: G_BREAKPOINT for alpha from Robert Wilhelm
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index 95e9b009a..3a1fa109a 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -1,3 +1,14 @@
+Sat Oct 31 05:08:26 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h: removed old G_ENUM(), G_FLAGS(), G_NV() and G_SV() macros.
+ added macros G_STRUCT_OFFSET(), G_STRUCT_MEMBER_P() and
+ G_STRUCT_MEMBER() for handling structure fields through their offsets.
+ (struct _GHookList): added a hook_free function member, that can be used
+ to free additional fields in derived hook structures.
+ g_hook_free(): if hook_list->hook_free != NULL, call this function prior
+ to freeing the hook. (this functionality should have been there in the
+ first place, it just got forgotten as an implementation detail).
+
Wed Oct 28 00:49:32 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: G_BREAKPOINT for alpha from Robert Wilhelm
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 95e9b009a..3a1fa109a 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,14 @@
+Sat Oct 31 05:08:26 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h: removed old G_ENUM(), G_FLAGS(), G_NV() and G_SV() macros.
+ added macros G_STRUCT_OFFSET(), G_STRUCT_MEMBER_P() and
+ G_STRUCT_MEMBER() for handling structure fields through their offsets.
+ (struct _GHookList): added a hook_free function member, that can be used
+ to free additional fields in derived hook structures.
+ g_hook_free(): if hook_list->hook_free != NULL, call this function prior
+ to freeing the hook. (this functionality should have been there in the
+ first place, it just got forgotten as an implementation detail).
+
Wed Oct 28 00:49:32 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: G_BREAKPOINT for alpha from Robert Wilhelm
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 95e9b009a..3a1fa109a 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,14 @@
+Sat Oct 31 05:08:26 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h: removed old G_ENUM(), G_FLAGS(), G_NV() and G_SV() macros.
+ added macros G_STRUCT_OFFSET(), G_STRUCT_MEMBER_P() and
+ G_STRUCT_MEMBER() for handling structure fields through their offsets.
+ (struct _GHookList): added a hook_free function member, that can be used
+ to free additional fields in derived hook structures.
+ g_hook_free(): if hook_list->hook_free != NULL, call this function prior
+ to freeing the hook. (this functionality should have been there in the
+ first place, it just got forgotten as an implementation detail).
+
Wed Oct 28 00:49:32 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: G_BREAKPOINT for alpha from Robert Wilhelm
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 95e9b009a..3a1fa109a 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,14 @@
+Sat Oct 31 05:08:26 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h: removed old G_ENUM(), G_FLAGS(), G_NV() and G_SV() macros.
+ added macros G_STRUCT_OFFSET(), G_STRUCT_MEMBER_P() and
+ G_STRUCT_MEMBER() for handling structure fields through their offsets.
+ (struct _GHookList): added a hook_free function member, that can be used
+ to free additional fields in derived hook structures.
+ g_hook_free(): if hook_list->hook_free != NULL, call this function prior
+ to freeing the hook. (this functionality should have been there in the
+ first place, it just got forgotten as an implementation detail).
+
Wed Oct 28 00:49:32 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: G_BREAKPOINT for alpha from Robert Wilhelm
diff --git a/ghook.c b/ghook.c
index a094a468e..91ab097ac 100644
--- a/ghook.c
+++ b/ghook.c
@@ -42,6 +42,7 @@ g_hook_list_init (GHookList *hook_list,
hook_size,
hook_size * G_HOOKS_PREALLOC,
G_ALLOC_AND_FREE);
+ hook_list->hook_free = NULL;
}
void
@@ -105,6 +106,9 @@ g_hook_free (GHookList *hook_list,
g_return_if_fail (hook_list->is_setup);
g_return_if_fail (hook != NULL);
g_return_if_fail (G_HOOK_IS_UNLINKED (hook));
+
+ if (hook_list->hook_free)
+ hook_list->hook_free (hook_list, hook);
g_chunk_free (hook, hook_list->hook_memchunk);
}
@@ -176,7 +180,7 @@ g_hook_unref (GHookList *hook_list,
}
hook->prev = NULL;
- g_chunk_free (hook, hook_list->hook_memchunk);
+ g_hook_free (hook_list, hook);
if (!hook_list->hooks &&
!hook_list->is_setup)
diff --git a/glib.h b/glib.h
index dad951b89..0639888cf 100644
--- a/glib.h
+++ b/glib.h
@@ -181,20 +181,15 @@ extern "C" {
#endif /* !G_VA_COPY */
-/* Provide simple enum value macro wrappers that ease automated
- * enum value stringification code. [abandoned]
- */
-#if !defined (G_CODE_GENERATION)
-#define G_ENUM( EnumerationName ) EnumerationName
-#define G_FLAGS( EnumerationName ) EnumerationName
-#define G_NV( VALUE_NAME , value_nick, VALUE) VALUE_NAME = (VALUE)
-#define G_SV( VALUE_NAME, value_nick ) VALUE_NAME
-#else /* G_CODE_GENERATION */
-#define G_ENUM( EnumerationName ) G_ENUM_E + EnumerationName +
-#define G_FLAGS( EnumerationName ) G_ENUM_F + EnumerationName +
-#define G_NV( VALUE_NAME , value_nick, VALUE) G_ENUM_V + VALUE_NAME + value_nick +
-#define G_SV( VALUE_NAME, value_nick ) G_ENUM_V + VALUE_NAME + value_nick +
-#endif /* G_CODE_GENERATION */
+/* Provide convenience macros for handling structure
+ * fields through their offsets.
+ */
+#define G_STRUCT_OFFSET(struct_type, member) \
+ ((gulong) ((gchar*) &((struct_type*) 0)->member))
+#define G_STRUCT_MEMBER_P(struct_p, struct_offset) \
+ ((gpointer) ((gchar*) (struct_p) + (gulong) (struct_offset)))
+#define G_STRUCT_MEMBER(member_type, struct_p, struct_offset) \
+ (*(member_type*) G_STRUCT_MEMBER_P ((struct_p), (struct_offset)))
/* inlining hassle. for compilers that don't allow the `inline' keyword,
@@ -936,6 +931,8 @@ typedef void (*GHookMarshaller) (GHook *hook,
gpointer data);
typedef void (*GHookFunc) (gpointer data);
typedef gboolean (*GHookCheckFunc) (gpointer data);
+typedef void (*GHookFreeFunc) (GHookList *hook_list,
+ GHook *hook);
typedef void (*GLogFunc) (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
@@ -1286,6 +1283,7 @@ struct _GHookList
guint is_setup : 1;
GHook *hooks;
GMemChunk *hook_memchunk;
+ GHookFreeFunc hook_free; /* virtual function */
};
struct _GHook
diff --git a/glib/ghook.c b/glib/ghook.c
index a094a468e..91ab097ac 100644
--- a/glib/ghook.c
+++ b/glib/ghook.c
@@ -42,6 +42,7 @@ g_hook_list_init (GHookList *hook_list,
hook_size,
hook_size * G_HOOKS_PREALLOC,
G_ALLOC_AND_FREE);
+ hook_list->hook_free = NULL;
}
void
@@ -105,6 +106,9 @@ g_hook_free (GHookList *hook_list,
g_return_if_fail (hook_list->is_setup);
g_return_if_fail (hook != NULL);
g_return_if_fail (G_HOOK_IS_UNLINKED (hook));
+
+ if (hook_list->hook_free)
+ hook_list->hook_free (hook_list, hook);
g_chunk_free (hook, hook_list->hook_memchunk);
}
@@ -176,7 +180,7 @@ g_hook_unref (GHookList *hook_list,
}
hook->prev = NULL;
- g_chunk_free (hook, hook_list->hook_memchunk);
+ g_hook_free (hook_list, hook);
if (!hook_list->hooks &&
!hook_list->is_setup)
diff --git a/glib/glib.h b/glib/glib.h
index dad951b89..0639888cf 100644
--- a/glib/glib.h
+++ b/glib/glib.h
@@ -181,20 +181,15 @@ extern "C" {
#endif /* !G_VA_COPY */
-/* Provide simple enum value macro wrappers that ease automated
- * enum value stringification code. [abandoned]
- */
-#if !defined (G_CODE_GENERATION)
-#define G_ENUM( EnumerationName ) EnumerationName
-#define G_FLAGS( EnumerationName ) EnumerationName
-#define G_NV( VALUE_NAME , value_nick, VALUE) VALUE_NAME = (VALUE)
-#define G_SV( VALUE_NAME, value_nick ) VALUE_NAME
-#else /* G_CODE_GENERATION */
-#define G_ENUM( EnumerationName ) G_ENUM_E + EnumerationName +
-#define G_FLAGS( EnumerationName ) G_ENUM_F + EnumerationName +
-#define G_NV( VALUE_NAME , value_nick, VALUE) G_ENUM_V + VALUE_NAME + value_nick +
-#define G_SV( VALUE_NAME, value_nick ) G_ENUM_V + VALUE_NAME + value_nick +
-#endif /* G_CODE_GENERATION */
+/* Provide convenience macros for handling structure
+ * fields through their offsets.
+ */
+#define G_STRUCT_OFFSET(struct_type, member) \
+ ((gulong) ((gchar*) &((struct_type*) 0)->member))
+#define G_STRUCT_MEMBER_P(struct_p, struct_offset) \
+ ((gpointer) ((gchar*) (struct_p) + (gulong) (struct_offset)))
+#define G_STRUCT_MEMBER(member_type, struct_p, struct_offset) \
+ (*(member_type*) G_STRUCT_MEMBER_P ((struct_p), (struct_offset)))
/* inlining hassle. for compilers that don't allow the `inline' keyword,
@@ -936,6 +931,8 @@ typedef void (*GHookMarshaller) (GHook *hook,
gpointer data);
typedef void (*GHookFunc) (gpointer data);
typedef gboolean (*GHookCheckFunc) (gpointer data);
+typedef void (*GHookFreeFunc) (GHookList *hook_list,
+ GHook *hook);
typedef void (*GLogFunc) (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
@@ -1286,6 +1283,7 @@ struct _GHookList
guint is_setup : 1;
GHook *hooks;
GMemChunk *hook_memchunk;
+ GHookFreeFunc hook_free; /* virtual function */
};
struct _GHook