File 0001-Honor-that-string-properties-with-EmbeddedInstance-q.patch of Package konkretcmpi

From 518201dcf90f1d95765f8764549780233463c327 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= <kkaempf@suse.de>
Date: Mon, 28 Apr 2014 14:05:39 +0200
Subject: [PATCH] Honor that string properties with EmbeddedInstance qualifier
 are handled as Instances, also for Override

This mapping of string->instance happens _after_ Override features are
checked for compatibility. If one does the mapping before, konkrete
fails with "EmbeddedInstance qualifier allowed only on string
properties".

This fixes https://github.com/rnovacek/konkretcmpi/issues/3
---
 src/mof/MOF_Class_Decl.cpp | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/src/mof/MOF_Class_Decl.cpp b/src/mof/MOF_Class_Decl.cpp
index 3d265de68b4e..09854517656e 100644
--- a/src/mof/MOF_Class_Decl.cpp
+++ b/src/mof/MOF_Class_Decl.cpp
@@ -171,7 +171,37 @@ static void _validate_feature_compatibility(
         MOF_Property_Decl* qq = (MOF_Property_Decl*)q;
 
         if (pp->data_type != qq->data_type)
-            MOF_error_printf(MESSAGE, p->name);
+        {
+            int embedded_instance = 0;
+
+            /* If this property is TOK_STRING and the parent is TOK_INSTANCE,
+             * then check if the EmbeddedInstance qualifier is set.
+             * In this case, data_type string will be mapped to instance later
+             * so allow it here.
+             */
+            if ((pp->data_type == TOK_STRING)
+                && (qq->data_type == TOK_INSTANCE))
+            {
+                for (MOF_Qualifier* qualifier = p->qualifiers; 
+                     qualifier;
+                     qualifier = (MOF_Qualifier*)qualifier->next)
+                {
+                    if (strcasecmp(qualifier->name, "EmbeddedInstance") == 0)
+                    {
+                        /* this string property defines actually an embedded_instance
+                         * so data_type string will actually match to instance
+                         */
+                        embedded_instance = 1;
+                        break;
+                    }
+                }
+            }
+            if (pp->data_type != qq->data_type
+                && embedded_instance == 0)
+            {
+                MOF_error_printf(MESSAGE, p->name);
+            }
+        }
 
         if (pp->array_index != qq->array_index)
             MOF_error_printf(MESSAGE, p->name);
-- 
1.8.4.5

openSUSE Build Service is sponsored by