[konkretcmpi] Add support for embedded instances
Radek Novacek
rnovacek at fedoraproject.org
Thu Jun 27 12:47:04 UTC 2013
commit 2f629ecc3871ba5849518fc121c2c4325496ca8b
Author: Radek Novacek <rnovacek at redhat.com>
Date: Thu Jun 27 14:46:49 2013 +0200
Add support for embedded instances
konkretcmpi-0.9.0-embeddedinstance-support.patch | 181 ++++++++++++++++++++++
konkretcmpi.spec | 8 +-
2 files changed, 188 insertions(+), 1 deletions(-)
---
diff --git a/konkretcmpi-0.9.0-embeddedinstance-support.patch b/konkretcmpi-0.9.0-embeddedinstance-support.patch
new file mode 100644
index 0000000..68ba52d
--- /dev/null
+++ b/konkretcmpi-0.9.0-embeddedinstance-support.patch
@@ -0,0 +1,181 @@
+diff --git a/src/konkret/konkret.h b/src/konkret/konkret.h
+index aed2782..a9bb57d 100644
+--- a/src/konkret/konkret.h
++++ b/src/konkret/konkret.h
+@@ -27,6 +27,10 @@
+ #ifndef _konkret_h
+ #define _konkret_h
+
++#ifndef _GNU_SOURCE
++#define _GNU_SOURCE
++#endif
++
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+@@ -2234,7 +2238,7 @@ KINLINE CMPIBoolean KInstanceA_Init(
+ {
+ const unsigned char* sig = self ? self->__sig : NULL;
+
+- if (!KArray_Init((KArray*)self, cb, max, CMPI_ref))
++ if (!KArray_Init((KArray*)self, cb, max, CMPI_instance))
+ {
+ if (self)
+ self->__sig = sig;
+@@ -2260,11 +2264,11 @@ KINLINE void KInstanceA_InitNull(KInstanceA* self)
+ KINLINE CMPIBoolean KInstanceA_Set(
+ KInstanceA* self,
+ CMPICount i,
+- CMPIObjectPath* x)
++ CMPIInstance* x)
+ {
+ const unsigned char* sig = self ? self->__sig : NULL;
+
+- if (!KArray_Set((KArray*)self, i, &x, CMPI_ref))
++ if (!KArray_Set((KArray*)self, i, &x, CMPI_instance))
+ {
+ if (self)
+ self->__sig = sig;
+@@ -2281,7 +2285,7 @@ KINLINE CMPIBoolean KInstanceA_Null(KInstanceA* self, CMPICount i)
+ {
+ const unsigned char* sig = self ? self->__sig : NULL;
+
+- if (!KArray_Null((KArray*)self, i, CMPI_ref))
++ if (!KArray_Null((KArray*)self, i, CMPI_instance))
+ {
+ if (self)
+ self->__sig = sig;
+@@ -2299,7 +2303,7 @@ KINLINE KInstance KInstanceA_Get(KInstanceA* self, CMPICount i)
+ const unsigned char* sig = self ? self->__sig : NULL;
+ KInstance result;
+
+- KArray_Get((KArray*)self, i, CMPI_ref, (KValue*)&result);
++ KArray_Get((KArray*)self, i, CMPI_instance, (KValue*)&result);
+
+ if (self)
+ self->__sig = sig;
+diff --git a/src/mof/MOF_Class_Decl.cpp b/src/mof/MOF_Class_Decl.cpp
+index 981aa60..3d265de 100644
+--- a/src/mof/MOF_Class_Decl.cpp
++++ b/src/mof/MOF_Class_Decl.cpp
+@@ -644,6 +644,9 @@ void MOF_Class_Decl::validate()
+ MOF_warning_printf("EmbeddedInstance qualifier allowed "
+ "only on string properties: %s.%s", name, prop->name);
+ }
++ // EmbeddedInstance has type string, but we want to work
++ // with it as Instance
++ prop->data_type = TOK_INSTANCE;
+ }
+ else if (p->type == MOF_FEATURE_METHOD)
+ {
+@@ -654,6 +657,9 @@ void MOF_Class_Decl::validate()
+ MOF_warning_printf("EmbeddedInstance qualifier allowed "
+ "only on string properties: %s.%s", name, meth->name);
+ }
++ // EmbeddedInstance has type string, but we want to work
++ // with it as Instance
++ meth->data_type = TOK_INSTANCE;
+ }
+ }
+ }
+diff --git a/src/program/main.cpp b/src/program/main.cpp
+index d07e395..5a910c1 100644
+--- a/src/program/main.cpp
++++ b/src/program/main.cpp
+@@ -299,6 +299,8 @@ static const char* _ctype_name(int data_type)
+ return "CMPIString*";
+ case TOK_DATETIME:
+ return "CMPIDateTime*";
++ case TOK_INSTANCE:
++ return "CMPIInstance*";
+ }
+
+ // Unreachable
+@@ -340,6 +342,8 @@ static const char* _ktype_name(int data_type)
+ return "KDateTime";
+ case TOK_REF:
+ return "KRef";
++ case TOK_INSTANCE:
++ return "KInstance";
+ }
+
+ // Unreachable
+@@ -403,6 +407,9 @@ static KTag _ktag(
+ case TOK_REF:
+ tag = KTYPE_REFERENCE;
+ break;
++ case TOK_INSTANCE:
++ tag = KTYPE_INSTANCE;
++ break;
+ }
+
+ if (array)
+@@ -472,10 +479,19 @@ static void gen_feature_decls(
+ if (ref && !key)
+ continue;
+
+- if (pd->array_index == 0)
+- put(os, " const $0 $1;\n", ktn, pn, NULL);
++ if (pd->qualifiers->has_key("EmbeddedInstance")) {
++ if (pd->array_index)
++ put(os, " const KInstanceA $0;\n", pn, NULL);
++ else
++ put(os, " const KInstance $0;\n", pn, NULL);
++ }
+ else
+- put(os, " const $0A $1;\n", ktn, pn, NULL);
++ {
++ if (pd->array_index == 0)
++ put(os, " const $0 $1;\n", ktn, pn, NULL);
++ else
++ put(os, " const $0A $1;\n", ktn, pn, NULL);
++ }
+
+ // Add sig entry [type][length][name][zero-terminator]
+
+@@ -612,10 +628,19 @@ static void gen_param(FILE* os, MOF_Parameter* p, vector<unsigned char>& sig)
+ {
+ const char* ktn = _ktype_name(p->data_type);
+
+- if (p->array_index)
+- put(os, " $0A $1;\n", ktn, p->name, NULL);
++ if (p->qualifiers->has_key("EmbeddedInstance")) {
++ if (p->array_index)
++ put(os, " KInstanceA $0;\n", p->name, NULL);
++ else
++ put(os, " KInstance $0;\n", p->name, NULL);
++ }
+ else
+- put(os, " $0 $1;\n", ktn, p->name, NULL);
++ {
++ if (p->array_index)
++ put(os, " $0A $1;\n", ktn, p->name, NULL);
++ else
++ put(os, " $0 $1;\n", ktn, p->name, NULL);
++ }
+ }
+
+ pack_tag(sig, tag);
+@@ -854,11 +879,17 @@ static void gen_meth_header(
+ else
+ {
+ const char* ktn = _ktype_name(p->data_type);
+-
+- if (p->array_index)
+- put(os, " $0$1A* $2,\n", mod, ktn, p->name, NULL);
+- else
+- put(os, " $0$1* $2,\n", mod, ktn, p->name, NULL);
++ if (p->qualifiers->has_key("EmbeddedInstance")) {
++ if (p->array_index)
++ put(os, " $0KInstanceA* $1,\n", mod, p->name, NULL);
++ else
++ put(os, " $0KInstance* $1,\n", mod, p->name, NULL);
++ } else {
++ if (p->array_index)
++ put(os, " $0$1A* $2,\n", mod, ktn, p->name, NULL);
++ else
++ put(os, " $0$1* $2,\n", mod, ktn, p->name, NULL);
++ }
+ }
+ }
+
diff --git a/konkretcmpi.spec b/konkretcmpi.spec
index e6e41c1..127e55b 100644
--- a/konkretcmpi.spec
+++ b/konkretcmpi.spec
@@ -1,6 +1,6 @@
Name: konkretcmpi
Version: 0.9.0
-Release: 6%{?dist}
+Release: 7%{?dist}
Summary: Tool for rapid CMPI providers development
License: MIT
@@ -19,6 +19,8 @@ Patch1: konkretcmpi-0.9.0-fix-inputoutput-method-arguments.patch
Patch2: konkretcmpi-0.9.0-fix-indication-return-type.patch
# Support varlist in KReturn2
Patch3: konkretcmpi-0.9.0-support-varlist-in-kreturn2.patch
+# Add support for embedded instances
+Patch4: konkretcmpi-0.9.0-embeddedinstance-support.patch
%description
KonkretCMPI makes CMPI provider development easier by generating type-safe
@@ -47,6 +49,7 @@ This package contains python binding for konkretcmpi.
%patch1 -p1
%patch2 -p1
%patch3 -p1
+%patch4 -p1
%build
mkdir -p %{_target_platform}
@@ -86,6 +89,9 @@ rm -rf $RPM_BUILD_ROOT/usr/lib*/libkonkret.la
%changelog
+* Thu Jun 27 2013 Radek Novacek <rnovacek at redhat.com> 0.9.0-7
+- Add support for embedded instances
+
* Thu Jun 13 2013 Radek Novacek <rnovacek at redhat.com> 0.9.0-6
- Apply the patch for KReturn2
More information about the scm-commits
mailing list