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/22 14:58:55 UTC
cvs commit: xml-axis/c/src/wcg Variable.h Variable.cpp Method.cpp Deploy.cpp actions.cpp
susantha 2003/07/22 05:58:55
Modified: c/src/wcg Variable.h Variable.cpp Method.cpp Deploy.cpp
actions.cpp
Log:
improved to support basic types and user types but not arrays yet
Revision Changes Path
1.4 +4 -1 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Variable.h 18 Jul 2003 13:33:07 -0000 1.3
+++ Variable.h 22 Jul 2003 12:58:55 -0000 1.4
@@ -79,7 +79,7 @@
using namespace std;
-enum VARTYPE { VAR_INT=1, VAR_FLOAT, VAR_STRING, VAR_LONG, VAR_SHORT, \
+enum VARTYPE { VAR_UNKNOWN=0, VAR_INT=1, VAR_FLOAT, VAR_STRING, VAR_LONG, VAR_SHORT, \
VAR_CHAR, VAR_DOUBLE, VAR_BOOL, VAR_UNSIGNEDLONG, VAR_UNSIGNEDINT,\
VAR_UNSIGNEDSHORT, VAR_UNSIGNED_CHAR, VAR_USER};
@@ -96,6 +96,8 @@
class Variable
{
public:
+ string& GetTypeEnumStr();
+ string& GetCorrespondingUnionMemberName();
void Reset();
int GetType();
bool IsArrayType();
@@ -109,6 +111,7 @@
Variable(Variable& Var);
virtual ~Variable();
private:
+ string m_sAuxStr;
void SetBasicTypeName();
int m_Type;
string m_TypeName; //if m_Type is user type
1.4 +64 -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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Variable.cpp 18 Jul 2003 13:33:07 -0000 1.3
+++ Variable.cpp 22 Jul 2003 12:58:55 -0000 1.4
@@ -143,7 +143,7 @@
bool Variable::IsComplexType()
{
- return false;
+ return (m_Type == VAR_USER);
}
bool Variable::IsArrayType()
@@ -163,3 +163,66 @@
m_TypeName = "";
m_VarName = "";
}
+
+string& Variable::GetCorrespondingUnionMemberName()
+{
+ switch (m_Type)
+ {
+ case VAR_INT: m_sAuxStr = "nValue"; break;
+ case VAR_FLOAT: m_sAuxStr = "fValue"; break;
+ case VAR_STRING: m_sAuxStr = "pStrValue"; break; //note that string too is taken as a basic type
+ case VAR_LONG: m_sAuxStr = "lValue"; break;
+ case VAR_SHORT: m_sAuxStr = "sValue"; break;
+ case VAR_CHAR: m_sAuxStr = "cValue"; break;
+ case VAR_DOUBLE: m_sAuxStr = "dValue"; break;
+ case VAR_BOOL: m_sAuxStr = "bValue"; break;
+ case VAR_UNSIGNEDLONG: m_sAuxStr = "ulValue"; break;
+ case VAR_UNSIGNEDINT: m_sAuxStr = "unValue"; break;
+ case VAR_UNSIGNEDSHORT: m_sAuxStr = "usValue"; break;
+ case VAR_UNSIGNED_CHAR: m_sAuxStr = "ucValue"; break;
+ case VAR_USER: m_sAuxStr = "pIBean"; break;
+ }
+ return m_sAuxStr;
+}
+
+string& Variable::GetTypeEnumStr()
+{
+ switch (m_Type)
+ {
+ case VAR_INT: m_sAuxStr = "XSD_INT"; break;
+ case VAR_FLOAT: m_sAuxStr = "XSD_FLOAT"; break;
+ case VAR_STRING: m_sAuxStr = "XSD_STRING"; break; //note that string too is taken as a basic type
+ case VAR_LONG: m_sAuxStr = "XSD_LONG"; break;
+ case VAR_SHORT: m_sAuxStr = "XSD_SHORT"; break;
+ case VAR_CHAR: m_sAuxStr = "XSD_CHAR"; break;
+ case VAR_DOUBLE: m_sAuxStr = "XSD_DOUBLE"; break;
+ case VAR_BOOL: m_sAuxStr = "XSD_BOOL"; break;
+ case VAR_UNSIGNEDLONG: m_sAuxStr = "XSD_UNSIGNEDLONG"; break;
+ case VAR_UNSIGNEDINT: m_sAuxStr = "XSD_UNSIGNEDINT"; break;
+ case VAR_UNSIGNEDSHORT: m_sAuxStr = "XSD_UNSIGNEDSHORT"; break;
+ case VAR_UNSIGNED_CHAR: m_sAuxStr = "XSD_UNSIGNED_CHAR"; break;
+ case VAR_USER: m_sAuxStr = "USER_TYPE"; break;
+ }
+ return m_sAuxStr;
+}
+
+/*
+ *When returning the return value of a web service method we have to set
+ *the return value from the web service method to a uParamValue union first
+ *The types in the uParamValue union is predefined. So we need to find what
+ *reference/dereference charactors should proceed the variable name.
+ *
+ * Ex: if web service method returns int
+ * value.nValue = ret;
+ * if web service method returns int*
+ * value.nValue = *ret;
+ * In case of strings this is somewhat different because in uParamValue union we
+ * have const char* for setting string value. So in this case we append ".c_str()"
+ * like,
+ * value.pStrValue = ret.c_str()
+ */
+
+//DEL string& Variable::GetAnyReferenceChars()
+//DEL {
+//DEL
+//DEL }
1.4 +18 -6 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Method.cpp 18 Jul 2003 13:33:51 -0000 1.3
+++ Method.cpp 22 Jul 2003 12:58:55 -0000 1.4
@@ -134,10 +134,13 @@
int nParam = 0;
for (list<Variable*>::iterator it = m_Params.begin(); it != m_Params.end(); it++)
{
- file << "\tParam *param" << nParam << " = mc->getSoapDeserializer()->GetParam();" << endl;
+ file << endl;
+ file << "\tIParam *param" << nParam << " = mc->getSoapDeserializer()->GetParam();" << endl;
if ((*it)->IsComplexType())
{
-
+ file << "\t" << (*it)->GetTypeName() << "* v" << nParam << " = new " << (*it)->GetTypeName() << "();" << endl;
+ file << "\tparam" << nParam << "->" << "SetUserType(" << "v" << nParam << ");" << endl;
+ file << "\tmc->getSoapDeserializer()->Deserialize(param" << nParam << ",0);" << endl; // 0 should be changed to 1 if multiref to be used
}
else if ((*it)->IsArrayType())
{
@@ -149,16 +152,25 @@
}
nParam++;
}
+ file << endl;
file << "\t//Call actual web service method with appropriate parameters" << endl;
- file << "\tParam ret(pWs->" << m_Name << "(";
+ file << "\t" << m_pReturnType->GetTypeName() << " ret = pWs->" << m_Name << "(";
for (int n=0; n<nParam;)
{
file << "v" << n++;
if (n<nParam) file << ", ";
}
- file << "));" << endl;
- file << "\tret.m_sName = \"" << m_Name << "Return\";" << endl;
- file << "\tmc->getSoapSerializer()->setResponseParam(&ret);" << endl;
+ file << ");" << endl;
+ file << endl;
+ file << "\tuParamValue value;" << endl;
+ file << "\tvalue." << m_pReturnType->GetCorrespondingUnionMemberName() << " = ret";
+ if (m_pReturnType->GetType() == VAR_STRING)
+ {
+ file << ".c_str()";
+ }
+ file << ";" << endl;
+ file << "\tIParam* pRetParam = mc->getSoapSerializer()->setResponseParam(" << m_pReturnType->GetTypeEnumStr() << ", value);" << endl;
+ file << "\tpRetParam->SetName(\"" << m_Name << "Return\");" << endl;
file << "\treturn SUCCESS;" << endl;
file << "}" << endl;
file << endl;
1.2 +3 -1 xml-axis/c/src/wcg/Deploy.cpp
Index: Deploy.cpp
===================================================================
RCS file: /home/cvs/xml-axis/c/src/wcg/Deploy.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Deploy.cpp 18 Jul 2003 13:20:51 -0000 1.1
+++ Deploy.cpp 22 Jul 2003 12:58:55 -0000 1.2
@@ -12,7 +12,7 @@
extern void init_keyword_map();
int parse_header_file(const char *filename);
extern FILE *yyin;
-
+extern list<string> g_classesfound;
//this map is populated with the type mapping and the services informaiion
//by the WSDD parser
map<string, string> g_ClassNamespaces;
@@ -20,6 +20,8 @@
int main(int argc, char* argv[])
{
init_keyword_map();
+ //add predefined classes to the list so that parser recognizes them
+ g_classesfound.push_back("IAccessBean");
//parse wsdd files
g_ClassNamespaces["webservice"] = "http://www.opensource.lk/webservice";
g_ClassNamespaces["root"] = "http://www.opensource.lk/root";
1.2 +20 -23 xml-axis/c/src/wcg/actions.cpp
Index: actions.cpp
===================================================================
RCS file: /home/cvs/xml-axis/c/src/wcg/actions.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- actions.cpp 18 Jul 2003 13:49:59 -0000 1.1
+++ actions.cpp 22 Jul 2003 12:58:55 -0000 1.2
@@ -48,7 +48,7 @@
if (!baselist) return false;
for (base_specifier_list::iterator it = baselist->begin(); it != baselist->end(); it++)
{
- if ((*(*it)->class_name) == "AccessBean")
+ if ((*(*it)->class_name) == "IAccessBean")
{
return true;
}
@@ -83,26 +83,17 @@
{
for (string_list::iterator tlit = decl_specs->begin(); tlit != decl_specs->end(); tlit++)
{
- string declstr = (*tlit)->c_str();
- if (lexer_keys.find(declstr) != lexer_keys.end())
- {
- cout << "Variable Type : " << declstr.c_str() << endl;
- nVarType = lexer_keys[declstr];
- if ((nConvVarType = map_var_type(nVarType)) != 0)
- {
- if (nConvVarType == VAR_USER)
- {
- Var.SetType(nConvVarType, declstr);
- }
- else
- {
- Var.SetType(nConvVarType);
- }
- }
- else //may be a variable qualifier like "const" or "static"
- {
-
- }
+ if (VAR_UNKNOWN != get_var_type((*tlit)->c_str())) //this is variable type not a qualifier
+ {
+ Var.SetType(get_var_type((*tlit)->c_str()));
+ }
+ else if (is_defined_class((*tlit)->c_str()))//user types
+ {
+ Var.SetType(VAR_USER, (*tlit)->c_str());
+ }
+ else
+ {
+ //handle other variable qualifiers here
}
}
}
@@ -143,10 +134,14 @@
{
for (string_list::iterator slit = (*pit)->decl_specs->begin(); slit != (*pit)->decl_specs->end(); slit++)
{
- if (0 != get_var_type((*slit)->c_str())) //this is variable type not a qualifier
+ if (VAR_UNKNOWN != get_var_type((*slit)->c_str())) //this is variable type not a qualifier
{
Var.SetType(get_var_type((*slit)->c_str()));
}
+ else if (is_defined_class((*slit)->c_str()))//user types
+ {
+ Var.SetType(VAR_USER, (*slit)->c_str());
+ }
else
{
//handle other variable qualifiers here
@@ -189,6 +184,7 @@
}
}
+//match parser types to our types for basic data types
int map_var_type(int parsertype)
{
switch (parsertype)
@@ -198,9 +194,10 @@
case KW_float: return VAR_FLOAT;
case KW_char: return VAR_CHAR;
case KW_double: return VAR_DOUBLE;
+ case KW_string: return VAR_STRING;
default:;
}
- return 0;
+ return VAR_UNKNOWN;
}
int get_var_type(const char* vartypename)