Blame 0001-Don-t-return-ModuleStream-objects-from-modulemd_modu.patch

f37170d
From 59573d72fbef9421eb5a77b7858ad60d78b7f7f0 Mon Sep 17 00:00:00 2001
f37170d
From: "Owen W. Taylor" <otaylor@fishsoup.net>
f37170d
Date: Thu, 9 Aug 2018 11:06:34 +0200
f37170d
Subject: [PATCH 1/2] Don't return ModuleStream objects from
f37170d
 modulemd_module_new_all_from_*_ext()
f37170d
f37170d
These older, deprecated functions should not have been changed to
f37170d
return ModuleStream objects rather than Module objects.
f37170d
---
f37170d
 .../modulemd-1.0/private/modulemd-yaml.h      |  3 ++
f37170d
 modulemd/v1/modulemd-common.c                 | 35 ++-----------------
f37170d
 modulemd/v1/modulemd-module.c                 | 18 ++++++++--
f37170d
 modulemd/v1/modulemd-yaml-utils.c             | 27 ++++++++++++++
f37170d
 4 files changed, 49 insertions(+), 34 deletions(-)
f37170d
f37170d
diff --git a/modulemd/include/modulemd-1.0/private/modulemd-yaml.h b/modulemd/include/modulemd-1.0/private/modulemd-yaml.h
f37170d
index aea47b6360cae37d478480a0479b9006a4a7a2b3..bea23f7fcf28c9bc7798b6d3cef121ebd4015681 100644
f37170d
--- a/modulemd/include/modulemd-1.0/private/modulemd-yaml.h
f37170d
+++ b/modulemd/include/modulemd-1.0/private/modulemd-yaml.h
f37170d
@@ -268,10 +268,13 @@ typedef gboolean (*ModulemdParsingFunc) (yaml_parser_t *parser,
f37170d
   while (0)
f37170d
 
f37170d
 ModulemdModule **
f37170d
 mmd_yaml_dup_modules (GPtrArray *objects);
f37170d
 
f37170d
+GPtrArray *
f37170d
+mmd_yaml_convert_modulestreams (GPtrArray *objects);
f37170d
+
f37170d
 gboolean
f37170d
 parse_yaml_file (const gchar *path,
f37170d
                  GPtrArray **data,
f37170d
                  GPtrArray **failures,
f37170d
                  GError **error);
f37170d
diff --git a/modulemd/v1/modulemd-common.c b/modulemd/v1/modulemd-common.c
f37170d
index f4339fbf7666c29a27c53e3a31defb020bf14b7f..a4936856fc38b0646267035e9ae9a8f42d5092b3 100644
f37170d
--- a/modulemd/v1/modulemd-common.c
f37170d
+++ b/modulemd/v1/modulemd-common.c
f37170d
@@ -25,39 +25,10 @@ modulemd_objects_from_file (const gchar *yaml_file, GError **error)
f37170d
 {
f37170d
   return modulemd_objects_from_file_ext (yaml_file, NULL, error);
f37170d
 }
f37170d
 
f37170d
 
f37170d
-static GPtrArray *
f37170d
-convert_modulestream_to_module (GPtrArray *objects)
f37170d
-{
f37170d
-  GPtrArray *compat_data = NULL;
f37170d
-  GObject *object = NULL;
f37170d
-  gsize i;
f37170d
-
f37170d
-
f37170d
-  compat_data = g_ptr_array_new_full (objects->len, g_object_unref);
f37170d
-
f37170d
-  for (i = 0; i < objects->len; i++)
f37170d
-    {
f37170d
-      object = g_ptr_array_index (objects, i);
f37170d
-      if (MODULEMD_IS_MODULESTREAM (object))
f37170d
-        {
f37170d
-          g_ptr_array_add (objects,
f37170d
-                           modulemd_module_new_from_modulestream (
f37170d
-                             MODULEMD_MODULESTREAM (object)));
f37170d
-        }
f37170d
-      else
f37170d
-        {
f37170d
-          g_ptr_array_add (compat_data, g_object_ref (object));
f37170d
-        }
f37170d
-    }
f37170d
-
f37170d
-  return compat_data;
f37170d
-}
f37170d
-
f37170d
-
f37170d
 GPtrArray *
f37170d
 modulemd_objects_from_file_ext (const gchar *yaml_file,
f37170d
                                 GPtrArray **failures,
f37170d
                                 GError **error)
f37170d
 {
f37170d
@@ -71,11 +42,11 @@ modulemd_objects_from_file_ext (const gchar *yaml_file,
f37170d
     }
f37170d
 
f37170d
   /* For backwards-compatibility, we need to return Modulemd.Module objects,
f37170d
    * not Modulemd.ModuleStream objects
f37170d
    */
f37170d
-  compat_data = convert_modulestream_to_module (data);
f37170d
+  compat_data = mmd_yaml_convert_modulestreams (data);
f37170d
 
f37170d
   return compat_data;
f37170d
 }
f37170d
 
f37170d
 
f37170d
@@ -112,11 +83,11 @@ modulemd_objects_from_stream_ext (FILE *stream,
f37170d
     }
f37170d
 
f37170d
   /* For backwards-compatibility, we need to return Modulemd.Module objects,
f37170d
    * not Modulemd.ModuleStream objects
f37170d
    */
f37170d
-  compat_data = convert_modulestream_to_module (data);
f37170d
+  compat_data = mmd_yaml_convert_modulestreams (data);
f37170d
 
f37170d
   return compat_data;
f37170d
 }
f37170d
 
f37170d
 
f37170d
@@ -153,11 +124,11 @@ modulemd_objects_from_string_ext (const gchar *yaml_string,
f37170d
     }
f37170d
 
f37170d
   /* For backwards-compatibility, we need to return Modulemd.Module objects,
f37170d
    * not Modulemd.ModuleStream objects
f37170d
    */
f37170d
-  compat_data = convert_modulestream_to_module (data);
f37170d
+  compat_data = mmd_yaml_convert_modulestreams (data);
f37170d
 
f37170d
   return compat_data;
f37170d
 }
f37170d
 
f37170d
 
f37170d
diff --git a/modulemd/v1/modulemd-module.c b/modulemd/v1/modulemd-module.c
f37170d
index 4da81fa4770a152c901ea14e8a5166b1a86da8bb..db6196c4b6476b03f62a44bc6b67fd4f223a9ecf 100644
f37170d
--- a/modulemd/v1/modulemd-module.c
f37170d
+++ b/modulemd/v1/modulemd-module.c
f37170d
@@ -3008,17 +3008,24 @@ modulemd_module_new_all_from_file (const gchar *yaml_file,
f37170d
 void
f37170d
 modulemd_module_new_all_from_file_ext (const gchar *yaml_file,
f37170d
                                        GPtrArray **data)
f37170d
 {
f37170d
   GError *error = NULL;
f37170d
+  g_autoptr (GPtrArray) to_convert = NULL;
f37170d
 
f37170d
-  if (!parse_yaml_file (yaml_file, data, NULL, &error))
f37170d
+  if (!parse_yaml_file (yaml_file, &to_convert, NULL, &error))
f37170d
     {
f37170d
       g_debug ("Error parsing YAML: %s", error->message);
f37170d
       g_error_free (error);
f37170d
       return;
f37170d
     }
f37170d
+
f37170d
+  /* For backwards-compatibility, we need to return Modulemd.Module objects,
f37170d
+   * not Modulemd.ModuleStream objects
f37170d
+   */
f37170d
+  if (data)
f37170d
+    *data = mmd_yaml_convert_modulestreams (to_convert);
f37170d
 }
f37170d
 
f37170d
 
f37170d
 /**
f37170d
  * modulemd_module_new_from_string:
f37170d
@@ -3127,17 +3134,24 @@ modulemd_module_new_all_from_string (const gchar *yaml_string,
f37170d
 void
f37170d
 modulemd_module_new_all_from_string_ext (const gchar *yaml_string,
f37170d
                                          GPtrArray **data)
f37170d
 {
f37170d
   GError *error = NULL;
f37170d
+  g_autoptr (GPtrArray) to_convert = NULL;
f37170d
 
f37170d
-  if (!parse_yaml_string (yaml_string, data, NULL, &error))
f37170d
+  if (!parse_yaml_string (yaml_string, &to_convert, NULL, &error))
f37170d
     {
f37170d
       g_debug ("Error parsing YAML: %s", error->message);
f37170d
       g_error_free (error);
f37170d
       return;
f37170d
     }
f37170d
+
f37170d
+  /* For backwards-compatibility, we need to return Modulemd.Module objects,
f37170d
+   * not Modulemd.ModuleStream objects
f37170d
+   */
f37170d
+  if (data)
f37170d
+    *data = mmd_yaml_convert_modulestreams (to_convert);
f37170d
 }
f37170d
 
f37170d
 
f37170d
 /**
f37170d
  * modulemd_module_new_from_stream:
f37170d
diff --git a/modulemd/v1/modulemd-yaml-utils.c b/modulemd/v1/modulemd-yaml-utils.c
f37170d
index 8e3e8d6bd923bf1753cfe9191db8f6a300c39032..453de0a92b8b50f13384acc4e73fae2f412f7776 100644
f37170d
--- a/modulemd/v1/modulemd-yaml-utils.c
f37170d
+++ b/modulemd/v1/modulemd-yaml-utils.c
f37170d
@@ -373,10 +373,37 @@ mmd_yaml_dup_modules (GPtrArray *objects)
f37170d
     }
f37170d
 
f37170d
   return modules;
f37170d
 }
f37170d
 
f37170d
+GPtrArray *
f37170d
+mmd_yaml_convert_modulestreams (GPtrArray *objects)
f37170d
+{
f37170d
+  GPtrArray *compat_data = NULL;
f37170d
+  GObject *object = NULL;
f37170d
+  gsize i;
f37170d
+
f37170d
+  compat_data = g_ptr_array_new_full (objects->len, g_object_unref);
f37170d
+
f37170d
+  for (i = 0; i < objects->len; i++)
f37170d
+    {
f37170d
+      object = g_ptr_array_index (objects, i);
f37170d
+      if (MODULEMD_IS_MODULESTREAM (object))
f37170d
+        {
f37170d
+          g_ptr_array_add (objects,
f37170d
+                           modulemd_module_new_from_modulestream (
f37170d
+                             MODULEMD_MODULESTREAM (object)));
f37170d
+        }
f37170d
+      else
f37170d
+        {
f37170d
+          g_ptr_array_add (compat_data, g_object_ref (object));
f37170d
+        }
f37170d
+    }
f37170d
+
f37170d
+  return compat_data;
f37170d
+}
f37170d
+
f37170d
 const gchar *
f37170d
 mmd_yaml_get_event_name (yaml_event_type_t type)
f37170d
 {
f37170d
   switch (type)
f37170d
     {
f37170d
-- 
f37170d
2.17.1
f37170d