Commit 004f0982 authored by Tim Janik's avatar Tim Janik Committed by Tim Janik

typedef gint gboolean; this is needed to provide portability with

Thu May 14 04:14:12 1998  Tim Janik  <timj@gtk.org>

        * glib.h: typedef gint gboolean;
        this is needed to provide portability with big-endian platforms (e.g.
        try sizeof(bool) for c++ on big-endians - it's 4).
        this is also needed to maintain some_union.d_gint==some_union.d_gboolean.
        plus, gint to gboolean casts and vice versa need to be possible without
        loss.

Thu May 14 03:04:43 1998  Tim Janik  <timj@gtk.org>

        * gtk/gtktypeutils.c (gtk_type_free): new function to take care about
        freeing types.
        (gtk_type_set_chunk_alloc): new function to allow allocation of new
        types from a mem_chunk of certain size (n_chunks==0 indicates allocation
        thorugh g_malloc).

        * gtk/gtkobject.c (gtk_object_finalize): free an object through
        gtk_type_free().

        * gtk/gtkbutton.c (gtk_button_get_type): set chunk preallocation for
        GtkButtons to 16.
        * gtk/gtkmenuitem.c (gtk_menu_item_get_type): likewise (16).
        * gtk/gtklabel.c (gtk_label_get_type): likewise (32).
parent 344a2717
Thu May 14 03:04:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtktypeutils.c (gtk_type_free): new function to take care about
freeing types.
(gtk_type_set_chunk_alloc): new function to allow allocation of new
types from a mem_chunk of certain size (n_chunks==0 indicates allocation
thorugh g_malloc).
* gtk/gtkobject.c (gtk_object_finalize): free an object through
gtk_type_free().
* gtk/gtkbutton.c (gtk_button_get_type): set chunk preallocation for
GtkButtons to 16.
* gtk/gtkmenuitem.c (gtk_menu_item_get_type): likewise (16).
* gtk/gtklabel.c (gtk_label_get_type): likewise (32).
Wed May 13 00:53:52 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktypeutils.c gtk/gtksignal.c gdk/gdkdnd.c: A few more
......
Thu May 14 03:04:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtktypeutils.c (gtk_type_free): new function to take care about
freeing types.
(gtk_type_set_chunk_alloc): new function to allow allocation of new
types from a mem_chunk of certain size (n_chunks==0 indicates allocation
thorugh g_malloc).
* gtk/gtkobject.c (gtk_object_finalize): free an object through
gtk_type_free().
* gtk/gtkbutton.c (gtk_button_get_type): set chunk preallocation for
GtkButtons to 16.
* gtk/gtkmenuitem.c (gtk_menu_item_get_type): likewise (16).
* gtk/gtklabel.c (gtk_label_get_type): likewise (32).
Wed May 13 00:53:52 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktypeutils.c gtk/gtksignal.c gdk/gdkdnd.c: A few more
......
Thu May 14 03:04:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtktypeutils.c (gtk_type_free): new function to take care about
freeing types.
(gtk_type_set_chunk_alloc): new function to allow allocation of new
types from a mem_chunk of certain size (n_chunks==0 indicates allocation
thorugh g_malloc).
* gtk/gtkobject.c (gtk_object_finalize): free an object through
gtk_type_free().
* gtk/gtkbutton.c (gtk_button_get_type): set chunk preallocation for
GtkButtons to 16.
* gtk/gtkmenuitem.c (gtk_menu_item_get_type): likewise (16).
* gtk/gtklabel.c (gtk_label_get_type): likewise (32).
Wed May 13 00:53:52 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktypeutils.c gtk/gtksignal.c gdk/gdkdnd.c: A few more
......
Thu May 14 03:04:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtktypeutils.c (gtk_type_free): new function to take care about
freeing types.
(gtk_type_set_chunk_alloc): new function to allow allocation of new
types from a mem_chunk of certain size (n_chunks==0 indicates allocation
thorugh g_malloc).
* gtk/gtkobject.c (gtk_object_finalize): free an object through
gtk_type_free().
* gtk/gtkbutton.c (gtk_button_get_type): set chunk preallocation for
GtkButtons to 16.
* gtk/gtkmenuitem.c (gtk_menu_item_get_type): likewise (16).
* gtk/gtklabel.c (gtk_label_get_type): likewise (32).
Wed May 13 00:53:52 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktypeutils.c gtk/gtksignal.c gdk/gdkdnd.c: A few more
......
Thu May 14 03:04:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtktypeutils.c (gtk_type_free): new function to take care about
freeing types.
(gtk_type_set_chunk_alloc): new function to allow allocation of new
types from a mem_chunk of certain size (n_chunks==0 indicates allocation
thorugh g_malloc).
* gtk/gtkobject.c (gtk_object_finalize): free an object through
gtk_type_free().
* gtk/gtkbutton.c (gtk_button_get_type): set chunk preallocation for
GtkButtons to 16.
* gtk/gtkmenuitem.c (gtk_menu_item_get_type): likewise (16).
* gtk/gtklabel.c (gtk_label_get_type): likewise (32).
Wed May 13 00:53:52 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktypeutils.c gtk/gtksignal.c gdk/gdkdnd.c: A few more
......
Thu May 14 03:04:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtktypeutils.c (gtk_type_free): new function to take care about
freeing types.
(gtk_type_set_chunk_alloc): new function to allow allocation of new
types from a mem_chunk of certain size (n_chunks==0 indicates allocation
thorugh g_malloc).
* gtk/gtkobject.c (gtk_object_finalize): free an object through
gtk_type_free().
* gtk/gtkbutton.c (gtk_button_get_type): set chunk preallocation for
GtkButtons to 16.
* gtk/gtkmenuitem.c (gtk_menu_item_get_type): likewise (16).
* gtk/gtklabel.c (gtk_label_get_type): likewise (32).
Wed May 13 00:53:52 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktypeutils.c gtk/gtksignal.c gdk/gdkdnd.c: A few more
......
Thu May 14 03:04:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtktypeutils.c (gtk_type_free): new function to take care about
freeing types.
(gtk_type_set_chunk_alloc): new function to allow allocation of new
types from a mem_chunk of certain size (n_chunks==0 indicates allocation
thorugh g_malloc).
* gtk/gtkobject.c (gtk_object_finalize): free an object through
gtk_type_free().
* gtk/gtkbutton.c (gtk_button_get_type): set chunk preallocation for
GtkButtons to 16.
* gtk/gtkmenuitem.c (gtk_menu_item_get_type): likewise (16).
* gtk/gtklabel.c (gtk_label_get_type): likewise (32).
Wed May 13 00:53:52 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtktypeutils.c gtk/gtksignal.c gdk/gdkdnd.c: A few more
......
Thu May 14 04:14:12 1998 Tim Janik <timj@gtk.org>
* glib.h: typedef gint gboolean;
this is needed to provide portability with big-endian platforms (e.g.
try sizeof(bool) for c++ on big-endians - it's 4).
this is also needed to maintain some_union.d_gint==some_union.d_gboolean.
plus, gint to gboolean casts and vice versa need to be possible without
loss.
Tue May 12 19:22:58 1998 Owen Taylor <otaylor@gtk.org>
* glib/glib.h: Added macros G[U]INT_TO_POINTER() and
......
......@@ -318,7 +318,7 @@ typedef char gchar;
typedef short gshort;
typedef long glong;
typedef int gint;
typedef char gboolean;
typedef gint gboolean;
typedef unsigned char guchar;
typedef unsigned short gushort;
......
......@@ -161,6 +161,17 @@
(center GTK_JUSTIFY_CENTER)
(fill GTK_JUSTIFY_FILL))
(define-enum GtkButtonBoxStyle
(default GTK_BUTTONBOX_DEFAULT_STYLE)
(spread GTK_BUTTONBOX_SPREAD)
(edge GTK_BUTTONBOX_EDGE)
(start GTK_BUTTONBOX_START)
(end GTK_BUTTONBOX_END))
(define-enum GtkOrientation
(horizontal GTK_ORIENTATION_HORIZONTAL)
(vertical GTK_ORIENTATION_VERTICAL))
;;; Gdk enums
(define-enum GdkWindowType
......
......@@ -112,6 +112,7 @@ gtk_button_get_type (void)
};
button_type = gtk_type_unique (gtk_container_get_type (), &button_info);
gtk_type_set_chunk_alloc (button_type, 16);
}
return button_type;
......
......@@ -68,6 +68,7 @@ gtk_label_get_type (void)
};
label_type = gtk_type_unique (gtk_misc_get_type (), &label_info);
gtk_type_set_chunk_alloc (label_type, 32);
}
return label_type;
......
......@@ -88,6 +88,7 @@ gtk_menu_item_get_type (void)
};
menu_item_type = gtk_type_unique (gtk_item_get_type (), &menu_item_info);
gtk_type_set_chunk_alloc (menu_item_type, 16);
}
return menu_item_type;
......
......@@ -272,7 +272,7 @@ gtk_object_finalize (GtkObject *object)
GTK_OBJECT_DATA_DESTROY (odata);
}
g_free (object);
gtk_type_free (GTK_OBJECT_TYPE (object), object);
}
/*****************************************
......
......@@ -24,6 +24,8 @@
{ "GtkCurveType", GTK_TYPE_ENUM },
{ "GtkFundamentalType", GTK_TYPE_ENUM },
{ "GtkJustification", GTK_TYPE_ENUM },
{ "GtkButtonBoxStyle", GTK_TYPE_ENUM },
{ "GtkOrientation", GTK_TYPE_ENUM },
{ "GdkWindowType", GTK_TYPE_ENUM },
{ "GdkWindowClass", GTK_TYPE_ENUM },
{ "GdkImageType", GTK_TYPE_ENUM },
......
......@@ -24,36 +24,38 @@
#define GTK_TYPE_CURVE_TYPE (gtk_type_builtins[21])
#define GTK_TYPE_FUNDAMENTAL_TYPE (gtk_type_builtins[22])
#define GTK_TYPE_JUSTIFICATION (gtk_type_builtins[23])
#define GTK_TYPE_GDK_WINDOW_TYPE (gtk_type_builtins[24])
#define GTK_TYPE_GDK_WINDOW_CLASS (gtk_type_builtins[25])
#define GTK_TYPE_GDK_IMAGE_TYPE (gtk_type_builtins[26])
#define GTK_TYPE_GDK_VISUAL_TYPE (gtk_type_builtins[27])
#define GTK_TYPE_GDK_WINDOW_ATTRIBUTES_TYPE (gtk_type_builtins[28])
#define GTK_TYPE_GDK_WINDOW_HINTS (gtk_type_builtins[29])
#define GTK_TYPE_GDK_FUNCTION (gtk_type_builtins[30])
#define GTK_TYPE_GDK_FILL (gtk_type_builtins[31])
#define GTK_TYPE_GDK_LINE_STYLE (gtk_type_builtins[32])
#define GTK_TYPE_GDK_CAP_STYLE (gtk_type_builtins[33])
#define GTK_TYPE_GDK_JOIN_STYLE (gtk_type_builtins[34])
#define GTK_TYPE_GDK_CURSOR_TYPE (gtk_type_builtins[35])
#define GTK_TYPE_GDK_EVENT_TYPE (gtk_type_builtins[36])
#define GTK_TYPE_GDK_EVENT_MASK (gtk_type_builtins[37])
#define GTK_TYPE_GDK_NOTIFY_TYPE (gtk_type_builtins[38])
#define GTK_TYPE_GDK_MODIFIER_TYPE (gtk_type_builtins[39])
#define GTK_TYPE_GDK_SUBWINDOW_MODE (gtk_type_builtins[40])
#define GTK_TYPE_GDK_INPUT_CONDITION (gtk_type_builtins[41])
#define GTK_TYPE_GDK_STATUS (gtk_type_builtins[42])
#define GTK_TYPE_GDK_BYTE_ORDER (gtk_type_builtins[43])
#define GTK_TYPE_GDK_GCVALUES_MASK (gtk_type_builtins[44])
#define GTK_TYPE_GDK_SELECTION (gtk_type_builtins[45])
#define GTK_TYPE_GDK_PROPERTY_STATE (gtk_type_builtins[46])
#define GTK_TYPE_GDK_PROP_MODE (gtk_type_builtins[47])
#define GTK_TYPE_ACCELERATOR_TABLE (gtk_type_builtins[48])
#define GTK_TYPE_STYLE (gtk_type_builtins[49])
#define GTK_TYPE_GDK_COLORMAP (gtk_type_builtins[50])
#define GTK_TYPE_GDK_VISUAL (gtk_type_builtins[51])
#define GTK_TYPE_GDK_FONT (gtk_type_builtins[52])
#define GTK_TYPE_GDK_WINDOW (gtk_type_builtins[53])
#define GTK_TYPE_GDK_EVENT (gtk_type_builtins[54])
#define GTK_TYPE_GDK_COLOR (gtk_type_builtins[55])
#define GTK_TYPE_NUM_BUILTINS 56
#define GTK_TYPE_BUTTON_BOX_STYLE (gtk_type_builtins[24])
#define GTK_TYPE_ORIENTATION (gtk_type_builtins[25])
#define GTK_TYPE_GDK_WINDOW_TYPE (gtk_type_builtins[26])
#define GTK_TYPE_GDK_WINDOW_CLASS (gtk_type_builtins[27])
#define GTK_TYPE_GDK_IMAGE_TYPE (gtk_type_builtins[28])
#define GTK_TYPE_GDK_VISUAL_TYPE (gtk_type_builtins[29])
#define GTK_TYPE_GDK_WINDOW_ATTRIBUTES_TYPE (gtk_type_builtins[30])
#define GTK_TYPE_GDK_WINDOW_HINTS (gtk_type_builtins[31])
#define GTK_TYPE_GDK_FUNCTION (gtk_type_builtins[32])
#define GTK_TYPE_GDK_FILL (gtk_type_builtins[33])
#define GTK_TYPE_GDK_LINE_STYLE (gtk_type_builtins[34])
#define GTK_TYPE_GDK_CAP_STYLE (gtk_type_builtins[35])
#define GTK_TYPE_GDK_JOIN_STYLE (gtk_type_builtins[36])
#define GTK_TYPE_GDK_CURSOR_TYPE (gtk_type_builtins[37])
#define GTK_TYPE_GDK_EVENT_TYPE (gtk_type_builtins[38])
#define GTK_TYPE_GDK_EVENT_MASK (gtk_type_builtins[39])
#define GTK_TYPE_GDK_NOTIFY_TYPE (gtk_type_builtins[40])
#define GTK_TYPE_GDK_MODIFIER_TYPE (gtk_type_builtins[41])
#define GTK_TYPE_GDK_SUBWINDOW_MODE (gtk_type_builtins[42])
#define GTK_TYPE_GDK_INPUT_CONDITION (gtk_type_builtins[43])
#define GTK_TYPE_GDK_STATUS (gtk_type_builtins[44])
#define GTK_TYPE_GDK_BYTE_ORDER (gtk_type_builtins[45])
#define GTK_TYPE_GDK_GCVALUES_MASK (gtk_type_builtins[46])
#define GTK_TYPE_GDK_SELECTION (gtk_type_builtins[47])
#define GTK_TYPE_GDK_PROPERTY_STATE (gtk_type_builtins[48])
#define GTK_TYPE_GDK_PROP_MODE (gtk_type_builtins[49])
#define GTK_TYPE_ACCELERATOR_TABLE (gtk_type_builtins[50])
#define GTK_TYPE_STYLE (gtk_type_builtins[51])
#define GTK_TYPE_GDK_COLORMAP (gtk_type_builtins[52])
#define GTK_TYPE_GDK_VISUAL (gtk_type_builtins[53])
#define GTK_TYPE_GDK_FONT (gtk_type_builtins[54])
#define GTK_TYPE_GDK_WINDOW (gtk_type_builtins[55])
#define GTK_TYPE_GDK_EVENT (gtk_type_builtins[56])
#define GTK_TYPE_GDK_COLOR (gtk_type_builtins[57])
#define GTK_TYPE_NUM_BUILTINS 58
......@@ -29,11 +29,13 @@ struct _GtkTypeNode
{
GtkType type;
GtkTypeInfo type_info;
guint n_supers;
guint n_supers : 24;
guint chunk_alloc_locked : 1;
GtkType *supers;
GtkType parent_type;
gpointer klass;
GList *children_types;
GMemChunk *mem_chunk;
};
......@@ -121,6 +123,29 @@ gtk_type_init (void)
}
}
void
gtk_type_set_chunk_alloc (GtkType type,
guint n_chunks)
{
GtkTypeNode *node;
LOOKUP_TYPE_NODE (node, type);
g_return_if_fail (node != NULL);
g_return_if_fail (node->chunk_alloc_locked == FALSE);
if (node->mem_chunk)
{
g_mem_chunk_destroy (node->mem_chunk);
node->mem_chunk = NULL;
}
if (n_chunks)
node->mem_chunk = g_mem_chunk_new (node->type_info.type_name,
node->type_info.object_size,
node->type_info.object_size * n_chunks,
G_ALLOC_AND_FREE);
}
GtkType
gtk_type_unique (GtkType parent_type,
GtkTypeInfo *type_info)
......@@ -169,10 +194,12 @@ gtk_type_unique (GtkType parent_type,
new_node->type_info = *type_info;
new_node->type_info.type_name = g_strdup (type_info->type_name);
new_node->n_supers = parent ? parent->n_supers + 1 : 0;
new_node->chunk_alloc_locked = FALSE;
new_node->supers = g_new0 (GtkType, new_node->n_supers + 1);
new_node->parent_type = parent_type;
new_node->klass = NULL;
new_node->children_types = NULL;
new_node->mem_chunk = NULL;
if (parent)
parent->children_types = g_list_append (parent->children_types, GUINT_TO_POINTER (new_node->type));
......@@ -279,7 +306,14 @@ gtk_type_new (GtkType type)
g_return_val_if_fail (node != NULL, NULL);
klass = gtk_type_class (type);
object = g_malloc0 (node->type_info.object_size);
node->chunk_alloc_locked = TRUE;
if (node->mem_chunk)
{
object = g_mem_chunk_alloc (node->mem_chunk);
memset (object, 0, node->type_info.object_size);
}
else
object = g_malloc0 (node->type_info.object_size);
object->klass = klass;
for (i = node->n_supers; i > 0; i--)
......@@ -296,6 +330,22 @@ gtk_type_new (GtkType type)
return object;
}
void
gtk_type_free (GtkType type,
gpointer mem)
{
GtkTypeNode *node;
g_return_if_fail (mem != NULL);
LOOKUP_TYPE_NODE (node, type);
g_return_if_fail (node != NULL);
if (node->mem_chunk)
g_mem_chunk_free (node->mem_chunk, mem);
else
g_free (mem);
}
void
gtk_type_describe_heritage (GtkType type)
{
......@@ -449,7 +499,7 @@ gtk_type_class_init (GtkTypeNode *node)
{
if (!node->klass && node->type_info.class_size)
{
node->klass = g_new0 (guchar, node->type_info.class_size);
node->klass = g_malloc0 (node->type_info.class_size);
if (node->parent_type)
{
......
......@@ -181,12 +181,16 @@ struct _GtkTypeInfo
void gtk_type_init (void);
GtkType gtk_type_unique (guint parent_type,
GtkTypeInfo *type_info);
void gtk_type_set_chunk_alloc (GtkType type,
guint n_chunks);
gchar* gtk_type_name (guint type);
GtkType gtk_type_from_name (const gchar *name);
GtkType gtk_type_parent (GtkType type);
gpointer gtk_type_class (GtkType type);
gpointer gtk_type_parent_class (GtkType type);
gpointer gtk_type_new (GtkType type);
void gtk_type_free (GtkType type,
gpointer mem);
void gtk_type_describe_heritage (GtkType type);
void gtk_type_describe_tree (GtkType type,
gint show_size);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment