r15784 - gnucash/branches/gobject-engine-dev-warlord - get libqof to build using GObject
Derek Atkins
warlord at cvs.gnucash.org
Tue Apr 3 18:30:59 EDT 2007
Author: warlord
Date: 2007-04-03 18:30:58 -0400 (Tue, 03 Apr 2007)
New Revision: 15784
Trac: http://svn.gnucash.org/trac/changeset/15784
Modified:
gnucash/branches/gobject-engine-dev-warlord/
gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofbook-p.h
gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofbook.c
gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofbook.h
gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofid.h
gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofinstance.h
Log:
get libqof to build using GObject
- migrate QofBook to GObject
- move around some typedef to get libqof to build again
Property changes on: gnucash/branches/gobject-engine-dev-warlord
___________________________________________________________________
Name: svk:merge
- 3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/branches/swig-redo:802
3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/trunk:1037
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/gobject-engine-dev-warlord:14369
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/gobject-engine-dev-warlord1:14377
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:14282
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk2:13366
+ 3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/branches/swig-redo:802
3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/trunk:1037
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/gobject-engine-dev-warlord:14369
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/gobject-engine-dev-warlord1:14379
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:14282
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk2:13366
Modified: gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofbook-p.h
===================================================================
--- gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofbook-p.h 2007-04-03 17:36:35 UTC (rev 15783)
+++ gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofbook-p.h 2007-04-03 22:30:58 UTC (rev 15784)
@@ -43,65 +43,6 @@
#include "qofid-p.h"
#include "qofinstance-p.h"
-/* Book structure */
-struct _QofBook
-{
- QofInstance inst; /* Unique guid for this book. */
-
- /* The time when the book was first dirtied. This is a secondary
- * indicator. It should only be used when inst.dirty is TRUE. */
- time_t dirty_time;
-
- /* This callback function is called any time the book dirty flag
- * changes state. Both clean->dirty and dirty->clean transitions
- * trigger a callback. */
- QofBookDirtyCB dirty_cb;
-
- /* This is the user supplied data that is returned in the dirty
- * callback function.*/
- gpointer dirty_data;
-
- /* The entity table associates the GUIDs of all the objects
- * belonging to this book, with their pointers to the respective
- * objects. This allows a lookup of objects based on thier guid.
- */
- GHashTable * hash_of_collections;
-
- /* In order to store arbitrary data, for extensibility, add a table
- * that will be used to hold arbitrary pointers.
- */
- GHashTable *data_tables;
-
- /* Hash table of destroy callbacks for the data table. */
- GHashTable *data_table_finalizers;
-
- /* state flag: 'y' means 'open for editing',
- * 'n' means 'book is closed'
- * xxxxx shouldn't this be replaced by the instance editlevel ???
- */
- char book_open;
-
- /* a flag denoting whether the book is closing down, used to
- * help the QOF objects shut down cleanly without maintaining
- * internal consistency.
- * XXX shouldn't this be replaced by instance->do_free ???
- */
- gboolean shutting_down;
-
- /* version number, used for tracking multiuser updates */
- gint32 version;
-
- /* To be technically correct, backends belong to sessions and
- * not books. So the pointer below "really shouldn't be here",
- * except that it provides a nice convenience, avoiding a lookup
- * from the session. Better solutions welcome ... */
- QofBackend *backend;
-
- /* -------------------------------------------------------------- */
- /* Backend private expansion data */
- guint32 idata; /* used by the sql backend for kvp management */
-};
-
/*
* qof_book_set_backend() is used by backends to
* initialize the pointers in the book structure to
Modified: gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofbook.c
===================================================================
--- gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofbook.c 2007-04-03 17:36:35 UTC (rev 15783)
+++ gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofbook.c 2007-04-03 22:30:58 UTC (rev 15784)
@@ -48,6 +48,8 @@
static QofLogModule log_module = QOF_MOD_ENGINE;
+QOF_GOBJECT_IMPL(qof_book, QofBook, QOF_TYPE_INSTANCE);
+
/* ====================================================================== */
/* constructor / destructor */
@@ -66,7 +68,7 @@
(GDestroyNotify)qof_util_string_cache_remove, /* key_destroy_func */
coll_destroy); /* value_destroy_func */
- qof_instance_init (&book->inst, QOF_ID_BOOK, book);
+ qof_instance_init_data (&book->inst, QOF_ID_BOOK, book);
book->data_tables = g_hash_table_new (g_str_hash, g_str_equal);
book->data_table_finalizers = g_hash_table_new (g_str_hash, g_str_equal);
@@ -82,8 +84,7 @@
QofBook *book;
ENTER (" ");
- book = g_new0(QofBook, 1);
- qof_book_init(book);
+ book = g_object_new(QOF_TYPE_BOOK, NULL);
qof_object_book_begin (book);
qof_event_gen (&book->inst, QOF_EVENT_CREATE, NULL);
@@ -101,6 +102,11 @@
(*cb) (book, key, user_data);
}
+static void
+qof_book_finalize_real (GObject *bookp)
+{
+}
+
void
qof_book_destroy (QofBook *book)
{
@@ -122,12 +128,12 @@
g_hash_table_destroy (book->data_tables);
book->data_tables = NULL;
- qof_instance_release (&book->inst);
+ /* qof_instance_release (&book->inst); */
g_hash_table_destroy (book->hash_of_collections);
book->hash_of_collections = NULL;
- g_free (book);
+ g_object_unref (book);
LEAVE ("book=%p", book);
}
Modified: gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofbook.h
===================================================================
--- gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofbook.h 2007-04-03 17:36:35 UTC (rev 15783)
+++ gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofbook.h 2007-04-03 22:30:58 UTC (rev 15784)
@@ -40,9 +40,93 @@
#ifndef QOF_BOOK_H
#define QOF_BOOK_H
+typedef struct _QofBookClass QofBookClass;
+
#include "qofid.h"
#include "kvp_frame.h"
+#include "qofinstance.h"
+/* --- type macros --- */
+#define QOF_TYPE_BOOK (qof_book_get_type ())
+#define QOF_BOOK(o) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((o), QOF_TYPE_BOOK, QofBook))
+#define QOF_BOOK_CLASS(k) \
+ (G_TYPE_CHECK_CLASS_CAST((k), QOF_TYPE_BOOK, QofBookClass))
+#define QOF_IS_BOOK(o) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((o), QOF_TYPE_BOOK))
+#define QOF_IS_BOOK_CLASS(k) \
+ (G_TYPE_CHECK_CLASS_TYPE ((k), QOF_TYPE_BOOK))
+#define QOF_BOOK_GET_CLASS(o) \
+ (G_TYPE_INSTANCE_GET_CLASS ((o), QOF_TYPE_BOOK, QofBookClass))
+
+typedef void (*QofBookDirtyCB) (QofBook *, gboolean dirty, gpointer user_data);
+
+/* Book structure */
+struct _QofBook
+{
+ QofInstance inst; /* Unique guid for this book. */
+
+ /* The time when the book was first dirtied. This is a secondary
+ * indicator. It should only be used when inst.dirty is TRUE. */
+ time_t dirty_time;
+
+ /* This callback function is called any time the book dirty flag
+ * changes state. Both clean->dirty and dirty->clean transitions
+ * trigger a callback. */
+ QofBookDirtyCB dirty_cb;
+
+ /* This is the user supplied data that is returned in the dirty
+ * callback function.*/
+ gpointer dirty_data;
+
+ /* The entity table associates the GUIDs of all the objects
+ * belonging to this book, with their pointers to the respective
+ * objects. This allows a lookup of objects based on thier guid.
+ */
+ GHashTable * hash_of_collections;
+
+ /* In order to store arbitrary data, for extensibility, add a table
+ * that will be used to hold arbitrary pointers.
+ */
+ GHashTable *data_tables;
+
+ /* Hash table of destroy callbacks for the data table. */
+ GHashTable *data_table_finalizers;
+
+ /* state flag: 'y' means 'open for editing',
+ * 'n' means 'book is closed'
+ * xxxxx shouldn't this be replaced by the instance editlevel ???
+ */
+ char book_open;
+
+ /* a flag denoting whether the book is closing down, used to
+ * help the QOF objects shut down cleanly without maintaining
+ * internal consistency.
+ * XXX shouldn't this be replaced by instance->do_free ???
+ */
+ gboolean shutting_down;
+
+ /* version number, used for tracking multiuser updates */
+ gint32 version;
+
+ /* To be technically correct, backends belong to sessions and
+ * not books. So the pointer below "really shouldn't be here",
+ * except that it provides a nice convenience, avoiding a lookup
+ * from the session. Better solutions welcome ... */
+ QofBackend *backend;
+
+ /* -------------------------------------------------------------- */
+ /* Backend private expansion data */
+ guint32 idata; /* used by the sql backend for kvp management */
+};
+
+struct _QofBookClass
+{
+ QofInstanceClass parent_class;
+};
+
+GType qof_book_get_type(void);
+
/** @brief Encapsulates all the information about a dataset
* manipulated by QOF. This is the top-most structure
* used for anchoring data.
@@ -59,14 +143,10 @@
(c_type *) val; \
})
-/** \brief QofBook reference */
-typedef struct _QofBook QofBook;
-
/** GList of QofBook */
typedef GList QofBookList;
typedef void (*QofBookFinalCB) (QofBook *, gpointer key, gpointer user_data);
-typedef void (*QofBookDirtyCB) (QofBook *, gboolean dirty, gpointer user_data);
/** Register the book object with the QOF object system. */
gboolean qof_book_register (void);
Modified: gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofid.h
===================================================================
--- gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofid.h 2007-04-03 17:36:35 UTC (rev 15783)
+++ gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofid.h 2007-04-03 22:30:58 UTC (rev 15784)
@@ -83,9 +83,10 @@
/** QofLogModule declaration */
typedef const gchar* QofLogModule;
-/* Forward declaration for later */
-typedef struct QofInstance_s QofInstance;
+typedef struct QofCollection_s QofCollection;
+#include "qofinstance.h"
+
#define QOF_ID_NONE NULL
#define QOF_ID_NULL "null"
@@ -133,8 +134,6 @@
@param data gpointer, place where object class can hang arbitrary data
*/
-typedef struct QofCollection_s QofCollection;
-
void qof_entity_init (QofInstance *ent, QofIdType type, QofCollection * tab);
void qof_entity_release (QofInstance *ent);
void qof_instance_set_guid (QofInstance *ent, const GUID *guid);
Modified: gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofinstance.h
===================================================================
--- gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofinstance.h 2007-04-03 17:36:35 UTC (rev 15783)
+++ gnucash/branches/gobject-engine-dev-warlord/lib/libqof/qof/qofinstance.h 2007-04-03 22:30:58 UTC (rev 15784)
@@ -37,12 +37,15 @@
#define QOF_INSTANCE_H
typedef struct _QofInstanceClass QofInstanceClass;
+typedef struct QofInstance_s QofInstance;
+/** \brief QofBook reference */
+typedef struct _QofBook QofBook;
+
#include "qofid.h"
#include "guid.h"
#include "gnc-date.h"
#include "kvp_frame.h"
-#include "qofbook.h"
#include "qof-gobject.h"
/* --- type macros --- */
More information about the gnucash-changes
mailing list