incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mvesc...@apache.org
Subject svn commit: r487237 - in /incubator/yoko/trunk/tools/src: main/java/org/apache/yoko/tools/processors/idl/ test/java/org/apache/yoko/tools/processors/
Date Thu, 14 Dec 2006 15:26:32 GMT
Author: mvescovi
Date: Thu Dec 14 07:26:31 2006
New Revision: 487237

URL: http://svn.apache.org/viewvc?view=rev&rev=487237
Log:
YOKO-249 Add support for typedef multiple declarators

Modified:
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/DeclaratorVisitor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ExceptionVisitor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/FixedVisitor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/Scope.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/SequenceVisitor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StringVisitor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StructVisitor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypedefVisitor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/UnionVisitor.java
    incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java?view=diff&rev=487237&r1=487236&r2=487237
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ArrayVisitor.java
Thu Dec 14 07:26:31 2006
@@ -34,7 +34,6 @@
 import org.apache.ws.commons.schema.XmlSchemaSequence;
 import org.apache.ws.commons.schema.XmlSchemaType;
 
-import org.apache.yoko.wsdl.CorbaConstants;
 import org.apache.yoko.wsdl.CorbaTypeImpl;
 
 public class ArrayVisitor extends VisitorBase {
@@ -57,10 +56,25 @@
     }
 
     public static boolean accept(AST node) {
-        if (node.getFirstChild() != null) {
-            return true;
+        boolean result = false;
+        AST sizeNode = node.getFirstChild();
+        if (sizeNode != null) {
+            // check that node has a fixed_array_size child node
+            result = true;
+            while (sizeNode != null
+                && result) {
+                // check that all fixed_array_size nodes encode
+                // positive integers
+                String s = sizeNode.toString();
+                for (int j = 0; j < s.length(); j++) {
+                    if (!Character.isDigit(s.charAt(j))) {
+                        result = false;
+                    }
+                }
+                sizeNode = sizeNode.getNextSibling();
+            }
         }
-        return false;
+        return result;
     }
 
     public void visit(AST node) {
@@ -177,9 +191,7 @@
         Array array = new Array();
         array.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
         array.setBound(size);
-        array.setRepositoryID(CorbaConstants.REPO_STRING
-                              + scopedName.toIDLRepositoryID()
-                              + CorbaConstants.IDL_VERSION);
+        array.setRepositoryID(scopedName.toIDLRepositoryID());
         array.setType(type);
         return array;
     }

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/DeclaratorVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/DeclaratorVisitor.java?view=diff&rev=487237&r1=487236&r2=487237
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/DeclaratorVisitor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/DeclaratorVisitor.java
Thu Dec 14 07:26:31 2006
@@ -19,14 +19,19 @@
 
 package org.apache.yoko.tools.processors.idl;
 
-//import javax.xml.namespace.QName;
+import javax.xml.namespace.QName;
 
 import antlr.collections.AST;
 
+import org.apache.schemas.yoko.bindings.corba.Alias;
+import org.apache.schemas.yoko.bindings.corba.Fixed;
+import org.apache.schemas.yoko.bindings.corba.Sequence;
 import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
 
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaSimpleType;
 import org.apache.ws.commons.schema.XmlSchemaType;
 
 import org.apache.yoko.wsdl.CorbaTypeImpl;
@@ -51,37 +56,6 @@
     }
     
     public void visit(AST node) {
-//        while (node != null) {
-//            // Need to make a copy of the schemaType and corbaType
-//            //XmlSchemaType stype = (XmlSchemaType) schemaType.clone();
-//
-//            // handle named or anonymous types
-//            String name = null;
-//            if (node == null) {
-//                // anonymous
-//                name = "_1_" + getScope().tail();
-//            } else {
-//                name = node.toString();
-//            }
-//
-//            // add schemaType
-//            schema.getItems().add(schemaType);
-//            schema.addType(schemaType);
-//            schemaType.setName(name);
-//            corbaType.setQName(new QName(typeMap.getTargetNamespace(), name));
-//
-//
-//            // add schemaType
-//            schema.getItems().add(schemaType);
-//            schema.addType(schemaType);
-//
-//
-//            // add corbaType
-//            typeMap.getStructOrExceptionOrUnion().add(corbaType);
-//
-//
-//            node = node.getNextSibling();
-//        }
     
         if (ArrayVisitor.accept(node)) {
             ArrayVisitor arrayVisitor = new ArrayVisitor(getScope(),
@@ -101,7 +75,111 @@
             // add corbaType
             typeMap.getStructOrExceptionOrUnion().add(getCorbaType());
         }
+        
+        AST nextDecl = node.getNextSibling(); 
+        while (nextDecl != null) {
+            Scope newScope = new Scope(getScope().getParent(), nextDecl);
+
+            if (ArrayVisitor.accept(nextDecl)) {
+                ArrayVisitor arrayVisitor = new ArrayVisitor(newScope,
+                                                             schemas,
+                                                             schema,
+                                                             typeMap,
+                                                             getSchemaType(),
+                                                             getCorbaType(),
+                                                             nextDecl); 
+                arrayVisitor.visit(nextDecl);
+
+            } else {
+                CorbaTypeImpl nextCorbaType = null;
+                XmlSchemaType nextSchemaType = null;
+
+                CorbaTypeImpl oldCorbaType = getCorbaType();
+
+                QName newQname = new QName(getCorbaType().getQName().getNamespaceURI(), newScope.toString());
+
+                if (oldCorbaType instanceof Alias) {
+                    // Alias
+                    //
+
+                    nextSchemaType = duplicateXmlSchemaSimpleType(newScope);
+
+                    Alias oldAlias = (Alias) oldCorbaType;
+                    Alias alias = new Alias();
+
+                    alias.setQName(newQname);
+                    alias.setBasetype(oldAlias.getBasetype());
+                    alias.setType(oldAlias.getType());
+                    alias.setRepositoryID(newScope.toIDLRepositoryID());
+
+                    nextCorbaType = alias;
+                } else if (oldCorbaType instanceof Sequence) {
+                    // Sequence
+                    //
+
+                    nextSchemaType = duplicateXmlSchemaComplexType(newScope);
+
+                    Sequence oldSequence = (Sequence) oldCorbaType;
+                    Sequence newSequence = new Sequence();
+
+                    newSequence.setQName(newQname);
+                    newSequence.setType(nextSchemaType.getQName());
+                    newSequence.setElemtype(oldSequence.getElemtype());
+                    newSequence.setBound(oldSequence.getBound());
+                    newSequence.setRepositoryID(newScope.toIDLRepositoryID());
+
+                    nextCorbaType = newSequence;
+                } else if (oldCorbaType instanceof Fixed) {
+                    // Fixed
+                    //
+
+                    nextSchemaType = duplicateXmlSchemaSimpleType(newScope);
+
+                    Fixed oldFixed = (Fixed) getCorbaType();
+                    Fixed newFixed = new Fixed();
+
+                    newFixed.setQName(newQname);
+                    newFixed.setDigits(oldFixed.getDigits());
+                    newFixed.setScale(oldFixed.getScale());
+                    newFixed.setType(oldFixed.getType());
+                    newFixed.setRepositoryID(newScope.toIDLRepositoryID());
+
+                    nextCorbaType = newFixed;
+                } else {
+                    System.err.println("[DeclaratorVisitor: Unexpected CORBA type error!]");
+                    System.exit(1);
+                }
+
+                if (nextCorbaType != null) {
+                    typeMap.getStructOrExceptionOrUnion().add(nextCorbaType);
+                }
+                if (nextSchemaType != null) {
+                    schema.getItems().add(nextSchemaType);
+                    schema.addType(nextSchemaType);                    
+                }
+            }
+            
+            nextDecl = nextDecl.getNextSibling();
+        }
+
+    }
+    
+    private XmlSchemaComplexType duplicateXmlSchemaComplexType(Scope newScope) {
+        XmlSchemaComplexType oldSchemaType = (XmlSchemaComplexType) getSchemaType();
+        XmlSchemaComplexType newSchemaType = new XmlSchemaComplexType(schema);
 
+        newSchemaType.setName(newScope.toString());
+        newSchemaType.setParticle(oldSchemaType.getParticle());
+
+        return newSchemaType;
+    }
+    
+    private XmlSchemaSimpleType duplicateXmlSchemaSimpleType(Scope newScope) {
+        XmlSchemaSimpleType oldSimpleType = (XmlSchemaSimpleType) getSchemaType();
+        XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema);
+        simpleType.setContent(oldSimpleType.getContent());
+        simpleType.setName(newScope.toString());
+        return simpleType;
     }
 
-}
\ No newline at end of file
+}

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java?view=diff&rev=487237&r1=487236&r2=487237
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/EnumVisitor.java
Thu Dec 14 07:26:31 2006
@@ -32,13 +32,9 @@
 import org.apache.ws.commons.schema.XmlSchemaEnumerationFacet;
 import org.apache.ws.commons.schema.XmlSchemaSimpleType;
 import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction;
-import org.apache.ws.commons.schema.XmlSchemaType;
 
 import org.apache.ws.commons.schema.constants.Constants;
 
-import org.apache.yoko.wsdl.CorbaConstants;
-import org.apache.yoko.wsdl.CorbaTypeImpl;
-
 public class EnumVisitor extends VisitorBase {
 
     public EnumVisitor(Scope scope,
@@ -77,9 +73,7 @@
         // corba:enum
         Enum corbaEnum = new Enum();
         corbaEnum.setQName(new QName(typeMap.getTargetNamespace(), enumNameScope.toString()));
-        corbaEnum.setRepositoryID(CorbaConstants.REPO_STRING
-                                  + enumNameScope.toIDLRepositoryID()
-                                  + CorbaConstants.IDL_VERSION);
+        corbaEnum.setRepositoryID(enumNameScope.toIDLRepositoryID());
         corbaEnum.setType(enumSchemaSimpleType.getQName());
         
         
@@ -98,16 +92,12 @@
             node = node.getNextSibling();
         }
         
-        XmlSchemaType schemaType = enumSchemaSimpleType;
-        CorbaTypeImpl corbaType = corbaEnum;
-        // declaration phase
-        DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(getScope(),
-                                                                    schemas,
-                                                                    schema,
-                                                                    typeMap,
-                                                                    schemaType,
-                                                                    corbaType);
-        declaratorVisitor.visit(enumNameNode);
+        // add schemaType
+        schema.getItems().add(enumSchemaSimpleType);
+        schema.addType(enumSchemaSimpleType);
+
+        // add corbaType
+        typeMap.getStructOrExceptionOrUnion().add(corbaEnum);
 
         // REVISIT: are there assignments needed?
         setSchemaType(enumSchemaSimpleType);

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ExceptionVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ExceptionVisitor.java?view=diff&rev=487237&r1=487236&r2=487237
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ExceptionVisitor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ExceptionVisitor.java
Thu Dec 14 07:26:31 2006
@@ -34,7 +34,6 @@
 import org.apache.ws.commons.schema.XmlSchemaSequence;
 import org.apache.ws.commons.schema.XmlSchemaType;
 
-import org.apache.yoko.wsdl.CorbaConstants;
 import org.apache.yoko.wsdl.CorbaTypeImpl;
 
 public class ExceptionVisitor extends VisitorBase {
@@ -95,9 +94,7 @@
         Exception exception = new Exception();
         exception.setQName(new QName(typeMap.getTargetNamespace(), exceptionName));
         exception.setType(complexType.getQName());
-        exception.setRepositoryID(CorbaConstants.REPO_STRING
-                               + scopedName.toIDLRepositoryID()
-                               + CorbaConstants.IDL_VERSION);
+        exception.setRepositoryID(scopedName.toIDLRepositoryID());
 
         
         // exception members

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/FixedVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/FixedVisitor.java?view=diff&rev=487237&r1=487236&r2=487237
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/FixedVisitor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/FixedVisitor.java
Thu Dec 14 07:26:31 2006
@@ -34,8 +34,6 @@
 import org.apache.ws.commons.schema.XmlSchemaTotalDigitsFacet;
 import org.apache.ws.commons.schema.constants.Constants;
 
-import org.apache.yoko.wsdl.CorbaConstants;
-
 public class FixedVisitor extends VisitorBase {
 
     private AST identifierNode;
@@ -122,9 +120,7 @@
         corbaFixed.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
         corbaFixed.setDigits(digits);
         corbaFixed.setScale(scale);
-        corbaFixed.setRepositoryID(CorbaConstants.REPO_STRING
-                                   + scopedName.toIDLRepositoryID()
-                                   + CorbaConstants.IDL_VERSION);
+        corbaFixed.setRepositoryID(scopedName.toIDLRepositoryID());
         //corbaFixed.setType(Constants.XSD_DECIMAL);
         corbaFixed.setType(fixedSimpleType.getQName());
         

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/Scope.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/Scope.java?view=diff&rev=487237&r1=487236&r2=487237
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/Scope.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/Scope.java
Thu Dec 14 07:26:31 2006
@@ -25,6 +25,8 @@
 
 import antlr.collections.AST;
 
+import org.apache.yoko.wsdl.CorbaConstants;
+
 public final class Scope {
 
     private static final String SEPARATOR = ".";
@@ -85,7 +87,11 @@
     }
 
     public String toIDLRepositoryID() {
-        return toString("/");
+        StringBuffer result = new StringBuffer();
+        result.append(CorbaConstants.REPO_STRING);
+        result.append(toString("/"));
+        result.append(CorbaConstants.IDL_VERSION);
+        return result.toString();
     }
     
 }

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/SequenceVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/SequenceVisitor.java?view=diff&rev=487237&r1=487236&r2=487237
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/SequenceVisitor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/SequenceVisitor.java
Thu Dec 14 07:26:31 2006
@@ -34,7 +34,6 @@
 import org.apache.ws.commons.schema.XmlSchemaSequence;
 import org.apache.ws.commons.schema.XmlSchemaType;
 
-import org.apache.yoko.wsdl.CorbaConstants;
 import org.apache.yoko.wsdl.CorbaTypeImpl;
 
 public class SequenceVisitor extends VisitorBase {
@@ -143,9 +142,7 @@
         corbaSeq.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
         corbaSeq.setType(schemaType.getQName());
         corbaSeq.setElemtype(ctype.getQName());
-        corbaSeq.setRepositoryID(CorbaConstants.REPO_STRING
-                                 + scopedName.toIDLRepositoryID()
-                                 + CorbaConstants.IDL_VERSION);
+        corbaSeq.setRepositoryID(scopedName.toIDLRepositoryID());
 
         return corbaSeq;
     }

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StringVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StringVisitor.java?view=diff&rev=487237&r1=487236&r2=487237
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StringVisitor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StringVisitor.java
Thu Dec 14 07:26:31 2006
@@ -187,9 +187,7 @@
         alias.setQName(new QName(typeMap.getTargetNamespace(), stringScopedName.toString()));
         alias.setBasetype(anon.getQName());
         alias.setType(simpleType.getQName());
-        alias.setRepositoryID(CorbaConstants.REPO_STRING
-                              + stringScopedName.toIDLRepositoryID()
-                              + CorbaConstants.IDL_VERSION);
+        alias.setRepositoryID(stringScopedName.toIDLRepositoryID());
 
         // add corba:alias
         setCorbaType(alias);
@@ -207,7 +205,7 @@
             corbaString.setName(CorbaConstants.NT_CORBA_STRING.getLocalPart());
         } else if (stringNode.getType() == IDLTokenTypes.LITERAL_wstring) {
             corbaString.setQName(CorbaConstants.NT_CORBA_WSTRING);
-            corbaString.setName(CorbaConstants.NT_CORBA_STRING.getLocalPart());
+            corbaString.setName(CorbaConstants.NT_CORBA_WSTRING.getLocalPart());
         } else { 
             // should never get here
             throw new RuntimeException("StringVisitor attempted to visit an invalid node");

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StructVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StructVisitor.java?view=diff&rev=487237&r1=487236&r2=487237
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StructVisitor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/StructVisitor.java
Thu Dec 14 07:26:31 2006
@@ -34,7 +34,6 @@
 import org.apache.ws.commons.schema.XmlSchemaSequence;
 import org.apache.ws.commons.schema.XmlSchemaType;
 
-import org.apache.yoko.wsdl.CorbaConstants;
 import org.apache.yoko.wsdl.CorbaTypeImpl;
 
 public class StructVisitor extends VisitorBase {
@@ -73,15 +72,14 @@
         Struct struct = new Struct();
         struct.setQName(new QName(typeMap.getTargetNamespace(), structScope.toString()));
         struct.setType(complexType.getQName());
-        struct.setRepositoryID(CorbaConstants.REPO_STRING
-                               + structScope.toIDLRepositoryID()
-                               + CorbaConstants.IDL_VERSION);
+        struct.setRepositoryID(structScope.toIDLRepositoryID());
 
         
         // struct members
         AST memberTypeNode = identifierNode.getNextSibling();
         while (memberTypeNode != null) {
-            AST memberNode = memberTypeNode.getNextSibling();
+            //AST memberNode = memberTypeNode.getNextSibling();
+            AST memberNode = TypesUtils.getPrimitiveCorbaTypeNameNode(memberTypeNode);
             
             XmlSchemaType schemaType = null;
             CorbaTypeImpl corbaType = null;
@@ -136,17 +134,13 @@
             memberTypeNode = memberNode.getNextSibling();
         }
 
-        // declaration phase
-        XmlSchemaType schemaType = complexType;
-        CorbaTypeImpl corbaType = struct;
-        DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(structScope,
-                                                                    schemas,
-                                                                    schema,
-                                                                    typeMap,
-                                                                    schemaType,
-                                                                    corbaType);
-        declaratorVisitor.visit(identifierNode);
+        // add schemaType
+        schema.getItems().add(complexType);
+        schema.addType(complexType);
 
+        // add corbaType
+        typeMap.getStructOrExceptionOrUnion().add(struct);
+        
         // REVISIT: are there assignment needed?
         setSchemaType(complexType);
         setCorbaType(struct);

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypedefVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypedefVisitor.java?view=diff&rev=487237&r1=487236&r2=487237
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypedefVisitor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypedefVisitor.java
Thu Dec 14 07:26:31 2006
@@ -93,24 +93,29 @@
                 declaratorVisitor.visit(identifierNode);
   
             } else {
-                Alias corbaString = new Alias();
-                if (typeDeclaratorNode.getType() == IDLTokenTypes.LITERAL_string) {
-                    corbaString.setBasetype(CorbaConstants.NT_CORBA_STRING);
-                } else if (typeDeclaratorNode.getType() == IDLTokenTypes.LITERAL_wstring)
{
-                    corbaString.setBasetype(CorbaConstants.NT_CORBA_WSTRING);
-                } else { 
-                    // should never get here
-                    throw new RuntimeException("[TypedefVisitor] Attempted to visit an invalid
node: "
-                                               + typeDeclaratorNode.toString());
-                }
-                corbaString.setQName(new QName(typeMap.getTargetNamespace(), typedefScope.toString()));
-                corbaString.setType(Constants.XSD_STRING);
-                corbaString.setRepositoryID(CorbaConstants.REPO_STRING
-                                            + typedefScope.toIDLRepositoryID()
-                                            + CorbaConstants.IDL_VERSION);
-
-                typeMap.getStructOrExceptionOrUnion().add(corbaString);
+                // unbounded string type is already in the XmlSchema and only needs to be
added
+                // to the CorbaTypeMap, therefore we cannot use DeclaratorVisitor here.
                 
+                while (identifierNode != null) {
+                    Alias corbaString = new Alias();
+                    if (typeDeclaratorNode.getType() == IDLTokenTypes.LITERAL_string) {
+                        corbaString.setBasetype(CorbaConstants.NT_CORBA_STRING);
+                    } else if (typeDeclaratorNode.getType() == IDLTokenTypes.LITERAL_wstring)
{
+                        corbaString.setBasetype(CorbaConstants.NT_CORBA_WSTRING);
+                    } else { 
+                        // should never get here
+                        throw new RuntimeException("[TypedefVisitor] Attempted to visit an
invalid node: "
+                                                   + typeDeclaratorNode.toString());
+                    }
+                    Scope newScope = new Scope(typedefScope.getParent(), identifierNode);
+                    corbaString.setQName(new QName(typeMap.getTargetNamespace(), newScope.toString()));
+                    corbaString.setType(Constants.XSD_STRING);
+                    corbaString.setRepositoryID(newScope.toIDLRepositoryID());
+
+                    typeMap.getStructOrExceptionOrUnion().add(corbaString);
+
+                    identifierNode = identifierNode.getNextSibling();
+                }
             }
 
         } else {
@@ -161,9 +166,7 @@
         alias.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
         alias.setBasetype(corbaType.getQName());
         alias.setType(schemaType.getQName());
-        alias.setRepositoryID(CorbaConstants.REPO_STRING
-                              + scopedName.toIDLRepositoryID()
-                              + CorbaConstants.IDL_VERSION);
+        alias.setRepositoryID(scopedName.toIDLRepositoryID());
         
         // add corba:alias
         setCorbaType(alias);

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/UnionVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/UnionVisitor.java?view=diff&rev=487237&r1=487236&r2=487237
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/UnionVisitor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/UnionVisitor.java
Thu Dec 14 07:26:31 2006
@@ -36,7 +36,6 @@
 import org.apache.ws.commons.schema.XmlSchemaSequence;
 import org.apache.ws.commons.schema.XmlSchemaType;
 
-import org.apache.yoko.wsdl.CorbaConstants;
 import org.apache.yoko.wsdl.CorbaTypeImpl;
 
 public class UnionVisitor extends VisitorBase {
@@ -108,25 +107,18 @@
         // corba:union
         Union corbaUnion = new Union();
         corbaUnion.setQName(new QName(typeMap.getTargetNamespace(), unionScope.toString()));
-        corbaUnion.setRepositoryID(CorbaConstants.REPO_STRING
-                                   + unionScope.toIDLRepositoryID()
-                                   + CorbaConstants.IDL_VERSION);
+        corbaUnion.setRepositoryID(unionScope.toIDLRepositoryID());
         corbaUnion.setType(unionSchemaComplexType.getQName());
         corbaUnion.setDiscriminator(ctype.getQName());
         
         processCaseNodes(caseNode, unionScope, choice, corbaUnion);
-            
-        
-        XmlSchemaType schemaType = unionSchemaComplexType;
-        CorbaTypeImpl corbaType = corbaUnion;
-        // declaration phase
-        DeclaratorVisitor declaratorVisitor = new DeclaratorVisitor(getScope(),
-                                                                    schemas,
-                                                                    schema,
-                                                                    typeMap,
-                                                                    schemaType,
-                                                                    corbaType);
-        declaratorVisitor.visit(identifierNode);
+
+        // add schemaType
+        schema.getItems().add(unionSchemaComplexType);
+        schema.addType(unionSchemaComplexType);
+
+        // add corbaType
+        typeMap.getStructOrExceptionOrUnion().add(corbaUnion);
 
         // REVISIT: are these assignments needed?
         setSchemaType(unionSchemaComplexType);

Modified: incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java?view=diff&rev=487237&r1=487236&r2=487237
==============================================================================
--- incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java
(original)
+++ incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java
Thu Dec 14 07:26:31 2006
@@ -198,4 +198,8 @@
         testWSDLGeneration("/idl/Anonstring.idl", "/idl/expected_Anonstring.wsdl");
     }
 
+    public void testMultipleDeclaratorsGeneration() throws Exception {
+        testWSDLGeneration("/idl/Declarators.idl", "/idl/expected_Declarators.wsdl");
+    }
+
 }



Mime
View raw message