axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dushshan...@apache.org
Subject svn commit: r354322 - in /webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp: BeanParamWriter.java ClientStubHeaderWriter.java ClientStubWriter.java WrapWriter.java
Date Tue, 06 Dec 2005 05:35:24 GMT
Author: dushshantha
Date: Mon Dec  5 21:35:12 2005
New Revision: 354322

URL: http://svn.apache.org/viewcvs?rev=354322&view=rev
Log:
Made the modifications to the code generation for RPC style wsdls to suit the new memory model
of Arrays.

Modified:
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubHeaderWriter.java
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/WrapWriter.java

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java?rev=354322&r1=354321&r2=354322&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java
(original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java
Mon Dec  5 21:35:12 2005
@@ -521,6 +521,8 @@
 
 	private void writeDeSerializeGlobalMethod() throws IOException, WrapperFault 
     {
+		int arrayCount = 0;
+		
 		writer.write("/*\n");
 		writer.write(" * This static method deserialize a " + classname
 				+ " type of object\n");
@@ -610,15 +612,18 @@
 				//if Array
 				if (attribs[i].isSimpleType()) 
                 {
-					writer.write("\tparam->"
-							+ attribs[i].getParamNameAsMember()
-							+ " = ("
-							+ CUtils.getBasicArrayNameforType(attribs[i]
-									.getTypeName())
-							+ "&)pIWSDZ->getBasicArray("
-							+ CUtils.getXSDTypeForBasicType(attribs[i]
-									.getTypeName()) + ", \""
-							+ attribs[i].getParamName() + "\",0);\n");
+					//new array memory model.					
+					 writer.write("\tAxis_Array * array" + arrayCount + " = pIWSDZ->getBasicArray("
+	                            + CUtils.getXSDTypeForBasicType(attribs[i].getTypeName()) +
", \""
+	                            + attribs[i].getParamNameAsSOAPElement()
+	                            + "\",0);\n");
+	                    writer.write("\tif(param->" + attribs[i].getParamNameAsMember() +
" == NULL)\n");
+	                    writer.write("\t{\n");
+	                    writer.write("\t\tparam->" + attribs[i].getParamNameAsMember() +
" = new " + attribs[i].getTypeName() + "_Array();\n");
+	                    writer.write("\t}\n");
+	                    writer.write("\tparam->" + attribs[i].getParamNameAsMember() + "->clone(
*array" + arrayCount + ");\n");
+	                    writer.write("\tAxis::AxisDelete((void*) array" + arrayCount + ", XSD_ARRAY);\n\n");
+	                    //end of new array memory model.
 				} 
                 else 
                 {
@@ -628,17 +633,27 @@
 						elm = attribs[i].getTypeName();
 					}
 					arrayType = attribs[i].getTypeName();
-					writer.write("\tparam->"
-									+ attribs[i].getParamNameAsMember()
-									+ " = ("
-									+ attribs[i].getTypeName()
-									+ "_Array&)pIWSDZ->getCmplxArray((void*)Axis_DeSerialize_"
-									+ arrayType + "\n\t\t, (void*)Axis_Create_"
-									+ arrayType + ", (void*)Axis_Delete_"
-									+ arrayType
-									+ "\n\t\t, (void*)Axis_GetSize_"
-									+ arrayType + ", \"" + elm
-									+ "\", Axis_URI_" + arrayType + ");\n");
+					
+					//new array memory model.
+					writer.write("\t" + arrayType + "_Array * array" + arrayCount + " = new " + arrayType
+ "_Array();\n");
+                    writer.write("\tarray" + arrayCount + " = (" + arrayType + "_Array *)
pIWSDZ->getCmplxArray(array" + arrayCount + ", (void*)Axis_DeSerialize_"
+                                    + arrayType
+                                    + ",\n"
+                                    + "\t\t\t\t\t\t\t\t  (void*)Axis_Create_"
+                                    + arrayType
+                                    + ",\n"
+                                    + "\t\t\t\t\t\t\t\t  (void*)Axis_Delete_"
+                                    + arrayType
+                                    + ",\n"
+                                    + "\t\t\t\t\t\t\t\t  (void*)Axis_GetSize_"
+                                    + arrayType
+                                    + ",\n"
+                                    + "\t\t\t\t\t\t\t\t  \""
+                                    + attribs[i].getElementNameAsString()
+                                    + "\", Axis_URI_" + arrayType + ");\n\n");
+                    
+                	writer.write("\tparam->" + attribs[i].getParamNameAsMember() + " = array"
+ arrayCount + ";\n\n");
+                	//end of new array memory model.
 				}
 			} 
             else if (attribs[i].isSimpleType()) 

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubHeaderWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubHeaderWriter.java?rev=354322&r1=354321&r2=354322&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubHeaderWriter.java
(original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubHeaderWriter.java
Mon Dec  5 21:35:12 2005
@@ -134,19 +134,21 @@
                                 .iterator()
                                 .next();
                         String outParamTypeName = WrapperUtils.getClassNameFromParamInfoConsideringArrays(returnParam,
wscontext);
-                        if (CUtils.isSimpleType(outParamTypeName)
-								&& returnParam.isNillable()
-								&& !(CUtils.isPointerType(outParamTypeName)))
+                        if ((outParamTypeName.lastIndexOf ("_Array") > 0)
+                        		||(CUtils.isSimpleType(outParamTypeName)
+								&& (returnParam.isNillable() || returnParam.isOptional())
+								&& !(CUtils.isPointerType(outParamTypeName))))
                         {
                         	writer.write(
                                     "\tSTORAGE_CLASS_INFO "
                                         + outParamTypeName
                                         + " * ");
                         }
-                        writer.write(
-                            "\tSTORAGE_CLASS_INFO "
-                                + outParamTypeName
-                                + " ");
+                        else
+                        	writer.write(
+                        			"\tSTORAGE_CLASS_INFO "
+                        			+ outParamTypeName
+                        			+ " ");
                     }
                     else
                     {
@@ -166,14 +168,16 @@
                     .getClassNameFromParamInfoConsideringArrays(
                             fparam,
                             wscontext);
-                    if (CUtils.isSimpleType(paramTypeName)
+                    if ((paramTypeName.lastIndexOf ("_Array") > 0)
+                    		||(CUtils.isSimpleType(paramTypeName)
 							&& fparam.isNillable()
-							&& !(CUtils.isPointerType(paramTypeName)))
+							&& !(CUtils.isPointerType(paramTypeName))))
                     {
                     	writer.write(
     	                        paramTypeName
     	                            + " * Value"
     	                            + 0);
+                    	System.out.println("Case 2");
                     }
                     else
                     {

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java?rev=354322&r1=354321&r2=354322&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java
(original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java
Mon Dec  5 21:35:12 2005
@@ -165,6 +165,8 @@
                         + CUtils.CPP_HEADER_SUFFIX + "\"\n\n");
             }
             writer.write("#include <axis/AxisWrapperAPI.hpp>\n");
+            writer.write ("#include <axis/Axis.hpp>\n\n");
+            
             writer.write("#include <string.h>\n\n"); // for memcpy
             writer.write("using namespace std;\n\n ");
 
@@ -248,15 +250,20 @@
         }
         else
         {
-            if (returntypeisarray || (returntypeissimple && returntype.isNillable()
-                    && !(CUtils.isPointerType(outparamTypeName))))
-            {
-                writer.write(outparamTypeName + " *");
-            }
-            else
-            {
-                writer.write(outparamTypeName);
-            }
+        	if (returntypeissimple
+                    && (!(returntype.isNillable() || returntype.isOptional()) ||
CUtils
+                            .isPointerType(outparamTypeName)))
+        	{
+	        writer.write (outparamTypeName);
+        	}
+        	else if (outparamTypeName.lastIndexOf ("*") > 0)
+    	    {
+    	        writer.write (outparamTypeName);
+    	    }
+    	    else
+    	    {			//for AnyType too
+    	        writer.write (outparamTypeName + "*");
+    	    }
 
             if (WSDL2Ws.verbose)
             {
@@ -276,15 +283,20 @@
                 writer.write(", ");
             }
             typeissimple = CUtils.isSimpleType(paramTypeName);
-            if (typeissimple && ((ParameterInfo) paramsB.get(i)).isNillable()
-                    && !(CUtils.isPointerType(paramTypeName)))
-            {
-                writer.write(paramTypeName + " * Value" + i);
-            }
-            else
-            {
-                writer.write(paramTypeName + " Value" + i);
-            }
+            if (typeissimple
+        		    && (!(((ParameterInfo) paramsB.get (0)).isNillable () || ((ParameterInfo)
paramsB.get (0)).isOptional())
+        			|| CUtils.isPointerType(paramTypeName)))
+        	{
+        		writer.write (paramTypeName + " Value0");
+        	}
+        	else if (paramTypeName.lastIndexOf ("*") > 0)
+        	{
+        		writer.write (paramTypeName + " Value0");
+        	}
+        	else
+        	{			//for AnyType too
+        		writer.write (paramTypeName + "* Value0");
+        	}
         }
         // Multiples parameters so fill the methods prototype
         ArrayList paramsC = (ArrayList) minfo.getOutputParameterTypes();
@@ -329,7 +341,7 @@
                     else if (outparamTypeName.equals("xsd__string"))
                     {
                         writer.write(outparamTypeName + " Ret;\n");
-                        writer.write("\t"+ outparamTypeName + "=0;\n");
+                        writer.write("\tRet = 0;\n");
                     }
                     else
                     {
@@ -524,60 +536,140 @@
                     if (CUtils.isSimpleType(qname))
                     {
                         containedType = CUtils.getclass4qname(qname);
-                        writer.write("\t\t\t\t" + currentParamName + " = ("
-                                + currentParaType + "&)m_pCall->getBasicArray("
-                                + CUtils.getXSDTypeForBasicType(containedType)
-                                + ", \"" + currentType.getParamName()
-                                + "\", 0);\n");
+                        writer.write("\n\t\t\tAxis_Array * pReturn" + i + " = m_pCall->getBasicArray("
+ CUtils.getXSDTypeForBasicType (containedType) 
+            					+ ", \"" + currentType.getParamName ()
+            					+ "\", 0);\n\n");
+            			writer.write("\t\t\tif( pReturn" + i + " != NULL && OutValue" + i
+ " != NULL)\n");
+            			writer.write("\t\t\t{\n");
+            			writer.write("\t\t\t\tif( *OutValue" + i + " == NULL)\n");
+            			writer.write("\t\t\t\t{\n");
+            			writer.write("\t\t\t\t\t*OutValue" + i + " = new " + currentParaType 
+            					+ "();\n");
+            			writer.write("\t\t\t\t}\n");
+            			writer.write("\t\t\t\telse\n");
+            			writer.write("\t\t\t\t{\n");
+            			writer.write("\t\t\t\t\t(*OutValue" + i + ")->clear();\n");
+            			writer.write("\t\t\t\t}\n\n");
+            			writer.write("\t\t\t\t(*OutValue" + i + ")->clone(*pReturn" + i + ");\n");
+            			writer.write("\t\t\t}\n\n");
+            			writer.write("\t\t\tAxis::AxisDelete( (void *) pReturn" + i + ", XSD_ARRAY);\n");
                     }
                     else
                     {
                         containedType = qname.getLocalPart();
-                        writer
-                                .write("\t\t\t\t"
-                                        + currentParamName
-                                        + " = ("
-                                        + currentParaType
-                                        + "&)m_pCall->getCmplxArray((void*) Axis_DeSerialize_"
-                                        + containedType);
-                        writer.write("\t\t\t\t, (void*) Axis_Create_"
-                                + containedType + ", (void*) Axis_Delete_"
-                                + containedType + ", (void*) Axis_GetSize_"
-                                + containedType + ", \""
-                                + currentType.getParamName() + "\", Axis_URI_"
-                                + containedType + ");\n");
+                        writer.write("\n\t\t\tif (OutValue" + i + " != NULL)\n" );
+        			    writer.write("\t\t\t{\n");
+        			    writer.write("\t\t\t\tif (" + currentParamName + " == NULL)\n");
+        			    writer.write("\t\t\t\t{\n");
+        			    writer.write("\t\t\t\t\t" + currentParamName + " = new " + containedType +
"_Array();\n");
+        			    writer.write("\t\t\t\t}\n");
+        			    writer.write("\t\t\t\telse\n");
+        			    writer.write("\t\t\t\t{\n");
+        			    writer.write("\t\t\t\t\t(" + currentParamName + ")->clear();\n");
+        			    writer.write("\t\t\t\t}\n");
+        			    writer.
+        				write
+        				("\t\t\t\tm_pCall->getCmplxArray(" + currentParamName + ", (void*) Axis_DeSerialize_"
+        				 + containedType);
+        			    //writer.write(", (void*) Axis_Create_"+containedType+", (void*) Axis_Delete_"+containedType+",
(void*) Axis_GetSize_"+containedType+", \""+currentType.getElementName().getLocalPart()+"\",
Axis_URI_"+containedType+");\n");
+        			    writer.write (", (void*) Axis_Create_"
+        					  + containedType
+        					  + ", (void*) Axis_Delete_"
+        					  + containedType
+        					  + ", (void*) Axis_GetSize_"
+        					  + containedType
+        					  + ", \""
+        					  +
+        					  currentType.
+        					  getElementNameAsString () +
+        					  "\", Axis_URI_" + containedType +
+        					  ");\n");
+        			    writer.write("\t\t\t}\n");
+        			    writer.write("\t\t\telse\n");
+        			    writer.write("\t\t\t{\n");
+        			    writer.write("\t\t\t\t// Unable to return value, but will deserialize to ensure
subsequent elements can be correctly processed.\n");
+        				writer.write("\t\t\t\t" + containedType + "_Array * pTemp" + i + " = new " +
containedType + "_Array();\n");
+        				writer.write("\t\t\t\tm_pCall->getCmplxArray(pTemp" + i + ", (void*) Axis_DeSerialize_"
+        						 + containedType);
+        			    writer.write (", (void*) Axis_Create_"
+        					  + containedType
+        					  + ", (void*) Axis_Delete_"
+        					  + containedType
+        					  + ", (void*) Axis_GetSize_"
+        					  + containedType
+        					  + ", \""
+        					  +
+        					  currentType.
+        					  getElementNameAsString () +
+        					  "\", Axis_URI_" + containedType +
+        					  ");\n");
+        				writer.write("\t\t\t\tdelete pTemp" + i + ";\n");
+        				writer.write("\t\t\t}\n");
                     }
                 }
                 else
                 {
                     if (typeissimple)
                     {
-                        //Chinthana:
-                        //Changes have done for handle AXIS_OUT_PARAM Types.
-                        if (CUtils.isPointerType(currentParaType))
-                        {
-                            writer.write("\t\t\t\t"
-                                    + currentParamName
-                                    + " = m_pCall->"
-                                    + CUtils.getParameterGetValueMethodName(
-                                            currentParaType, false) + "(\""
-                                    + currentType.getParamName() + "\", 0);\n");
-                        }
-                        else
-                        {
-                            writer
-                                    .write("\t\t\t\t"
-                                            + currentParamName
-                                            + " = *(m_pCall->"
-                                            + CUtils
-                                                    .getParameterGetValueMethodName(
-                                                            currentParaType,
-                                                            false) + "(\""
-                                            + currentType.getParamName()
-                                            + "\", 0));\n");
-                        }
-                        //02/06/2006.....................................................
-                    }
+                    	if( i > 0)
+        		        {
+        				    writer.write( "\n");
+        		        }
+        		        
+        				if (CUtils.isPointerType(currentParaType))
+        				{
+        				    String xsdType =  WrapperUtils.getClassNameFromParamInfoConsideringArrays
((ParameterInfo) paramsC.get (i), wscontext);
+        				    
+        				    if( !CUtils.isPointerType(xsdType))
+        				    {
+        				        xsdType += " *";
+        				    }
+        				    
+        				    writer.write( "\t\t\t" + currentParaType + " pReturn" + i + " = m_pCall->"
+ CUtils.getParameterGetValueMethodName( currentParaType, false) + "( \"" + currentType.getParamName()
+ "\", 0);\n");
+        				    writer.write( "\n");
+        				    writer.write( "\t\t\tif( pReturn" + i + " != NULL && OutValue" +
i + " != NULL)\n");
+        				    writer.write( "\t\t\t\t{\n");
+        				    writer.write( "\t\t\t\tif( *OutValue" + i + " != NULL)\n");
+        				    writer.write( "\t\t\t\t{\n");
+        				    writer.write( "\t\t\t\t\tint\tiStringSize" + i + " = strlen( (char *) *OutValue"
+ i + ");\n");
+        				    writer.write( "\t\t\t\t\tint\tiStrLenValue" + i + " = strlen( pReturn" +
i + ");\n");
+        				    writer.write( "\n");
+        				    writer.write( "\t\t\t\t\tif( iStrLenValue" + i + " > iStringSize" + i
+ ")\n");
+        				    writer.write( "\t\t\t\t\t{\n");
+        				    writer.write( "\t\t\t\t\t\t*OutValue" + i + " =(" + xsdType + ") new char[iStrLenValue"
+ i + " + 1];\n");
+        				    writer.write( "\t\t\t\t\t\tstrcpy( (char *) *OutValue" + i + ", pReturn"
+ i + ");\n");
+        				    writer.write( "\t\t\t\t\t}\n");
+        				    writer.write( "\t\t\t\t\telse\n");
+        				    writer.write( "\t\t\t\t\t{\n");
+        				    writer.write( "\t\t\t\t\t\tstrcpy( (char *) *OutValue" + i + ", pReturn"
+ i + ");\n");
+        				    writer.write( "\t\t\t\t\t}\n");
+        				    writer.write( "\t\t\t\t}\n");
+        				    writer.write( "\t\t\t\telse\n");
+        				    writer.write( "\t\t\t\t{\n");
+        				    writer.write( "\t\t\t\t\t*OutValue" + i + " = (" + xsdType + ") new char[strlen(
pReturn" + i + ") + 1];\n");
+        				    writer.write( "\t\t\t\t\tstrcpy( (char *) *OutValue" + i + ", pReturn" +
i + ");\n");
+        				    writer.write( "\t\t\t\t}\n");
+        				    writer.write( "\t\t\t}\n");
+        				    writer.write( "\n");
+        				    writer.write( "\t\t\tAxis::AxisDelete( (void *) pReturn" + i + ", " + CUtils.getXSDTypeForBasicType(
currentParaType) + ");\n");
+        				}
+        				else 
+        				{
+        				    writer.write( "\t\t\t" + currentParaType + " * pReturn" + i + " = m_pCall->"
+ CUtils.getParameterGetValueMethodName( currentParaType, false) + "( \"" + currentType.getParamName()
+ "\", 0);\n");
+        				    writer.write( "\n");
+        				    writer.write( "\t\t\tif( pReturn" + i + " != NULL && OutValue" +
i + " != NULL)\n");
+        				    writer.write( "\t\t\t{\n");
+        				    writer.write( "\t\t\t\tif( *OutValue" + i + " == NULL)\n");
+        				    writer.write( "\t\t\t\t{\n");
+        				    writer.write( "\t\t\t\t\t*OutValue" + i + " = new " + currentParaType + "();\n");
+        				    writer.write( "\t\t\t\t}\n");
+        				    writer.write( "\n");
+        				    writer.write( "\t\t\t**OutValue" + i + " = *pReturn" + i + ";\n");
+        				    writer.write( "\t\t\t}\n");
+        				    writer.write( "\n");
+        				    writer.write( "\t\t\tAxis::AxisDelete( (void *) pReturn" + i + ", " + CUtils.getXSDTypeForBasicType(
currentParaType) + ");\n");
+        				}
+        			}
                     else
                     {
                         writer
@@ -617,13 +709,13 @@
                         + "m_pCall->getBasicArray("
                         + CUtils.getXSDTypeForBasicType(containedType) + ", \""
                         + returntype.getParamName() + "\", 0);\n");
-                writer.write ("\t\t\t\tRetArray.clone(*RetAxisArray);\n\t\t\t}\n");
+                writer.write ("\t\t\t\tRetArray->clone(*RetAxisArray);\n");
             }
             else
             {
                 containedType = qname.getLocalPart();
                 writer.write("\t\t\t\tAxis_Array * RetAxisArray = "
-                        + "m_pCall->getCmplxArray((void*) Axis_DeSerialize_"
+                        + "m_pCall->getCmplxArray(RetArray, (void*) Axis_DeSerialize_"
                         + containedType);
                 //damitha
                 writer.write(", (void*) Axis_Create_" + containedType
@@ -632,7 +724,7 @@
                         + returntype.getParamName() + "\", Axis_URI_"
                         + containedType + ");\n");
                 writer.write("\t\t\tRetArray->clone(*(" + containedType + "_Array *)RetAxisArray);\n");
-				writer.write("\t\t\t((" + containedType + "_Array *)RetAxisArray)->clear();\n");
+				
             }
             
             writer.write ("\t\t\t\tAxis::AxisDelete( (void *)RetAxisArray, XSD_ARRAY);\n\t\t\t}\n");

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/WrapWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/WrapWriter.java?rev=354322&r1=354321&r2=354322&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/WrapWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/WrapWriter.java Mon
Dec  5 21:35:12 2005
@@ -395,11 +395,11 @@
                                 + i
                                 + " = ("
                                 + CUtils.getBasicArrayNameforType(containedType)
-                                + "&)pIWSDZ->getBasicArray("
+                                + "&)*(pIWSDZ->getBasicArray("
                                 + CUtils.getXSDTypeForBasicType(containedType)
                                 + ", \""
                                 + parameterName
-                                + "\",0);\n");
+                                + "\",0));\n");
                     }
                     else
                     {



Mime
View raw message