susantha    2003/07/23 21:13:41

  Modified:    c/src/wcg Variable.h Variable.cpp TranslationUnit.h
                        TranslationUnit.cpp Method.h Method.cpp
  Log:
  now WCG can generate wrapper classes for web services that passes and returns 
complex types as well but not arrays
  
  Revision  Changes    Path
  1.5       +7 -2      xml-axis/c/src/wcg/Variable.h
  
  Index: Variable.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wcg/Variable.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Variable.h        22 Jul 2003 12:58:55 -0000      1.4
  +++ Variable.h        24 Jul 2003 04:13:40 -0000      1.5
  @@ -73,6 +73,8 @@
   #pragma once
   #endif // _MSC_VER > 1000
   
  +#include "File.h"
  +
   #include <string>
   #include <list>
   #include <map>
  @@ -95,7 +97,10 @@
   
   class Variable  
   {
  -public:
  +public:      
  +     static string& GetParamGetMethod(int nType);
  +     int GenerateDeserializerImpl(File& file);
  +     int GenerateSerializerImpl(File& file);
        string& GetTypeEnumStr();
        string& GetCorrespondingUnionMemberName();
        void Reset();
  @@ -111,7 +116,7 @@
        Variable(Variable& Var);
        virtual ~Variable();
   private:
  -     string m_sAuxStr;
  +     static string m_sAuxStr;
        void SetBasicTypeName();
        int m_Type;
        string m_TypeName; //if m_Type is user type
  
  
  
  1.5       +53 -0     xml-axis/c/src/wcg/Variable.cpp
  
  Index: Variable.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wcg/Variable.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Variable.cpp      22 Jul 2003 12:58:55 -0000      1.4
  +++ Variable.cpp      24 Jul 2003 04:13:40 -0000      1.5
  @@ -73,6 +73,7 @@
   //////////////////////////////////////////////////////////////////////
   // Construction/Destruction
   //////////////////////////////////////////////////////////////////////
  +string Variable::m_sAuxStr="";
   
   Variable::Variable()
   {
  @@ -226,3 +227,55 @@
   //DEL {
   //DEL        
   //DEL }
  +
  +
  +int Variable::GenerateSerializerImpl(File &file)
  +{
  +     file << "\t"; 
  +     if (IsComplexType())
  +     {
  +             file << m_VarName << "->" << "Serialize(pSZ);";         
  +     }
  +     else
  +     {
  +             file << "pSZ << " << "pSZ.SerializeBasicType(\"" << m_VarName << "\", 
" << m_VarName << ").c_str();";
  +     }
  +     file << endl;
  +     return 0;
  +}
  +
  +int Variable::GenerateDeserializerImpl(File &file)
  +{
  +     file << "\t";
  +     if (IsComplexType())
  +     {
  +             file << m_VarName << "->" << "DeSerialize(pDZ);";       
  +     }
  +     else
  +     {
  +             file << m_VarName << " = pDZ->GetParam()->" << 
GetParamGetMethod(m_Type).c_str() << "();";
  +     }
  +     file << endl;
  +     return 0;
  +}
  +
  +string& Variable::GetParamGetMethod(int nType)
  +{
  +     //All get methods of Param class should be listed here
  +     switch(nType)
  +     {
  +             case VAR_INT: m_sAuxStr = "GetInt"; break;
  +             case VAR_FLOAT: m_sAuxStr = "GetFloat"; break;
  +             case VAR_STRING: m_sAuxStr = "GetString"; break;
  +             case VAR_LONG: m_sAuxStr = "GetLong"; break;
  +             case VAR_SHORT: m_sAuxStr = "GetShort"; break;
  +             case VAR_CHAR: m_sAuxStr = "GetChar"; break;
  +             case VAR_DOUBLE: m_sAuxStr = "GetDouble"; break;
  +             case VAR_BOOL: m_sAuxStr = "GetBool"; break;
  +             case VAR_UNSIGNEDLONG: m_sAuxStr = "GetUnsignedLong"; break;
  +             case VAR_UNSIGNEDINT: m_sAuxStr = "GetUnsignedInt"; break;
  +             case VAR_UNSIGNEDSHORT: m_sAuxStr = "GetUnsignedShort"; break;
  +             case VAR_UNSIGNED_CHAR: m_sAuxStr = "GetUnsignedChar"; break;
  +     }
  +     return m_sAuxStr;
  +}
  \ No newline at end of file
  
  
  
  1.2       +2 -0      xml-axis/c/src/wcg/TranslationUnit.h
  
  Index: TranslationUnit.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wcg/TranslationUnit.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TranslationUnit.h 18 Jul 2003 13:34:31 -0000      1.1
  +++ TranslationUnit.h 24 Jul 2003 04:13:40 -0000      1.2
  @@ -82,6 +82,7 @@
   class TranslationUnit  
   {
   public:
  +     void SetWsFileName(const char* sFileName);
        void AddBeanClass(BeanClass* pClass);
        void SetWSClass(WSClass* pClass);
        void AddNSDecl(string& sNSDecl);
  @@ -92,6 +93,7 @@
        TranslationUnit();
        virtual ~TranslationUnit();
   private:
  +     string m_sWsFileName;
        list<string> m_includes;
        list<string> m_nsdecls;
        WSClass *m_pWSClass; //there can be only one web service class per header file.
  
  
  
  1.2       +19 -2     xml-axis/c/src/wcg/TranslationUnit.cpp
  
  Index: TranslationUnit.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wcg/TranslationUnit.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TranslationUnit.cpp       18 Jul 2003 13:34:31 -0000      1.1
  +++ TranslationUnit.cpp       24 Jul 2003 04:13:40 -0000      1.2
  @@ -111,7 +111,12 @@
                file << "#define " << WCID(m_pWSClass->GetName().c_str()) << endl;
                file << endl;
                //add includes
  -             //generate wrapper class declarations for bean classes
  +             file << "#include \"" << m_sWsFileName.c_str() << "\"" << endl;
  +             file << "#include \"../common/WrapperClassHandler.h\"" << endl;
  +             file << "#include \"../common/IMessageData.h\"" << endl;
  +             file << "#include \"../common/GDefine.h\"" << endl;
  +             file << "#include \"../common/IAccessBean.h\"" << endl;
  +             file << endl;
                //generate wrapper class declaration
                m_pWSClass->GenerateClassDef(file);
                file << endl;
  @@ -136,10 +141,17 @@
                //add includes
                file << "#include \"../common/ISoapDeserializer.h\"" << endl;
                file << "#include \"../common/ISoapSerializer.h\"" << endl;
  -             file << "#include \"../common/BasicTypeSerializer.h\"" << endl;
  +             file << "#include \"../common/ISoapMethod.h\"" << endl;
  +             file << "#include \"../common/IParam.h\"" << endl;
  +
                file << "#include <string>" << endl;
                file << "using namespace std;" << endl;
                file << endl;
  +             //generate serializers and deserializers for bean classes
  +             for (list<BeanClass*>::iterator it = m_Beans.begin(); it != 
m_Beans.end(); it++)
  +             {
  +                     (*it)->GenerateSerializerAndDeSerializerImpl(file);
  +             }
                //generate wrapper class's methods
                m_pWSClass->GenerateClassImpl(file);
                //generate IAccessBean implementations for bean classes
  @@ -170,4 +182,9 @@
   void TranslationUnit::AddBeanClass(BeanClass *pClass)
   {
        m_Beans.push_back(pClass);
  +}
  +
  +void TranslationUnit::SetWsFileName(const char *sFileName)
  +{
  +     m_sWsFileName = sFileName;
   }
  
  
  
  1.4       +0 -1      xml-axis/c/src/wcg/Method.h
  
  Index: Method.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wcg/Method.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Method.h  18 Jul 2003 13:33:07 -0000      1.3
  +++ Method.h  24 Jul 2003 04:13:40 -0000      1.4
  @@ -82,7 +82,6 @@
   class Method  
   {
   public:
  -     string& GetParamGetMethod(int nType);
        int GenerateMethodImpl(string& sClassName, File& file);
        string& GetName();
        int GenerateMethodDef(File &file);
  
  
  
  1.5       +17 -23    xml-axis/c/src/wcg/Method.cpp
  
  Index: Method.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wcg/Method.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Method.cpp        22 Jul 2003 12:58:55 -0000      1.4
  +++ Method.cpp        24 Jul 2003 04:13:40 -0000      1.5
  @@ -71,6 +71,15 @@
   // Construction/Destruction
   //////////////////////////////////////////////////////////////////////
   
  +/*
  +     Features:
  +     Limitations:
  +             1. All basic types are passed/returned to/from web service methods by 
value.
  +             2. All user types are passed/returned to/from web service methods by 
reference (pointers)
  +             3. No arrays can be passed or returned from web service methods.
  +             4. 
  +             5.
  +  */
   Method::Method()
   {
        m_Qualifier=0;
  @@ -130,7 +139,7 @@
   {
        file << "int " << sClassName << "::" << m_Name << "(IMessageData* mc)" << 
endl;         
        file << "{" << endl;
  -     file << "\tSetResponseMethod(mc, " << m_Name << "\");" << endl;
  +     file << "\tSetResponseMethod(mc, \"" << m_Name << "\");" << endl;
        int nParam = 0;
        for (list<Variable*>::iterator it = m_Params.begin(); it != m_Params.end(); 
it++)
        {
  @@ -148,13 +157,18 @@
                }
                else //basic types
                {
  -                     file << "\t" << (*it)->GetTypeName() << " v" << nParam << " = 
" << "param" << nParam << "->" << GetParamGetMethod((*it)->GetType()) << "();" << endl;
  +                     file << "\t" << (*it)->GetTypeName() << " v" << nParam << " = 
" << "param" << nParam << "->" << Variable::GetParamGetMethod((*it)->GetType()) << 
"();" << endl;
                }
                nParam++;
        }
        file << endl;
        file << "\t//Call actual web service method with appropriate parameters" << 
endl;
  -     file << "\t" << m_pReturnType->GetTypeName() << " ret = pWs->" << m_Name << 
"(";
  +     file << "\t" << m_pReturnType->GetTypeName();
  +     if (m_pReturnType->IsComplexType()) 
  +     {
  +             file << "*"; //this is because of the convention that all user types 
return by reference (pointer) //
  +     }
  +     file << " ret = pWs->" << m_Name << "(";
        for (int n=0; n<nParam;)
        {
                file << "v" << n++;
  @@ -177,23 +191,3 @@
        return 0;
   }
   
  -string& Method::GetParamGetMethod(int nType)
  -{
  -     //All get methods of Param class should be listed here
  -     switch(nType)
  -     {
  -             case VAR_INT: m_AuxStr = "GetInt"; break;
  -             case VAR_FLOAT: m_AuxStr = "GetFloat"; break;
  -             case VAR_STRING: m_AuxStr = "GetString"; break;
  -             case VAR_LONG: m_AuxStr = "GetLong"; break;
  -             case VAR_SHORT: m_AuxStr = "GetShort"; break;
  -             case VAR_CHAR: m_AuxStr = "GetChar"; break;
  -             case VAR_DOUBLE: m_AuxStr = "GetDouble"; break;
  -             case VAR_BOOL: m_AuxStr = "GetBool"; break;
  -             case VAR_UNSIGNEDLONG: m_AuxStr = "GetUnsignedLong"; break;
  -             case VAR_UNSIGNEDINT: m_AuxStr = "GetUnsignedInt"; break;
  -             case VAR_UNSIGNEDSHORT: m_AuxStr = "GetUnsignedShort"; break;
  -             case VAR_UNSIGNED_CHAR: m_AuxStr = "GetUnsignedChar"; break;
  -     }
  -     return m_AuxStr;
  -}
  
  
  

Reply via email to