(file) Return to instance.c CVS log (file) (dir) Up to [OMI] / omi / base

Diff for /omi/base/instance.c between version 1.1 and 1.2

version 1.1, 2012/05/30 22:47:49 version 1.2, 2012/06/25 19:51:01
Line 118 
Line 118 
     return (MI_Uint32)-1;     return (MI_Uint32)-1;
 } }
  
   static MI_PropertyDecl* _LookupPropertyDecl(
       const MI_ClassDecl* cd,
       const MI_Char* name)
   {
       MI_Uint32 index = _FindPropertyDecl(cd, name);
   
       if (index == (MI_Uint32)-1)
           return NULL;
   
       return cd->properties[index];
   }
   
 static MI_PropertyDecl* _ClonePropertyDecl( static MI_PropertyDecl* _ClonePropertyDecl(
     const MI_PropertyDecl* pd,     const MI_PropertyDecl* pd,
     Batch* batch)     Batch* batch)
Line 460 
Line 472 
     else if (cd1->flags & MI_FLAG_CLASS)     else if (cd1->flags & MI_FLAG_CLASS)
         sd1 = cd1->schema;         sd1 = cd1->schema;
     else     else
       {
         return MI_RESULT_FAILED;         return MI_RESULT_FAILED;
       }
  
     /* Check parameters */     /* Check parameters */
     if (!self_ || !cd1 || !inst || !batch)     if (!self_ || !cd1 || !inst || !batch)
Line 471 
Line 485 
     {     {
         batch = Batch_New(_NUM_PAGES);         batch = Batch_New(_NUM_PAGES);
         if (!batch)         if (!batch)
           {
             return MI_RESULT_FAILED;             return MI_RESULT_FAILED;
     }     }
       }
  
     cd2 = inst->classDecl;     cd2 = inst->classDecl;
  
     /* Initialize the instance */     /* Initialize the instance */
     r = Instance_Construct(self_, cd1, batch);     r = Instance_Construct(self_, cd1, batch);
     if (r != MI_RESULT_OK)     if (r != MI_RESULT_OK)
       {
         goto failed;         goto failed;
       }
  
     /* Get the self pointer from the newly initialized instance */     /* Get the self pointer from the newly initialized instance */
     self = _SelfOf(self_);     self = _SelfOf(self_);
Line 589 
Line 607 
             {             {
                 MI_Instance* tmpInst;                 MI_Instance* tmpInst;
                 MI_ClassDecl* tmpCd;                 MI_ClassDecl* tmpCd;
                 MI_Value v;                  MI_Type type;
  
                 /* Find the class declaration in the schema */                 /* Find the class declaration in the schema */
                 tmpCd = SchemaDecl_FindClassDecl(sd1,                 tmpCd = SchemaDecl_FindClassDecl(sd1,
Line 613 
Line 631 
                     ((MI_Value*)field)->instance, keysOnly, MI_FALSE, copy,                     ((MI_Value*)field)->instance, keysOnly, MI_FALSE, copy,
                     ((Instance*)tmpInst)->batch);                     ((Instance*)tmpInst)->batch);
  
   
                 if (r != MI_RESULT_OK)                 if (r != MI_RESULT_OK)
                 {                 {
   
                     __MI_Instance_Delete(tmpInst);                     __MI_Instance_Delete(tmpInst);
                     r = MI_RESULT_TYPE_MISMATCH;                     r = MI_RESULT_TYPE_MISMATCH;
                     goto failed;                     goto failed;
                 }                 }
  
                   /* Get the target property type */
                   {
                       MI_PropertyDecl* pd = _LookupPropertyDecl(cd1, pd2->name);
   
                       if (!pd)
                       {
                           r = MI_RESULT_NO_SUCH_PROPERTY;
                           goto failed;
                       }
   
                       type = pd->type;
                   }
   
                   /* Reject if not instance or reference */
   
                   switch (type)
                   {
                       case MI_INSTANCE:
                       case MI_REFERENCE:
                       {
                           MI_Value v;
                 v.instance = tmpInst;                 v.instance = tmpInst;
  
                 /* Set the instance value (use the ADOPT policy) */  
                 r = __MI_Instance_SetElement(                 r = __MI_Instance_SetElement(
                     self_,                     self_,
                     pd2->name,                     pd2->name,
                     &v,                     &v,
                     pd2->type,                              type,
                     MI_FLAG_ADOPT);                     MI_FLAG_ADOPT);
  
                 if (r == MI_RESULT_TYPE_MISMATCH)                          break;
                       }
                       case MI_INSTANCEA:
                       case MI_REFERENCEA:
                 {                 {
                     /* Try to process instance as array with one element */                          MI_Value v;
                     v.instancea.size = 1;                     v.instancea.size = 1;
                     v.instancea.data = BAlloc(batch,                          v.instancea.data =
                         1 * sizeof(void*), CALLSITE);                              BAlloc(batch, sizeof(void*), CALLSITE);
  
                     if (!v.instancea.data)                     if (!v.instancea.data)
                     {                     {
Line 648 
Line 687 
  
                     v.instancea.data[0] = tmpInst;                     v.instancea.data[0] = tmpInst;
  
                     r = __MI_Instance_SetElement(self_, pd2->name, &v, pd2->type | MI_ARRAY_BIT,                          r = __MI_Instance_SetElement(
                               self_,
                               pd2->name,
                               &v,
                               type,
                         MI_FLAG_ADOPT);                         MI_FLAG_ADOPT);
  
                           break;
                       }
                       default:
                       {
                           r = MI_RESULT_TYPE_MISMATCH;
                           break;
                       }
                 }                 }
  
                 if (r != MI_RESULT_OK)                 if (r != MI_RESULT_OK)


Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

ViewCVS 0.9.2