You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by su...@apache.org on 2003/07/01 12:50:12 UTC

cvs commit: xml-axis/c/src/wcg WCGenerator.h WCGenerator.cpp File.h File.cpp WSClass.h WSClass.cpp Variable.h Variable.cpp Method.h Method.cpp HeaderFile.h HeaderFile.cpp BeanClass.h BeanClass.cpp

susantha    2003/07/01 03:50:12

  Modified:    c/src/wcg WSClass.h WSClass.cpp Variable.h Variable.cpp
                        Method.h Method.cpp HeaderFile.h HeaderFile.cpp
                        BeanClass.h BeanClass.cpp
  Added:       c/src/wcg WCGenerator.h WCGenerator.cpp File.h File.cpp
  Log:
  more code added
  
  Revision  Changes    Path
  1.2       +9 -0      xml-axis/c/src/wcg/WSClass.h
  
  Index: WSClass.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wcg/WSClass.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WSClass.h	27 Jun 2003 12:28:37 -0000	1.1
  +++ WSClass.h	1 Jul 2003 10:50:11 -0000	1.2
  @@ -73,6 +73,7 @@
   
   #include "Variable.h"
   #include "Method.h"
  +#include "File.h"
   
   #include <list>
   using namespace std;
  @@ -80,6 +81,14 @@
   class WSClass  
   {
   public:
  +	int GenerateClassImpl(File& file);
  +	int GenerateClassDef(File& file);
  +	const string& GetName();
  +	void SetDestructor(Method* pMethod);
  +	void AddMethod(Method* pMethod);
  +	void AddConstructor(Method* pMethod);
  +	void AddVariable(Variable* pVar);
  +	void SetClassName(string& sName);
   	WSClass();
   	virtual ~WSClass();
   private:
  
  
  
  1.2       +66 -1     xml-axis/c/src/wcg/WSClass.cpp
  
  Index: WSClass.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wcg/WSClass.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WSClass.cpp	27 Jun 2003 12:28:37 -0000	1.1
  +++ WSClass.cpp	1 Jul 2003 10:50:11 -0000	1.2
  @@ -72,10 +72,75 @@
   
   WSClass::WSClass()
   {
  -
  +	m_Name = "";
  +	m_pDestructor = NULL;
   }
   
   WSClass::~WSClass()
   {
  +	for(list<Variable*>::iterator it = m_Variables.begin(); it != m_Variables.end(); it++)
  +	{	
  +		delete *it;
  +	}
  +	list<Method*>::iterator it1;
  +	for( it1 = m_Constructors.begin(); it1 != m_Constructors.end(); it1++)
  +	{	
  +		delete *it1;
  +	}
  +	for (it1 = m_Methods.begin(); it1 != m_Methods.end(); it1++)
  +	{
  +		delete *it1;
  +	}
  +	if (m_pDestructor) delete m_pDestructor;
  +
  +}
   
  +void WSClass::SetClassName(string &sName)
  +{
  +	m_Name = sName;
  +}
  +
  +void WSClass::AddVariable(Variable *pVar)
  +{
  +	m_Variables.push_back(pVar);
  +}
  +
  +void WSClass::AddConstructor(Method *pMethod)
  +{
  +	m_Constructors.push_back(pMethod);
  +}
  +
  +void WSClass::AddMethod(Method *pMethod)
  +{
  +	m_Methods.push_back(pMethod);
  +}
  +
  +void WSClass::SetDestructor(Method *pMethod)
  +{
  +	m_pDestructor = pMethod;
  +}
  +
  +const string& WSClass::GetName()
  +{
  +	return m_Name;
  +}
  +
  +int WSClass::GenerateClassDef(File &file)
  +{
  +	try {
  +		//add wrapper class
  +		file << "class " << GetName() << "Wrapper" << " : public WrapperClassHandler" << endl << "{" << endl;
  +		
  +		file << "};" << endl;	
  +	}
  +	catch(...) //any exception
  +	{
  +		return 1;
  +	}
  +	return 0; //success
  +}
  +
  +int WSClass::GenerateClassImpl(File &file)
  +{
  +	return 0;
   }
  
  
  
  1.2       +12 -7     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Variable.h	27 Jun 2003 12:28:37 -0000	1.1
  +++ Variable.h	1 Jul 2003 10:50:11 -0000	1.2
  @@ -74,26 +74,31 @@
   #include <string>
   using namespace std;
   
  +enum VARTYPE { VAR_INT=1, VAR_FLOAT, VAR_STRING, VAR_LONG, VAR_SHORT, VAR_BYTE, VAR_UNSIGNEDLONG, \
  +				VAR_BOOLEAN, VAR_UNSIGNEDINT, VAR_UNSIGNEDSHORT, VAR_UNSIGNEDBYTE, \
  +				VAR_DOUBLE, VAR_USER};
  +
   //Variable Qualifiers
   const unsigned char VQ_PRIVATE = 0x01;
   const unsigned char VQ_PROTECTED = 0x02;
  -const unsigned char VQ_PUBLIC = 0x04;
  -const unsigned char VQ_STATIC = 0x08;
  -const unsigned char VQ_CONST = 0x10;
  -const unsigned char VQ_REFTYPE = 0x20;
  -const unsigned char VQ_PTRTYPE = 0x40;
  -const unsigned char VQ_PTRPTRTYPE = 0x80;
  +const unsigned char VQ_STATIC = 0x04;
  +const unsigned char VQ_CONST = 0x08;
  +const unsigned char VQ_REFTYPE = 0x10;
  +const unsigned char VQ_PTRTYPE = 0x20;
  +const unsigned char VQ_PTRPTRTYPE = 0x40;
   
   class Variable  
   {
   public:
  +	void SetVarName(string& sVarName);
  +	void SetType(int nType, string sType="");
   	Variable();
   	virtual ~Variable();
   private:
   	int m_Type;
   	string m_TypeName; //if m_Type is user type
   	string m_VarName;
  -	unsigned char m_Qualifier; //private=1/protected=2/public=4/static=8/const=16/reference type=32/pointer type=64/pointer to pointer type=128
  +	unsigned char m_Qualifier; //private=1/protected=2/public=0/static=4/const=8/reference type=16/pointer type=32/pointer to pointer type=64
   };
   
   #endif // !defined(AFX_VARIABLE_H__F9272406_BB8F_4151_8346_E033DDDDA468__INCLUDED_)
  
  
  
  1.2       +15 -1     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Variable.cpp	27 Jun 2003 12:28:37 -0000	1.1
  +++ Variable.cpp	1 Jul 2003 10:50:11 -0000	1.2
  @@ -72,10 +72,24 @@
   
   Variable::Variable()
   {
  -
  +	m_Qualifier = 0;
  +	m_Type = 0;
  +	m_TypeName = "";
  +	m_VarName = "";
   }
   
   Variable::~Variable()
   {
   
  +}
  +
  +void Variable::SetType(int nType, string sType)
  +{
  +	m_Type = nType;
  +	if (nType == VAR_USER) m_TypeName = sType;
  +}
  +
  +void Variable::SetVarName(string &sVarName)
  +{
  +	m_VarName = sVarName;
   }
  
  
  
  1.2       +9 -6      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Method.h	27 Jun 2003 12:28:37 -0000	1.1
  +++ Method.h	1 Jul 2003 10:50:11 -0000	1.2
  @@ -81,21 +81,24 @@
   //Method Qualifiers
   const unsigned char MQ_PRIVATE = 0x01;
   const unsigned char MQ_PROTECTED = 0x02;
  -const unsigned char MQ_PUBLIC = 0x04;
  -const unsigned char MQ_STATIC = 0x08;
  -const unsigned char MQ_CONST = 0x10;
  -const unsigned char MQ_VIRTUAL = 0x20;
  +const unsigned char MQ_STATIC = 0x04;
  +const unsigned char MQ_CONST = 0x08;
  +const unsigned char MQ_VIRTUAL = 0x10;
   
   class Method  
   {
   public:
  +	void SetQualification(unsigned char sQualifier);
  +	void SetMethodName(string& sName);
  +	void AddParameter(Variable* pVar);
  +	void AddReturnType(Variable* pVar);
   	Method();
   	virtual ~Method();
   private:
  -	Variable m_ReturnType;
  +	Variable* m_pReturnType;
   	string m_Name;
   	list<Variable*> m_Params;
  -	unsigned char m_Qualifier; //private=1/protected=2/public=4/static=8/const=16/virtual=32
  +	unsigned char m_Qualifier; //private=1/protected=2/public=0/static=4/const=8/virtual=16
   };
   
   #endif // !defined(AFX_METHOD_H__87FCCB11_EF9C_409E_81F6_99F054B5E609__INCLUDED_)
  
  
  
  1.2       +27 -1     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Method.cpp	27 Jun 2003 12:28:37 -0000	1.1
  +++ Method.cpp	1 Jul 2003 10:50:11 -0000	1.2
  @@ -72,10 +72,36 @@
   
   Method::Method()
   {
  -
  +	m_Qualifier=0;
  +	m_Name="";
  +	m_pReturnType = NULL;
   }
   
   Method::~Method()
   {
  +	if (m_pReturnType) delete m_pReturnType;
  +	for (list<Variable*>::iterator it = m_Params.begin(); it != m_Params.end(); it++)
  +	{
  +		delete *it;
  +	}
  +}
  +
  +void Method::AddReturnType(Variable *pVar)
  +{
  +	m_pReturnType = pVar;
  +}
  +
  +void Method::AddParameter(Variable *pVar)
  +{
  +	m_Params.push_back(pVar);
  +}
  +
  +void Method::SetMethodName(string &sName)
  +{
  +	m_Name = sName;
  +}
   
  +void Method::SetQualification(unsigned char sQualifier)
  +{
  +	m_Qualifier|=sQualifier;
   }
  
  
  
  1.2       +8 -1      xml-axis/c/src/wcg/HeaderFile.h
  
  Index: HeaderFile.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wcg/HeaderFile.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HeaderFile.h	27 Jun 2003 12:28:37 -0000	1.1
  +++ HeaderFile.h	1 Jul 2003 10:50:11 -0000	1.2
  @@ -81,12 +81,19 @@
   class HeaderFile  
   {
   public:
  +	void AddBeanClass(BeanClass* pClass);
  +	void SetWSClass(WSClass* pClass);
  +	void AddNSDecl(string& sNSDecl);
  +	void AddInclude(string& sInclude);
  +	int GenerateWrapperClassImpl();
  +	int GenerateWrapperClassDef();
  +	int GenerateWSDL();
   	HeaderFile();
   	virtual ~HeaderFile();
   private:
   	list<string> m_includes;
   	list<string> m_nsdecls;
  -	WSClass m_WSClass; //there can be only one web service class per header file.
  +	WSClass *m_pWSClass; //there can be only one web service class per header file.
   	list<BeanClass*> m_Beans;
   };
   
  
  
  
  1.2       +72 -1     xml-axis/c/src/wcg/HeaderFile.cpp
  
  Index: HeaderFile.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wcg/HeaderFile.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HeaderFile.cpp	27 Jun 2003 12:28:37 -0000	1.1
  +++ HeaderFile.cpp	1 Jul 2003 10:50:11 -0000	1.2
  @@ -65,17 +65,88 @@
   //////////////////////////////////////////////////////////////////////
   
   #include "HeaderFile.h"
  +#include "File.h"
   
   //////////////////////////////////////////////////////////////////////
   // Construction/Destruction
   //////////////////////////////////////////////////////////////////////
  +#define WCID(X) "__WRAPPER_CLASS_" << X << "_INCLUDED__"
   
   HeaderFile::HeaderFile()
   {
  -
  +	m_pWSClass = NULL;
   }
   
   HeaderFile::~HeaderFile()
   {
  +	if (m_pWSClass) delete m_pWSClass;
  +	for (list<BeanClass*>::iterator it = m_Beans.begin(); it != m_Beans.end(); it++)
  +	{
  +		delete *it;
  +	}
  +}
  +
  +int HeaderFile::GenerateWSDL()
  +{
  +	try {
  +
  +	
  +	}
  +	catch(...) //any exception
  +	{
  +		return 1;
  +	}
  +	return 0; //success
  +}
  +
  +int HeaderFile::GenerateWrapperClassDef()
  +{
  +	try {
  +		if (!m_pWSClass) return 1;
  +		string fname = m_pWSClass->GetName() + "Wrapper.hpp"; 
  +		File file(fname);
  +		file << "#if !defined " << WCID(m_pWSClass->GetName().c_str()) << endl;
  +		file << "#define " << WCID(m_pWSClass->GetName().c_str()) << endl;
  +		//add includes
  +		m_pWSClass->GenerateClassDef(file);
  +		file << "#endif" << endl;
  +	}
  +	catch(...) //any exception
  +	{
  +		return 1;
  +	}
  +	return 0; //success
  +}
  +
  +int HeaderFile::GenerateWrapperClassImpl()
  +{
  +	try {
   
  +	
  +	}
  +	catch(...) //any exception
  +	{
  +		return 1;
  +	}
  +	return 0; //success
  +}
  +
  +void HeaderFile::AddInclude(string &sInclude)
  +{
  +	m_includes.push_back(sInclude);
  +}
  +
  +void HeaderFile::AddNSDecl(string &sNSDecl)
  +{
  +	m_nsdecls.push_back(sNSDecl);
  +}
  +
  +void HeaderFile::SetWSClass(WSClass *pClass)
  +{
  +	m_pWSClass = pClass;
  +}
  +
  +void HeaderFile::AddBeanClass(BeanClass *pClass)
  +{
  +	m_Beans.push_back(pClass);
   }
  
  
  
  1.2       +1 -0      xml-axis/c/src/wcg/BeanClass.h
  
  Index: BeanClass.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wcg/BeanClass.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BeanClass.h	27 Jun 2003 12:28:37 -0000	1.1
  +++ BeanClass.h	1 Jul 2003 10:50:11 -0000	1.2
  @@ -79,6 +79,7 @@
   class BeanClass  
   {
   public:
  +	void AddVariable(Variable* pVar);
   	BeanClass();
   	virtual ~BeanClass();
   private:
  
  
  
  1.2       +8 -0      xml-axis/c/src/wcg/BeanClass.cpp
  
  Index: BeanClass.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wcg/BeanClass.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BeanClass.cpp	27 Jun 2003 12:28:37 -0000	1.1
  +++ BeanClass.cpp	1 Jul 2003 10:50:11 -0000	1.2
  @@ -78,5 +78,13 @@
   
   BeanClass::~BeanClass()
   {
  +	for (list<Variable*>::iterator it = m_Variables.begin(); it != m_Variables.end(); it++)
  +	{
  +		delete *it;
  +	}
  +}
   
  +void BeanClass::AddVariable(Variable *pVar)
  +{
  +	m_Variables.push_back(pVar);
   }
  
  
  
  1.1                  xml-axis/c/src/wcg/WCGenerator.h
  
  Index: WCGenerator.h
  ===================================================================
  // WCGenerator.h: interface for the WCGenerator class.
  //
  //////////////////////////////////////////////////////////////////////
  
  #if !defined(AFX_WCGENERATOR_H__720250A8_3F71_4C41_88BD_BB590C1E44A8__INCLUDED_)
  #define AFX_WCGENERATOR_H__720250A8_3F71_4C41_88BD_BB590C1E44A8__INCLUDED_
  
  #if _MSC_VER > 1000
  #pragma once
  #endif // _MSC_VER > 1000
  
  #include <string>
  using namespace std;
  
  class WCGenerator  
  {
  public:
  	int DoDeploy();
  	void SetWSDD(string& sWsddfile);
  	void SetWSLibrary(string& sLibfile);
  	void SetWSDefinition(string& sHeaderfile);
  	WCGenerator();
  	virtual ~WCGenerator();
  
  };
  
  #endif // !defined(AFX_WCGENERATOR_H__720250A8_3F71_4C41_88BD_BB590C1E44A8__INCLUDED_)
  
  
  
  1.1                  xml-axis/c/src/wcg/WCGenerator.cpp
  
  Index: WCGenerator.cpp
  ===================================================================
  // WCGenerator.cpp: implementation of the WCGenerator class.
  //
  //////////////////////////////////////////////////////////////////////
  
  #include "WCGenerator.h"
  
  //////////////////////////////////////////////////////////////////////
  // Construction/Destruction
  //////////////////////////////////////////////////////////////////////
  #include "WSClass.h"
  #include "HeaderFile.h"
  
  WCGenerator::WCGenerator()
  {
  
  }
  
  WCGenerator::~WCGenerator()
  {
  
  }
  
  void WCGenerator::SetWSDefinition(string &sHeaderfile)
  {
  
  }
  
  void WCGenerator::SetWSLibrary(string &sLibfile)
  {
  
  }
  
  void WCGenerator::SetWSDD(string &sWsddfile)
  {
  
  }
  
  int WCGenerator::DoDeploy()
  {
  	return 0;
  }
  
  int main(int argc, char*argv[])
  {
  	WSClass* pCl = new WSClass();
  	pCl->SetClassName(string("Test"));
  	HeaderFile hf;
  	hf.SetWSClass(pCl);
  	hf.GenerateWrapperClassDef();
  	return 0;
  }
  
  
  
  1.1                  xml-axis/c/src/wcg/File.h
  
  Index: File.h
  ===================================================================
  // File.h: interface for the File class.
  //
  //////////////////////////////////////////////////////////////////////
  
  #if !defined(AFX_FILE_H__E30356C1_DD4A_4FCF_A529_713455BB6E02__INCLUDED_)
  #define AFX_FILE_H__E30356C1_DD4A_4FCF_A529_713455BB6E02__INCLUDED_
  
  #if _MSC_VER > 1000
  #pragma once
  #endif // _MSC_VER > 1000
  
  #include <string>
  #include <fstream>
  using namespace std;
  
  class File : public ofstream
  {
  public:
  	int Write(char* pChars);
  	File(const string& sFileName);
  	virtual ~File();
  };
  
  #endif // !defined(AFX_FILE_H__E30356C1_DD4A_4FCF_A529_713455BB6E02__INCLUDED_)
  
  
  
  1.1                  xml-axis/c/src/wcg/File.cpp
  
  Index: File.cpp
  ===================================================================
  // File.cpp: implementation of the File class.
  //
  //////////////////////////////////////////////////////////////////////
  
  #include "File.h"
  
  //////////////////////////////////////////////////////////////////////
  // Construction/Destruction
  //////////////////////////////////////////////////////////////////////
  
  File::File(const string& sFileName): ofstream(sFileName.c_str())
  {
  
  }
  
  File::~File()
  {
  }
  
  int File::Write(char *pChars)
  {
  	return 0;
  }