(file) Return to cimmofSourceConsumer.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Compiler / Attic

Diff for /pegasus/src/Pegasus/Compiler/Attic/cimmofSourceConsumer.cpp between version 1.1.2.3 and 1.1.2.4

version 1.1.2.3, 2007/09/29 00:09:28 version 1.1.2.4, 2007/09/29 08:02:07
Line 208 
Line 208 
 // //
 //============================================================================== //==============================================================================
  
 cimmofSourceConsumer::cimmofSourceConsumer() : _os(0)  cimmofSourceConsumer::cimmofSourceConsumer(bool discard) :
       _discard(discard), _os(0)
 { {
 } }
  
Line 233 
Line 234 
     const CIMNamespaceName& nameSpace,     const CIMNamespaceName& nameSpace,
     CIMQualifierDecl& cimQualifierDecl)     CIMQualifierDecl& cimQualifierDecl)
 { {
     if (_findQualifier(nameSpace, cimQualifierDecl.getName()) != PEG_NOT_FOUND)      if (_findQualifier(cimQualifierDecl.getName()) != PEG_NOT_FOUND)
     {     {
         _throw(CIM_ERR_ALREADY_EXISTS, "qualifier already defined: %s:%s",         _throw(CIM_ERR_ALREADY_EXISTS, "qualifier already defined: %s:%s",
             *Str(nameSpace), *Str(cimQualifierDecl.getName()));             *Str(nameSpace), *Str(cimQualifierDecl.getName()));
Line 253 
Line 254 
     const CIMNamespaceName& nameSpace,     const CIMNamespaceName& nameSpace,
     const CIMName& qualifierName)     const CIMName& qualifierName)
 { {
     Uint32 pos = _findQualifier(nameSpace, qualifierName);      Uint32 pos = _findQualifier(qualifierName);
  
     if (pos == PEG_NOT_FOUND)     if (pos == PEG_NOT_FOUND)
     {     {
Line 370 
Line 371 
     return PEG_NOT_FOUND;     return PEG_NOT_FOUND;
 } }
  
 Uint32 cimmofSourceConsumer::_findQualifier(  Uint32 cimmofSourceConsumer::_findQualifier(const CIMName& qualifierName) const
     const CIMNamespaceName& nameSpace,  
     const CIMName& qualifierName) const  
 { {
     for (Uint32 i = 0; i < _qualifiers.size(); i++)     for (Uint32 i = 0; i < _qualifiers.size(); i++)
     {     {
Line 665 
Line 664 
     fputc('"', os);     fputc('"', os);
 } }
  
 template<class C>  static void _writeStringLiteralArray(FILE* os, const Array<String>& x)
 static void _writeDescription(  
     FILE* os,  
     const C& c)  
 { {
 #if defined(PEGASUS_INCLUDE_DESCRIPTIONS) || 1      fputc('"', os);
     Uint32 pos = c.findQualifier("Description");  
  
     if (pos != PEG_NOT_FOUND)      for (Uint32 i = 0; i < x.size(); i++)
     {     {
         CIMConstQualifier cq = c.getQualifier(pos);          Str str(x[i]);
         const CIMValue& cv = cq.getValue();          const char* s = str;
           size_t n = strlen(s);
  
         if (cv.getType() == CIMTYPE_STRING)          for (size_t j = 0; j < n; j++)
         {         {
             String x;              char c = s[j];
             cv.get(x);  
               if (isprint(c) && c != '"')
                   fprintf(os, "%c", c);
               else
                   fprintf(os, "\\%03o", c);
           }
  
             fprintf(os, "    ");          fprintf(os, "\\000");
             _writeStringLiteral(os, *Str(x));      }
             fprintf(os, ",\n");  
       fprintf(os, "\\000");
   
       fputc('"', os);
   }
   
   void cimmofSourceConsumer::_writeQualifier(
       const Array<CIMQualifierDecl>& qualifierDecls,
       const String& root,
       const CIMConstQualifier& cq)
   {
       CIMName qn = cq.getName();
       CIMType qt = cq.getType();
       CIMValue qv = cq.getValue();
   
       // Ignore descriptions?
   
       if (_discard && qn == "Description")
             return;             return;
   
   #if 0
       if (qn == "Values" || qn == "ValueMap")
           return;
   #endif
   
       // Ignore boolean qualifiers:
   
       if (qt == CIMTYPE_BOOLEAN && !cq.isArray())
           return;
   
       // Print qualifier value structure if any:
   
       String path = root + "_" + qn.getString() + "_qualifier";
       Uint32 size = 0;
   
       if (qt != CIMTYPE_STRING)
           _writeValue(path, qv, size);
   
       // Find the qualifier:
   
       Uint32 pos = _findQualifier(qn);
   
       if (pos == PEG_NOT_FOUND)
           _throw(CIM_ERR_FAILED, "undefined qualifier: %s", *Str(qn));
   
       // Get the original case of the qualifier name:
   
       qn = _qualifiers[pos].getName();
   
       // SourceQualifier header:
   
       _outn("static SourceQualifier");
       _outn("%s =", *Str(path));
       _outn("{");
   
       // SourceQualifier.decl:
   
       _outn("    &_%s_qualifier_decl,", *Str(qn));
   
       // SourceQualifier.value:
   
       if (qt == CIMTYPE_STRING)
       {
           if (qv.isArray())
           {
               Array<String> x;
               qv.get(x);
               size = x.size();
               _out("    ");
               _writeStringLiteralArray(_os, x);
               _outn(",");
           }
           else
           {
               String x;
               qv.get(x);
               _out("    ");
               _writeStringLiteral(_os, *Str(x));
               _outn(",");
           }
         }         }
       else
       {
           _outn("    &%s_value,", *Str(path));
     }     }
  
 #endif /* defined(PEGASUS_INCLUDE_DESCRIPTIONS) */      // SourceQualifier.size:
   
       _outn("    %u, /* size */", size);
  
     fprintf(os, "    0, /* description */\n");      _outn("};");
       _nl();
 } }
  
 void cimmofSourceConsumer::_writeValue( void cimmofSourceConsumer::_writeValue(
     const String& name,      const String& root,
     const CIMValue& cv,     const CIMValue& cv,
     Uint32& size)     Uint32& size)
 { {
       String path = root + "_value";
   
     size = 0;     size = 0;
  
     if (cv.isNull())     if (cv.isNull())
Line 728 
Line 815 
  
     if (cv.isArray())     if (cv.isArray())
     {     {
         _outn("static %s %s[] =", _typeStrings[cv.getType()], *Str(name));          _outn("static %s %s[] =", _typeStrings[cv.getType()], *Str(path));
         _outn("{");         _outn("{");
         _indent++;         _indent++;
  
Line 912 
Line 999 
             {             {
                 bool x;                 bool x;
                 cv.get(x);                 cv.get(x);
                 _outn("static bool %s = %s;", *Str(name), x ? "true" : "false");                  _outn("static bool %s = %s;", *Str(path), x ? "true" : "false");
                 break;                 break;
             }             }
  
Line 920 
Line 1007 
             {             {
                 Uint8 x;                 Uint8 x;
                 cv.get(x);                 cv.get(x);
                 _outn("static Uint8 %s = %u;", *Str(name), x);                  _outn("static Uint8 %s = %u;", *Str(path), x);
                 break;                 break;
             }             }
  
Line 928 
Line 1015 
             {             {
                 Sint8 x;                 Sint8 x;
                 cv.get(x);                 cv.get(x);
                 _outn("static Sint8 %s = %d;", *Str(name), x);                  _outn("static Sint8 %s = %d;", *Str(path), x);
                 break;                 break;
             }             }
  
Line 936 
Line 1023 
             {             {
                 Uint16 x;                 Uint16 x;
                 cv.get(x);                 cv.get(x);
                 _outn("static Uint16 %s = %u;", *Str(name), x);                  _outn("static Uint16 %s = %u;", *Str(path), x);
                 break;                 break;
             }             }
  
Line 944 
Line 1031 
             {             {
                 Sint16 x;                 Sint16 x;
                 cv.get(x);                 cv.get(x);
                 _outn("static Sint16 %s = %d;", *Str(name), x);                  _outn("static Sint16 %s = %d;", *Str(path), x);
                 break;                 break;
             }             }
  
Line 952 
Line 1039 
             {             {
                 Uint32 x;                 Uint32 x;
                 cv.get(x);                 cv.get(x);
                 _outn("static Uint32 %s = %u;", *Str(name), x);                  _outn("static Uint32 %s = %u;", *Str(path), x);
                 break;                 break;
             }             }
  
Line 960 
Line 1047 
             {             {
                 Sint32 x;                 Sint32 x;
                 cv.get(x);                 cv.get(x);
                 _outn("static Sint32 %s = %d;", *Str(name), x);                  _outn("static Sint32 %s = %d;", *Str(path), x);
                 break;                 break;
             }             }
  
Line 968 
Line 1055 
             {             {
                 Uint64 x;                 Uint64 x;
                 cv.get(x);                 cv.get(x);
                 _outn("static Uint64 %s = " PEGASUS_LLU ";", *Str(name), x);                  _outn("static Uint64 %s = " PEGASUS_LLU ";", *Str(path), x);
                 break;                 break;
             }             }
  
Line 976 
Line 1063 
             {             {
                 Sint64 x;                 Sint64 x;
                 cv.get(x);                 cv.get(x);
                 _outn("static Sint64 %s = " PEGASUS_LLU ";", *Str(name), x);                  _outn("static Sint64 %s = " PEGASUS_LLD ";", *Str(path), x);
                 break;                 break;
             }             }
  
Line 984 
Line 1071 
             {             {
                 Real32 x;                 Real32 x;
                 cv.get(x);                 cv.get(x);
                 _outn("static Real32 %s = %f;", *Str(name), x);                  _outn("static Real32 %s = %f;", *Str(path), x);
                 break;                 break;
             }             }
  
Line 992 
Line 1079 
             {             {
                 Real64 x;                 Real64 x;
                 cv.get(x);                 cv.get(x);
                 _outn("static Real64 %s = %lf;", *Str(name), x);                  _outn("static Real64 %s = %lf;", *Str(path), x);
                 break;                 break;
             }             }
  
Line 1000 
Line 1087 
             {             {
                 Char16 x;                 Char16 x;
                 cv.get(x);                 cv.get(x);
                 _outn("static Uint16 %s = %u;", *Str(name), Uint16(x));                  _outn("static Uint16 %s = %u;", *Str(path), Uint16(x));
                 break;                 break;
             }             }
  
Line 1010 
Line 1097 
                 cv.get(x);                 cv.get(x);
                 Str str(x);                 Str str(x);
  
                 _out("static const char* %s = ", *Str(name));                  _out("static const char* %s = ", *Str(path));
                 _writeStringLiteral(_os, str);                 _writeStringLiteral(_os, str);
                 _outn(";");                 _outn(";");
                 break;                 break;
Line 1033 
Line 1120 
     CIMType qt = cq.getType();     CIMType qt = cq.getType();
     const CIMValue& cv = cq.getValue();     const CIMValue& cv = cq.getValue();
  
     // Write separe value definition (if any).      // Write value definition (if any).
   
       String path = "_" + qn.getString() + "_qualifier_decl";
  
     String vn = String("_") + qn.getString() + "_qualifier_value";  
     Uint32 size = 0;     Uint32 size = 0;
     _writeValue(vn, cv, size);      _writeValue(path, cv, size);
  
     // Write SourceQualifierDecl header:     // Write SourceQualifierDecl header:
  
     _outn("static SourceQualifierDecl _%s_qualifier =", *Str(qn));      _outn("static SourceQualifierDecl");
       _outn("%s =", *Str(path));
     _outn("{");     _outn("{");
     _indent++;     _indent++;
  
Line 1143 
Line 1232 
     if (cv.isNull())     if (cv.isNull())
         _outn("0, /* value */");         _outn("0, /* value */");
     else     else
         _outn("&%s,", *Str(vn));          _outn("&%s_value,", *Str(path));
  
     // SourceQualifierDecl.size:     // SourceQualifierDecl.size:
  
Line 1154 
Line 1243 
     _nl();     _nl();
 } }
  
   template<class C>
   Array<CIMConstQualifier> _Qualifiers(const C& c)
   {
       Array<CIMConstQualifier> tmp;
   
       for (Uint32 i = 0; i < c.getQualifierCount(); i++)
           tmp.append(c.getQualifier(i));
   
       return tmp;
   }
   
   void cimmofSourceConsumer::_writeQualifierArray(
       const String& root,
       const Array<CIMConstQualifier>& qualifiers)
   {
       _outn("static SourceQualifier*");
       _outn("%s_qualifiers[] =", *Str(root));
       _outn("{");
   
       for (Uint32 i = 0; i < qualifiers.size(); i++)
       {
           CIMConstQualifier cq = qualifiers[i];
           CIMName qn = cq.getName();
   
           if (_discard && qn == "Description")
               continue;
   
   #if 0
           if (qn == "Values" || qn == "ValueMap")
               continue;
   #endif
   
           if (cq.getType() == CIMTYPE_BOOLEAN && !cq.isArray())
               continue;
   
           _outn("    &%s_%s_qualifier,", *Str(root), *Str(cq.getName()));
       }
   
       _outn("    0,");
   
       _outn("};");
       _nl();
   }
   
 void cimmofSourceConsumer::_writeProperty( void cimmofSourceConsumer::_writeProperty(
     const CIMName& cn,     const CIMName& cn,
     const CIMConstProperty& cp)     const CIMConstProperty& cp)
Line 1161 
Line 1294 
     CIMName pn = cp.getName();     CIMName pn = cp.getName();
     CIMType ct = cp.getType();     CIMType ct = cp.getType();
  
     _outn("static SourceProperty _%s_%s =", *Str(cn), *Str(pn));      String path = "_" + cn.getString() + "_" + pn.getString();
   
       // Write qualifiers:
   
       for (Uint32 i = 0; i < cp.getQualifierCount(); i++)
           _writeQualifier(_qualifiers, path, cp.getQualifier(i));
   
       _writeQualifierArray(path, _Qualifiers(cp));
   
       // Header:
   
       _outn("static SourceProperty");
       _outn("%s =", *Str(path));
     _outn("{");     _outn("{");
     _indent++;     _indent++;
  
Line 1175 
Line 1320 
  
     _outn("\"%s\", /* name */", *Str(pn));     _outn("\"%s\", /* name */", *Str(pn));
  
     // SourceProperty.description:      // SourceProperty.qualifiers:
  
     _writeDescription(_os, cp);      _outn("%s_qualifiers, /* qualifiers */", *Str(path));
  
     // SourceProperty.type:     // SourceProperty.type:
  
Line 1210 
Line 1355 
     _indent--;     _indent--;
     _outn("};");     _outn("};");
     _nl();     _nl();
   
     // ATTN: define qualifiers:  
 } }
  
 void cimmofSourceConsumer::_writeParameter( void cimmofSourceConsumer::_writeParameter(
Line 1222 
Line 1365 
     CIMName pn = cp.getName();     CIMName pn = cp.getName();
     CIMType ct = cp.getType();     CIMType ct = cp.getType();
  
     _outn("static SourceProperty _%s_%s_%s =", *Str(cn), *Str(mn), *Str(pn));      String path =
           "_" + cn.getString() + "_" + mn.getString() + "_" + pn.getString();
   
       for (Uint32 i = 0; i < cp.getQualifierCount(); i++)
           _writeQualifier(_qualifiers, path, cp.getQualifier(i));
   
       _writeQualifierArray(path, _Qualifiers(cp));
   
       _outn("static SourceProperty");
       _outn("%s =", *Str(path));
     _outn("{");     _outn("{");
     _indent++;     _indent++;
  
Line 1236 
Line 1388 
  
     _outn("\"%s\", /* name */", *Str(pn));     _outn("\"%s\", /* name */", *Str(pn));
  
     // SourceProperty.description:      // SourceProperty.qualifiers:
  
     _writeDescription(_os, cp);      _outn("%s_qualifiers, /* qualifiers */", *Str(path));
  
     // SourceProperty.type:     // SourceProperty.type:
  
Line 1271 
Line 1423 
     _indent--;     _indent--;
     _outn("};");     _outn("};");
     _nl();     _nl();
   
     // ATTN: define qualifiers:  
 } }
  
 void cimmofSourceConsumer::_writeMethod( void cimmofSourceConsumer::_writeMethod(
Line 1294 
Line 1444 
  
     // Write parameters array:     // Write parameters array:
  
     _outn("static SourceProperty* _%s_%s_parameters[] =", *Str(cn), *Str(mn));      _outn("static SourceProperty*");
       _outn("_%s_%s_parameters[] =", *Str(cn), *Str(mn));
     _outn("{");     _outn("{");
     _indent++;     _indent++;
  
Line 1311 
Line 1462 
  
     // Method header:     // Method header:
  
     _outn("static SourceMethod _%s_%s =", *Str(cn), *Str(mn));      String path = "_" + cn.getString() + "_" + mn.getString();
   
       for (Uint32 i = 0; i < cm.getQualifierCount(); i++)
           _writeQualifier(_qualifiers, path, cm.getQualifier(i));
   
       _writeQualifierArray(path, _Qualifiers(cm));
   
       _outn("static SourceMethod");
       _outn("%s =", *Str(path));
     _outn("{");     _outn("{");
     _indent++;     _indent++;
  
Line 1325 
Line 1484 
  
     _outn("\"%s\", /* name */", *Str(cn));     _outn("\"%s\", /* name */", *Str(cn));
  
     // SourceMethod.description:      // SourceMethod.qualifiers:
   
     _writeDescription(_os, cm);  
  
     // SourceMethod.type:      _outn("%s_qualifiers, /* qualifiers */", *Str(path));
  
     // SourceProperty.type:     // SourceProperty.type:
  
Line 1395 
Line 1552 
  
     // Write feature array:     // Write feature array:
  
     _outn("static SourceFeature* _%s_features[] =", *Str(cn));      _outn("static SourceFeature*");
       _outn("_%s_features[] =", *Str(cn));
     _outn("{");     _outn("{");
     _indent++;     _indent++;
  
Line 1412 
Line 1570 
  
     // Class header:     // Class header:
  
     _outn("static SourceClass _%s =", *Str(cn));      String path = "_" + cn.getString();
   
       for (Uint32 i = 0; i < cc.getQualifierCount(); i++)
           _writeQualifier(_qualifiers, path, cc.getQualifier(i));
   
       _writeQualifierArray(path, _Qualifiers(cc));
   
       _outn("static SourceClass");
       _outn("%s =", *Str(path));
     _outn("{");     _outn("{");
     _indent++;     _indent++;
  
Line 1432 
Line 1598 
  
     _outn("\"%s\", /* name */", *Str(cn));     _outn("\"%s\", /* name */", *Str(cn));
  
     // SourceClass.description:      // SourceClass.qualifiers:
  
     _writeDescription(_os, cc);      _outn("%s_qualifiers, /* qualifiers */", *Str(path));
  
     // SourceClass.super:     // SourceClass.super:
  
Line 1480 
Line 1646 
     _box(_os, "Qualifier array");     _box(_os, "Qualifier array");
     _nl();     _nl();
  
     _outn("static SourceQualifierDecl* _qualifiers[] =");      _outn("static SourceQualifierDecl*");
       _outn("_qualifiers[] =");
     _outn("{");     _outn("{");
     _indent++;     _indent++;
  
     for (Uint32 i = 0; i < _qualifiers.size(); i++)     for (Uint32 i = 0; i < _qualifiers.size(); i++)
     {     {
         _outn("&_%s_qualifier,", *Str(_qualifiers[i].getName()));          _outn("&_%s_qualifier_decl,", *Str(_qualifiers[i].getName()));
     }     }
  
     _outn("0,");     _outn("0,");
Line 1500 
Line 1667 
     _box(_os, "Class array");     _box(_os, "Class array");
     _nl();     _nl();
  
     _outn("static SourceClass* _classes[] =");      _outn("static SourceClass*");
       _outn("_classes[] =");
     _outn("{");     _outn("{");
     _indent++;     _indent++;
  


Legend:
Removed from v.1.1.2.3  
changed lines
  Added in v.1.1.2.4

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2