[json-glib] Update after the json_object_add_member() deprecation



commit 4819ca625d1b73270797f913495a3835297950c2
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Fri Apr 17 11:44:01 2009 +0100

    Update after the json_object_add_member() deprecation
    
    Since json_object_add_member() has been deprecated and it's using
    a gcc compiler attribute to loudly complain while compiling the
    library, we should restore the sanity and use json_object_set_member()
    instead.
---
 json-glib/json-gobject.c       |    2 +-
 json-glib/json-parser.c        |    6 +++---
 json-glib/tests/node-test.c    |    2 +-
 json-glib/tests/object-test.c  |    4 ++--
 tests/test-generator.c         |   26 +++++++++++++-------------
 tests/test-serialize-complex.c |    4 ++--
 tests/test-serialize-full.c    |    4 ++--
 7 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/json-glib/json-gobject.c b/json-glib/json-gobject.c
index 5224250..6eea9a5 100644
--- a/json-glib/json-gobject.c
+++ b/json-glib/json-gobject.c
@@ -723,7 +723,7 @@ json_serialize_gobject (GObject *gobject,
         node = json_serialize_pspec (&value, pspec);
 
       if (node)
-        json_object_add_member (object, pspec->name, node);
+        json_object_set_member (object, pspec->name, node);
 
       g_value_unset (&value);
     }
diff --git a/json-glib/json-parser.c b/json-glib/json-parser.c
index 8786ff3..8224576 100644
--- a/json-glib/json-parser.c
+++ b/json-glib/json-parser.c
@@ -605,7 +605,7 @@ json_parse_object (JsonParser *parser,
               return token;
             }
 
-          json_object_add_member (object, name, node);
+          json_object_set_member (object, name, node);
           node->parent = priv->current_node;
 
           g_signal_emit (parser, parser_signals[OBJECT_MEMBER], 0,
@@ -648,7 +648,7 @@ json_parse_object (JsonParser *parser,
               return token;
             }
 
-          json_object_add_member (object, name, node);
+          json_object_set_member (object, name, node);
           node->parent = priv->current_node;
           
           g_signal_emit (parser, parser_signals[OBJECT_MEMBER], 0,
@@ -726,7 +726,7 @@ json_parse_object (JsonParser *parser,
 
       if (node)
         {
-          json_object_add_member (object, name, node);
+          json_object_set_member (object, name, node);
           node->parent = priv->current_node;
           
           g_signal_emit (parser, parser_signals[OBJECT_MEMBER], 0,
diff --git a/json-glib/tests/node-test.c b/json-glib/tests/node-test.c
index 145eb31..1a9294b 100644
--- a/json-glib/tests/node-test.c
+++ b/json-glib/tests/node-test.c
@@ -42,7 +42,7 @@ test_copy_object (void)
   JsonNode *copy;
 
   json_node_set_int (value, 42);
-  json_object_add_member (obj, "answer", value);
+  json_object_set_member (obj, "answer", value);
 
   json_node_take_object (node, obj);
 
diff --git a/json-glib/tests/object-test.c b/json-glib/tests/object-test.c
index 34d6539..4803e96 100644
--- a/json-glib/tests/object-test.c
+++ b/json-glib/tests/object-test.c
@@ -24,7 +24,7 @@ test_add_member (void)
 
   g_assert_cmpint (json_object_get_size (object), ==, 0);
 
-  json_object_add_member (object, "Null", node);
+  json_object_set_member (object, "Null", node);
   g_assert_cmpint (json_object_get_size (object), ==, 1);
 
   node = json_object_get_member (object, "Null");
@@ -39,7 +39,7 @@ test_remove_member (void)
   JsonObject *object = json_object_new ();
   JsonNode *node = json_node_new (JSON_NODE_NULL);
 
-  json_object_add_member (object, "Null", node);
+  json_object_set_member (object, "Null", node);
 
   json_object_remove_member (object, "Null");
   g_assert_cmpint (json_object_get_size (object), ==, 0);
diff --git a/tests/test-generator.c b/tests/test-generator.c
index f3edda7..32fd910 100644
--- a/tests/test-generator.c
+++ b/tests/test-generator.c
@@ -205,31 +205,31 @@ test_simple_object (void)
   g_value_init (&value, G_TYPE_BOOLEAN);
   g_value_set_boolean (&value, TRUE);
   json_node_set_value (val, &value);
-  json_object_add_member (object, "Bool1", val);
+  json_object_set_member (object, "Bool1", val);
   g_value_unset (&value);
 
   val = json_node_new (JSON_NODE_VALUE);
   g_value_init (&value, G_TYPE_BOOLEAN);
   g_value_set_boolean (&value, FALSE);
   json_node_set_value (val, &value);
-  json_object_add_member (object, "Bool2", val);
+  json_object_set_member (object, "Bool2", val);
   g_value_unset (&value);
 
   val = json_node_new (JSON_NODE_NULL);
-  json_object_add_member (object, "Null", val);
+  json_object_set_member (object, "Null", val);
 
   val = json_node_new (JSON_NODE_VALUE);
   g_value_init (&value, G_TYPE_INT);
   g_value_set_int (&value, 42);
   json_node_set_value (val, &value);
-  json_object_add_member (object, "Int", val);
+  json_object_set_member (object, "Int", val);
   g_value_unset (&value);
 
   val = json_node_new (JSON_NODE_VALUE);
   g_value_init (&value, G_TYPE_STRING);
   g_value_set_string (&value, "foo");
   json_node_set_value (val, &value);
-  json_object_add_member (object, "String", val);
+  json_object_set_member (object, "String", val);
   g_value_unset (&value);
 
   json_node_take_object (root, object);
@@ -277,21 +277,21 @@ test_nested_object (void)
   g_value_init (&value, G_TYPE_STRING);
   g_value_set_string (&value, "View from 15th Floor");
   json_node_set_value (val, &value);
-  json_object_add_member (object, "Title", val);
+  json_object_set_member (object, "Title", val);
   g_value_unset (&value);
 
   val = json_node_new (JSON_NODE_VALUE);
   g_value_init (&value, G_TYPE_INT);
   g_value_set_int (&value, 800);
   json_node_set_value (val, &value);
-  json_object_add_member (object, "Width", val);
+  json_object_set_member (object, "Width", val);
   g_value_unset (&value);
 
   val = json_node_new (JSON_NODE_VALUE);
   g_value_init (&value, G_TYPE_INT);
   g_value_set_int (&value, 600);
   json_node_set_value (val, &value);
-  json_object_add_member (object, "Height", val);
+  json_object_set_member (object, "Height", val);
   g_value_unset (&value);
 
   {
@@ -327,7 +327,7 @@ test_nested_object (void)
     g_value_unset (&value);
 
     json_node_take_array (val, array);
-    json_object_add_member (object, "IDs", val);
+    json_object_set_member (object, "IDs", val);
   }
 
   {
@@ -338,25 +338,25 @@ test_nested_object (void)
     g_value_init (&value, G_TYPE_STRING);
     g_value_set_string (&value, "http://www.example.com/image/481989943";);
     json_node_set_value (nested_val, &value);
-    json_object_add_member (nested, "Url", nested_val);
+    json_object_set_member (nested, "Url", nested_val);
     g_value_unset (&value);
 
     nested_val = json_node_new (JSON_NODE_VALUE);
     g_value_init (&value, G_TYPE_INT);
     g_value_set_int (&value, 125);
     json_node_set_value (nested_val, &value);
-    json_object_add_member (nested, "Width", nested_val);
+    json_object_set_member (nested, "Width", nested_val);
     g_value_unset (&value);
 
     nested_val = json_node_new (JSON_NODE_VALUE);
     g_value_init (&value, G_TYPE_INT);
     g_value_set_int (&value, 100);
     json_node_set_value (nested_val, &value);
-    json_object_add_member (nested, "Height", nested_val);
+    json_object_set_member (nested, "Height", nested_val);
     g_value_unset (&value);
 
     json_node_take_object (val, nested);
-    json_object_add_member (object, "Thumbnail", val);
+    json_object_set_member (object, "Thumbnail", val);
   }
 
   json_node_take_object (root, object);
diff --git a/tests/test-serialize-complex.c b/tests/test-serialize-complex.c
index 452cd24..0b361e6 100644
--- a/tests/test-serialize-complex.c
+++ b/tests/test-serialize-complex.c
@@ -113,11 +113,11 @@ test_object_serialize_property (JsonSerializable *serializable,
 
       val = json_node_new (JSON_NODE_VALUE);
       json_node_set_int (val, boxed->foo);
-      json_object_add_member (obj, "foo", val);
+      json_object_set_member (obj, "foo", val);
 
       val = json_node_new (JSON_NODE_VALUE);
       json_node_set_boolean (val, boxed->bar);
-      json_object_add_member (obj, "bar", val);
+      json_object_set_member (obj, "bar", val);
 
       json_node_take_object (retval, obj);
     }
diff --git a/tests/test-serialize-full.c b/tests/test-serialize-full.c
index 95925da..f38bc5c 100644
--- a/tests/test-serialize-full.c
+++ b/tests/test-serialize-full.c
@@ -156,11 +156,11 @@ test_object_serialize_property (JsonSerializable *serializable,
 
       val = json_node_new (JSON_NODE_VALUE);
       json_node_set_int (val, boxed->foo);
-      json_object_add_member (obj, "foo", val);
+      json_object_set_member (obj, "foo", val);
 
       val = json_node_new (JSON_NODE_VALUE);
       json_node_set_boolean (val, boxed->bar);
-      json_object_add_member (obj, "bar", val);
+      json_object_set_member (obj, "bar", val);
 
       json_node_take_object (retval, obj);
 



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