[couchdb-glib: 7/21] Still not compiling, but much closer again. There are a lot of cross-class references to internal/pr



commit 6b1de615fc760637590d674c3f0da9574669307a
Author: Mikkel Kamstrup Erlandsen <mikkel kamstrup gmail com>
Date:   Sun Oct 4 21:14:37 2009 +0200

    Still not compiling, but much closer again. There are a lot of cross-class references to internal/private API that needs to be cleaned up

 NOTES.kamstrup                      |   10 ++++++++++
 couchdb-glib/Makefile.am            |    3 +++
 couchdb-glib/couchdb-document.c     |   14 +++++++-------
 couchdb-glib/couchdb-document.h     |   12 +++++-------
 couchdb-glib/couchdb-struct-field.c |    9 ++++++++-
 couchdb-glib/couchdb-struct-field.h |    3 +++
 couchdb-glib/couchdb.h              |    3 +--
 7 files changed, 37 insertions(+), 17 deletions(-)
---
diff --git a/NOTES.kamstrup b/NOTES.kamstrup
new file mode 100644
index 0000000..265fb67
--- /dev/null
+++ b/NOTES.kamstrup
@@ -0,0 +1,10 @@
+In couchdb-document.c:
+ * Change refs to internal API of CouchDB object's ->hostname to method calls
+ * Change refs to internal API of CouchDBStructField ->json_object to use method call
+
+In couchdb-struct-field.*:
+ * Add method _get_json_object()
+ 
+THOUGHTS:
+ * CouchDBStructField seems to be a superfluous wrapper of JSonObject
+ * Rename CouchDB object to CouchDBConnection
diff --git a/couchdb-glib/Makefile.am b/couchdb-glib/Makefile.am
index e5ed6fa..6a60488 100644
--- a/couchdb-glib/Makefile.am
+++ b/couchdb-glib/Makefile.am
@@ -34,6 +34,9 @@ libcouchdb_glib_1_0_la_SOURCES =	\
 	couchdb-document-info.c		\
 	couchdb-document-info.h		\
 	couchdb-glib.h			\
+	couchdb-struct-field.c		\
+	couchdb-struct-field.h		\
+	couchdb-types.h			\
 	dbwatch.c			\
 	dbwatch.h			\
 	utils.c				\
diff --git a/couchdb-glib/couchdb-document.c b/couchdb-glib/couchdb-document.c
index a5a5cbe..20356e3 100644
--- a/couchdb-glib/couchdb-document.c
+++ b/couchdb-glib/couchdb-document.c
@@ -26,8 +26,6 @@
 #include "couchdb-document.h"
 #include "utils.h"
 
-G_DEFINE_TYPE(CouchDBDocument, couchdb_document, G_TYPE_OBJECT);
-
 struct _CouchDBDocument {
 	GObject		parent;
 
@@ -36,6 +34,8 @@ struct _CouchDBDocument {
 	JsonNode	*root_node;
 };
 
+G_DEFINE_TYPE(CouchDBDocument, couchdb_document, G_TYPE_OBJECT);
+
 static void
 couchdb_document_finalize (GObject *object)
 {
@@ -93,7 +93,7 @@ couchdb_document_get (CouchDB *couchdb,
 	g_return_val_if_fail (docid != NULL, NULL);
 
 	encoded_docid = soup_uri_encode (docid, NULL);
-	url = g_strdup_printf ("%s/%s/%s", couchdb->hostname, dbname, encoded_docid);
+	url = g_strdup_printf ("%s/%s/%s", couchdb_get_hostname (couchdb), dbname, encoded_docid);
 	parser = send_message_and_parse (couchdb, SOUP_METHOD_GET, url, NULL, error);
 	if (parser) {
 		document = g_object_new (COUCHDB_TYPE_DOCUMENT, NULL);
@@ -129,12 +129,12 @@ couchdb_document_put (CouchDBDocument *document,
 		char *encoded_docid;
 
 		encoded_docid = soup_uri_encode (id, NULL);
-		url = g_strdup_printf ("%s/%s/%s", document->couchdb->hostname, dbname, encoded_docid);
+		url = g_strdup_printf ("%s/%s/%s", couchdb_get_hostname (document->couchdb), dbname, encoded_docid);
 		parser = send_message_and_parse (document->couchdb, SOUP_METHOD_PUT, url, body, error);
 
 		g_free (encoded_docid);
 	} else {
-		url = g_strdup_printf ("%s/%s/", document->couchdb->hostname, dbname);
+		url = g_strdup_printf ("%s/%s/", couchdb_get_hostname (document->couchdb), dbname);
 		parser = send_message_and_parse (document->couchdb, SOUP_METHOD_POST, url, body, error);
 	}
 
@@ -182,7 +182,7 @@ couchdb_document_delete (CouchDBDocument *document, GError **error)
 	if (!id || !revision) /* we can't remove a document without an ID and/or a REVISION */
 		return FALSE;
 
-	url = g_strdup_printf ("%s/%s/%s?rev=%s", document->couchdb->hostname, document->dbname, id, revision);
+	url = g_strdup_printf ("%s/%s/%s?rev=%s", couchdb_get_hostname (document->couchdb), document->dbname, id, revision);
 	parser = send_message_and_parse (document->couchdb, SOUP_METHOD_DELETE, url, NULL, error);
 	if (parser) {
 		g_object_unref (G_OBJECT (parser));
@@ -418,7 +418,7 @@ couchdb_document_set_struct_field (CouchDBDocument *document, const char *field,
 
 	json_object_set_object_member (json_node_get_object (document->root_node),
 				       field,
-				       json_object_ref (value->json_object));
+				       json_object_ref (couchdb_struct_field_get_json_object (value)));
 }
 
 CouchDBStructField *
diff --git a/couchdb-glib/couchdb-document.h b/couchdb-glib/couchdb-document.h
index 8a807f2..c86c24b 100644
--- a/couchdb-glib/couchdb-document.h
+++ b/couchdb-glib/couchdb-document.h
@@ -26,12 +26,11 @@
 
 #include <glib.h>
 #include <glib-object.h>
-#include "couchdb.h"
+#include "couchdb-types.h"
 #include "couchdb-struct-field.h"
 
 G_BEGIN_DECLS
 
-
 #define COUCHDB_TYPE_DOCUMENT                (couchdb_document_get_type ())
 #define COUCHDB_DOCUMENT(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), COUCHDB_TYPE_DOCUMENT, CouchDBDocument))
 #define COUCHDB_IS_DOCUMENT(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), COUCHDB_TYPE_DOCUMENT))
@@ -39,12 +38,9 @@ G_BEGIN_DECLS
 #define COUCHDB_IS_DOCUMENT_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE ((klass), COUCHDB_TYPE_DOCUMENT))
 #define COUCHDB_DOCUMENT_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), COUCHDB_TYPE_DOCUMENT, CouchDBDocumentClass))
 
-typedef struct _CouchDBDocument CouchDBDocument;
-typedef struct _CouchDBDocumentClass CouchDBDocumentClass;
-
-struct {
+typedef struct {
 	GObjectClass parent_class;
-} _CouchDBDocumentClass;
+} CouchDBDocumentClass;
 
 
 GType            couchdb_document_get_type 		(void);
@@ -130,4 +126,6 @@ void             couchdb_document_set_application_annotations
       
 char*		couchdb_document_to_string		(CouchDBDocument *document);
 
+G_END_DECLS
+
 #endif /* __COUCHDB_DOCUMENT_H__ */
diff --git a/couchdb-glib/couchdb-struct-field.c b/couchdb-glib/couchdb-struct-field.c
index 15394d4..21f7bd9 100644
--- a/couchdb-glib/couchdb-struct-field.c
+++ b/couchdb-glib/couchdb-struct-field.c
@@ -21,7 +21,6 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#include <json-glib/json-glib.h>
 #include "couchdb-struct-field.h"
 
 struct _CouchDBStructField {
@@ -282,3 +281,11 @@ couchdb_struct_field_to_string (CouchDBStructField *sf)
 	return str;
 }
 
+JsonObject *
+couchdb_struct_field_get_json_object (CouchDBStructField *sf)
+{
+	return_val_if_fail (sf != NULL, NULL);
+	
+	return sf->json_object;
+}
+
diff --git a/couchdb-glib/couchdb-struct-field.h b/couchdb-glib/couchdb-struct-field.h
index 776e0d3..707ebdf 100644
--- a/couchdb-glib/couchdb-struct-field.h
+++ b/couchdb-glib/couchdb-struct-field.h
@@ -26,6 +26,7 @@
 
 #include <glib.h>
 #include <glib-object.h>
+#include <json-glib/json-glib.h>
 #include "couchdb.h"
 #include "couchdb-struct-field.h"
 
@@ -62,6 +63,8 @@ char               *couchdb_struct_field_to_string (CouchDBStructField *sf);
 
 CouchDBStructField *couchdb_struct_field_new_from_json_object (JsonObject *json_object);
 
+JsonObject         *couchdb_struct_field_get_json_object (CouchDBStructField *sf);  
+
 G_END_DECLS
 
 #endif /* __COUCHDB_STRUCT_FIELD__ */
diff --git a/couchdb-glib/couchdb.h b/couchdb-glib/couchdb.h
index 8f95898..63011eb 100644
--- a/couchdb-glib/couchdb.h
+++ b/couchdb-glib/couchdb.h
@@ -26,7 +26,7 @@
 
 #include <glib.h>
 #include <glib-object.h>
-#include "couchdb-document.h"
+#include "couchdb-types.h"
 #include "couchdb-database-info.h"
 
 G_BEGIN_DECLS
@@ -38,7 +38,6 @@ G_BEGIN_DECLS
 #define COUCHDB_IS_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE ((klass), COUCHDB_TYPE))
 #define COUCHDB_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), COUCHDB_TYPE, CouchDBClass))
 
-typedef struct _CouchDB CouchDB;
 typedef struct {
 	GObjectClass parent_class;
 



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