version 1.2, 2015/04/20 18:10:13
|
version 1.3, 2015/04/20 18:19:53
|
|
|
#include "dinstance.h" | #include "dinstance.h" |
#include <cctype> | #include <cctype> |
#include <base/instance.h> | #include <base/instance.h> |
#include <base/strings.h> |
#include <pal/strings.h> |
#include <base/naming.h> | #include <base/naming.h> |
#include <base/schemadecl.h> | #include <base/schemadecl.h> |
#include <base/helpers.h> | #include <base/helpers.h> |
|
#include <pal/format.h> |
| |
// ATTN: work on object size reduction of this module. | // ATTN: work on object size reduction of this module. |
| |
|
|
| |
while (p != end) | while (p != end) |
{ | { |
if ((*p)->code == code && Zcasecmp((*p)->name, name) == 0) |
if ((*p)->code == code && Tcscasecmp((*p)->name, name) == 0) |
return (MI_Uint32)(p - start); | return (MI_Uint32)(p - start); |
p++; | p++; |
} | } |
|
|
if (h->u.refs != 1) | if (h->u.refs != 1) |
{ | { |
MI_Instance* self = m_self; | MI_Instance* self = m_self; |
|
|
|
// |
|
// Suppressing a false-positive for 28931 - Unused assignment of variable 'r' |
|
// |
|
#ifdef _MSC_VER |
|
#pragma prefast(push) |
|
#pragma prefast (disable: 28931) |
|
#endif |
|
|
MI_Result r = MI_Instance_Clone(self, &m_self); | MI_Result r = MI_Instance_Clone(self, &m_self); |
DEBUG_ASSERT(r == MI_RESULT_OK); | DEBUG_ASSERT(r == MI_RESULT_OK); |
__MI_Instance_Unref(self); | __MI_Instance_Unref(self); |
MI_UNUSED(r); | MI_UNUSED(r); |
|
|
|
#ifdef _MSC_VER |
|
#pragma prefast(pop) |
|
#endif |
} | } |
} | } |
| |
|
|
| |
String DInstance::GetNamespace() const | String DInstance::GetNamespace() const |
{ | { |
const MI_Char* nameSpace; |
const MI_Char* nameSpace = NULL; |
|
|
|
// |
|
// Suppressing a false-positive for 28931 - Unused assignment of variable 'r' |
|
// |
|
#ifdef _MSC_VER |
|
#pragma prefast(push) |
|
#pragma prefast (disable: 28931) |
|
#endif |
|
|
MI_Result r = MI_Instance_GetNameSpace(m_self, &nameSpace); | MI_Result r = MI_Instance_GetNameSpace(m_self, &nameSpace); |
DEBUG_ASSERT(r == MI_RESULT_OK); | DEBUG_ASSERT(r == MI_RESULT_OK); |
MI_UNUSED(r); | MI_UNUSED(r); |
| |
|
#ifdef _MSC_VER |
|
#pragma prefast(pop) |
|
#endif |
|
|
return String(nameSpace); | return String(nameSpace); |
} | } |
| |
|
|
| |
for (i = 0; i < count; i++) | for (i = 0; i < count; i++) |
{ | { |
const MI_Char* tmpName; |
const MI_Char* tmpName = NULL; |
MI_Result r; | MI_Result r; |
r = MI_Instance_GetElementAt(m_self, i, &tmpName, NULL, NULL, NULL); | r = MI_Instance_GetElementAt(m_self, i, &tmpName, NULL, NULL, NULL); |
| |
|
|
bool DInstance::GetName(Uint32 index, String& name) const | bool DInstance::GetName(Uint32 index, String& name) const |
{ | { |
MI_Result r; | MI_Result r; |
const MI_Char* tmpName; |
const MI_Char* tmpName = NULL; |
r = MI_Instance_GetElementAt(m_self, index, &tmpName, NULL, NULL, NULL); | r = MI_Instance_GetElementAt(m_self, index, &tmpName, NULL, NULL, NULL); |
if (r != MI_RESULT_OK) | if (r != MI_RESULT_OK) |
return false; | return false; |
|
|
bool showNulls) const | bool showNulls) const |
{ | { |
MI_Result r = Instance_Print(m_self, os, level, | MI_Result r = Instance_Print(m_self, os, level, |
showNulls ? MI_TRUE : MI_FALSE); |
showNulls ? MI_TRUE : MI_FALSE, MI_FALSE); |
DEBUG_ASSERT(r == MI_RESULT_OK); | DEBUG_ASSERT(r == MI_RESULT_OK); |
MI_UNUSED(r); | MI_UNUSED(r); |
} | } |
|
|
| |
DInstance::DInstance(MI_Instance* self, DInstance::CloneTag) | DInstance::DInstance(MI_Instance* self, DInstance::CloneTag) |
{ | { |
|
// |
|
// Suppressing a false-positive for 28931 - Unused assignment of variable 'r' |
|
// |
|
#ifdef _MSC_VER |
|
#pragma prefast(push) |
|
#pragma prefast (disable: 28931) |
|
#endif |
|
|
MI_Result r = MI_Instance_Clone(self, &m_self); | MI_Result r = MI_Instance_Clone(self, &m_self); |
DEBUG_ASSERT(r == MI_RESULT_OK); | DEBUG_ASSERT(r == MI_RESULT_OK); |
MI_UNUSED(r); | MI_UNUSED(r); |
|
|
|
#ifdef _MSC_VER |
|
#pragma prefast(pop) |
|
#endif |
} | } |
| |
bool DInstance::AddValue( | bool DInstance::AddValue( |
|
|
{ | { |
if (!sinst.m_instance) | if (!sinst.m_instance) |
{ | { |
TRACE; |
|
return false; | return false; |
} | } |
| |
|
|
| |
if (!cd) | if (!cd) |
{ | { |
TRACE; |
|
return false; | return false; |
} | } |
| |
|
|
| |
if (MI_Instance_GetElementCount(dinst.m_self, &count) != MI_RESULT_OK) | if (MI_Instance_GetElementCount(dinst.m_self, &count) != MI_RESULT_OK) |
{ | { |
TRACE; |
|
return false; | return false; |
} | } |
| |
// For each property in the dynamic instance. | // For each property in the dynamic instance. |
for (Uint32 i = 0; i < count; i++) | for (Uint32 i = 0; i < count; i++) |
{ | { |
const MI_Char* name; |
const MI_Char* name = NULL; |
MI_Value value; | MI_Value value; |
MI_Type type; | MI_Type type; |
MI_Uint32 flags; | MI_Uint32 flags; |
|
|
if (MI_Instance_GetElementAt( | if (MI_Instance_GetElementAt( |
dinst.m_self, i, &name, &value, &type, &flags) != MI_RESULT_OK) | dinst.m_self, i, &name, &value, &type, &flags) != MI_RESULT_OK) |
{ | { |
TRACE; |
|
return false; | return false; |
} | } |
| |
|
|
if (ignoreUnknownProperties) | if (ignoreUnknownProperties) |
continue; | continue; |
| |
TRACE; |
|
return false; | return false; |
} | } |
| |
|
|
{ | { |
if (!value.instance) | if (!value.instance) |
{ | { |
TRACE; |
|
return false; | return false; |
} | } |
| |
|
|
| |
if (!tcd) | if (!tcd) |
{ | { |
TRACE; |
|
return false; | return false; |
} | } |
| |
|
|
if (!DynamicToStatic(tdinst, keysOnly, | if (!DynamicToStatic(tdinst, keysOnly, |
ignoreUnknownProperties, x)) | ignoreUnknownProperties, x)) |
{ | { |
TRACE; |
|
return false; | return false; |
} | } |
| |
|
|
{ | { |
if (!value.instancea.data) | if (!value.instancea.data) |
{ | { |
TRACE; |
|
return false; | return false; |
} | } |
| |
|
|
| |
if (!tcd) | if (!tcd) |
{ | { |
TRACE; |
|
return false; | return false; |
} | } |
| |
|
|
{ | { |
if (!value.instancea.data[j]) | if (!value.instancea.data[j]) |
{ | { |
TRACE; |
|
return false; | return false; |
} | } |
| |
|
|
if (!DynamicToStatic(tdinst, keysOnly, | if (!DynamicToStatic(tdinst, keysOnly, |
ignoreUnknownProperties, x)) | ignoreUnknownProperties, x)) |
{ | { |
TRACE; |
|
return false; | return false; |
} | } |
| |
|
|
// Reject if static instance has no internal instance. | // Reject if static instance has no internal instance. |
if (!sinst.m_instance) | if (!sinst.m_instance) |
{ | { |
TRACE; |
|
return false; | return false; |
} | } |
| |
|
|
const MI_ClassDecl* cd = sinst.m_instance->classDecl; | const MI_ClassDecl* cd = sinst.m_instance->classDecl; |
if (!cd) | if (!cd) |
{ | { |
TRACE; |
|
return false; | return false; |
} | } |
| |