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 na...@apache.org on 2006/04/08 05:52:36 UTC
svn commit: r392478 - in
/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c:
AllParamWriter.java ArrayParamHeaderWriter.java ArrayParamWriter.java
Author: nadiramra
Date: Fri Apr 7 20:52:34 2006
New Revision: 392478
URL: http://svn.apache.org/viewcvs?rev=392478&view=rev
Log:
C support fixes/enhancements.
Added:
webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ArrayParamHeaderWriter.java
Modified:
webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/AllParamWriter.java
webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ArrayParamWriter.java
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/AllParamWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/AllParamWriter.java?rev=392478&r1=392477&r2=392478&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/AllParamWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/AllParamWriter.java Fri Apr 7 20:52:34 2006
@@ -66,7 +66,34 @@
{
if (WSDL2Ws.verbose)
System.out.println("Array writer called ......");
- (new ArrayParamWriter(wscontext, type)).writeSource();
+
+ QName qname = type.getName();
+
+ String elementType = type.getElementType();
+ if (elementType != null)
+ {
+ elementType = elementType.replace('>', '_');
+ QName elementQname = new QName(qname.getNamespaceURI(), elementType);
+
+ Type currentType = wscontext.getTypemap().getType(elementQname);
+ if (currentType != null)
+ if ( currentType.isSimpleType())
+ continue;
+ }
+
+ if (CUtils.isSimpleType(qname) && !CUtils.isDefinedSimpleType(qname))
+ {
+ throw new WrapperFault(
+ "No need to create an Array for simple type " + qname + "\n"
+ + "It seems that some thing wrong with symbolTable population");
+ }
+
+ ArrayParamHeaderWriter writer = (new ArrayParamHeaderWriter(wscontext, type));
+ if (!writer.isSimpleTypeArray())
+ {
+ writer.writeSource();
+ (new ArrayParamWriter(wscontext, type)).writeSource();
+ }
}
/* TODO check whether this type is referenced or not. Synthesize only if reference
* But of course that depends on the commandline option too */
Added: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ArrayParamHeaderWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ArrayParamHeaderWriter.java?rev=392478&view=auto
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ArrayParamHeaderWriter.java (added)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ArrayParamHeaderWriter.java Fri Apr 7 20:52:34 2006
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2003-2004 The Apache Software Foundation.
+// (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Srinath Perera(hemapani@openource.lk)
+ * @author Susantha Kumara(susantha@opensource.lk, skumara@virtusa.com)
+ * @author Samisa Abeysinghe (sabeysinghe@virtusa.com)
+ */
+
+package org.apache.axis.wsdl.wsdl2ws.c;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis.wsdl.wsdl2ws.CUtils;
+import org.apache.axis.wsdl.wsdl2ws.ParamWriter;
+import org.apache.axis.wsdl.wsdl2ws.WSDL2Ws;
+import org.apache.axis.wsdl.wsdl2ws.WrapperFault;
+import org.apache.axis.wsdl.wsdl2ws.WrapperUtils;
+import org.apache.axis.wsdl.wsdl2ws.info.Type;
+import org.apache.axis.wsdl.wsdl2ws.info.WebServiceContext;
+
+public class ArrayParamHeaderWriter extends ParamWriter
+{
+ public ArrayParamHeaderWriter(WebServiceContext wscontext, Type type)
+ throws WrapperFault
+ {
+ super(wscontext, type);
+ }
+
+ public void writeSource() throws WrapperFault
+ {
+ try
+ {
+ this.writer = new BufferedWriter(new FileWriter(getFilePath(), false));
+ writeClassComment();
+
+ this.writer.write("#if !defined(__" + classname.toUpperCase() + "_H__INCLUDED_)\n");
+ this.writer.write("#define __" + classname.toUpperCase() + "_H__INCLUDED_\n\n");
+
+ if (attribs.length != 1)
+ {
+ System.out.println("Array " + classname + " contains unexpected no of variables");
+ throw new WrapperFault("Array type " + classname + " contain unexpected no of types");
+ }
+
+ writer.write("#include <axis/AxisUserAPI.h>\n\n");
+
+ //include header file for the contained type
+ QName qname = WrapperUtils.getArrayType(type).getName();
+ if (!CUtils.isSimpleType(qname))
+ writer.write("#include \"" + attribs[0].getTypeName() + CUtils.C_HEADER_SUFFIX + "\"\n");
+ this.writer.write("\n");
+
+ writeArrayClassDefinition();
+
+ this.writer.write("\n");
+ this.writer.write("#endif /* !defined(__" + classname.toUpperCase() + "_H__INCLUDED_)*/\n");
+
+ writer.flush();
+ writer.close();
+ if (WSDL2Ws.verbose)
+ System.out.println(getFilePath().getAbsolutePath() + " created.....");
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ throw new WrapperFault(e);
+ }
+ }
+
+ public boolean isSimpleTypeArray() throws WrapperFault
+ {
+ QName qname = WrapperUtils.getArrayType(type).getName();
+ return CUtils.isSimpleType(qname);
+ }
+
+ protected File getFilePath() throws WrapperFault
+ {
+ return this.getFilePath(false);
+ }
+
+ protected File getFilePath(boolean useServiceName) throws WrapperFault
+ {
+ String targetOutputLocation = this.wscontext.getWrapInfo().getTargetOutputLocation();
+ if (targetOutputLocation.endsWith("/"))
+ targetOutputLocation = targetOutputLocation.substring(0,targetOutputLocation.length() - 1);
+
+ new File(targetOutputLocation).mkdirs();
+
+ String fileName = targetOutputLocation + "/" + classname + CUtils.C_HEADER_SUFFIX;
+
+ if (useServiceName)
+ {
+ fileName = targetOutputLocation + "/"
+ + this.wscontext.getSerInfo().getServicename()
+ + "_" + classname + CUtils.C_HEADER_SUFFIX;
+ }
+
+ return new File(fileName);
+ }
+
+ protected void writeArrayClassDefinition() throws WrapperFault
+ {
+ try
+ {
+ writer.write("typedef struct " + classname + "Tag {\n");
+ writer.write("\tstruct " + attribs[0].getTypeName()
+ + "Tag ** m_Array;\n\tint m_Size;\n\tAXISC_XSDTYPE m_Type;\n} "
+ + classname + ";\n");
+ writer.write("\n");
+ this.writeConstructors();
+ this.writeDestructors();
+ }
+ catch (IOException e)
+ {
+ throw new WrapperFault(e);
+ }
+ }
+
+ protected void writeConstructors() throws WrapperFault
+ {
+ try
+ {
+ this.writer.write("extern void* Axis_Create_" + classname + "(int nSize);\n");
+ }
+ catch (IOException e)
+ {
+ throw new WrapperFault(e);
+ }
+
+ }
+
+ protected void writeDestructors() throws WrapperFault
+ {
+ try
+ {
+ this.writer.write("extern void Axis_Delete_" + classname
+ + "(" + classname + "* param);\n");
+ }
+ catch (IOException e)
+ {
+ throw new WrapperFault(e);
+ }
+ }
+
+ protected void writeMethods() throws WrapperFault
+ {
+ }
+
+ protected String getFileType()
+ {
+ return "Array";
+ }
+}
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ArrayParamWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ArrayParamWriter.java?rev=392478&r1=392477&r2=392478&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ArrayParamWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ArrayParamWriter.java Fri Apr 7 20:52:34 2006
@@ -51,16 +51,6 @@
super(wscontext, type);
}
- /**
- * @return
- * @throws WrapperFault
- */
- public boolean isSimpleTypeArray() throws WrapperFault
- {
- QName qname = WrapperUtils.getArrayType(type).getName();
- return CUtils.isSimpleType(qname);
- }
-
/* (non-Javadoc)
* @see org.apache.axis.wsdl.wsdl2ws.SourceWriter#writeSource()
*/
@@ -69,28 +59,14 @@
try
{
this.writer = new BufferedWriter(new FileWriter(getFilePath(), false));
- writeClassComment();
- // if this headerfile not defined define it
- this.writer.write("#if !defined(__" + classname.toUpperCase() + "_"
- + getFileType().toUpperCase() + "_H__INCLUDED_)\n");
- this.writer.write("#define __" + classname.toUpperCase() + "_"
- + getFileType().toUpperCase() + "_H__INCLUDED_\n\n");
- if (attribs.length != 1)
- {
- System.out.println("Array " + classname + " contains unexpected no of variables");
- throw new WrapperFault("Array type " + classname + " contain unexpected no of types");
- }
-
- //include header file for the contained type
- QName qname = WrapperUtils.getArrayType(type).getName();
- if (!CUtils.isSimpleType(qname))
- writer.write("#include \"" + attribs[0].getTypeName() + CUtils.C_HEADER_SUFFIX + "\"\n\n");
- else
- writer.write("#include <axis/server/AxisUserAPI.h>\n\n");
-
- writeArrayStruct();
- this.writer.write("#endif /* !defined(__" + classname.toUpperCase() + "_"
- + getFileType().toUpperCase() + "_H__INCLUDED_)*/\n");
+
+ writeClassComment();
+
+ writer.write("#include \"" + classname + ".h\"\n");
+ writer.write("\n");
+
+ this.writeMethods();
+
writer.flush();
writer.close();
if (WSDL2Ws.verbose)
@@ -102,90 +78,126 @@
throw new WrapperFault(e);
}
}
-
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#getFilePath()
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeMethods()
*/
- protected File getFilePath() throws WrapperFault
+ protected void writeMethods() throws WrapperFault
{
- return this.getFilePath(false);
+ this.writeConstructors();
+ this.writeDestructors();
+ this.writeSetMethod();
+ this.writeGetMethod();
+ this.writeCloneMethod();
+ this.writeClearMethod();
}
- /* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#getFilePath(boolean)
+ /**
+ * @throws WrapperFault
+ *
*/
- protected File getFilePath(boolean useServiceName) throws WrapperFault
+ protected void writeClearMethod() throws WrapperFault
+ {}
+
+ /**
+ * @throws IOException
+ */
+ protected void writeCloneMethod() throws WrapperFault
+ { }
+
+ /**
+ * @throws IOException
+ */
+ protected void writeGetMethod() throws WrapperFault
+ {}
+
+ /**
+ * @throws IOException
+ */
+ protected void writeSetMethod() throws WrapperFault
+ {}
+
+ protected void writeConstructors() throws WrapperFault
{
- String targetOutputLocation =
- this.wscontext.getWrapInfo().getTargetOutputLocation();
- if (targetOutputLocation.endsWith("/"))
- targetOutputLocation = targetOutputLocation.substring(0,targetOutputLocation.length() - 1);
-
- new File(targetOutputLocation).mkdirs();
+ try
+ {
+ writer.write("extern void* Axis_Create_" + classname + "(int nSize)\n");
+ writer.write("{\n");
- String fileName = targetOutputLocation + "/" + classname + CUtils.C_HEADER_SUFFIX;
+// writer.write("\tm_Type = USER_TYPE;\n");
+
+ writer.write("\treturn NULL;");
- if (useServiceName)
+ writer.write("}\n");
+ writer.write("\n");
+ }
+ catch (IOException e)
{
- fileName = targetOutputLocation + "/" + this.wscontext.getSerInfo().getServicename()
- + "_" + classname + CUtils.C_HEADER_SUFFIX;
+ throw new WrapperFault(e);
}
-
- return new File(fileName);
+
}
-
- /**
- * @throws WrapperFault
- */
- protected void writeArrayStruct() throws WrapperFault
+
+ protected void writeDestructors() throws WrapperFault
{
try
{
- writer.write("typedef struct " + classname + "Tag\n{\n");
- /*
- * Needed for self referenced array else compilation failed.
- * <xsd:complexType name="Type1">
- * <xsd:sequence>
- * <xsd:element name="followings" maxOccurs="unbounded" minOccurs="0" type="tns:Type1" />
- * <xsd:element name="kind" type="xsd:string" />
- * <xsd:element name="index" type="xsd:int" />
- * </xsd:sequence>
- * <xsd:attribute name="att_kind" type="tns:Kind" />
- * </xsd:complexType>
- */
- writer.write("\tstruct " + attribs[0].getTypeName()
- + "Tag ** m_Array;\n\tint m_Size;\n\tAXISC_XSDTYPE m_Type;\n} "
- + classname + ";\n\n");
+ this.writer.write("extern void Axis_Delete_" + classname
+ + "(" + classname + "* param)\n");
+ writer.write("{\n");
+
+ writer.write("\tif (m_Array != NULL)\n");
+ writer.write("\t{\n");
+ writer.write("\t\tif (m_Size > 0)\n");
+ writer.write("\t\t{\n");
+ writer.write("\t\t\tfor (int count = 0 ; count < m_Size ; count++)\n");
+ writer.write("\t\t\t{\n");
+ writer.write("\t\t\t\tif (m_Array[count] != NULL)\n");
+ writer.write("\t\t\t\t{\n");
+ writer.write("\t\t\t\t\tdelete ((" + attribs[0].getTypeName() + "**) m_Array)[count];\n");
+ writer.write("\t\t\t\t\tm_Array[count] = NULL;\n");
+ writer.write("\t\t\t\t}\n");
+ writer.write("\t\t\t}\n");
+ writer.write("\t\t}\n");
+ writer.write("\t\t\tdelete [] m_Array;\n");
+ writer.write("\t}\n");
+
+ writer.write("}\n");
+ writer.write("\n");
}
catch (IOException e)
{
throw new WrapperFault(e);
}
}
-
+
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeConstructors()
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#getFilePath()
*/
- protected void writeConstructors() throws WrapperFault
- {}
+ protected File getFilePath() throws WrapperFault
+ {
+ return this.getFilePath(false);
+ }
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeDestructors()
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#getFilePath(boolean)
*/
- protected void writeDestructors() throws WrapperFault
- {}
+ protected File getFilePath(boolean useServiceName) throws WrapperFault
+ {
+ String targetOutputLocation = this.wscontext.getWrapInfo().getTargetOutputLocation();
+ if (targetOutputLocation.endsWith("/"))
+ targetOutputLocation = targetOutputLocation.substring(0,targetOutputLocation.length() - 1);
- /* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeMethods()
- */
- protected void writeMethods() throws WrapperFault
- {}
+ new File(targetOutputLocation).mkdirs();
- /**
- * @return
- */
- protected String getFileType()
- {
- return "Array";
+ String fileName = targetOutputLocation + "/" + classname + CUtils.C_FILE_SUFFIX;
+
+ if (useServiceName)
+ {
+ fileName = targetOutputLocation + "/"
+ + this.wscontext.getSerInfo().getServicename()
+ + "_" + classname + CUtils.C_HEADER_SUFFIX;
+ }
+
+ return new File(fileName);
}
}