axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nadira...@apache.org
Subject svn commit: r660678 - in /webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws: c/BeanParamWriter.java cpp/BeanParamWriter.java
Date Tue, 27 May 2008 20:00:52 GMT
Author: nadiramra
Date: Tue May 27 13:00:48 2008
New Revision: 660678

URL: http://svn.apache.org/viewvc?rev=660678&view=rev
Log:
AXISCPP-540 - remove duplication, simplify

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

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/BeanParamWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/BeanParamWriter.java?rev=660678&r1=660677&r2=660678&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/BeanParamWriter.java
(original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/BeanParamWriter.java
Tue May 27 13:00:48 2008
@@ -224,6 +224,7 @@
                 namespace = "Axis_URI_" + classname;
             
             // if the attribute is a choice following should do
+            boolean ifCheckPrinted = false;
             if (attribs[i].getChoiceElement())
             {
                 if (!firstIfWritten)
@@ -234,13 +235,17 @@
                 else
                     writer.write("\telse if");
 
+                ifCheckPrinted = true;
                 writer.write("(param->" + attribs[i].getParamNameAsMember() + ")\n\t{\n\t");
             }
  
             //if the attribute is a 'all' following should do
             if (attribs[i].getAllElement())
                 if (attribs[i].getMinOccurs() == 0)
+                {
+                    ifCheckPrinted = true;
                     writer.write("\tif(param->" + attribs[i].getParamNameAsMember() +
")\n\t{\n\t");
+                }
              
             if (attribs[i].isAnyType())
             {
@@ -291,92 +296,66 @@
                 else
                     baseTypeName = typeName;
                 
-                if (attribs[i].isOptional())
+                if (!ifCheckPrinted && attribs[i].isOptional())
                     writer.write("\tif (param->" + attribs[i].getParamNameAsMember() +
" != NULL)\n\t");
                 
-                if (CUtils.isPointerType(baseTypeName))
-                {
-                    writer.write("\taxiscSoapSerializerSerializeAsElement(pSZ, \""
-                            + attribs[i].getElementNameAsSOAPString()
-                            + "\", " + namespace
-                            + ", (void*)(param->" + attribs[i].getParamNameAsMember()
+ "), "
-                            + CUtils.getXSDTypeForBasicType(baseTypeName) + ");\n");
-                }
-                else if (attribs[i].getChoiceElement()
+                // If the simple type is a choice it is handled
+                // as a pointer variable.  This is the same in 'all' element and nillable
elements.
+                String ampersand = "&";
+                if (CUtils.isPointerType(baseTypeName)
+                            || attribs[i].getChoiceElement()
                             || attribs[i].getAllElement()
                             || isElementNillable(i) || isElementOptional(i))
-                {
-                    // If the simple type is a choice it is handled
-                    // as a pointer variable. These variables should be defined
-                    // as pointers in the header file. This is the same in 'all' element
-                    
-                    if (((attribs[i].getChoiceElement())
-                            && (isElementNillable(i)))
-                            && !(CUtils.isPointerType(attribs[i].getTypeName()))
)
-                    {
-                        writer.write("\t\taxiscSoapSerializerSerializeAsElement(pSZ, \""
-                                + attribs[i].getElementNameAsSOAPString() + "\", " + namespace
-                                + ", (void*)(*(param->" + attribs[i].getParamNameAsMember()
-                                + ")), " + CUtils.getXSDTypeForBasicType(baseTypeName) +
");\n");
-                    }
-                    else
-                    {
-                        writer.write("\t\taxiscSoapSerializerSerializeAsElement(pSZ, \""
-                                + attribs[i].getElementNameAsSOAPString() + "\", " + namespace
-                                + ", (void*)(param->" + attribs[i].getParamNameAsMember()
-                                + "), " + CUtils.getXSDTypeForBasicType(baseTypeName) + ");\n");
-                    }    
-                }                           
-                else
-                {
-                    writer.write("\taxiscSoapSerializerSerializeAsElement(pSZ, \""
-                            + attribs[i].getElementNameAsSOAPString() + "\", " + namespace
-                            + ", (void*)&(param->" + attribs[i].getParamNameAsMember()
-                            + "), " + CUtils.getXSDTypeForBasicType(baseTypeName) + ");\n");
-                }
+                    ampersand = "";
+                
+                writer.write("\taxiscSoapSerializerSerializeAsElement(pSZ, \""
+                        + attribs[i].getElementNameAsSOAPString() + "\", " + namespace
+                        + ", (void*)" + ampersand + "(param->" + attribs[i].getParamNameAsMember()
+ "), "
+                        + CUtils.getXSDTypeForBasicType(baseTypeName) + ");\n");
             }
             else
             {
                 //if complex type
                 String elm = attribs[i].getParamNameAsSOAPString();
-
                 if (attribs[i].isReference())
                     elm = attribs[i].getTypeName();
                 
-                if (attribs[i].isOptional())
-                    writer.write("\tif (param->" + attribs[i].getParamNameAsMember() +
" != NULL)\n\t{\n");
+                String tab = "";
+                if (ifCheckPrinted)
+                    tab = "\t";
+                else if (attribs[i].isOptional())
+                {
+                    tab = "\t";
+                    writer.write("\tif (param->" + attribs[i].getParamNameAsMember() +
" != NULL)\n\t{\n\t");
+                }
                 
                 if (attribs[i].getNsQualified())
                 {
                     writer.write("\taxiscSoapSerializerSerialize(pSZ, \"<\", axiscSoapSerializerGetNamespacePrefix(pSZ,
\""
                                     + type.getName().getNamespaceURI()
                                     + "\", NULL), \":\", \"" + elm + "\", 0);\n");
-                    writer.write("\tAxis_Serialize_" + attribs[i].getTypeName()
+                    writer.write(tab + "\tAxis_Serialize_" + attribs[i].getTypeName()
                             + "(param->" + attribs[i].getParamNameAsMember() + ", pSZ,
0);\n");
-                    writer.write("\taxiscSoapSerializerSerialize(pSZ, \"</\", axiscSoapSerializerGetNamespacePrefix(pSZ,
\""
+                    writer.write(tab + "\taxiscSoapSerializerSerialize(pSZ, \"</\", axiscSoapSerializerGetNamespacePrefix(pSZ,
\""
                                     + type.getName().getNamespaceURI()
                                     + "\", NULL), \":\", \"" + elm + "\", \">\", 0);\n");
                 }
                 else
                 {
                     writer.write("\taxiscSoapSerializerSerialize(pSZ, \"<" + elm + "\",
0);\n");
-                    writer.write("\tAxis_Serialize_" + attribs[i].getTypeName()
+                    writer.write(tab + "\tAxis_Serialize_" + attribs[i].getTypeName()
                             + "(param->" + attribs[i].getParamNameAsMember() + ", pSZ,
0);\n");
-                    writer.write("\taxiscSoapSerializerSerialize(pSZ, \"</" + elm + "\",
\">\", 0);\n");
+                    writer.write(tab + "\taxiscSoapSerializerSerialize(pSZ, \"</" + elm
+ "\", \">\", 0);\n");
                 }
                 
-                if (attribs[i].isOptional())
+                if (!ifCheckPrinted && attribs[i].isOptional())
                     writer.write("\t}\n");
             }
 
             //end if choice element
 
-            if (attribs[i].getChoiceElement())
+            if (ifCheckPrinted)
                 writer.write("\t}\n");
-            
-            if (attribs[i].getAllElement())
-                if (attribs[i].getMinOccurs() == 0)
-                    writer.write("\t}\n");
         }
         
         //=============================================================================
@@ -500,8 +479,15 @@
             return;
         }  
         
-        // We always use this...
-        writer.write("\tconst char* peekedElementName;\n");
+        // Determine whether to print variable used for peaking ahead
+        for (int i = 0; i < attribs.length; i++)
+        {
+            if (attribs[i].isOptional() && !attribs[i].isAttribute())
+            {
+                writer.write("\tconst char* peekedElementName;\n");
+                break;
+            }
+        }
 
         //=============================================================================
         // Deserialize attributes.

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java?rev=660678&r1=660677&r2=660678&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
Tue May 27 13:00:48 2008
@@ -447,6 +447,7 @@
                 namespace = "Axis_URI_" + classname;
             
             // if the attribute is a choice following should do
+            boolean ifCheckPrinted = false;
             if (attribs[i].getChoiceElement())
             {
                 if (!firstIfWritten)
@@ -457,13 +458,17 @@
                 else
                     writer.write("\telse if");
 
+                ifCheckPrinted = true;
                 writer.write("(param->" + attribs[i].getParamNameAsMember() + ")\n\t{\n\t");
             }
  
             //if the attribute is a 'all' following should do
             if (attribs[i].getAllElement())
                 if (attribs[i].getMinOccurs() == 0)
+                {
+                    ifCheckPrinted = true;
                     writer.write("\tif(param->" + attribs[i].getParamNameAsMember() +
")\n\t{\n\t");
+                }
              
             if (attribs[i].isAnyType())
             {
@@ -513,49 +518,22 @@
                 else
                     baseTypeName = typeName;
                 
-                if (attribs[i].isOptional())
+                if (!ifCheckPrinted && attribs[i].isOptional())
                     writer.write("\tif (param->" + attribs[i].getParamNameAsMember() +
" != NULL)\n\t");
                 
-                if (CUtils.isPointerType(baseTypeName))
-                {
-                    writer.write("\tpSZ->serializeAsElement(\""
-                            + attribs[i].getElementNameAsSOAPString()
-                            + "\", " + namespace
-                            + ", (void*)(param->" + attribs[i].getParamNameAsMember()
+ "), "
-                            + CUtils.getXSDTypeForBasicType(baseTypeName) + ");\n");
-                }
-                else if (attribs[i].getChoiceElement()
+                // If the simple type is a choice it is handled
+                // as a pointer variable.  This is the same in 'all' element and nillable
elements.
+                String ampersand = "&";
+                if (CUtils.isPointerType(baseTypeName)
+                            || attribs[i].getChoiceElement()
                             || attribs[i].getAllElement()
                             || isElementNillable(i) || isElementOptional(i))
-                {
-                    // If the simple type is a choice it is handled
-                    // as a pointer variable. These variables should be defined
-                    // as pointers in the header file. This is the same in 'all' element
-                    
-                    if (((attribs[i].getChoiceElement())
-                            && (isElementNillable(i)))
-                            && !(CUtils.isPointerType(attribs[i].getTypeName()))
)
-                    {
-                        writer.write("\tpSZ->serializeAsElement(\""
-                                + attribs[i].getElementNameAsSOAPString() + "\", " + namespace
-                                + ", (void*)(*(param->" + attribs[i].getParamNameAsMember()
-                                + ")), " + CUtils.getXSDTypeForBasicType(baseTypeName) +
");\n");
-                    }
-                    else
-                    {
-                        writer.write("\tpSZ->serializeAsElement(\""
-                                + attribs[i].getElementNameAsSOAPString() + "\", " + namespace
-                                + ", (void*)(param->" + attribs[i].getParamNameAsMember()
-                                + "), " + CUtils.getXSDTypeForBasicType(baseTypeName) + ");\n");
-                    }    
-                }                           
-                else
-                {
-                    writer.write("\tpSZ->serializeAsElement(\""
-                            + attribs[i].getElementNameAsSOAPString() + "\", " + namespace
-                            + ", (void*)&(param->" + attribs[i].getParamNameAsMember()
-                            + "), " + CUtils.getXSDTypeForBasicType(baseTypeName) + ");\n");
-                }
+                    ampersand = "";
+
+                writer.write("\tpSZ->serializeAsElement(\""
+                        + attribs[i].getElementNameAsSOAPString() + "\", " + namespace
+                        + ", (void*)" + ampersand + "(param->" + attribs[i].getParamNameAsMember()
+ "), " 
+                        + CUtils.getXSDTypeForBasicType(baseTypeName) + ");\n");
             }
             else
             {
@@ -564,40 +542,42 @@
                 if (attribs[i].isReference())
                     elm = attribs[i].getTypeName();
                 
-                if (attribs[i].isOptional())
-                    writer.write("\tif (param->" + attribs[i].getParamNameAsMember() +
" != NULL)\n\t{\n");
+                String tab = "";
+                if (ifCheckPrinted)
+                    tab = "\t";
+                else if (attribs[i].isOptional())
+                {
+                    tab = "\t";
+                    writer.write("\tif (param->" + attribs[i].getParamNameAsMember() +
" != NULL)\n\t{\n\t");
+                }
                 
                 if (attribs[i].getNsQualified())
                 {
                     writer.write("\tpSZ->serialize(\"<\", pSZ->getNamespacePrefix(\""
                                     + type.getName().getNamespaceURI()
                                     + "\"), \":\", \"" + elm + "\", 0);\n");
-                    writer.write("\tAxis_Serialize_" + attribs[i].getTypeName()
+                    writer.write(tab + "\tAxis_Serialize_" + attribs[i].getTypeName()
                             + "(param->" + attribs[i].getParamNameAsMember() + ", pSZ);\n");
-                    writer.write("\tpSZ->serialize(\"</\", pSZ->getNamespacePrefix(\""
+                    writer.write(tab + "\tpSZ->serialize(\"</\", pSZ->getNamespacePrefix(\""
                                     + type.getName().getNamespaceURI()
                                     + "\"), \":\", \"" + elm + "\", \">\", 0);\n");
                 }
                 else
                 {
                     writer.write("\tpSZ->serialize(\"<" + elm + "\", 0);\n");
-                    writer.write("\tAxis_Serialize_" + attribs[i].getTypeName()
+                    writer.write(tab + "\tAxis_Serialize_" + attribs[i].getTypeName()
                             + "(param->" + attribs[i].getParamNameAsMember() + ", pSZ);\n");
-                    writer.write("\tpSZ->serialize(\"</" + elm + "\", \">\", 0);\n");
+                    writer.write(tab + "\tpSZ->serialize(\"</" + elm + "\", \">\",
0);\n");
                 }
                 
-                if (attribs[i].isOptional())
+                if (!ifCheckPrinted && attribs[i].isOptional())
                     writer.write("\t}\n");
             }
 
             //end if choice element
 
-            if (attribs[i].getChoiceElement())
+            if (ifCheckPrinted)
                 writer.write("\t}\n");
-            
-            if (attribs[i].getAllElement())
-                if (attribs[i].getMinOccurs() == 0)
-                    writer.write("\t}\n");
         }
 
         //=============================================================================
@@ -731,8 +711,15 @@
         }
 
         
-        // We always use this...
-        writer.write("\tconst char* peekedElementName;\n");
+        // Determine whether to print variable used for peaking ahead
+        for (int i = 0; i < attribs.length; i++)
+        {
+            if (attribs[i].isOptional() && !attribs[i].isAttribute())
+            {
+                writer.write("\tconst char* peekedElementName;\n");
+                break;
+            }
+        }
 
         //=============================================================================
         // Deserialize attributes.



Mime
View raw message